From 11877ae7daf1b427650597c7a694d5c4427aa984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eva=20M=C3=BCller?= Date: Mon, 23 Dec 2024 22:26:41 +0100 Subject: [PATCH] Add test if custom user ID strategy is null --- .../java/org/jenkinsci/plugins/oic/PluginTest.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/oic/PluginTest.java b/src/test/java/org/jenkinsci/plugins/oic/PluginTest.java index 74cb85a6..1fd2d7b2 100644 --- a/src/test/java/org/jenkinsci/plugins/oic/PluginTest.java +++ b/src/test/java/org/jenkinsci/plugins/oic/PluginTest.java @@ -170,7 +170,7 @@ public void testLoginWithDefaults() throws Exception { }); // Use Default: ID Strategy CASE-INSENSITIVE - // Login another user with same username but in upper cases + // Login with another user with same username but in upper cases mockTokenReturnsIdTokenWithGroup(usernameUpper, setUpKeyValuesWithGroup(groupsUpper)); browseLoginPage(); var userUpperCaseInsensitive = assertTestUser(usernameUpper); @@ -179,6 +179,16 @@ public void testLoginWithDefaults() throws Exception { usernameLower, userUpperCaseInsensitive.getId()); assertTestUserIsMemberOfGroups(userUpperCaseInsensitive, groupsUpper); + + // Fallback to default ID Strategy CASE-INSENSITIVE if custom user ID strategy is not set + // Login with another user with same username but in upper cases + configureTestRealm(sc -> sc.setCustomUserIdStrategy(null)); + browseLoginPage(); + var userUpperCaseInsensitive2 = assertTestUser(usernameUpper); + assertEquals( + "With ID strategy case-insensitive, the username is to be expected in lower case", + usernameLower, + userUpperCaseInsensitive2.getId()); } @Test @@ -219,7 +229,7 @@ public void testLoginWithDefaultsCaseSensitive() throws Exception { return null; }); - // Login another user with same username but in upper cases + // Login with another user with same username but in upper cases mockTokenReturnsIdTokenWithGroup(usernameUpper, setUpKeyValuesWithGroup(groupsUpper)); browseLoginPage(); var userUpperCase = assertTestUser(usernameUpper);