KEYCLOAK-7584 Fix some admin console tests broken by adding clientScopes support
This commit is contained in:
parent
c0b5c12dee
commit
5ae126b10e
5 changed files with 44 additions and 81 deletions
|
@ -38,12 +38,6 @@ public class CreateClientMappersForm extends Form {
|
|||
@FindBy(id = "name")
|
||||
private WebElement nameElement;
|
||||
|
||||
@FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='consentRequired']]")
|
||||
private OnOffSwitch consentRequiredSwitch;
|
||||
|
||||
@FindBy(id = "consentText")
|
||||
private WebElement consentTextElement;
|
||||
|
||||
@FindBy(id = "mapperTypeCreate")
|
||||
private Select mapperTypeSelect;
|
||||
|
||||
|
@ -154,22 +148,6 @@ public class CreateClientMappersForm extends Form {
|
|||
UIUtils.setTextInputValue(nameElement, value);
|
||||
}
|
||||
|
||||
public boolean isConsentRequired() {
|
||||
return consentRequiredSwitch.isOn();
|
||||
}
|
||||
|
||||
public void setConsentRequired(boolean consentRequired) {
|
||||
consentRequiredSwitch.setOn(consentRequired);
|
||||
}
|
||||
|
||||
public String getConsentText() {
|
||||
return UIUtils.getTextInputValue(consentTextElement);
|
||||
}
|
||||
|
||||
public void setConsentText(String consentText) {
|
||||
UIUtils.setTextInputValue(consentTextElement, consentText);
|
||||
}
|
||||
|
||||
public void setMapperType(String type) {
|
||||
mapperTypeSelect.selectByVisibleText(type);
|
||||
}
|
||||
|
|
|
@ -19,9 +19,6 @@ public class RoleDetailsForm extends Form {
|
|||
@FindBy(id = "description")
|
||||
private WebElement descriptionInput;
|
||||
|
||||
@FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='scopeParamRequired']]")
|
||||
private OnOffSwitch scopeParamRequired;
|
||||
|
||||
@FindBy(xpath = ".//div[contains(@class,'onoffswitch') and ./input[@id='compositeSwitch']]")
|
||||
private OnOffSwitch compositeSwitch;
|
||||
|
||||
|
@ -32,7 +29,7 @@ public class RoleDetailsForm extends Form {
|
|||
private WebElement removeIcon;
|
||||
|
||||
public RoleRepresentation getRole() {
|
||||
RoleRepresentation role = new RoleRepresentation(getName(), getDescription(), isScopeParamRequired());
|
||||
RoleRepresentation role = new RoleRepresentation(getName(), getDescription(), false);
|
||||
role.setComposite(isComposite());
|
||||
if (role.isComposite()) {
|
||||
role.setComposites(compositeRoles.getComposites());
|
||||
|
@ -48,7 +45,6 @@ public class RoleDetailsForm extends Form {
|
|||
RoleRepresentation role = new RoleRepresentation();
|
||||
role.setName(getName());
|
||||
role.setDescription(getDescription());
|
||||
//role.setScopeParamRequired(isScopeParamRequired()); // TODO Do we need this param?
|
||||
role.setComposite(isComposite());
|
||||
log.info(role.getName() + ": " + role.getDescription() + ", comp: " + role.isComposite());
|
||||
return role;
|
||||
|
@ -57,7 +53,6 @@ public class RoleDetailsForm extends Form {
|
|||
public void setBasicAttributes(RoleRepresentation role) {
|
||||
setName(role.getName());
|
||||
setDescription(role.getDescription());
|
||||
setScopeParamRequired(role.isScopeParamRequired());
|
||||
if (role.isComposite()) {
|
||||
setCompositeRoles(role);
|
||||
}
|
||||
|
@ -88,14 +83,6 @@ public class RoleDetailsForm extends Form {
|
|||
return UIUtils.getTextInputValue(descriptionInput);
|
||||
}
|
||||
|
||||
public void setScopeParamRequired(boolean scopeParamRequired) {
|
||||
this.scopeParamRequired.setOn(scopeParamRequired);
|
||||
}
|
||||
|
||||
public boolean isScopeParamRequired() {
|
||||
return scopeParamRequired.isOn();
|
||||
}
|
||||
|
||||
public void setComposite(boolean composite) {
|
||||
compositeSwitch.setOn(composite);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.jboss.arquillian.graphene.page.Page;
|
|||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.protocol.oidc.mappers.OIDCAttributeMapperHelper;
|
||||
import org.keycloak.representations.idm.ClientRepresentation;
|
||||
import org.keycloak.representations.idm.ProtocolMapperRepresentation;
|
||||
import org.keycloak.testsuite.console.page.clients.mappers.ClientMapper;
|
||||
|
@ -68,19 +69,15 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
clientMappersPage.navigateTo();
|
||||
}
|
||||
|
||||
private void setInitialValues(String name, boolean consentRequired, String consentText) {
|
||||
private void setInitialValues(String name) {
|
||||
createClientMappersPage.form().setName(name);
|
||||
createClientMappersPage.form().setConsentRequired(consentRequired);
|
||||
if (consentRequired) {
|
||||
createClientMappersPage.form().setConsentText(consentText);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHardcodedRole() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("hardcoded role", true, "Consent Text");
|
||||
setInitialValues("hardcoded role");
|
||||
createClientMappersPage.form().setMapperType(HARDCODED_ROLE);
|
||||
createClientMappersPage.form().selectRole(REALM_ROLE, "offline_access", null);
|
||||
createClientMappersPage.form().save();
|
||||
|
@ -90,8 +87,6 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
ProtocolMapperRepresentation found = findClientMapperByName(id, "hardcoded role");
|
||||
assertNotNull(found);
|
||||
|
||||
assertTrue(found.isConsentRequired());
|
||||
assertEquals("Consent Text", found.getConsentText());
|
||||
assertEquals("oidc-hardcoded-role-mapper", found.getProtocolMapper());
|
||||
Map<String, String> config = found.getConfig();
|
||||
|
||||
|
@ -119,7 +114,7 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
public void testHardcodedClaim() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("hardcoded claim", false, null);
|
||||
setInitialValues("hardcoded claim");
|
||||
createClientMappersPage.form().setMapperType(HARDCODED_CLAIM);
|
||||
createClientMappersPage.form().setTokenClaimName("claim name");
|
||||
createClientMappersPage.form().setTokenClaimValue("claim value");
|
||||
|
@ -133,7 +128,6 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
ProtocolMapperRepresentation found = findClientMapperByName(id, "hardcoded claim");
|
||||
assertNotNull(found);
|
||||
|
||||
assertFalse(found.isConsentRequired());
|
||||
assertEquals("oidc-hardcoded-claim-mapper", found.getProtocolMapper());
|
||||
|
||||
Map<String, String> config = found.getConfig();
|
||||
|
@ -148,7 +142,7 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
public void testUserSessionNote() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("user session note", false, null);
|
||||
setInitialValues("user session note");
|
||||
createClientMappersPage.form().setMapperType(USER_SESSION_NOTE);
|
||||
createClientMappersPage.form().setUserSessionNote("session note");
|
||||
createClientMappersPage.form().setTokenClaimName("claim name");
|
||||
|
@ -162,7 +156,6 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
ProtocolMapperRepresentation found = findClientMapperByName(id, "user session note");
|
||||
assertNotNull(found);
|
||||
|
||||
assertFalse(found.isConsentRequired());
|
||||
assertEquals("oidc-usersessionmodel-note-mapper", found.getProtocolMapper());
|
||||
|
||||
Map<String, String> config = found.getConfig();
|
||||
|
@ -175,7 +168,7 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
public void testRoleName() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("role name", false, null);
|
||||
setInitialValues("role name");
|
||||
createClientMappersPage.form().setMapperType(ROLE_NAME_MAPPER);
|
||||
createClientMappersPage.form().setRole("offline_access");
|
||||
createClientMappersPage.form().setNewRole("new role");
|
||||
|
@ -195,7 +188,7 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
public void testUserAddress() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("user address", false, null);
|
||||
setInitialValues("user address");
|
||||
createClientMappersPage.form().setMapperType(USERS_FULL_NAME);
|
||||
createClientMappersPage.form().save();
|
||||
assertAlertSuccess();
|
||||
|
@ -209,7 +202,7 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
public void testUserFullName() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("user full name", false, null);
|
||||
setInitialValues("user full name");
|
||||
createClientMappersPage.form().setMapperType(USERS_FULL_NAME);
|
||||
createClientMappersPage.form().save();
|
||||
assertAlertSuccess();
|
||||
|
@ -223,7 +216,7 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
public void testUserAttribute() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("user attribute", false, null);
|
||||
setInitialValues("user attribute");
|
||||
createClientMappersPage.form().setMapperType(USER_ATTRIBUTE);
|
||||
createClientMappersPage.form().setUserAttribute("user attribute");
|
||||
createClientMappersPage.form().setMultivalued(true);
|
||||
|
@ -243,7 +236,7 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
public void testUserProperty() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("user property", false, null);
|
||||
setInitialValues("user property");
|
||||
createClientMappersPage.form().setMapperType(USER_PROPERTY);
|
||||
createClientMappersPage.form().setProperty("property");
|
||||
createClientMappersPage.form().save();
|
||||
|
@ -261,7 +254,7 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
public void testGroupMembership() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("group membership", false, null);
|
||||
setInitialValues("group membership");
|
||||
createClientMappersPage.form().setMapperType(GROUP_MEMBERSHIP);
|
||||
createClientMappersPage.form().setFullGroupPath(true);
|
||||
createClientMappersPage.form().save();
|
||||
|
@ -306,8 +299,6 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
assertEquals("openid-connect", clientMapperPage.form().getProtocol());
|
||||
assertEquals(mapperId, clientMapperPage.form().getMapperId());
|
||||
assertEquals("mapper name", clientMapperPage.form().getName());
|
||||
assertTrue(clientMapperPage.form().isConsentRequired());
|
||||
assertEquals("consent text", clientMapperPage.form().getConsentText());
|
||||
assertEquals("User Session Note", clientMapperPage.form().getMapperType());
|
||||
assertEquals("session note", clientMapperPage.form().getUserSessionNote());
|
||||
assertEquals("claim name", clientMapperPage.form().getTokenClaimName());
|
||||
|
@ -316,12 +307,18 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
assertTrue(clientMapperPage.form().isAddToAccessToken());
|
||||
|
||||
//edit
|
||||
clientMapperPage.form().setConsentRequired(false);
|
||||
clientMapperPage.form().setAddToAccessToken(false);
|
||||
clientMapperPage.form().save();
|
||||
assertAlertSuccess();
|
||||
|
||||
//check
|
||||
assertFalse(findClientMapperByName(id, "mapper name").isConsentRequired());
|
||||
assertTrue(clientMapperPage.form().isAddToIDToken());
|
||||
assertFalse(clientMapperPage.form().isAddToAccessToken());
|
||||
|
||||
ProtocolMapperRepresentation rep = findClientMapperByName(id, "mapper name");
|
||||
assertEquals("false", rep.getConfig().get(OIDCAttributeMapperHelper.INCLUDE_IN_ACCESS_TOKEN));
|
||||
assertEquals("true", rep.getConfig().get(OIDCAttributeMapperHelper.INCLUDE_IN_ID_TOKEN));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -353,7 +350,16 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
|
||||
@Test
|
||||
public void testCreateMapperInvalidValues() {
|
||||
//create some mapper, so we have some existing
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("hardcoded role - existing");
|
||||
createClientMappersPage.form().setMapperType(HARDCODED_ROLE);
|
||||
createClientMappersPage.form().selectRole(REALM_ROLE, "offline_access", null);
|
||||
createClientMappersPage.form().save();
|
||||
assertAlertSuccess();
|
||||
|
||||
//empty mapper type
|
||||
clientMappersPage.navigateTo();
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
createClientMappersPage.form().save();
|
||||
assertAlertDanger();
|
||||
|
@ -373,7 +379,7 @@ public class ClientMappersOIDCTest extends AbstractClientTest {
|
|||
assertAlertDanger();
|
||||
|
||||
//existing name
|
||||
createClientMappersPage.form().setName("email");
|
||||
createClientMappersPage.form().setName("hardcoded role - existing");
|
||||
createClientMappersPage.form().save();
|
||||
assertAlertDanger();
|
||||
}
|
||||
|
|
|
@ -63,19 +63,15 @@ public class ClientMappersSAMLTest extends AbstractClientTest {
|
|||
clientMappersPage.navigateTo();
|
||||
}
|
||||
|
||||
private void setInitialValues(String name, boolean consentRequired, String consentText) {
|
||||
private void setInitialValues(String name) {
|
||||
createClientMappersPage.form().setName(name);
|
||||
createClientMappersPage.form().setConsentRequired(consentRequired);
|
||||
if (consentRequired) {
|
||||
createClientMappersPage.form().setConsentText(consentText);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRoleName() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("role name", false, null);
|
||||
setInitialValues("role name");
|
||||
createClientMappersPage.form().setMapperType(ROLE_NAME_MAPPER);
|
||||
createClientMappersPage.form().setRole("offline_access");
|
||||
createClientMappersPage.form().setNewRole("new role");
|
||||
|
@ -95,7 +91,7 @@ public class ClientMappersSAMLTest extends AbstractClientTest {
|
|||
public void testRoleList() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("new role list", false, null);
|
||||
setInitialValues("new role list");
|
||||
createClientMappersPage.form().setMapperType(ROLE_LIST);
|
||||
createClientMappersPage.form().setRoleAttributeName("role attribute name");
|
||||
createClientMappersPage.form().setFriendlyName("friendly name");
|
||||
|
@ -108,7 +104,6 @@ public class ClientMappersSAMLTest extends AbstractClientTest {
|
|||
ProtocolMapperRepresentation found = findClientMapperByName(id, "new role list");
|
||||
assertNotNull(found);
|
||||
|
||||
assertFalse(found.isConsentRequired());
|
||||
assertEquals("saml-role-list-mapper", found.getProtocolMapper());
|
||||
|
||||
Map<String, String> config = found.getConfig();
|
||||
|
@ -122,7 +117,7 @@ public class ClientMappersSAMLTest extends AbstractClientTest {
|
|||
public void testUserProperty() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("user property", false, null);
|
||||
setInitialValues("user property");
|
||||
createClientMappersPage.form().setMapperType(USER_PROPERTY);
|
||||
createClientMappersPage.form().save();
|
||||
assertAlertSuccess();
|
||||
|
@ -136,7 +131,7 @@ public class ClientMappersSAMLTest extends AbstractClientTest {
|
|||
public void testUserSessionNote() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("user session note", false, null);
|
||||
setInitialValues("user session note");
|
||||
createClientMappersPage.form().setMapperType(USER_SESSION_NOTE);
|
||||
createClientMappersPage.form().save();
|
||||
assertAlertSuccess();
|
||||
|
@ -145,7 +140,6 @@ public class ClientMappersSAMLTest extends AbstractClientTest {
|
|||
ProtocolMapperRepresentation found = findClientMapperByName(id, "user session note");
|
||||
assertNotNull(found);
|
||||
|
||||
assertFalse(found.isConsentRequired());
|
||||
assertEquals("saml-user-session-note-mapper", found.getProtocolMapper());
|
||||
}
|
||||
|
||||
|
@ -153,7 +147,7 @@ public class ClientMappersSAMLTest extends AbstractClientTest {
|
|||
public void testHardcodedAttribute() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("hardcoded attribute", false, null);
|
||||
setInitialValues("hardcoded attribute");
|
||||
createClientMappersPage.form().setMapperType(HARDCODED_ATTRIBUTE);
|
||||
createClientMappersPage.form().setAttributeValue("attribute value");
|
||||
createClientMappersPage.form().save();
|
||||
|
@ -163,7 +157,6 @@ public class ClientMappersSAMLTest extends AbstractClientTest {
|
|||
ProtocolMapperRepresentation found = findClientMapperByName(id, "hardcoded attribute");
|
||||
assertNotNull(found);
|
||||
|
||||
assertFalse(found.isConsentRequired());
|
||||
assertEquals("saml-hardcode-attribute-mapper", found.getProtocolMapper());
|
||||
|
||||
Map<String, String> config = found.getConfig();
|
||||
|
@ -174,7 +167,7 @@ public class ClientMappersSAMLTest extends AbstractClientTest {
|
|||
public void testGroupList() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("group list", false, null);
|
||||
setInitialValues("group list");
|
||||
createClientMappersPage.form().setMapperType(GROUP_LIST);
|
||||
createClientMappersPage.form().setGroupAttributeName("group attribute name");
|
||||
createClientMappersPage.form().setSingleGroupAttribute(true);
|
||||
|
@ -196,7 +189,7 @@ public class ClientMappersSAMLTest extends AbstractClientTest {
|
|||
public void testHardcodedRole() {
|
||||
//create
|
||||
clientMappersPage.mapperTable().createMapper();
|
||||
setInitialValues("hardcoded role", false, null);
|
||||
setInitialValues("hardcoded role");
|
||||
createClientMappersPage.form().setMapperType(HARDCODED_ROLE_SAML);
|
||||
createClientMappersPage.form().selectRole(REALM_ROLE, "offline_access", null);
|
||||
createClientMappersPage.form().save();
|
||||
|
|
|
@ -74,7 +74,6 @@ public class ClientRolesTest extends AbstractClientTest {
|
|||
RoleRepresentation role = clientRoles.get(0);
|
||||
assertEquals(TEST_CLIENT_ROLE_NAME, role.getName());
|
||||
assertEquals("description", role.getDescription());
|
||||
assertFalse(role.isScopeParamRequired());
|
||||
assertFalse(role.isComposite());
|
||||
assertNull(role.getComposites());
|
||||
|
||||
|
|
Loading…
Reference in a new issue