Skip to content

Commit b819fad

Browse files
committed
Fix unit tests
1 parent 8fe4eef commit b819fad

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

extensions-core/druid-pac4j/src/test/java/org/apache/druid/security/pac4j/Pac4jSessionStoreTest.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import org.pac4j.core.context.Cookie;
2727
import org.pac4j.core.context.WebContext;
2828
import org.pac4j.core.profile.CommonProfile;
29-
import org.pac4j.core.profile.definition.CommonProfileDefinition;
30-
import org.pac4j.core.util.Pac4jConstants;
3129

3230
import java.util.Collections;
3331
import java.util.HashMap;
@@ -239,13 +237,13 @@ public void testSetAndGetClearUserProfile()
239237

240238
CommonProfile profile = new CommonProfile();
241239
profile.setId("profile1");
242-
profile.addAttribute(CommonProfileDefinition.DISPLAY_NAME, "name");
240+
profile.addAttribute("display_name", "name");
243241
profile.addAttribute("access_token", "token");
244242
profile.addAttribute("refresh_token", "refresh");
245243
profile.addAttribute("id_token", "id");
246244
profile.addAttribute("credentials", "creds");
247245

248-
sessionStore.set(webContext1, Pac4jConstants.USER_PROFILES, profile);
246+
sessionStore.set(webContext1, "pac4j.user.profiles", profile);
249247

250248
Cookie cookie = cookieCapture.getValue();
251249
Assert.assertTrue(cookie.isSecure());
@@ -256,10 +254,10 @@ public void testSetAndGetClearUserProfile()
256254
EasyMock.expect(webContext2.getRequestCookies()).andReturn(Collections.singletonList(cookie));
257255
EasyMock.replay(webContext2);
258256

259-
Optional<Object> value = sessionStore.get(webContext2, Pac4jConstants.USER_PROFILES);
257+
Optional<Object> value = sessionStore.get(webContext2, "pac4j.user.profiles");
260258
Assert.assertTrue(Objects.requireNonNull(value).isPresent());
261259
CommonProfile retrievedProfile = (CommonProfile) value.get();
262-
Assert.assertEquals("name", retrievedProfile.getAttribute(CommonProfileDefinition.DISPLAY_NAME));
260+
Assert.assertEquals("name", retrievedProfile.getAttribute("display_name"));
263261

264262
// Verify sensitive data was removed
265263
Assert.assertNull(retrievedProfile.getAttribute("access_token"));
@@ -284,19 +282,19 @@ public void testSetAndGetClearUserMultipleProfile()
284282

285283
CommonProfile profile1 = new CommonProfile();
286284
profile1.setId("profile1");
287-
profile1.addAttribute(CommonProfileDefinition.DISPLAY_NAME, "name1");
285+
profile1.addAttribute("display_name", "name1");
288286
profile1.addAttribute("access_token", "token1");
289287

290288
CommonProfile profile2 = new CommonProfile();
291289
profile2.setId("profile2");
292-
profile2.addAttribute(CommonProfileDefinition.DISPLAY_NAME, "name2");
290+
profile2.addAttribute("display_name", "name2");
293291
profile2.addAttribute("refresh_token", "refresh2");
294292

295293
Map<String, CommonProfile> profiles = new HashMap<>();
296294
profiles.put("profile1", profile1);
297295
profiles.put("profile2", profile2);
298296

299-
sessionStore.set(webContext1, Pac4jConstants.USER_PROFILES, profiles);
297+
sessionStore.set(webContext1, "pac4j.user.profiles", profiles);
300298

301299
Cookie cookie = cookieCapture.getValue();
302300
Assert.assertTrue(cookie.isSecure());
@@ -307,7 +305,7 @@ public void testSetAndGetClearUserMultipleProfile()
307305
EasyMock.expect(webContext2.getRequestCookies()).andReturn(Collections.singletonList(cookie));
308306
EasyMock.replay(webContext2);
309307

310-
Optional<Object> value = sessionStore.get(webContext2, Pac4jConstants.USER_PROFILES);
308+
Optional<Object> value = sessionStore.get(webContext2, "pac4j.user.profiles");
311309
Assert.assertTrue(Objects.requireNonNull(value).isPresent());
312310
@SuppressWarnings("unchecked")
313311
Map<String, CommonProfile> retrievedProfiles = (Map<String, CommonProfile>) value.get();

0 commit comments

Comments
 (0)