Skip to content
New issue

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

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

Already on GitHub? # to your account

[JENKINS-74005] Obtaining login button via href instead of text #1805

Merged
merged 3 commits into from
Oct 23, 2024
Merged
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
13 changes: 9 additions & 4 deletions src/test/java/plugins/OicAuthPluginTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.keycloak.representations.idm.RoleRepresentation;
import org.keycloak.representations.idm.UserRepresentation;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;

@WithPlugins("oic-auth")
public class OicAuthPluginTest extends AbstractJUnitTest {
Expand Down Expand Up @@ -234,7 +235,7 @@ public void loginAndLogoutInJenkinsIsReflectedInKeycloak() {
new KeycloakUtils.User(userJohnKeycloakId, "john", "john@jenkins-ath.test", "John", "Smith");
jenkins.open();

jenkins.clickLink("log in");
getLogin().click();
keycloakUtils.login(bob.getUserName());
assertLoggedUser(bob, "jenkinsAdmin");

Expand All @@ -246,7 +247,7 @@ public void loginAndLogoutInJenkinsIsReflectedInKeycloak() {
// so the login page will appear again
jenkins.open();

clickLink("log in");
getLogin().click();
keycloakUtils.login(john.getUserName());
assertLoggedUser(john, "jenkinsRead");
}
Expand All @@ -268,7 +269,7 @@ public void loginAndLogoutInKeycloakIsReflectedInJenkins() throws Exception {

keycloakUtils.login(bob.getUserName());
jenkins.open();
jenkins.clickLink("log in"); // won't request a login, but log in directly with user from
getLogin().click(); // won't request a login, but log in directly with user from

assertLoggedUser(bob, "jenkinsAdmin");

Expand All @@ -279,11 +280,15 @@ public void loginAndLogoutInKeycloakIsReflectedInJenkins() throws Exception {

// Once logged out, we can change the user
jenkins.open();
jenkins.clickLink("log in");
getLogin().click();
keycloakUtils.login(john.getUserName());
assertLoggedUser(john, "jenkinsRead");
}

private WebElement getLogin() {
return getElement(by.href("/securityRealm/commenceLogin?from=%2F"));
}

private void assertLoggedOut() {
assertNull("User has logged out from Jenkins", jenkins.getCurrentUser().id());

Expand Down
Loading