Skip to content

Commit

Permalink
Add test if custom user ID strategy is null
Browse files Browse the repository at this point in the history
  • Loading branch information
eva-mueller-coremedia committed Dec 23, 2024
1 parent 1e74b6d commit 11877ae
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/test/java/org/jenkinsci/plugins/oic/PluginTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 11877ae

Please sign in to comment.