Skip to content

Commit

Permalink
[JENKINS-74005] Obtaining login button via href instead of text (#1805)
Browse files Browse the repository at this point in the history
  • Loading branch information
PereBueno authored Oct 23, 2024
1 parent 122bbab commit 7bb95bd
Showing 1 changed file with 9 additions and 4 deletions.
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

0 comments on commit 7bb95bd

Please # to comment.