Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt the OicAuthPluginTest to the changes in the describables #1724

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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 setAutomaticConfiguration(String wellKnownEndpoint) {
control(by.radioButton("Automatic configuration")).click();
control("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: 5 additions & 1 deletion 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,7 +207,10 @@ private void configureRealm() {
sc.open();
OicAuthSecurityRealm securityRealm = sc.useRealm(OicAuthSecurityRealm.class);
securityRealm.configureClient(CLIENT, CLIENT);
securityRealm.setAutomaticConfiguration(
// 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());
Expand Down
Loading