-
Notifications
You must be signed in to change notification settings - Fork 237
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
Add oic auth e2e #1701
Merged
Merged
Add oic auth e2e #1701
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
66f2942
Add test for oic-auth plugin
fcojfernandez 984124f
Retrieve and check the roles from the OICD provider
fcojfernandez 7e52a88
Merge branch 'master' into add-oic-auth-e2e
fcojfernandez ac188a0
Update src/main/java/org/jenkinsci/test/acceptance/po/OicAuthSecurity…
fcojfernandez 7cfbcf9
Apply suggestions
fcojfernandez 95e5e31
Add the WhoAmI page
fcojfernandez 067ae95
Fix permissions on the docker socket
jtnord 5df158e
Merge branch 'master' into add-oic-auth-e2e
jtnord b0a679c
Merge remote-tracking branch 'origin/master' into add-oic-auth-e2e
basil 5fbb288
Incremental build
basil d3393fb
Remove unused libraries
fcojfernandez 9c7ae5a
Add missing dependencies
fcojfernandez edb1a50
Merge branch 'master' of https://github.com/jenkinsci/acceptance-test…
basil d007fd0
New incremental
basil ecfdff1
Merge branch 'master' into add-oic-auth-e2e
basil a58d1f9
New incremental
basil 49159eb
update to 2.476
jtnord fe0afc9
Merge branch 'master' into add-oic-auth-e2e
basil da7973e
document testcontainers requirement
jtnord d9fa1de
update keycloak container vie renovate
jtnord ed35891
s/TestContainers/Testcontainers
jtnord 49d9388
keep the spotless overlords happy
jtnord File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG_LEVEL=debug RENOVATE_CONFIG_FILE=/usr/src/app/.github/renovate.json renovate --platform=local
shows this will match: