-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from WrenSecurity/feature/22
Fix inconsistency between CHF and Servlet API cookie handling. #22
- Loading branch information
Showing
5 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...on-module/src/test/java/org/forgerock/jaspi/modules/session/jwt/JwtSessionModuleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.forgerock.jaspi.modules.session.jwt; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.assertNull; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
import org.forgerock.http.protocol.Cookie; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
public class JwtSessionModuleTest { | ||
|
||
JwtSessionModule jwtSessionModule; | ||
|
||
@BeforeMethod | ||
public void setUp() { | ||
jwtSessionModule = new JwtSessionModule(); | ||
jwtSessionModule.cookieDomains = Collections.singleton("example.com"); | ||
} | ||
|
||
@Test | ||
public void shouldCreateSessionCookieWithMaxAge() { | ||
Collection<CookieWrapper> cookies = jwtSessionModule.createCookies("foo", 7, "/"); | ||
assertEquals(cookies.size(), 1); | ||
Cookie cookie = cookies.iterator().next().getCookie(); | ||
assertEquals(cookie.getMaxAge(), Integer.valueOf(7)); | ||
assertNull(cookie.getExpires()); | ||
} | ||
|
||
@Test | ||
public void shouldCreateSessionCookieWithoutMaxAge() { | ||
Collection<CookieWrapper> cookies = jwtSessionModule.createCookies("foo", -1, "/"); | ||
assertEquals(cookies.size(), 1); | ||
Cookie cookie = cookies.iterator().next().getCookie(); | ||
assertNull(cookie.getMaxAge()); | ||
assertNull(cookie.getExpires()); | ||
} | ||
|
||
@Test | ||
public void shouldCreateSessionExpiredCookie() { | ||
Collection<CookieWrapper> cookies = jwtSessionModule.createCookies("foo", 0, "/"); | ||
assertEquals(cookies.size(), 1); | ||
Cookie cookie = cookies.iterator().next().getCookie(); | ||
assertTrue(cookie.getMaxAge() <= 0); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters