Ejemplo n.º 1
0
 @Test
 public void testAuthentication() throws RequiresHttpAction {
   final DirectBasicAuthClient client =
       new DirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator());
   final MockWebContext context = MockWebContext.create();
   final String header = USERNAME + ":" + USERNAME;
   context.addRequestHeader(
       HttpConstants.AUTHORIZATION_HEADER,
       "Basic " + Base64.encodeBase64String(header.getBytes()));
   final UsernamePasswordCredentials credentials = client.getCredentials(context);
   final UserProfile profile = client.getUserProfile(credentials, context);
   assertEquals(USERNAME, profile.getId());
 }
Ejemplo n.º 2
0
 @Test
 public void testHasDefaultProfileCreator() {
   final DirectBasicAuthClient basicAuthClient =
       new DirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator());
   basicAuthClient.init(null);
 }