@Test public void testMissingProfileCreator() { final CookieClient cookieClient = new CookieClient("testcookie", new SimpleTestTokenAuthenticator()); cookieClient.setProfileCreator(null); TestsHelper.initShouldFail(cookieClient, "profileCreator cannot be null"); }
@Test public void testAuthentication() throws RequiresHttpAction, UnsupportedEncodingException { final CookieClient client = new CookieClient(USERNAME, new SimpleTestTokenAuthenticator()); final MockWebContext context = MockWebContext.create(); final Cookie c = new Cookie( USERNAME, Base64.getEncoder() .encodeToString(getClass().getName().getBytes(HttpConstants.UTF8_ENCODING))); context.getRequestCookies().add(c); final TokenCredentials credentials = client.getCredentials(context); final CommonProfile profile = client.getUserProfile(credentials, context); assertEquals(c.getValue(), profile.getId()); }
@Test(expected = Exception.class) public void testMissingCookieName() { final CookieClient cookieClient = new CookieClient(null, new SimpleTestTokenAuthenticator()); cookieClient.init(null); }
@Test public void testHasDefaultProfileCreator() { final CookieClient cookieClient = new CookieClient("testcookie", new SimpleTestTokenAuthenticator()); cookieClient.init(null); }