github-advanced-security[bot] commented on code in PR #15522:
URL: https://github.com/apache/druid/pull/15522#discussion_r1424338236
##########
extensions-core/druid-pac4j/src/test/java/org/apache/druid/security/pac4j/Pac4jSessionStoreTest.java:
##########
@@ -54,7 +60,73 @@
WebContext webContext2 = EasyMock.mock(WebContext.class);
EasyMock.expect(webContext2.getRequestCookies()).andReturn(Collections.singletonList(cookie));
EasyMock.replay(webContext2);
+ Assert.assertEquals("value",
Objects.requireNonNull(sessionStore.get(webContext2, "key")).orElse(null));
+ }
+
+ @Test
+ public void testSetAndGetClearUserProfile()
+ {
+ Pac4jSessionStore<WebContext> sessionStore = new
Pac4jSessionStore("test-cookie-passphrase");
Review Comment:
## Hard-coded credential in API call
Hard-coded value flows to [sensitive API call](1).
[Show more
details](https://github.com/apache/druid/security/code-scanning/6349)
##########
extensions-core/druid-pac4j/src/test/java/org/apache/druid/security/pac4j/Pac4jSessionStoreTest.java:
##########
@@ -54,7 +60,73 @@
WebContext webContext2 = EasyMock.mock(WebContext.class);
EasyMock.expect(webContext2.getRequestCookies()).andReturn(Collections.singletonList(cookie));
EasyMock.replay(webContext2);
+ Assert.assertEquals("value",
Objects.requireNonNull(sessionStore.get(webContext2, "key")).orElse(null));
+ }
+
+ @Test
+ public void testSetAndGetClearUserProfile()
+ {
+ Pac4jSessionStore<WebContext> sessionStore = new
Pac4jSessionStore("test-cookie-passphrase");
+
+ WebContext webContext1 = EasyMock.mock(WebContext.class);
+ EasyMock.expect(webContext1.getScheme()).andReturn("https");
+ Capture<Cookie> cookieCapture = EasyMock.newCapture();
+
+ webContext1.addResponseCookie(EasyMock.capture(cookieCapture));
+ EasyMock.replay(webContext1);
- Assert.assertEquals("value", sessionStore.get(webContext2, "key"));
+ CommonProfile profile = new CommonProfile();
+ profile.addAttribute(CommonProfileDefinition.DISPLAY_NAME, "name");
+ sessionStore.set(webContext1, "pac4jUserProfiles", profile);
+
+ Cookie cookie = cookieCapture.getValue();
+ Assert.assertTrue(cookie.isSecure());
+ Assert.assertTrue(cookie.isHttpOnly());
+ Assert.assertTrue(cookie.isSecure());
+ Assert.assertEquals(900, cookie.getMaxAge());
+
+
+ WebContext webContext2 = EasyMock.mock(WebContext.class);
+
EasyMock.expect(webContext2.getRequestCookies()).andReturn(Collections.singletonList(cookie));
+ EasyMock.replay(webContext2);
+ Optional<Object> value = sessionStore.get(webContext2,
"pac4jUserProfiles");
+ Assert.assertTrue(Objects.requireNonNull(value).isPresent());
+ Assert.assertEquals("name", ((CommonProfile)
value.get()).getAttribute(CommonProfileDefinition.DISPLAY_NAME));
+ }
+
+ @Test
+ public void testSetAndGetClearUserMultipleProfile()
+ {
+ Pac4jSessionStore<WebContext> sessionStore = new
Pac4jSessionStore("test-cookie-passphrase");
Review Comment:
## Hard-coded credential in API call
Hard-coded value flows to [sensitive API call](1).
[Show more
details](https://github.com/apache/druid/security/code-scanning/6350)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]