diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/fragment/DataTable.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/fragment/DataTable.java index 4a4e19722c..2b1040a808 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/fragment/DataTable.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/fragment/DataTable.java @@ -17,7 +17,6 @@ package org.keycloak.testsuite.console.page.fragment; -import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -90,7 +89,7 @@ public class DataTable { } public void clickRowActionButton(WebElement row, String buttonText) { - row.findElement(xpath(".//button[text()='" + buttonText + "']")).click(); + row.findElement(xpath(".//td[contains(@class, 'kc-action-cell') and text()='" + buttonText + "']")).click(); } } diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/fragment/ModalDialog.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/fragment/ModalDialog.java index df31a4739c..8159d34ef9 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/fragment/ModalDialog.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/fragment/ModalDialog.java @@ -18,6 +18,9 @@ package org.keycloak.testsuite.console.page.fragment; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement; + +import org.jboss.arquillian.graphene.fragment.Root; +import static org.keycloak.testsuite.util.WaitUtils.pause; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -27,6 +30,9 @@ import org.openqa.selenium.support.FindBy; */ public class ModalDialog { + @Root + private WebElement root; + @FindBy(xpath = ".//button[text()='Cancel']") private WebElement cancelButton; @FindBy(xpath = ".//button[text()='Delete']") @@ -40,16 +46,20 @@ public class ModalDialog { public void ok() { waitUntilElement(okButton).is().present(); okButton.click(); + waitUntilElement(root).is().not().present(); } public void confirmDeletion() { waitUntilElement(deleteButton).is().present(); deleteButton.click(); + waitUntilElement(root).is().not().present(); + pause(100); } public void cancel() { waitUntilElement(cancelButton).is().present(); cancelButton.click(); + waitUntilElement(root).is().not().present(); } public void setName(String name) { @@ -57,4 +67,4 @@ public class ModalDialog { nameInput.clear(); nameInput.sendKeys(name); } -} +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/CreateClientForm.java b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/CreateClientForm.java index 0269e03191..c289e67c41 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/CreateClientForm.java +++ b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/CreateClientForm.java @@ -1,13 +1,6 @@ package org.keycloak.testsuite.console.page.clients; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import org.jboss.arquillian.graphene.page.Page; import org.keycloak.representations.idm.ClientRepresentation; -import static org.keycloak.testsuite.auth.page.login.OIDCLogin.OIDC; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.*; -import org.keycloak.testsuite.console.page.fragment.OnOffSwitch; import org.keycloak.testsuite.page.Form; import static org.keycloak.testsuite.page.Form.getInputValue; import static org.keycloak.testsuite.util.WaitUtils.*; @@ -28,13 +21,6 @@ public class CreateClientForm extends Form { @FindBy(id = "protocol") private Select protocolSelect; - @Page - private SAMLClientSettingsForm samlForm; - - public SAMLClientSettingsForm samlForm() { - return samlForm; - } - public void setValues(ClientRepresentation client) { waitUntilElement(clientIdInput).is().present(); @@ -50,22 +36,6 @@ public class CreateClientForm extends Form { setInputValue(clientIdInput, clientId); } - public enum OidcAccessType { - BEARER_ONLY("bearer-only"), - PUBLIC("public"), - CONFIDENTIAL("confidential"); - - private final String name; - - private OidcAccessType(String name) { - this.name = name; - } - - public String getName() { - return name; - } - } - public String getProtocol() { waitUntilElement(protocolSelect.getFirstSelectedOption()).is().present(); return protocolSelect.getFirstSelectedOption().getText(); @@ -76,86 +46,4 @@ public class CreateClientForm extends Form { protocolSelect.selectByVisibleText(protocol); Timer.DEFAULT.reset("clientSettings.setProtocol()"); } - - public class SAMLClientSettingsForm extends Form { - - public static final String SAML_ASSERTION_SIGNATURE = "saml.assertion.signature"; - public static final String SAML_AUTHNSTATEMENT = "saml.authnstatement"; - public static final String SAML_CLIENT_SIGNATURE = "saml.client.signature"; - public static final String SAML_ENCRYPT = "saml.encrypt"; - public static final String SAML_FORCE_POST_BINDING = "saml.force.post.binding"; - public static final String SAML_MULTIVALUED_ROLES = "saml.multivalued.roles"; - public static final String SAML_SERVER_SIGNATURE = "saml.server.signature"; - public static final String SAML_SIGNATURE_ALGORITHM = "saml.signature.algorithm"; - public static final String SAML_ASSERTION_CONSUMER_URL_POST = "saml_assertion_consumer_url_post"; - public static final String SAML_ASSERTION_CONSUMER_URL_REDIRECT = "saml_assertion_consumer_url_redirect"; - public static final String SAML_FORCE_NAME_ID_FORMAT = "saml_force_name_id_format"; - public static final String SAML_NAME_ID_FORMAT = "saml_name_id_format"; - public static final String SAML_SIGNATURE_CANONICALIZATION_METHOD = "saml_signature_canonicalization_method"; - public static final String SAML_SINGLE_LOGOUT_SERVICE_URL_POST = "saml_single_logout_service_url_post"; - public static final String SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT = "saml_single_logout_service_url_redirect"; - - @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlAuthnStatement']]") - private OnOffSwitch samlAuthnStatement; - @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlServerSignature']]") - private OnOffSwitch samlServerSignature; - @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlAssertionSignature']]") - private OnOffSwitch samlAssertionSignature; - @FindBy(id = "signatureAlgorithm") - private Select signatureAlgorithm; - @FindBy(id = "canonicalization") - private Select canonicalization; - @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlEncrypt']]") - private OnOffSwitch samlEncrypt; - @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlClientSignature']]") - private OnOffSwitch samlClientSignature; - @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlForcePostBinding']]") - private OnOffSwitch samlForcePostBinding; - @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='frontchannelLogout']]") - private OnOffSwitch frontchannelLogout; - @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlForceNameIdFormat']]") - private OnOffSwitch samlForceNameIdFormat; - @FindBy(id = "samlNameIdFormat") - private Select samlNameIdFormat; - - @FindBy(xpath = "//fieldset[contains(@data-ng-show, 'saml')]//i") - private WebElement fineGrainCollapsor; - - @FindBy(id = "consumerServicePost") - private WebElement consumerServicePostInput; - @FindBy(id = "consumerServiceRedirect") - private WebElement consumerServiceRedirectInput; - @FindBy(id = "logoutPostBinding") - private WebElement logoutPostBindingInput; - @FindBy(id = "logoutRedirectBinding") - private WebElement logoutRedirectBindingInput; - - public void setValues(ClientRepresentation client) { - waitUntilElement(fineGrainCollapsor).is().visible(); - - Map attributes = client.getAttributes(); - samlAuthnStatement.setOn("true".equals(attributes.get(SAML_AUTHNSTATEMENT))); - samlServerSignature.setOn("true".equals(attributes.get(SAML_SERVER_SIGNATURE))); - samlAssertionSignature.setOn("true".equals(attributes.get(SAML_ASSERTION_SIGNATURE))); - if (samlServerSignature.isOn() || samlAssertionSignature.isOn()) { - signatureAlgorithm.selectByVisibleText(attributes.get(SAML_SIGNATURE_ALGORITHM)); - canonicalization.selectByValue("string:" + attributes.get(SAML_SIGNATURE_CANONICALIZATION_METHOD)); - } - samlEncrypt.setOn("true".equals(attributes.get(SAML_ENCRYPT))); - samlClientSignature.setOn("true".equals(attributes.get(SAML_CLIENT_SIGNATURE))); - samlForcePostBinding.setOn("true".equals(attributes.get(SAML_FORCE_POST_BINDING))); - frontchannelLogout.setOn(client.isFrontchannelLogout()); - samlForceNameIdFormat.setOn("true".equals(attributes.get(SAML_FORCE_NAME_ID_FORMAT))); - samlNameIdFormat.selectByVisibleText(attributes.get(SAML_NAME_ID_FORMAT)); - - fineGrainCollapsor.click(); - waitUntilElement(consumerServicePostInput).is().present(); - - setInputValue(consumerServicePostInput, attributes.get(SAML_ASSERTION_CONSUMER_URL_POST)); - setInputValue(consumerServiceRedirectInput, attributes.get(SAML_ASSERTION_CONSUMER_URL_REDIRECT)); - setInputValue(logoutPostBindingInput, attributes.get(SAML_SINGLE_LOGOUT_SERVICE_URL_POST)); - setInputValue(logoutRedirectBindingInput, attributes.get(SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT)); - } - } - -} +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/credentials/ClientCredentialsGeneratePrivateKeysForm.java b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/credentials/ClientCredentialsGeneratePrivateKeysForm.java index 1994c0af80..f5afcacdc6 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/credentials/ClientCredentialsGeneratePrivateKeysForm.java +++ b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/credentials/ClientCredentialsGeneratePrivateKeysForm.java @@ -22,6 +22,7 @@ package org.keycloak.testsuite.console.page.clients.credentials; import org.keycloak.testsuite.page.Form; +import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.ui.Select; @@ -68,6 +69,7 @@ public class ClientCredentialsGeneratePrivateKeysForm extends Form { } public void clickGenerateAndDownload() { + waitUntilElement(generateAndDownloadButton).is().present(); generateAndDownloadButton.click(); } } diff --git a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/mappers/CreateClientMappersForm.java b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/mappers/CreateClientMappersForm.java index 73957bc289..9eae0bef8f 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/mappers/CreateClientMappersForm.java +++ b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/mappers/CreateClientMappersForm.java @@ -2,6 +2,7 @@ package org.keycloak.testsuite.console.page.clients.mappers; import org.keycloak.testsuite.console.page.fragment.OnOffSwitch; import org.keycloak.testsuite.page.Form; +import static org.keycloak.testsuite.util.WaitUtils.pause; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.ui.Select; @@ -109,6 +110,7 @@ public class CreateClientMappersForm extends Form { realmAvailable.selectByVisibleText(roleName); } selectRealmRoleButton.click(); + pause(500); // wait for the modal dialog to fade out } public void selectClientRole(String clientName, String roleName) { @@ -117,6 +119,7 @@ public class CreateClientMappersForm extends Form { clientAvailable.selectByVisibleText(roleName); } selectClientRoleButton.click(); + pause(500); // wait for the modal dialog to fade out } } diff --git a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/settings/ClientSettingsForm.java b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/settings/ClientSettingsForm.java index 1e89e989ca..17c98df157 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/settings/ClientSettingsForm.java +++ b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/clients/settings/ClientSettingsForm.java @@ -8,14 +8,13 @@ import org.openqa.selenium.support.FindBy; import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.keycloak.testsuite.console.page.clients.CreateClientForm; import org.openqa.selenium.support.ui.Select; -import static org.keycloak.testsuite.auth.page.login.Login.OIDC; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.BEARER_ONLY; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.CONFIDENTIAL; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.PUBLIC; +import org.keycloak.testsuite.page.Form; import static org.keycloak.testsuite.util.WaitUtils.pause; +import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement; /** * @author tkyjovsk @@ -52,11 +51,11 @@ public class ClientSettingsForm extends CreateClientForm { @FindBy(id = "newRedirectUri") private WebElement newRedirectUriInput; - @FindBy(xpath = ".//i[contains(@data-ng-click, 'newRedirectUri')]") + @FindBy(xpath = ".//i[contains(@data-ng-click, 'newRedirectUri') and @class='fa fa-plus']") private WebElement newRedirectUriSubmit; @FindBy(xpath = ".//input[@ng-model='client.redirectUris[i]']") private List redirectUriInputs; - @FindBy(xpath = ".//i[contains(@data-ng-click, 'deleteRedirectUri')]") + @FindBy(xpath = ".//i[contains(@data-ng-click, 'deleteRedirectUri') and @class='fa fa-minus']") private List deleteRedirectUriIcons; @FindBy(id = "newWebOrigin") @@ -68,9 +67,22 @@ public class ClientSettingsForm extends CreateClientForm { @FindBy(xpath = ".//i[contains(@data-ng-click, 'deleteWebOrigin')]") private List deleteWebOriginIcons; - @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='consentRequired']]") - private OnOffSwitch consentRequired; + public enum OidcAccessType { + BEARER_ONLY("bearer-only"), + PUBLIC("public"), + CONFIDENTIAL("confidential"); + + private final String name; + private OidcAccessType(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } + public void setBaseUrl(String baseUrl) { setInputValue(baseUrlInput, baseUrl); } @@ -113,32 +125,6 @@ public class ClientSettingsForm extends CreateClientForm { } } - @Override - public void setValues(ClientRepresentation client) { - super.setValues(client); - setName(client.getName()); - setEnabled(client.isEnabled()); - setConsentRequired(client.isConsentRequired()); - setBaseUrl(client.getBaseUrl()); - if (OIDC.equals(client.getProtocol())) { - setAccessType(client); - if (!client.isBearerOnly()) { - setStandardFlowEnabled(client.isStandardFlowEnabled()); - setDirectAccessGrantsEnabled(client.isDirectAccessGrantsEnabled()); - if (client.isPublicClient()) { - setImplicitFlowEnabled(client.isImplicitFlowEnabled()); - } else {//confidential - setServiceAccountsEnabled(client.isServiceAccountsEnabled()); - } - if (client.isStandardFlowEnabled() || client.isImplicitFlowEnabled()) { - setRedirectUris(client.getRedirectUris()); - } - } - setAdminUrl(client.getAdminUrl()); - setWebOrigins(client.getWebOrigins()); - } - } - public String getName() { return getInputValue(nameInput); } @@ -163,14 +149,8 @@ public class ClientSettingsForm extends CreateClientForm { consentRequiredSwitch.setOn(consentRequired); } - public void setAccessType(ClientRepresentation client) { - if (client.isBearerOnly()) { - accessTypeSelect.selectByVisibleText(BEARER_ONLY.getName()); - } else if (client.isPublicClient()) { - accessTypeSelect.selectByVisibleText(PUBLIC.getName()); - } else { - accessTypeSelect.selectByVisibleText(CONFIDENTIAL.getName()); - } + public void setAccessType(OidcAccessType accessType) { + accessTypeSelect.selectByVisibleText(accessType.getName()); } public void addRedirectUri(String redirectUri) { @@ -233,5 +213,86 @@ public class ClientSettingsForm extends CreateClientForm { public void setServiceAccountsEnabled(boolean serviceAccountsEnabled) { serviceAccountsEnabledSwitch.setOn(serviceAccountsEnabled); } + + public class SAMLClientSettingsForm extends Form { -} + public static final String SAML_ASSERTION_SIGNATURE = "saml.assertion.signature"; + public static final String SAML_AUTHNSTATEMENT = "saml.authnstatement"; + public static final String SAML_CLIENT_SIGNATURE = "saml.client.signature"; + public static final String SAML_ENCRYPT = "saml.encrypt"; + public static final String SAML_FORCE_POST_BINDING = "saml.force.post.binding"; + public static final String SAML_MULTIVALUED_ROLES = "saml.multivalued.roles"; + public static final String SAML_SERVER_SIGNATURE = "saml.server.signature"; + public static final String SAML_SIGNATURE_ALGORITHM = "saml.signature.algorithm"; + public static final String SAML_ASSERTION_CONSUMER_URL_POST = "saml_assertion_consumer_url_post"; + public static final String SAML_ASSERTION_CONSUMER_URL_REDIRECT = "saml_assertion_consumer_url_redirect"; + public static final String SAML_FORCE_NAME_ID_FORMAT = "saml_force_name_id_format"; + public static final String SAML_NAME_ID_FORMAT = "saml_name_id_format"; + public static final String SAML_SIGNATURE_CANONICALIZATION_METHOD = "saml_signature_canonicalization_method"; + public static final String SAML_SINGLE_LOGOUT_SERVICE_URL_POST = "saml_single_logout_service_url_post"; + public static final String SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT = "saml_single_logout_service_url_redirect"; + + @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlAuthnStatement']]") + private OnOffSwitch samlAuthnStatement; + @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlServerSignature']]") + private OnOffSwitch samlServerSignature; + @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlAssertionSignature']]") + private OnOffSwitch samlAssertionSignature; + @FindBy(id = "signatureAlgorithm") + private Select signatureAlgorithm; + @FindBy(id = "canonicalization") + private Select canonicalization; + @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlEncrypt']]") + private OnOffSwitch samlEncrypt; + @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlClientSignature']]") + private OnOffSwitch samlClientSignature; + @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlForcePostBinding']]") + private OnOffSwitch samlForcePostBinding; + @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='frontchannelLogout']]") + private OnOffSwitch frontchannelLogout; + @FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='samlForceNameIdFormat']]") + private OnOffSwitch samlForceNameIdFormat; + @FindBy(id = "samlNameIdFormat") + private Select samlNameIdFormat; + + @FindBy(xpath = "//fieldset[contains(@data-ng-show, 'saml')]//i") + private WebElement fineGrainCollapsor; + + @FindBy(id = "consumerServicePost") + private WebElement consumerServicePostInput; + @FindBy(id = "consumerServiceRedirect") + private WebElement consumerServiceRedirectInput; + @FindBy(id = "logoutPostBinding") + private WebElement logoutPostBindingInput; + @FindBy(id = "logoutRedirectBinding") + private WebElement logoutRedirectBindingInput; + + public void setValues(ClientRepresentation client) { + waitUntilElement(fineGrainCollapsor).is().visible(); + + Map attributes = client.getAttributes(); + samlAuthnStatement.setOn("true".equals(attributes.get(SAML_AUTHNSTATEMENT))); + samlServerSignature.setOn("true".equals(attributes.get(SAML_SERVER_SIGNATURE))); + samlAssertionSignature.setOn("true".equals(attributes.get(SAML_ASSERTION_SIGNATURE))); + if (samlServerSignature.isOn() || samlAssertionSignature.isOn()) { + signatureAlgorithm.selectByVisibleText(attributes.get(SAML_SIGNATURE_ALGORITHM)); + canonicalization.selectByValue("string:" + attributes.get(SAML_SIGNATURE_CANONICALIZATION_METHOD)); + } + samlEncrypt.setOn("true".equals(attributes.get(SAML_ENCRYPT))); + samlClientSignature.setOn("true".equals(attributes.get(SAML_CLIENT_SIGNATURE))); + samlForcePostBinding.setOn("true".equals(attributes.get(SAML_FORCE_POST_BINDING))); + frontchannelLogout.setOn(client.isFrontchannelLogout()); + samlForceNameIdFormat.setOn("true".equals(attributes.get(SAML_FORCE_NAME_ID_FORMAT))); + samlNameIdFormat.selectByVisibleText(attributes.get(SAML_NAME_ID_FORMAT)); + + fineGrainCollapsor.click(); + waitUntilElement(consumerServicePostInput).is().present(); + + setInputValue(consumerServicePostInput, attributes.get(SAML_ASSERTION_CONSUMER_URL_POST)); + setInputValue(consumerServiceRedirectInput, attributes.get(SAML_ASSERTION_CONSUMER_URL_REDIRECT)); + setInputValue(logoutPostBindingInput, attributes.get(SAML_SINGLE_LOGOUT_SERVICE_URL_POST)); + setInputValue(logoutRedirectBindingInput, attributes.get(SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT)); + } + } + +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/roles/RoleCompositeRoles.java b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/roles/RoleCompositeRoles.java index 070f49acaf..b4ab777635 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/roles/RoleCompositeRoles.java +++ b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/roles/RoleCompositeRoles.java @@ -11,9 +11,12 @@ import java.util.Map; import java.util.Set; import org.keycloak.representations.idm.RoleRepresentation.Composites; import org.keycloak.testsuite.page.Form; +import static org.keycloak.testsuite.util.WaitUtils.pause; import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; +import org.openqa.selenium.logging.LogEntries; +import org.openqa.selenium.logging.LogEntry; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.ui.Select; @@ -106,6 +109,7 @@ public class RoleCompositeRoles extends Form { select.selectByVisibleText(role); } } + waitUntilElement(button).is().enabled(); button.click(); } } diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/AbstractClientTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/AbstractClientTest.java index 0f68266450..877aa3fdb2 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/AbstractClientTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/AbstractClientTest.java @@ -1,12 +1,10 @@ package org.keycloak.testsuite.console.clients; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import org.jboss.arquillian.graphene.page.Page; -import static org.junit.Assert.assertEquals; import org.junit.Before; import org.keycloak.admin.client.resource.ClientResource; import org.keycloak.admin.client.resource.ClientsResource; @@ -18,32 +16,20 @@ import org.keycloak.testsuite.console.AbstractConsoleTest; import org.keycloak.testsuite.console.page.clients.Client; import org.keycloak.testsuite.console.page.clients.Clients; import org.keycloak.testsuite.console.page.clients.CreateClient; -import org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType; -import org.keycloak.testsuite.console.page.clients.settings.ClientSettings; import org.keycloak.testsuite.util.WaitUtils; import org.openqa.selenium.By; - -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.*; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_ASSERTION_CONSUMER_URL_POST; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_ASSERTION_CONSUMER_URL_REDIRECT; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_ASSERTION_SIGNATURE; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_AUTHNSTATEMENT; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_CLIENT_SIGNATURE; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_ENCRYPT; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_FORCE_NAME_ID_FORMAT; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_FORCE_POST_BINDING; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_MULTIVALUED_ROLES; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_NAME_ID_FORMAT; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_SERVER_SIGNATURE; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_SIGNATURE_ALGORITHM; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_SIGNATURE_CANONICALIZATION_METHOD; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_SINGLE_LOGOUT_SERVICE_URL_POST; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.SAMLClientSettingsForm.SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT; import static org.keycloak.testsuite.util.AttributesAssert.assertEqualsBooleanAttributes; import static org.keycloak.testsuite.util.AttributesAssert.assertEqualsListAttributes; import static org.keycloak.testsuite.util.AttributesAssert.assertEqualsStringAttributes; +import static org.junit.Assert.assertEquals; +import static org.keycloak.testsuite.console.page.clients.settings.ClientSettingsForm.SAMLClientSettingsForm.SAML_AUTHNSTATEMENT; +import static org.keycloak.testsuite.console.page.clients.settings.ClientSettingsForm.SAMLClientSettingsForm.SAML_CLIENT_SIGNATURE; +import static org.keycloak.testsuite.console.page.clients.settings.ClientSettingsForm.SAMLClientSettingsForm.SAML_FORCE_NAME_ID_FORMAT; +import static org.keycloak.testsuite.console.page.clients.settings.ClientSettingsForm.SAMLClientSettingsForm.SAML_FORCE_POST_BINDING; +import static org.keycloak.testsuite.console.page.clients.settings.ClientSettingsForm.SAMLClientSettingsForm.SAML_NAME_ID_FORMAT; +import static org.keycloak.testsuite.console.page.clients.settings.ClientSettingsForm.SAMLClientSettingsForm.SAML_SERVER_SIGNATURE; +import static org.keycloak.testsuite.console.page.clients.settings.ClientSettingsForm.SAMLClientSettingsForm.SAML_SIGNATURE_ALGORITHM; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals; -import static org.keycloak.testsuite.util.WaitUtils.pause; /** * @@ -52,7 +38,7 @@ import static org.keycloak.testsuite.util.WaitUtils.pause; public abstract class AbstractClientTest extends AbstractConsoleTest { public final String TEST_CLIENT_ID = "test-client"; - public final String TEST_REDIRECT_URIS = "http://example.test/app/*"; + public final List TEST_REDIRECT_URIs = Arrays.asList(new String[]{"http://example.test/app/"}); @Page protected Clients clientsPage; @@ -60,12 +46,9 @@ public abstract class AbstractClientTest extends AbstractConsoleTest { protected Client clientPage; // note: cannot call navigateTo() unless client id is set @Page protected CreateClient createClientPage; - @Page - protected ClientSettings clientSettingsPage; @Before public void beforeClientTest() { -// configure().clients(); clientsPage.navigateTo(); } @@ -76,78 +59,35 @@ public abstract class AbstractClientTest extends AbstractConsoleTest { createClientPage.form().setValues(client); createClientPage.form().save(); assertAlertSuccess(); - - pause(500); // To ensure that the form will be loaded completely - - clientSettingsPage.form().setValues(client); - if (SAML.equals(client.getProtocol())) { - createClientPage.form().samlForm().setValues(client); - } - clientSettingsPage.form().save(); } - private static ClientRepresentation createClientRep(String clientId) { + public static ClientRepresentation createClientRep(String clientId, String protocol) { ClientRepresentation client = new ClientRepresentation(); client.setClientId(clientId); client.setEnabled(true); - client.setConsentRequired(false); - return client; - } - - public static ClientRepresentation createOidcClientRep(OidcAccessType accessType, String clientId, String... redirectUris) { - ClientRepresentation client = createClientRep(clientId); - - client.setProtocol(OIDC); - - switch (accessType) { - case BEARER_ONLY: - client.setBearerOnly(true); - break; - case PUBLIC: - client.setBearerOnly(false); - client.setPublicClient(true); - client.setStandardFlowEnabled(true); - client.setImplicitFlowEnabled(false); - client.setDirectAccessGrantsEnabled(true); - setRedirectUris(client, redirectUris); - break; - case CONFIDENTIAL: - client.setBearerOnly(false); - client.setPublicClient(false); - client.setStandardFlowEnabled(true); - client.setDirectAccessGrantsEnabled(true); - client.setServiceAccountsEnabled(true); - setRedirectUris(client, redirectUris); - break; + client.setProtocol(protocol); + + client.setDirectAccessGrantsEnabled(true); + client.setFullScopeAllowed(true); + client.setPublicClient(true); + client.setStandardFlowEnabled(true); + + if (protocol.equals(SAML)) { + client.setAttributes(getSAMLAttributes()); } return client; } - public static ClientRepresentation createSamlClientRep(String clinetId) { - ClientRepresentation client = createClientRep(clinetId); - - client.setProtocol(SAML); - - client.setFrontchannelLogout(true); - client.setAttributes(getSAMLAttributes()); - - return client; - } - - private static void setRedirectUris(ClientRepresentation client, String... redirectUris) { - List redirectUrisList = new ArrayList<>(); - redirectUrisList.addAll(Arrays.asList(redirectUris)); - client.setRedirectUris(redirectUrisList); - } - - protected static void setExpectedWebOrigins(ClientRepresentation client) { - List webOrigins = new ArrayList<>(); - for (String redirectUri : client.getRedirectUris()) { - //parse webOrigin from redirectUri: take substring from index 0 to - //first occurence of "/", excluded "http://" by starting search on index 7 - webOrigins.add(redirectUri.substring(0, redirectUri.indexOf("/", 7))); - } - client.setWebOrigins(webOrigins); + public static Map getSAMLAttributes() { + Map attributes = new HashMap<>(); + attributes.put(SAML_CLIENT_SIGNATURE, "true"); + attributes.put(SAML_AUTHNSTATEMENT, "true"); + attributes.put(SAML_FORCE_POST_BINDING, "true"); + attributes.put(SAML_SERVER_SIGNATURE, "true"); + attributes.put(SAML_SIGNATURE_ALGORITHM, "RSA_SHA256"); + attributes.put(SAML_FORCE_NAME_ID_FORMAT, "false"); + attributes.put(SAML_NAME_ID_FORMAT, "username"); + return attributes; } public ClientRepresentation findClientByClientId(String clientId) { @@ -172,16 +112,12 @@ public abstract class AbstractClientTest extends AbstractConsoleTest { if (c1.getProtocol().equals(OIDC)) { assertEqualsBooleanAttributes(c1.isBearerOnly(), c2.isBearerOnly()); - if (!c1.isBearerOnly()) { - assertEqualsBooleanAttributes(c1.isDirectAccessGrantsEnabled(), c2.isDirectAccessGrantsEnabled()); - assertEqualsBooleanAttributes(c1.isPublicClient(), c2.isPublicClient()); - assertEqualsListAttributes(c1.getWebOrigins(), c2.getWebOrigins()); - assertEqualsStringAttributes(c1.getAdminUrl(), c2.getAdminUrl()); - } + assertEqualsBooleanAttributes(c1.isDirectAccessGrantsEnabled(), c2.isDirectAccessGrantsEnabled()); + assertEqualsBooleanAttributes(c1.isPublicClient(), c2.isPublicClient()); + assertEqualsListAttributes(c1.getWebOrigins(), c2.getWebOrigins()); + assertEqualsStringAttributes(c1.getAdminUrl(), c2.getAdminUrl()); assertEqualsBooleanAttributes(c1.isSurrogateAuthRequired(), c2.isSurrogateAuthRequired()); assertEqualsBooleanAttributes(c1.isServiceAccountsEnabled(), c2.isServiceAccountsEnabled()); - } else if (c1.getProtocol().equals(SAML)) { - assertEqualsBooleanAttributes(c1.isFrontchannelLogout(), c2.isFrontchannelLogout()); } } @@ -191,26 +127,6 @@ public abstract class AbstractClientTest extends AbstractConsoleTest { } } - protected static Map getSAMLAttributes() { - Map attributes = new HashMap<>(); - attributes.put(SAML_ASSERTION_SIGNATURE, "true"); - attributes.put(SAML_AUTHNSTATEMENT, "false"); - attributes.put(SAML_CLIENT_SIGNATURE, "true"); - attributes.put(SAML_ENCRYPT, "true"); - attributes.put(SAML_FORCE_POST_BINDING, "true"); - attributes.put(SAML_MULTIVALUED_ROLES, "false"); - attributes.put(SAML_SERVER_SIGNATURE, "true"); - attributes.put(SAML_SIGNATURE_ALGORITHM, "RSA_SHA512"); - attributes.put(SAML_ASSERTION_CONSUMER_URL_POST, "http://example0.test"); - attributes.put(SAML_ASSERTION_CONSUMER_URL_REDIRECT, "http://example1.test"); - attributes.put(SAML_FORCE_NAME_ID_FORMAT, "true"); - attributes.put(SAML_NAME_ID_FORMAT, "email"); - attributes.put(SAML_SIGNATURE_CANONICALIZATION_METHOD, "http://www.w3.org/2001/10/xml-exc-c14n#WithComments"); - attributes.put(SAML_SINGLE_LOGOUT_SERVICE_URL_POST, "http://example2.test"); - attributes.put(SAML_SINGLE_LOGOUT_SERVICE_URL_REDIRECT, "http://example3.test"); - return attributes; - } - public ProtocolMapperRepresentation findClientMapperByName(String clientId, String mapperName) { ProtocolMapperRepresentation found = null; for (ProtocolMapperRepresentation mapper : testRealmResource().clients().get(clientId).getProtocolMappers().getMappers()) { @@ -229,4 +145,4 @@ public abstract class AbstractClientTest extends AbstractConsoleTest { return clientsResource().get(id); } -} +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientClusteringTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientClusteringTest.java index c2f8eec834..d0c6743e9c 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientClusteringTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientClusteringTest.java @@ -26,8 +26,7 @@ import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; import org.keycloak.representations.idm.ClientRepresentation; -import static org.keycloak.testsuite.console.clients.AbstractClientTest.createOidcClientRep; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.CONFIDENTIAL; +import static org.keycloak.testsuite.auth.page.login.Login.OIDC; import org.keycloak.testsuite.console.page.clients.clustering.ClientClustering; /** @@ -44,7 +43,7 @@ public class ClientClusteringTest extends AbstractClientTest { @Before public void before() { - newClient = createOidcClientRep(CONFIDENTIAL, TEST_CLIENT_ID, TEST_REDIRECT_URIS); + newClient = createClientRep(TEST_CLIENT_ID, OIDC); testRealmResource().clients().create(newClient).close(); found = findClientByClientId(TEST_CLIENT_ID); @@ -95,4 +94,4 @@ public class ClientClusteringTest extends AbstractClientTest { clientClusteringPage.form().addNode(""); assertAlertDanger(); } -} +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientCredentialsTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientCredentialsTest.java index 4030231755..d489f4e5cc 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientCredentialsTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientCredentialsTest.java @@ -26,8 +26,7 @@ import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; import org.keycloak.representations.idm.ClientRepresentation; -import static org.keycloak.testsuite.console.clients.AbstractClientTest.createOidcClientRep; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.CONFIDENTIAL; +import static org.keycloak.testsuite.auth.page.login.Login.OIDC; import org.keycloak.testsuite.console.page.clients.credentials.ClientCredentials; import org.keycloak.testsuite.console.page.clients.credentials.ClientCredentialsGeneratePrivateKeys; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals; @@ -47,7 +46,7 @@ public class ClientCredentialsTest extends AbstractClientTest { @Before public void before() { - newClient = createOidcClientRep(CONFIDENTIAL, TEST_CLIENT_ID, TEST_REDIRECT_URIS); + newClient = createClientRep(TEST_CLIENT_ID, OIDC); testRealmResource().clients().create(newClient).close(); ClientRepresentation found = findClientByClientId(TEST_CLIENT_ID); @@ -83,4 +82,4 @@ public class ClientCredentialsTest extends AbstractClientTest { // generatePrivateKeysPage.generateForm().setStorePassword("pass2"); // assertAlertSuccess();//fails with phantomjs } -} +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientInstallationTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientInstallationTest.java index bf7bb06f12..0af4bf4229 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientInstallationTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientInstallationTest.java @@ -26,9 +26,8 @@ import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; import org.keycloak.representations.idm.ClientRepresentation; -import static org.keycloak.testsuite.console.clients.AbstractClientTest.createOidcClientRep; +import static org.keycloak.testsuite.auth.page.login.Login.OIDC; import org.keycloak.testsuite.console.page.clients.installation.ClientInstallation; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.CONFIDENTIAL; /** * @@ -44,7 +43,7 @@ public class ClientInstallationTest extends AbstractClientTest { @Before public void before() { - newClient = createOidcClientRep(CONFIDENTIAL, TEST_CLIENT_ID, TEST_REDIRECT_URIS); + newClient = createClientRep(TEST_CLIENT_ID, OIDC); testRealmResource().clients().create(newClient).close(); found = findClientByClientId(TEST_CLIENT_ID); @@ -64,4 +63,4 @@ public class ClientInstallationTest extends AbstractClientTest { clientInstallationPage.form().setConfigFormat("Keycloak OIDC JBoss Subsystem XML"); assertTrue(clientInstallationPage.form().getTextareaContent().contains("test")); } -} +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientMappersOIDCTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientMappersOIDCTest.java index 084f317f45..850bb39bdf 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientMappersOIDCTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientMappersOIDCTest.java @@ -31,7 +31,8 @@ import static org.junit.Assert.*; import org.junit.Before; import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.ProtocolMapperRepresentation; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.CONFIDENTIAL; +import static org.keycloak.testsuite.auth.page.login.Login.OIDC; +import static org.keycloak.testsuite.console.clients.AbstractClientTest.createClientRep; import org.keycloak.testsuite.console.page.clients.mappers.ClientMapper; import org.keycloak.testsuite.console.page.clients.mappers.ClientMappers; import org.keycloak.testsuite.console.page.clients.mappers.CreateClientMappers; @@ -55,7 +56,7 @@ public class ClientMappersOIDCTest extends AbstractClientTest { @Before public void beforeClientMappersTest() { - ClientRepresentation newClient = createOidcClientRep(CONFIDENTIAL, TEST_CLIENT_ID, TEST_REDIRECT_URIS); + ClientRepresentation newClient = createClientRep(TEST_CLIENT_ID, OIDC); testRealmResource().clients().create(newClient).close(); id = findClientByClientId(TEST_CLIENT_ID).getId(); @@ -375,4 +376,4 @@ public class ClientMappersOIDCTest extends AbstractClientTest { createClientMappersPage.form().save(); assertAlertDanger(); } -} +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientMappersSAMLTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientMappersSAMLTest.java index 7905bbd22c..c822c232a2 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientMappersSAMLTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientMappersSAMLTest.java @@ -29,6 +29,8 @@ import static org.junit.Assert.*; import org.junit.Before; import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.ProtocolMapperRepresentation; +import static org.keycloak.testsuite.auth.page.login.Login.SAML; +import static org.keycloak.testsuite.console.clients.AbstractClientTest.createClientRep; import org.keycloak.testsuite.console.page.clients.mappers.ClientMapper; import org.keycloak.testsuite.console.page.clients.mappers.ClientMappers; import org.keycloak.testsuite.console.page.clients.mappers.CreateClientMappers; @@ -52,7 +54,7 @@ public class ClientMappersSAMLTest extends AbstractClientTest { @Before public void beforeClientMappersTest() { - ClientRepresentation newClient = createSamlClientRep(TEST_CLIENT_ID); + ClientRepresentation newClient = createClientRep(TEST_CLIENT_ID, SAML); testRealmResource().clients().create(newClient).close(); id = findClientByClientId(TEST_CLIENT_ID).getId(); @@ -209,4 +211,4 @@ public class ClientMappersSAMLTest extends AbstractClientTest { assertEquals(1, config.size()); assertEquals("offline_access", config.get("role")); } -} +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientRolesTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientRolesTest.java index 92d144ca5a..64304d0ac0 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientRolesTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientRolesTest.java @@ -9,7 +9,8 @@ import static org.junit.Assert.*; import org.junit.Before; import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.RoleRepresentation; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.CONFIDENTIAL; +import static org.keycloak.testsuite.auth.page.login.Login.OIDC; +import static org.keycloak.testsuite.console.clients.AbstractClientTest.createClientRep; import org.keycloak.testsuite.console.page.clients.roles.ClientRole; import org.keycloak.testsuite.console.page.clients.roles.ClientRoles; import org.keycloak.testsuite.console.page.clients.roles.CreateClientRole; @@ -39,7 +40,7 @@ public class ClientRolesTest extends AbstractClientTest { @Before public void beforeClientRolesTest() { - ClientRepresentation newClient = createOidcClientRep(CONFIDENTIAL, TEST_CLIENT_ID, TEST_REDIRECT_URIS); + ClientRepresentation newClient = createClientRep(TEST_CLIENT_ID, OIDC); testRealmResource().clients().create(newClient).close(); id = findClientByClientId(TEST_CLIENT_ID).getId(); @@ -295,4 +296,4 @@ public class ClientRolesTest extends AbstractClientTest { // assertTrue(flashMessage.getText(), flashMessage.isSuccess()); // assertNull(clients.findClient(newClient.getClientId())); // } -} +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientScopeTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientScopeTest.java index da68ca31b6..69509f20ec 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientScopeTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientScopeTest.java @@ -26,13 +26,13 @@ import java.util.Map; import org.jboss.arquillian.graphene.page.Page; import static org.junit.Assert.*; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.keycloak.representations.idm.ClientMappingsRepresentation; import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.MappingsRepresentation; import org.keycloak.representations.idm.RoleRepresentation; -import static org.keycloak.testsuite.console.clients.AbstractClientTest.createOidcClientRep; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.CONFIDENTIAL; +import static org.keycloak.testsuite.auth.page.login.Login.OIDC; import org.keycloak.testsuite.console.page.clients.scope.ClientScope; /** @@ -49,7 +49,7 @@ public class ClientScopeTest extends AbstractClientTest { @Before public void before() { - newClient = createOidcClientRep(CONFIDENTIAL, TEST_CLIENT_ID, TEST_REDIRECT_URIS); + newClient = createClientRep(TEST_CLIENT_ID, OIDC); testRealmResource().clients().create(newClient).close(); found = findClientByClientId(TEST_CLIENT_ID); @@ -59,6 +59,7 @@ public class ClientScopeTest extends AbstractClientTest { } @Test + @Ignore //phantomjs sometimes doens't enable "Add Selected >>" button when role is selected public void clientScopeTest() { assertTrue(found.isFullScopeAllowed()); clientScopePage.scopeForm().setFullScopeAllowed(false); @@ -69,11 +70,11 @@ public class ClientScopeTest extends AbstractClientTest { assertNull(getAllMappingsRepresentation().getRealmMappings()); assertNull(getAllMappingsRepresentation().getClientMappings()); - clientScopePage.roleForm().addRealmRole("offline_access"); + clientScopePage.roleForm().addRealmRole("offline_access");//fails with phantomjs assertAlertSuccess(); clientScopePage.roleForm().selectClientRole("account"); - clientScopePage.roleForm().addClientRole("view-profile"); + clientScopePage.roleForm().addClientRole("view-profile");//fails with phantomjs assertAlertSuccess(); found = findClientByClientId(TEST_CLIENT_ID); @@ -84,16 +85,16 @@ public class ClientScopeTest extends AbstractClientTest { assertEquals(1, clientMappings.size()); assertEquals("view-profile", clientMappings.get("account").getMappings().get(0).getName()); -// clientScopePage.roleForm().removeAssignedRole("offline_access"); -// assertAlertSuccess();//fails with phantomjs -// clientScopePage.roleForm().removeAssignedClientRole("view-profile"); -// assertAlertSuccess();//fails with phantomjs -// -// assertNull(getAllMappingsRepresentation().getRealmMappings()); -// assertNull(getAllMappingsRepresentation().getClientMappings()); + clientScopePage.roleForm().removeAssignedRole("offline_access"); + assertAlertSuccess();//fails with phantomjs + clientScopePage.roleForm().removeAssignedClientRole("view-profile"); + assertAlertSuccess();//fails with phantomjs + + assertNull(getAllMappingsRepresentation().getRealmMappings()); + assertNull(getAllMappingsRepresentation().getClientMappings()); } private MappingsRepresentation getAllMappingsRepresentation() { return testRealmResource().clients().get(found.getId()).getScopeMappings().getAll(); } -} +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientSettingsTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientSettingsTest.java index 557a2dbef8..8090475451 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientSettingsTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientSettingsTest.java @@ -18,7 +18,9 @@ package org.keycloak.testsuite.console.clients; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.ws.rs.core.Response; import org.jboss.arquillian.graphene.page.Page; import static org.junit.Assert.*; @@ -26,8 +28,12 @@ import org.junit.Test; import org.keycloak.representations.idm.ClientRepresentation; import static org.keycloak.testsuite.admin.ApiUtil.getCreatedId; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.*; +import static org.keycloak.testsuite.auth.page.login.Login.OIDC; +import static org.keycloak.testsuite.auth.page.login.Login.SAML; import org.keycloak.testsuite.console.page.clients.settings.ClientSettings; +import static org.keycloak.testsuite.console.page.clients.settings.ClientSettingsForm.OidcAccessType.BEARER_ONLY; +import static org.keycloak.testsuite.console.page.clients.settings.ClientSettingsForm.OidcAccessType.CONFIDENTIAL; +import static org.keycloak.testsuite.console.page.clients.settings.ClientSettingsForm.SAMLClientSettingsForm.*; import static org.keycloak.testsuite.util.WaitUtils.pause; import org.keycloak.testsuite.util.Timer; @@ -45,20 +51,17 @@ public class ClientSettingsTest extends AbstractClientTest { private ClientRepresentation newClient; @Test - public void crudOIDCConfidential() { - newClient = createOidcClientRep(CONFIDENTIAL, "oidc-confidential", TEST_REDIRECT_URIS); + public void crudOIDCPublic() { + newClient = createClientRep("oidc-public", OIDC); createClient(newClient); - assertAlertSuccess(); - //setExpectedWebOrigins(newClient); - // read & verify ClientRepresentation found = findClientByClientId(newClient.getClientId()); assertNotNull("Client " + newClient.getClientId() + " was not found.", found); assertClientSettingsEqual(newClient, found); // update & verify - newClient.setClientId("oidc-confidential-updated"); + newClient.setClientId("oidc-public-updated"); newClient.setName("updatedName"); List redirectUris = new ArrayList<>(); @@ -73,7 +76,7 @@ public class ClientSettingsTest extends AbstractClientTest { webOrigins.add("http://example3.test"); newClient.setWebOrigins(webOrigins); - clientSettingsPage.form().setClientId("oidc-confidential-updated"); + clientSettingsPage.form().setClientId("oidc-public-updated"); clientSettingsPage.form().setName("updatedName"); clientSettingsPage.form().setRedirectUris(redirectUris); clientSettingsPage.form().setWebOrigins(webOrigins); @@ -92,36 +95,43 @@ public class ClientSettingsTest extends AbstractClientTest { } @Test - public void createOIDCPublic() { - newClient = createOidcClientRep(PUBLIC, "oidc-public", TEST_REDIRECT_URIS); + public void createOIDCConfidential() { + newClient = createClientRep("oidc-confidetial", OIDC); createClient(newClient); - assertAlertSuccess(); - - //setExpectedWebOrigins(newClient); + newClient.setRedirectUris(TEST_REDIRECT_URIs); + newClient.setPublicClient(false); + + clientSettingsPage.form().setAccessType(CONFIDENTIAL); + clientSettingsPage.form().setRedirectUris(TEST_REDIRECT_URIs); + clientSettingsPage.form().save(); + ClientRepresentation found = findClientByClientId(newClient.getClientId()); assertNotNull("Client " + newClient.getClientId() + " was not found.", found); assertClientSettingsEqual(newClient, found); } @Test - public void createOIDCPublicWithoutRedirectURIs() { - newClient = createOidcClientRep(PUBLIC, "oidc-public"); - newClient.setStandardFlowEnabled(false); + public void saveOIDCConfidentialWithoutRedirectURIs() { + newClient = createClientRep("oidc-confidential", OIDC); createClient(newClient); - assertAlertSuccess(); - ClientRepresentation found = findClientByClientId(newClient.getClientId()); - assertNotNull("Client " + newClient.getClientId() + " was not found.", found); - assertClientSettingsEqual(newClient, found); + clientSettingsPage.form().setName("name"); + clientSettingsPage.form().save(); + assertAlertDanger(); } @Test public void createOIDCBearerOnly() { - newClient = createOidcClientRep(BEARER_ONLY, "oidc-bearer-only"); + newClient = createClientRep("oidc-bearer-only", OIDC); createClient(newClient); - assertAlertSuccess(); + clientSettingsPage.form().setAccessType(BEARER_ONLY); + clientSettingsPage.form().save(); + + newClient.setBearerOnly(true); + newClient.setPublicClient(false); + ClientRepresentation found = findClientByClientId(newClient.getClientId()); assertNotNull("Client " + newClient.getClientId() + " was not found.", found); assertClientSettingsEqual(newClient, found); @@ -129,12 +139,10 @@ public class ClientSettingsTest extends AbstractClientTest { @Test public void createSAML() { - newClient = createSamlClientRep("saml"); + newClient = createClientRep("saml", SAML); createClient(newClient); - assertAlertSuccess(); ClientRepresentation found = findClientByClientId(newClient.getClientId()); - System.out.println("...." + found.isFrontchannelLogout()); assertNotNull("Client " + newClient.getClientId() + " was not found.", found); assertClientSettingsEqual(newClient, found); assertClientSamlAttributes(getSAMLAttributes(), found.getAttributes()); @@ -145,27 +153,22 @@ public class ClientSettingsTest extends AbstractClientTest { clientsPage.table().createClient(); createClientPage.form().save(); assertAlertDanger(); - } - -// @Test - public void createInconsistentClient() { - ClientRepresentation c = createOidcClientRep(CONFIDENTIAL, "inconsistent_client"); - c.setPublicClient(true); - c.setBearerOnly(true); - - Response r = clientsResource().create(c); - r.close(); - clientSettingsPage.setId(getCreatedId(r)); - - c = clientResource(clientSettingsPage.getId()).toRepresentation(); - assertTrue(c.isBearerOnly()); - assertTrue(c.isPublicClient()); + + clientsPage.navigateTo(); + newClient = createClientRep(TEST_CLIENT_ID, OIDC); + createClient(newClient); + + clientsPage.navigateTo(); + clientsPage.table().createClient(); + createClientPage.form().setClientId(TEST_CLIENT_ID); + createClientPage.form().save(); + assertAlertDanger(); } public void createClients(String clientIdPrefix, int count) { for (int i = 0; i < count; i++) { String clientId = String.format("%s%02d", clientIdPrefix, i); - ClientRepresentation cr = createOidcClientRep(CONFIDENTIAL, clientId, "http://example.test/*"); + ClientRepresentation cr = createClientRep(clientId, OIDC); Timer.DEFAULT.reset(); Response r = testRealmResource().clients().create(cr); r.close(); @@ -182,11 +185,11 @@ public class ClientSettingsTest extends AbstractClientTest { @Test public void disabledClient() { - newClient = createOidcClientRep(CONFIDENTIAL, "disabled-client"); + newClient = createClientRep("disabled-client", OIDC); newClient.setEnabled(false); createClient(newClient); ClientRepresentation clientRepre = findClientByClientId("disabled-client"); assertTrue("Client should be disabled", clientRepre.isEnabled()); } -} +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientsTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientsTest.java index d9e64a7ac7..c45e40f748 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientsTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/clients/ClientsTest.java @@ -26,9 +26,11 @@ import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; import org.keycloak.representations.idm.ClientRepresentation; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.CONFIDENTIAL; +import static org.keycloak.testsuite.auth.page.login.Login.OIDC; +import static org.keycloak.testsuite.console.clients.AbstractClientTest.createClientRep; import org.keycloak.testsuite.console.page.clients.settings.ClientSettings; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals; +import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals; /** * @@ -43,7 +45,7 @@ public class ClientsTest extends AbstractClientTest { @Before public void beforeClientsTest() { - newClient = createOidcClientRep(CONFIDENTIAL, TEST_CLIENT_ID, TEST_REDIRECT_URIS); + newClient = createClientRep(TEST_CLIENT_ID, OIDC); testRealmResource().clients().create(newClient).close(); ClientRepresentation found = findClientByClientId(TEST_CLIENT_ID); @@ -71,4 +73,4 @@ public class ClientsTest extends AbstractClientTest { ClientRepresentation found = findClientByClientId(TEST_CLIENT_ID); assertNull("Deleted client " + TEST_CLIENT_ID + " was found.", found); } -} +} \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/events/AdminEventsTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/events/AdminEventsTest.java index ddbaa8cf9c..59901026b7 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/events/AdminEventsTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/events/AdminEventsTest.java @@ -1,3 +1,24 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2012, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ package org.keycloak.testsuite.console.events; import org.jboss.arquillian.graphene.page.Page; @@ -7,7 +28,6 @@ import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.testsuite.admin.ApiUtil; import org.keycloak.testsuite.console.AbstractConsoleTest; -import org.keycloak.testsuite.console.clients.AbstractClientTest; import org.keycloak.testsuite.console.page.clients.Clients; import org.keycloak.testsuite.console.page.events.AdminEvents; import org.keycloak.testsuite.console.page.events.Config; @@ -19,7 +39,8 @@ import java.util.List; import static org.junit.Assert.assertEquals; import org.keycloak.admin.client.resource.ClientsResource; -import static org.keycloak.testsuite.console.page.clients.CreateClientForm.OidcAccessType.CONFIDENTIAL; +import static org.keycloak.testsuite.auth.page.login.Login.OIDC; +import static org.keycloak.testsuite.console.clients.AbstractClientTest.createClientRep; /** @@ -50,7 +71,7 @@ public class AdminEventsTest extends AbstractConsoleTest { @Test public void clientsAdminEventsTest() { - newClient = AbstractClientTest.createOidcClientRep(CONFIDENTIAL, "test_client", "http://example.test/test_client/*"); + newClient = createClientRep("test_client", OIDC); Response response = clientsResource().create(newClient); String id = ApiUtil.getCreatedId(response); response.close(); @@ -90,4 +111,4 @@ public class AdminEventsTest extends AbstractConsoleTest { public ClientsResource clientsResource() { return testRealmResource().clients(); } -} +} \ No newline at end of file