From 405dbfb4cc59ef4f1474ee107aa09008ed1805c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eva=20M=C3=BCller?= Date: Wed, 25 Dec 2024 12:50:05 +0100 Subject: [PATCH] Fix FormValidation check when overwriting scopes --- .../plugins/oic/OicServerWellKnownConfiguration.java | 6 +++--- .../plugins/oic/OicServerWellKnownConfigurationTest.java | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/oic/OicServerWellKnownConfiguration.java b/src/main/java/org/jenkinsci/plugins/oic/OicServerWellKnownConfiguration.java index bbb329b9..504dfc96 100644 --- a/src/main/java/org/jenkinsci/plugins/oic/OicServerWellKnownConfiguration.java +++ b/src/main/java/org/jenkinsci/plugins/oic/OicServerWellKnownConfiguration.java @@ -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(); diff --git a/src/test/java/org/jenkinsci/plugins/oic/OicServerWellKnownConfigurationTest.java b/src/test/java/org/jenkinsci/plugins/oic/OicServerWellKnownConfigurationTest.java index 3d1e103c..418bd5e9 100644 --- a/src/test/java/org/jenkinsci/plugins/oic/OicServerWellKnownConfigurationTest.java +++ b/src/test/java/org/jenkinsci/plugins/oic/OicServerWellKnownConfigurationTest.java @@ -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?")));