forked from datahub-project/datahub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(oidc): fix oidc authentication loop (datahub-project#6848)
* fix(oidc): fix oidc authentication loop
- Loading branch information
1 parent
3fd0dbf
commit 5f7b8a8
Showing
4 changed files
with
32 additions
and
22 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,10 +24,13 @@ | |
|
||
import java.io.IOException; | ||
import java.net.InetAddress; | ||
import java.net.URLEncoder; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static play.mvc.Http.Status.NOT_FOUND; | ||
import static play.mvc.Http.Status.OK; | ||
import static play.test.Helpers.fakeRequest; | ||
|
@@ -72,11 +75,14 @@ protected TestBrowser provideBrowser(int port) { | |
|
||
private String _wellKnownUrl; | ||
|
||
private static final String TEST_USER = "urn:li:corpuser:[email protected]"; | ||
private static final String TEST_TOKEN = "faketoken_YCpYIrjQH4sD3_rAc3VPPFg4"; | ||
|
||
@BeforeAll | ||
public void init() throws IOException, InterruptedException { | ||
_gmsServer = new MockWebServer(); | ||
_gmsServer.enqueue(new MockResponse().setBody("{\"value\":\"urn:li:corpuser:[email protected]\"}")); | ||
_gmsServer.enqueue(new MockResponse().setBody("{\"accessToken\":\"faketoken_YCpYIrjQH4sD3_rAc3VPPFg4\"}")); | ||
_gmsServer.enqueue(new MockResponse().setBody(String.format("{\"value\":\"%s\"}", TEST_USER))); | ||
_gmsServer.enqueue(new MockResponse().setBody(String.format("{\"accessToken\":\"%s\"}", TEST_TOKEN))); | ||
_gmsServer.start(gmsServerPort()); | ||
|
||
_oauthServer = new MockOAuth2Server(); | ||
|
@@ -140,8 +146,13 @@ public void testOpenIdConfig() { | |
public void testHappyPathOidc() throws InterruptedException { | ||
browser.goTo("/authenticate"); | ||
assertEquals("", browser.url()); | ||
|
||
Cookie actorCookie = browser.getCookie("actor"); | ||
assertEquals("urn:li:corpuser:[email protected]", actorCookie.getValue()); | ||
assertEquals(TEST_USER, actorCookie.getValue()); | ||
|
||
Cookie sessionCookie = browser.getCookie("PLAY_SESSION"); | ||
assertTrue(sessionCookie.getValue().contains("token=" + TEST_TOKEN)); | ||
assertTrue(sessionCookie.getValue().contains("actor=" + URLEncoder.encode(TEST_USER, StandardCharsets.UTF_8))); | ||
} | ||
|
||
} |