Skip to content

Commit

Permalink
Fix FormValidation check when overwriting scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
eva-mueller-coremedia committed Dec 25, 2024
1 parent 5c28d5f commit 405dbfb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,12 @@ public FormValidation doCheckWellKnownOpenIDConfigurationUrl(
}

@POST
public FormValidation doCheckOverrideScopes(@QueryParameter String overrideScopes) {
public FormValidation doCheckScopesOverride(@QueryParameter String scopesOverride) {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
if (Util.fixEmptyAndTrim(overrideScopes) == null) {
if (Util.fixEmptyAndTrim(scopesOverride) == null) {
return FormValidation.ok();
}
if (!overrideScopes.toLowerCase().contains("openid")) {
if (!scopesOverride.toLowerCase().contains("openid")) {
return FormValidation.warning(Messages.OicSecurityRealm_RUSureOpenIdNotInScope());
}
return FormValidation.ok();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ public void doCheckWellKnownOpenIDConfigurationUrl() throws IOException {
public void doCheckOverrideScopes() throws IOException {
DescriptorImpl descriptor = getDescriptor();

assertThat(descriptor.doCheckOverrideScopes(null), hasKind(FormValidation.Kind.OK));
assertThat(descriptor.doCheckOverrideScopes(""), hasKind(FormValidation.Kind.OK));
assertThat(descriptor.doCheckScopesOverride(null), hasKind(FormValidation.Kind.OK));
assertThat(descriptor.doCheckScopesOverride(""), hasKind(FormValidation.Kind.OK));
assertThat(
descriptor.doCheckOverrideScopes("openid email profile address phone offline_access"),
descriptor.doCheckScopesOverride("openid email profile address phone offline_access"),
hasKind(FormValidation.Kind.OK));
assertThat(
descriptor.doCheckOverrideScopes("blah"),
descriptor.doCheckScopesOverride("blah"),
allOf(
hasKind(FormValidation.Kind.WARNING),
withMessage("Are you sure you don't want to include 'openid' as a scope?")));
Expand Down

0 comments on commit 405dbfb

Please sign in to comment.