Skip to content

Commit

Permalink
make the test more deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecirioli committed Sep 4, 2024
1 parent 8facd12 commit 8f1e903
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/test/java/org/jenkinsci/plugins/oic/PluginTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,10 @@ public void testAccessUsingJenkinsApiTokens() throws Exception {
mockAuthorizationRedirectsToFinishLogin();
configureWellKnown(null, null, "authorization_code");
jenkins.setSecurityRealm(new TestRealm(wireMockRule, null, EMAIL_FIELD, GROUPS_FIELD, AUTO_CONFIG_FIELD));
// explicitly ensure allowTokenAccessWithoutOicSession is disabled
TestRealm testRealm = (TestRealm) jenkins.getSecurityRealm();
testRealm.setAllowTokenAccessWithoutOicSession(true);

// login and assert normal auth is working
mockTokenReturnsIdTokenWithGroup(PluginTest::withoutRefreshToken);
mockUserInfoWithTestGroups();
Expand Down Expand Up @@ -1012,8 +1016,7 @@ public void testAccessUsingJenkinsApiTokens() throws Exception {
MatcherAssert.assertThat("response should have been 401\n" + rsp.body(), rsp.statusCode(), is(401));

// enable "traditional api token access"
TestRealm tr = (TestRealm) jenkins.getSecurityRealm();
tr.setTraditionalApiTokenAccessEnabled(true);
testRealm.setAllowTokenAccessWithoutOicSession(true);

// verify that jenkins api token is now working again
rsp = getPageWithGet(TEST_USER_USERNAME, token, "/whoAmI/api/xml");
Expand Down

0 comments on commit 8f1e903

Please sign in to comment.