Skip to content

Commit

Permalink
Use a PageArea for the Describable part
Browse files Browse the repository at this point in the history
  • Loading branch information
fcojfernandez committed Sep 20, 2024
1 parent ce6c12e commit 1d8a510
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jenkinsci.test.acceptance.po;

import org.openqa.selenium.WebElement;

/**
* Security Realm provided by oic-auth plugin
*/
Expand All @@ -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 extends OicAuthConfigurationMode> T useConfigurationMode(Class<T> type) {
WebElement option = findCaption(type, caption -> getElement(by.option(caption)));
option.click();
return newInstance(type, this);
}

public void setLogoutFromOpenidProvider(boolean logout) {
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/plugins/OicAuthPluginTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 1d8a510

Please sign in to comment.