diff --git a/src/main/java/org/jenkinsci/test/acceptance/po/OicAuthConfigurationMode.java b/src/main/java/org/jenkinsci/test/acceptance/po/OicAuthConfigurationMode.java new file mode 100644 index 000000000..a03b0128d --- /dev/null +++ b/src/main/java/org/jenkinsci/test/acceptance/po/OicAuthConfigurationMode.java @@ -0,0 +1,25 @@ +package org.jenkinsci.test.acceptance.po; + +/** + * Class representing the entry controls for the configuration mode when using the oic-auth plugin + */ +public abstract class OicAuthConfigurationMode extends PageAreaImpl { + + protected OicAuthConfigurationMode(OicAuthSecurityRealm realm) { + super(realm, "serverConfiguration"); + } + + /** + * Class representing the entry controls for well-known endpoint when using the oic-auth plugin + */ + @Describable("Discovery via well-known endpoint") + public static class WellKnownEndpoint extends OicAuthConfigurationMode { + + public final Control wellKnownEndpoint = control("wellKnownOpenIDConfigurationUrl"); + + public WellKnownEndpoint(OicAuthSecurityRealm realm) { + super(realm); + } + } + +} diff --git a/src/main/java/org/jenkinsci/test/acceptance/po/OicAuthSecurityRealm.java b/src/main/java/org/jenkinsci/test/acceptance/po/OicAuthSecurityRealm.java index 01ff225e4..8c2042c8a 100644 --- a/src/main/java/org/jenkinsci/test/acceptance/po/OicAuthSecurityRealm.java +++ b/src/main/java/org/jenkinsci/test/acceptance/po/OicAuthSecurityRealm.java @@ -1,5 +1,7 @@ package org.jenkinsci.test.acceptance.po; +import org.openqa.selenium.WebElement; + /** * Security Realm provided by oic-auth plugin */ @@ -15,9 +17,10 @@ public void configureClient(String clientId, String clientSecret) { control("clientSecret").set(clientSecret); } - public void setWellKnownEndpoint(String wellKnownEndpoint) { - control("").select("Discovery via well-known endpoint"); // Select doesn't have the relative path, directly path=/securityRealm/ - control("serverConfiguration/wellKnownOpenIDConfigurationUrl").set(wellKnownEndpoint); + public T useConfigurationMode(Class type) { + WebElement option = findCaption(type, caption -> getElement(by.option(caption))); + option.click(); + return newInstance(type, this); } public void setLogoutFromOpenidProvider(boolean logout) { diff --git a/src/test/java/plugins/OicAuthPluginTest.java b/src/test/java/plugins/OicAuthPluginTest.java index 38f1efc62..f6ec1743e 100644 --- a/src/test/java/plugins/OicAuthPluginTest.java +++ b/src/test/java/plugins/OicAuthPluginTest.java @@ -18,6 +18,7 @@ import org.jenkinsci.test.acceptance.junit.WithPlugins; import org.jenkinsci.test.acceptance.po.GlobalSecurityConfig; import org.jenkinsci.test.acceptance.po.LoggedInAuthorizationStrategy; +import org.jenkinsci.test.acceptance.po.OicAuthConfigurationMode; import org.jenkinsci.test.acceptance.po.OicAuthSecurityRealm; import org.jenkinsci.test.acceptance.po.WhoAmI; import org.jenkinsci.test.acceptance.utils.keycloack.KeycloakUtils; @@ -206,8 +207,9 @@ private void configureRealm() { sc.open(); OicAuthSecurityRealm securityRealm = sc.useRealm(OicAuthSecurityRealm.class); securityRealm.configureClient(CLIENT, CLIENT); - securityRealm.setWellKnownEndpoint( - String.format("%s/realms/%s/.well-known/openid-configuration", keycloakUrl, REALM)); + // Configuration mode + OicAuthConfigurationMode.WellKnownEndpoint configurationMode = securityRealm.useConfigurationMode(OicAuthConfigurationMode.WellKnownEndpoint.class); + configurationMode.wellKnownEndpoint.set(String.format("%s/realms/%s/.well-known/openid-configuration", keycloakUrl, REALM)); securityRealm.setLogoutFromOpenidProvider(true); securityRealm.setPostLogoutUrl(jenkins.url("OicLogout").toExternalForm()); securityRealm.setUserFields(null, null, null, "groups");