@Test public void testParseCookieIncorrectVersion() throws Exception { String unprotectedvalue = "1.1.1.1:bearer token:testscope:PUBLIC:1111:test-hash"; when(cryptoSupportMock.unprotect(URL_ENCODING_AGNOSTIC_VALUE)).thenReturn(unprotectedvalue); AemCortexContext result = processor.deserializeValue(URL_ENCODING_AGNOSTIC_VALUE); assertNull("Context should not have been created", result); }
@Test public void testParseCookieMissingData() throws Exception { String unprotectedvalue = AemCortexCookieTransformerImpl.CURRENT_VERSION + ":bearer token:1111:test-hash"; when(cryptoSupportMock.unprotect(URL_ENCODING_AGNOSTIC_VALUE)).thenReturn(unprotectedvalue); AemCortexContext result = processor.deserializeValue(URL_ENCODING_AGNOSTIC_VALUE); assertNull("Context should not have been created", result); }
@Test public void testParseValidCookieValue() throws Exception { String unprotectedvalue = AemCortexCookieTransformerImpl.CURRENT_VERSION + ":bearer token:testscope:PUBLIC:1111:test-hash"; when(cryptoSupportMock.unprotect(URL_ENCODING_AGNOSTIC_VALUE)).thenReturn(unprotectedvalue); AemCortexContext result = processor.deserializeValue(URL_ENCODING_AGNOSTIC_VALUE); assertEquals( "Cookie version did not match", AemCortexCookieTransformerImpl.CURRENT_VERSION, result.getVersion()); assertEquals("Cookie token did not match", TEST_TOKEN, result.getAuthenticationToken()); assertEquals("Cookie scope did not match", "testscope", result.getScope()); assertEquals("Cookie role did not match", PUBLIC_ROLE, result.getRole()); assertEquals( "Cookie expires did not match", TEST_EXPIRES_PAST, result.getExpiryDate().getTime()); assertEquals("Cookie hash did not match", "test-hash", result.getIdentifier()); }