.expectRedirectUri(REDIRECT_URI)
.expectBasicAuthHeader(null)
.build();
replay(request);
OAuthUnauthenticatedTokenRequest req = null;
try {
req = new OAuthUnauthenticatedTokenRequest(request);
} catch (OAuthProblemException e) {
fail("Exception not expected");
}
assertEquals(GrantType.AUTHORIZATION_CODE.toString(), req.getGrantType());
assertEquals(CLIENT_ID, req.getClientId());
assertEquals(REDIRECT_URI, req.getRedirectURI());
assertEquals(ACCESS_GRANT, req.getCode());
verify(request);
request = new OauthMockRequestBuilder()
.expectGrantType(GrantType.PASSWORD.toString())
.expectHttpMethod(OAuth.HttpMethod.POST)
.expectContentType(OAuth.ContentType.URL_ENCODED)
.expectClientId(CLIENT_ID)
.expectBasicAuthHeader(null)
.expectOauthUsername(USERNAME)
.expectOauthPassword(PASSWORD)
.build();
replay(request);
try {
req = new OAuthUnauthenticatedTokenRequest(request);
} catch (OAuthProblemException e) {
fail("Exception not expected");
}
assertEquals(CLIENT_ID, req.getClientId());
assertEquals(USERNAME, req.getUsername());
assertEquals(PASSWORD, req.getPassword());
verify(request);
request = new OauthMockRequestBuilder()
.expectGrantType(GrantType.REFRESH_TOKEN.toString())
.expectHttpMethod(OAuth.HttpMethod.POST)
.expectContentType(OAuth.ContentType.URL_ENCODED)
.expectClientId(CLIENT_ID)
.expectOauthRefreshToken(REFRESH_TOKEN)
.expectBasicAuthHeader(null)
.build();
replay(request);
try {
req = new OAuthUnauthenticatedTokenRequest(request);
} catch (OAuthProblemException e) {
fail("Exception not expected");
}
assertEquals(CLIENT_ID, req.getClientId());
assertEquals(REFRESH_TOKEN, req.getRefreshToken());
verify(request);
}