-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add test for oic-auth plugin * Retrieve and check the roles from the OICD provider * Update src/main/java/org/jenkinsci/test/acceptance/po/OicAuthSecurityRealm.java Co-authored-by: James Nord <[email protected]> * Apply suggestions * Add the WhoAmI page * Fix permissions on the docker socket TestContainers does not use docker, but talks directly to the docker socket. The permissions on this socket come from the host where it is mapped and the docker groupid may not match what we have in the container. So allow th arg to be passed through at build time and add the ath-user to the docker group so it has the permissions. We retain the legacy suid on the docker binary as we publish the container and there is only a single test so far using this test-containers. (this can be revistied if required). * Incremental build * Remove unused libraries * Add missing dependencies * New incremental * New incremental * update to 2.476 * document testcontainers requirement * update keycloak container vie renovate * s/TestContainers/Testcontainers Testcontainers is with a lower case c --------- Co-authored-by: James Nord <[email protected]> Co-authored-by: Basil Crow <[email protected]>
- Loading branch information
1 parent
0d0b9d0
commit 39030e8
Showing
9 changed files
with
507 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/org/jenkinsci/test/acceptance/po/OicAuthSecurityRealm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.jenkinsci.test.acceptance.po; | ||
|
||
/** | ||
* Security Realm provided by oic-auth plugin | ||
*/ | ||
@Describable("Login with Openid Connect") | ||
public class OicAuthSecurityRealm extends SecurityRealm { | ||
|
||
public OicAuthSecurityRealm(GlobalSecurityConfig context, String path) { | ||
super(context, path); | ||
} | ||
|
||
public void configureClient(String clientId, String clientSecret) { | ||
control("clientId").set(clientId); | ||
control("clientSecret").set(clientSecret); | ||
} | ||
|
||
public void setAutomaticConfiguration(String wellKnownEndpoint) { | ||
control(by.radioButton("Automatic configuration")).click(); | ||
control("wellKnownOpenIDConfigurationUrl").set(wellKnownEndpoint); | ||
} | ||
|
||
public void setLogoutFromOpenidProvider(boolean logout) { | ||
Control check = control(by.checkbox("Logout from OpenID Provider")); | ||
if (logout) { | ||
check.check(); | ||
} else { | ||
check.uncheck(); | ||
} | ||
} | ||
|
||
public void setPostLogoutUrl(String postLogoutUrl) { | ||
control("postLogoutRedirectUrl").set(postLogoutUrl); | ||
} | ||
|
||
public void setUserFields( | ||
String userNameFieldName, String emailFieldName, String fullNameFieldName, String groupsFieldName) { | ||
clickButton("User fields"); | ||
waitFor(by.path("/securityRealm/groupsFieldName")); | ||
control("userNameField").set(userNameFieldName); | ||
control("emailFieldName").set(emailFieldName); | ||
control("fullNameFieldName").set(fullNameFieldName); | ||
control("groupsFieldName").set(groupsFieldName); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/org/jenkinsci/test/acceptance/po/WhoAmI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.jenkinsci.test.acceptance.po; | ||
|
||
/** | ||
* Who Am I page in Jenkins | ||
*/ | ||
public class WhoAmI extends ContainerPageObject { | ||
|
||
public WhoAmI(ContainerPageObject parent) { | ||
super(parent, parent.url("whoAmI/")); | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
src/main/java/org/jenkinsci/test/acceptance/utils/keycloack/KeycloakUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package org.jenkinsci.test.acceptance.utils.keycloack; | ||
|
||
import jakarta.inject.Inject; | ||
import java.net.URL; | ||
import org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl; | ||
import org.jenkinsci.test.acceptance.utils.ElasticTime; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
public class KeycloakUtils extends CapybaraPortingLayerImpl { | ||
|
||
@Inject | ||
public WebDriver driver; | ||
|
||
@Inject | ||
public ElasticTime time; | ||
|
||
public KeycloakUtils() { | ||
super(null); | ||
} | ||
|
||
public void open(URL url) { | ||
visit(url); | ||
} | ||
|
||
public void login(String user) { | ||
login(user, user); | ||
} | ||
|
||
public void login(String user, String passwd) { | ||
waitFor(by.id("username"), 5); | ||
find(by.id("username")).sendKeys(user); | ||
find(by.id("password")).sendKeys(passwd); | ||
find(by.id("kc-login")).click(); | ||
} | ||
|
||
public User getCurrentUser(String keycloakUrl, String realm) { | ||
driver.get(String.format("%s/realms/%s/account", keycloakUrl, realm)); | ||
|
||
waitFor(by.id("username"), 5); | ||
String username = find(by.id("username")).getDomProperty("value"); | ||
String email = find(by.id("email")).getDomProperty("value"); | ||
String firstName = find(by.id("firstName")).getDomProperty("value"); | ||
String lastName = find(by.id("lastName")).getDomProperty("value"); | ||
|
||
return new User(null /* id not available in this page*/, username, email, firstName, lastName); | ||
} | ||
|
||
public void logout(User user) { | ||
final String caption = user.getFirstName() + " " + user.getLastName(); | ||
waitFor(by.button(caption), 5); | ||
clickButton(caption); | ||
waitFor(by.button("Sign out")); | ||
clickButton("Sign out"); | ||
} | ||
|
||
public static class User { | ||
|
||
private final String id; | ||
private final String userName; | ||
private final String email; | ||
private final String firstName; | ||
private final String lastName; | ||
|
||
public User(String id, String userName, String email, String firstName, String lastName) { | ||
this.id = id; | ||
this.userName = userName; | ||
this.email = email; | ||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public String getUserName() { | ||
return userName; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
public String getLastName() { | ||
return lastName; | ||
} | ||
} | ||
} |
Oops, something went wrong.