8000 Fix build problems by stianst · Pull Request #48325 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
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
Expand Up @@ -106,9 +106,9 @@ public void clickTryAnotherWayLink() {
public void assertSwitchOrganizationLinkAvailability(boolean expectedAvailability) {
try {
driver.findElement(By.id("switch-organization"));
Assert.assertTrue(expectedAvailability);
Assertions.assertTrue(expectedAvailability);
} catch (NoSuchElementException nse) {
Assert.assertFalse(expectedAvailability);
Assertions.assertFalse(expectedAvailability);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

public class ProtectionResourceTest extends AbstractResourceServerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ public void testUsernameExposureWhenEnteringEmail() {
public void testSwitchOrganizationDuringLogin() {
OrganizationRepresentation orgA = createOrganization();
OrganizationRepresentation orgB = createOrganization("org-b");
OrganizationResource orgAResource = testRealm().organizations().get(orgA.getId());
OrganizationResource orgBResource = testRealm().organizations().get(orgB.getId());
OrganizationResource orgAResource = managedRealm.admin().organizations().get(orgA.getId());
OrganizationResource orgBResource = managedRealm.admin().organizations().get(orgB.getId());
UserRepresentation member = addMember(orgAResource);
orgBResource.members().addMember(member.getId()).close();

Expand All @@ -425,15 +425,15 @@ public void testSwitchOrganizationDuringLogin() {

// org selection page should be shown
selectOrganizationPage.assertCurrent();
Assert.assertTrue(selectOrganizationPage.isOrganizationButtonPresent(orgA.getAlias()));
Assert.assertTrue(selectOrganizationPage.isOrganizationButtonPresent(orgB.getAlias()));
Assertions.assertTrue(selectOrganizationPage.isOrganizationButtonPresent(orgA.getAlias()));
Assertions.assertTrue(selectOrganizationPage.isOrganizationButtonPresent(orgB.getAlias()));

// select org A
selectOrganizationPage.selectOrganization(orgA.getAlias());

// should be on the password page now
loginPage.assertAttemptedUsernameAvailability(true);
Assert.assertTrue(loginPage.isPasswordInputPresent());
Assertions.assertTrue(loginPage.isPasswordInputPresent());

// switch organization link should be available
loginPage.assertSwitchOrganizationLinkAvailability(true);
Expand All @@ -443,14 +443,14 @@ public void testSwitchOrganizationDuringLogin() {

// org selection page should be shown again
selectOrganizationPage.assertCurrent();
Assert.assertTrue(selectOrganizationPage.isOrganizationButtonPresent(orgA.getAlias()));
Assert.assertTrue(selectOrganizationPage.isOrganizationButtonPresent(orgB.getAlias()));
Assertions.assertTrue(selectOrganizationPage.isOrganizationButtonPresent(orgA.getAlias()));
Assertions.assertTrue(selectOrganizationPage.isOrganizationButtonPresent(orgB.getAlias()));

// select org B this time
selectOrganizationPage.selectOrganization(orgB.getAlias());

// should be on the password page again
Assert.assertTrue(loginPage.isPasswordInputPresent());
Assertions.assertTrue(loginPage.isPasswordInputPresent());

// complete login
loginPage.login(memberPassword);
Expand All @@ -469,17 +469,17 @@ public void testSwitchOrganizationDuringLogin() {
@Test
public void testSwitchOrganizationNotAvailableForSingleOrgUser() {
OrganizationRepresentation org = createOrganization();
OrganizationResource orgResource = testRealm().organizations().get(org.getId());
OrganizationResource orgResource = managedRealm.admin().organizations().get(org.getId());
UserRepresentation member = addMember(orgResource);

// login with "organization" scope — single org member should NOT see org selection
oauth.clientId("broker-app");
oauth.client("broker-app");
oauth.scope("organization");
loginPage.open(bc.consumerRealmName());
loginPage.loginUsername(member.getEmail());

// should go directly to password page (no org selection for single-org users)
Assert.assertTrue(loginPage.isPasswordInputPresent());
Assertions.assertTrue(loginPage.isPasswordInputPresent());

// switch organization link should NOT be available
loginPage.assertSwitchOrganizationLinkAvailability(false);
Expand All @@ -489,19 +489,19 @@ public void testSwitchOrganizationNotAvailableForSingleOrgUser() {
public void testSwitchOrganizationNotAvailableWithSpecificScope() {
OrganizationRepresentation orgA = createOrganization();
OrganizationRepresentation orgB = createOrganization("org-b");
OrganizationResource orgAResource = testRealm().organizations().get(orgA.getId());
OrganizationResource orgBResource = testRealm().organizations().get(orgB.getId());
OrganizationResource orgAResource = managedRealm.admin().organizations().get(orgA.getId());
OrganizationResource orgBResource = managedRealm.admin().organizations().get(orgB.getId());
UserRepresentation member = addMember(orgAResource);
orgBResource.members().addMember(member.getId()).close();

// login with specific organization scope — no org selection should be shown
oauth.clientId("broker-app");
oauth.client("broker-app");
oauth.scope("organization:" + orgA.getAlias());
loginPage.open(bc.consumerRealmName());
loginPage.loginUsername(member.getEmail());

// should go directly to password page (specific org requested by client)
Assert.assertTrue(loginPage.isPasswordInputPresent());
Assertions.assertTrue(loginPage.isPasswordInputPresent());

// switch organization link should NOT be available
loginPage.assertSwitchOrganizationLinkAvailability(false);
Expand All @@ -511,19 +511,19 @@ public void testSwitchOrganizationNotAvailableWithSpecificScope() {
public void testSwitchOrganizationNotAvailableWithWildcardScope() {
OrganizationRepresentation orgA = createOrganization();
OrganizationRepresentation orgB = createOrganization("org-b");
OrganizationResource orgAResource = testRealm().organizations().get(orgA.getId());
OrganizationResource orgBResource = testRealm().organizations().get(orgB.getId());
OrganizationResource orgAResource = managedRealm.admin().organizations().get(orgA.getId());
OrganizationResource orgBResource = managedRealm.admin().organizations().get(orgB.getId());
UserRepresentation member = addMember(orgAResource);
orgBResource.members().addMember(member.getId()).close();

// login with wildcard organization scope — no org selection should be shown
oauth.clientId("broker-app");
oauth.client("broker-app");
oauth.scope("organization:*");
loginPage.open(bc.consumerRealmName());
loginPage.loginUsername(member.getEmail());

// should go directly to password page (all orgs mapped)
Assert.assertTrue(loginPage.isPasswordInputPresent());
Assertions.assertTrue(loginPage.isPasswordInputPresent());

// switch organization link should NOT be available
loginPage.assertSwitchOrganizationLinkAvailability(false);
Expand All @@ -533,13 +533,13 @@ public void testSwitchOrganizationNotAvailableWithWildcardScope() {
public void testUsernamePreservedAfterSwitchOrganization() {
OrganizationRepresentation orgA = createOrganization();
OrganizationRepresentation orgB = createOrganization("org-b");
OrganizationResource orgAResource = testRealm().organizations().get(orgA.getId());
OrganizationResource orgBResource = testRealm().organizations().get(orgB.getId());
OrganizationResource orgAResource = managedRealm.admin().organizations().get(orgA.getId());
OrganizationResource orgBResource = managedRealm.admin().organizations().get(orgB.getId());
UserRepresentation member = addMember(orgAResource);
orgBResource.members().addMember(member.getId()).close();

// login with "organization" scope to trigger org selection
oauth.clientId("broker-app");
oauth.client("broker-app");
oauth.scope("organization");
loginPage.open(bc.consumerRealmName());
loginPage.loginUsername(member.getEmail());
Expand Down
Loading
0