KEYCLOAK-2732

This commit is contained in:
Vaclav Muzikar 2016-03-31 18:16:03 +02:00
parent e506e385f1
commit 4ce8b2431b
26 changed files with 341 additions and 418 deletions

View file

@ -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();
}
}

View file

@ -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);
}
}
}

View file

@ -276,7 +276,7 @@ public abstract class AbstractKeycloakTest {
}
private void loadConstantsProperties() throws ConfigurationException {
constantsProperties = new PropertiesConfiguration("test-constants.properties");
constantsProperties = new PropertiesConfiguration(System.getProperty("testsuite.constants"));
constantsProperties.setThrowExceptionOnMissing(true);
}

View file

@ -1,6 +1,7 @@
package org.keycloak.testsuite.console.page.authentication;
import org.jboss.arquillian.graphene.findby.ByJQuery;
import org.keycloak.testsuite.page.Form;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
@ -14,6 +15,7 @@ import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
* @author Petr Mensik
* @author tkyjovsk
* @author mhajas
* @author Vaclav Muzikar <vmuzikar@redhat.com>
*/
public class PasswordPolicy extends Authentication {
@ -28,10 +30,10 @@ public class PasswordPolicy extends Authentication {
@FindBy(tagName = "select")
private WebElement addPolicySelectElement;
@FindBy(css = "tr.ng-scope")
private List<WebElement> allRows;
@FindBy(tagName = "table")
private WebElement table;
public void addPolicy(PasswordPolicy.Type policy, String value) {
public void addPolicy(Type policy, String value) {
waitUntilElement(addPolicySelectElement).is().present();
addPolicySelect.selectByVisibleText(policy.getName());
setPolicyValue(policy, value);
@ -39,45 +41,36 @@ public class PasswordPolicy extends Authentication {
}
public void addPolicy(PasswordPolicy.Type policy, int value) {
public void addPolicy(Type policy, int value) {
addPolicy(policy, String.valueOf(value));
}
public void addPolicy(PasswordPolicy.Type policy) {
public void addPolicy(Type policy) {
addPolicySelect.selectByVisibleText(policy.getName());
primaryButton.click();
}
public void removePolicy(PasswordPolicy.Type policy) {
int policyInputLocation = findPolicy(policy);
allRows.get(policyInputLocation).findElements(By.tagName("button")).get(0).click();
public void removePolicy(Type policy) {
getPolicyRow(policy).findElement(By.cssSelector("td.kc-action-cell")).click();
primaryButton.click();
}
public void editPolicy(PasswordPolicy.Type policy, int value) {
public void editPolicy(Type policy, int value) {
editPolicy(policy, String.valueOf(value));
}
public void editPolicy(PasswordPolicy.Type policy, String value) {
public void editPolicy(Type policy, String value) {
setPolicyValue(policy, value);
primaryButton.click();
}
private void setPolicyValue(PasswordPolicy.Type policy, String value) {
int policyInputLocation = findPolicy(policy);
WebElement input = allRows.get(policyInputLocation).findElement(By.tagName("input"));
input.clear();
input.sendKeys(value);
private void setPolicyValue(Type policy, String value) {
WebElement input = getPolicyRow(policy).findElement(By.tagName("input"));
Form.setInputValue(input, value);
}
private int findPolicy(PasswordPolicy.Type policy) {
for (int i = 0; i < allRows.size(); i++) {
String policyName = allRows.get(i).findElement(ByJQuery.selector("td:eq(0)")).getText();
if (policyName.equals(policy.getName())) {
return i;
}
}
return 0;
private WebElement getPolicyRow(Type policy) {
return table.findElement(By.xpath("//tr[td[text()='" + policy.getName() + "']]"));
}
public enum Type {

View file

@ -1,5 +1,6 @@
package org.keycloak.testsuite.console.page.authentication;
import org.keycloak.testsuite.util.WaitUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
@ -28,6 +29,8 @@ public class RequiredActions extends Authentication {
}
private void setRequiredActionValue(String id, boolean value) {
WaitUtils.waitUntilElement(requiredActionTable).is().present();
WebElement checkbox = requiredActionTable.findElement(By.id(id));
if (checkbox.isSelected() != value) {

View file

@ -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<String, String> 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));
}
}
}
}

View file

@ -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();
}
}

View file

@ -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
}
}

View file

@ -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<WebElement> redirectUriInputs;
@FindBy(xpath = ".//i[contains(@data-ng-click, 'deleteRedirectUri')]")
@FindBy(xpath = ".//i[contains(@data-ng-click, 'deleteRedirectUri') and @class='fa fa-minus']")
private List<WebElement> deleteRedirectUriIcons;
@FindBy(id = "newWebOrigin")
@ -68,9 +67,22 @@ public class ClientSettingsForm extends CreateClientForm {
@FindBy(xpath = ".//i[contains(@data-ng-click, 'deleteWebOrigin')]")
private List<WebElement> 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<String, String> 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));
}
}
}

View file

@ -191,6 +191,10 @@ public class LdapUserProviderForm extends Form {
vendorSelect.selectByVisibleText(vendor);
}
public void selectVendor(int index) {
vendorSelect.selectByIndex(index);
}
public List<String> getVendors() {
waitUntilElement(By.id("vendor")).is().present();

View file

@ -1,6 +1,8 @@
package org.keycloak.testsuite.console.page.realm;
import org.keycloak.testsuite.console.page.AdminConsoleRealm;
import org.keycloak.testsuite.util.WaitUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
@ -11,11 +13,14 @@ import static org.keycloak.testsuite.util.WaitUtils.*;
* @author tkyjovsk
*/
public class RealmSettings extends AdminConsoleRealm {
private static final String navTabsClassName = "nav-tabs";
@FindBy(className = "nav-tabs")
@FindBy(className = navTabsClassName)
private RealmTabs realmTabs;
public RealmTabs tabs() {
waitUntilElement(By.className(navTabsClassName)).is().present();
return realmTabs;
}

View file

@ -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();
}
}

View file

@ -32,6 +32,7 @@ import org.keycloak.testsuite.console.page.authentication.otppolicy.OTPPolicy;
import org.keycloak.testsuite.console.page.authentication.otppolicy.OTPPolicyForm.Digits;
import org.keycloak.testsuite.console.page.authentication.otppolicy.OTPPolicyForm.OTPHashAlg;
import org.keycloak.testsuite.console.page.authentication.otppolicy.OTPPolicyForm.OTPType;
import org.keycloak.testsuite.util.WaitUtils;
/**
*
@ -45,6 +46,7 @@ public class OTPPolicyTest extends AbstractConsoleTest {
@Before
public void beforeOTPPolicyTest() {
otpPolicyPage.navigateTo();
WaitUtils.pause(1000); // wait for the form to fully render
}
@Test

View file

@ -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<String> 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<String> redirectUrisList = new ArrayList<>();
redirectUrisList.addAll(Arrays.asList(redirectUris));
client.setRedirectUris(redirectUrisList);
}
protected static void setExpectedWebOrigins(ClientRepresentation client) {
List<String> 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<String, String> getSAMLAttributes() {
Map<String, String> 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<String, String> getSAMLAttributes() {
Map<String, String> 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);
}
}
}

View file

@ -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();
}
}
}

View file

@ -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
}
}
}

View file

@ -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("<realm>test</realm>"));
}
}
}

View file

@ -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();
}
}
}

View file

@ -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"));
}
}
}

View file

@ -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()));
// }
}
}

View file

@ -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();
}
}
}

View file

@ -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<String> 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());
}
}
}

View file

@ -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);
}
}
}

View file

@ -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();
}
}
}

View file

@ -133,7 +133,7 @@ public class LdapUserFederationTest extends AbstractConsoleTest {
@Test
public void testConnection() throws Exception {
createLdapUserProvider.navigateTo();
createLdapUserProvider.form().selectVendor("Other");
createLdapUserProvider.form().selectVendor(1);
createLdapUserProvider.form().setConsoleDisplayNameInput("ldap");
createLdapUserProvider.form().selectEditMode(WRITABLE);
createLdapUserProvider.form().setLdapConnectionUrlInput("ldap://localhost:10389");

View file

@ -32,7 +32,7 @@
<artifactId>integration-arquillian-tests</artifactId>
<name>Tests</name>
<modules>
<module>base</module>
<module>other</module>
@ -45,7 +45,7 @@
<auth.server.container>auth-server-${auth.server}</auth.server.container>
<auth.server.home>${containers.home}/${auth.server.container}</auth.server.home>
<auth.server.config.dir>${auth.server.home}</auth.server.config.dir>
<auth.server.port.offset>100</auth.server.port.offset>
<auth.server.http.port>8180</auth.server.http.port>
<auth.server.events.http.port>8089</auth.server.events.http.port>
@ -55,19 +55,22 @@
<auth.server.ssl.required>false</auth.server.ssl.required>
<auth.server.jboss.startup.timeout>60</auth.server.jboss.startup.timeout>
<auth.server.memory.settings>-Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m</auth.server.memory.settings>
<auth.server.jboss.artifactId>integration-arquillian-servers-auth-server-${auth.server}</auth.server.jboss.artifactId>
<auth.server.jboss.skip.unpack>${auth.server.undertow}</auth.server.jboss.skip.unpack>
<auth.server.jboss.startup.timeout>300</auth.server.jboss.startup.timeout>
<adapter.test.props/>
<examples.home>${project.build.directory}/examples</examples.home>
<browser>phantomjs</browser>
<firefox_binary>/usr/bin/firefox</firefox_binary>
<frontend.console.output>true</frontend.console.output>
<backends.console.output>true</backends.console.output>
<testsuite.constants>test-constants.properties</testsuite.constants>
</properties>
<build>
@ -128,14 +131,14 @@
<systemPropertyVariables>
<project.build.directory>${project.build.directory}</project.build.directory>
<arquillian.xml>${project.build.directory}/dependency/arquillian.xml</arquillian.xml>
<auth.server>${auth.server}</auth.server>
<auth.server.container>${auth.server.container}</auth.server.container>
<auth.server.undertow>${auth.server.undertow}</auth.server.undertow>
<auth.server.jboss>${auth.server.jboss}</auth.server.jboss>
<auth.server.memory.settings>${auth.server.memory.settings}</auth.server.memory.settings>
<auth.server.home>${auth.server.home}</auth.server.home>
<auth.server.java.home>${auth.server.java.home}</auth.server.java.home>
@ -150,9 +153,11 @@
<auth.server.config.dir>${auth.server.config.dir}</auth.server.config.dir>
<frontend.console.output>${frontend.console.output}</frontend.console.output>
<backends.console.output>${backend.console.output}</backends.console.output>
<adapter.test.props>${adapter.test.props}</adapter.test.props>
<testsuite.constants>${testsuite.constants}</testsuite.constants>
<browser>${browser}</browser>
<firefox_binary>${firefox_binary}</firefox_binary>
@ -166,7 +171,7 @@
</configuration>
</plugin>
</plugins>
</pluginManagement>
</pluginManagement>
</build>
<profiles>
@ -187,7 +192,7 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>auth-server-eap</id>
<properties>
@ -204,13 +209,13 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>auth-server-cluster</id>
<properties>
<!--disable exclusion pattern for cluster test which is enabled by default in base/pom.xml-->
<exclude.cluster>-</exclude.cluster>
<auth.server.balancer.home>${containers.home}/auth-server-balancer-wildfly</auth.server.balancer.home>
<auth.server.backend1.home>${containers.home}/auth-server-${auth.server}-backend1</auth.server.backend1.home>
<auth.server.backend2.home>${containers.home}/auth-server-${auth.server}-backend2</auth.server.backend2.home>
@ -303,7 +308,7 @@
<auth.server.jboss>false</auth.server.jboss>
<auth.server.cluster>true</auth.server.cluster>
<auth.server.balancer.home>${auth.server.balancer.home}</auth.server.balancer.home>
<auth.server.backend1.home>${auth.server.backend1.home}</auth.server.backend1.home>
<auth.server.backend2.home>${auth.server.backend2.home}</auth.server.backend2.home>
@ -364,7 +369,7 @@
</plugins>
</pluginManagement>
</build>
</profile>
</profile>
<!-- Profiles for migration tests-->
@ -577,9 +582,9 @@
</build>
</profile>
<profile>
<id>no-account</id>
<properties>
@ -599,7 +604,7 @@
<exclude.client>**/client/**/*Test.java</exclude.client>
</properties>
</profile>
<profile>
<id>common-test-dependencies</id>
<activation>
@ -644,19 +649,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.13</version>
</dependency>
<!-- <dependency>
<groupId>org.arquillian.extension</groupId>
<artifactId>arquillian-recorder-reporter-impl</artifactId>
<version>1.1.0.Final</version>
</dependency>-->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
@ -682,13 +687,13 @@
<version>1.9.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>compile</scope>
</dependency>
<!-- Email Test Server -->
<dependency>
<groupId>com.icegreen</groupId>
@ -700,7 +705,7 @@
</exclusion>
</exclusions>
</dependency>
<!-- Keycloak deps for tests -->
<dependency>
@ -741,13 +746,13 @@
<artifactId>integration-arquillian-servers-auth-server-undertow</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>undertow-embedded</artifactId>
<version>1.0.0.Alpha1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
@ -803,7 +808,7 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
@ -847,8 +852,8 @@
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
@ -858,9 +863,9 @@
<artifactId>liquibase-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</build>
</profile>
</profiles>
</project>