Merge pull request #1896 from vramik/authFlows

arquillian-testsuite: auth flows tests
This commit is contained in:
Stian Thorgersen 2015-11-30 09:52:12 +01:00
commit 54b5a6c41e
9 changed files with 602 additions and 1 deletions

View file

@ -1,6 +1,6 @@
<assembly> <assembly>
<id>auth-server-wildfly-kc14</id> <id>auth-server-wildfly-kc15</id>
<formats> <formats>
<format>zip</format> <format>zip</format>

View file

@ -0,0 +1,40 @@
/*
* 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.page.authentication.flows;
import org.jboss.arquillian.graphene.page.Page;
import org.keycloak.testsuite.console.page.authentication.Authentication;
/**
*
* @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a>
*/
public class CreateExecution extends Authentication {
@Page
private CreateExecutionForm form;
public CreateExecutionForm form() {
return form;
}
}

View file

@ -0,0 +1,63 @@
/*
* 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.page.authentication.flows;
import org.keycloak.testsuite.page.Form;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;
/**
*
* @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a>
*/
public class CreateExecutionForm extends Form {
public enum ProviderOption {
DIRECT_GRANT_VALIDATE_USERNAME("direct-grant-validate-username"),
RESET_OTP("reset-otp"),
AUTH_COOKIE("auth-cookie"),
RESET_CREDENTIALS_CHOOSE_USER("reset-credentials-choose-user"),
DIRECT_GRANT_VALIDATE_PASSWORD("direct-grant-validate-password"),
AUTH_USERNAME_PASSWORD_FORM("auth-username-password-form"),
AUTH_OTP_FORM("auth-otp-form"),
AUTH_SPNEGO("auth-spnego"),
DIRECT_GRANT_VALIDATE_OPT("direct-grant-validate-otp"),
RESET_CREDENTIALS_EMAIL("reset-credential-email"),
RESET_PASSWORD("reset-password");
private final String name;
private ProviderOption(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
@FindBy(id = "provider")
private Select providerSelect;
public void selectProviderOption(ProviderOption value) {
providerSelect.selectByVisibleText(value.getName());
}
}

View file

@ -0,0 +1,44 @@
/*
* 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.page.authentication.flows;
import org.jboss.arquillian.graphene.page.Page;
import org.keycloak.testsuite.console.page.authentication.Authentication;
/**
*
* @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a>
*/
public class CreateFlow extends Authentication {
@Page
private CreateFlowForm form;
@Override
public String getUriFragment() {
return super.getUriFragment() + "/create/flow";
}
public CreateFlowForm form() {
return form;
}
}

View file

@ -0,0 +1,67 @@
/*
* 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.page.authentication.flows;
import org.keycloak.testsuite.page.Form;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;
/**
*
* @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a>
*/
public class CreateFlowForm extends Form {
@FindBy(id = "alias")
private WebElement aliasInput;
@FindBy(id = "description")
private WebElement descriptionTextarea;
@FindBy(id = "flowType")
private Select flowTypeSelect;
public enum FlowType {
GENERIC("generic"),
FORM("form"),
CLIENT("client");
private final String name;
private FlowType(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
public void setValues(String alias, String description, FlowType flowType) {
setInputValue(aliasInput, alias);
setInputValue(descriptionTextarea, description);
flowTypeSelect.selectByVisibleText(flowType.getName());
save();
}
}

View file

@ -0,0 +1,90 @@
package org.keycloak.testsuite.console.page.authentication.flows;
import org.keycloak.testsuite.console.page.authentication.Authentication;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;
/**
* @author tkyjovsk
* @author mhajas
*/
public class Flows extends Authentication {
@Override
public String getUriFragment() {
return super.getUriFragment() + "/flows";
}
@FindBy(tagName = "select")
private Select flowSelect;
@FindBy(xpath = "//button[text() = 'New']")
private WebElement newButton;
@FindBy(xpath = "//button[text() = 'Copy']")
private WebElement copyButton;
@FindBy(xpath = "//button[text() = 'Delete']")
private WebElement deleteButton;
@FindBy(xpath = "//button[text() = 'Add Execution']")
private WebElement addExecutionButton;
@FindBy(xpath = "//button[text() = 'Add Flow']")
private WebElement addFlowButton;
@FindBy(tagName = "table")
private FlowsTable flowsTable;
public enum FlowOption {
DIRECT_GRANT("Direct grant"),
REGISTRATION("Registration"),
BROWSER("Browser"),
RESET_CREDENTIALS("Reset credentials"),
CLIENTS("Clients");
private final String name;
private FlowOption(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
public void selectFlowOption(FlowOption option) {
flowSelect.selectByVisibleText(option.getName());
}
public String getFlowSelectValue() {
return flowSelect.getFirstSelectedOption().getText();
}
public FlowsTable table() {
return flowsTable;
}
public void clickNew() {
newButton.click();
}
public void clickCopy() {
copyButton.click();
}
public void clickDelete() {
deleteButton.click();
}
public void clickAddExecution() {
addExecutionButton.click();
}
public void clickAddFlow() {
addFlowButton.click();
}
}

View file

@ -0,0 +1,93 @@
/*
* 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.page.authentication.flows;
import static org.keycloak.testsuite.util.WaitUtils.waitAjaxForElement;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
/**
*
* @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a>
*/
public class FlowsTable {
public enum RequirementOption {
ALTERNATIVE("ALTERNATIVE"),
DISABLED("DISABLED"),
OPTIONAL("OPTIONAL"),
REQUIRED("REQUIRED");
private final String name;
private RequirementOption(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
public enum Action {
DELETE("Delete"),
ADD_EXECUTION("Add Execution"),
ADD_FLOW("Add Flow");
private final String name;
private Action(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
@FindBy(tagName = "tbody")
private WebElement tbody;
private WebElement getRowByLabelText(String text) {
WebElement row = tbody.findElement(By.xpath("//span[text() = '" + text + "']/../.."));
waitAjaxForElement(row);
return row;
}
public void clickLevelUpButton(String rowLabel) {
getRowByLabelText(rowLabel).findElement(By.xpath("//i[contains(@class, 'up')]/..")).click();
}
public void clickLevelDownButton(String rowLabel) {
getRowByLabelText(rowLabel).findElement(By.xpath("//i[contains(@class, 'down')]/..")).click();
}
public void changeRequirement(String rowLabel, RequirementOption option) {
getRowByLabelText(rowLabel).findElement(By.xpath("//input[@value = '" + option + "']")).click();
}
public void performAction(String rowLabel, Action action) {
}
}

View file

@ -17,6 +17,8 @@ public class ModalDialog {
@FindBy(xpath = ".//button[@ng-click='ok()']") @FindBy(xpath = ".//button[@ng-click='ok()']")
private WebElement okButton; private WebElement okButton;
@FindBy(id = "name")
private WebElement nameInput;
public void ok() { public void ok() {
waitAjaxForElement(okButton); waitAjaxForElement(okButton);
@ -32,5 +34,11 @@ public class ModalDialog {
waitAjaxForElement(cancelButton); waitAjaxForElement(cancelButton);
cancelButton.click(); cancelButton.click();
} }
public void setName(String name) {
waitAjaxForElement(nameInput);
nameInput.clear();
nameInput.sendKeys(name);
}
} }

View file

@ -0,0 +1,196 @@
/*
* 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.authentication;
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.testsuite.console.AbstractConsoleTest;
import org.keycloak.testsuite.console.page.authentication.flows.CreateExecution;
import org.keycloak.testsuite.console.page.authentication.flows.CreateExecutionForm;
import org.keycloak.testsuite.console.page.authentication.flows.CreateFlow;
import org.keycloak.testsuite.console.page.authentication.flows.CreateFlowForm;
import org.keycloak.testsuite.console.page.authentication.flows.Flows;
import org.keycloak.testsuite.console.page.authentication.flows.FlowsTable;
/**
*
* @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a>
*/
@Ignore //waiting for KEYCLOAK-1967(KEYCLOAK-1966)
public class FlowsTest extends AbstractConsoleTest {
@Page
private Flows flowsPage;
@Page
private CreateFlow createFlowPage;
@Page
private CreateExecution createExecutionPage;
@Before
public void beforeFlowsTest() {
flowsPage.navigateTo();
}
@Test
public void createDeleteFlowTest() {
log.info("add new flow");
flowsPage.clickNew();
createFlowPage.form().setValues("testFlow", "testDesc", CreateFlowForm.FlowType.GENERIC);
assertEquals("Success! Flow Created.", createFlowPage.getSuccessMessage());
log.debug("new flow created via UI");
log.info("check if test flow is created via rest");
//rest: flow is present
log.debug("checked");
log.debug("check if testFlow is selected in UI");
assertEquals("TestFlow", flowsPage.getFlowSelectValue());
log.info("add new execution flow within testFlow");
flowsPage.clickAddFlow();
createFlowPage.form().setValues("testExecutionFlow", "executionDesc", CreateFlowForm.FlowType.GENERIC);
assertEquals("Success! Flow Created.", createFlowPage.getSuccessMessage());
log.debug("new execution flow created via UI");
log.info("check if execution flow is created via rest");
//rest: flow within nested flow is present
log.debug("checked");
log.debug("check if testFlow is selected in UI");
assertEquals("TestFlow", flowsPage.getFlowSelectValue());
log.info("delete test flow");
flowsPage.clickDelete();
assertEquals("Success! Flow removed", createFlowPage.getSuccessMessage());
log.debug("test flow removed via UI");
log.info("check if both test flow and execution flow is removed via rest");
//rest
log.debug("checked");
}
@Test
public void createFlowWithEmptyAliasTest() {
flowsPage.clickNew();
createFlowPage.form().setValues("", "testDesc", CreateFlowForm.FlowType.GENERIC);
assertEquals("Error! Missing or invalid field(s). Please verify the fields in red.", createFlowPage.getErrorMessage());
//rest:flow isn't present
//best-efford: check empty alias in nested flow
}
@Test
public void copyFlowTest() {
flowsPage.selectFlowOption(Flows.FlowOption.BROWSER);
flowsPage.clickCopy();
modalDialog.setName("test copy of browser");
modalDialog.ok();
assertEquals("Success! Flow copied.", createFlowPage.getSuccessMessage());
//rest: copied flow present
}
@Test
public void createDeleteExecutionTest() {
//rest: add new flow
log.info("add new execution within testFlow");
flowsPage.clickAddExecution();
createExecutionPage.form().selectProviderOption(CreateExecutionForm.ProviderOption.RESET_PASSWORD);
createExecutionPage.form().save();
assertEquals("Success! Execution Created.", createExecutionPage.getSuccessMessage());
log.debug("new execution flow created via UI");
//rest:check new execution
log.debug("check if testFlow is selected in UI");
assertEquals("TestFlow", flowsPage.getFlowSelectValue());
log.info("delete test flow");
flowsPage.clickDelete();
assertEquals("Success! Flow removed", createFlowPage.getSuccessMessage());
log.debug("test flow removed via UI");
log.info("check if both test flow and execution flow is removed via rest");
//rest
log.debug("checked");
}
@Test
public void navigationTest() {
//rest: add or copy flow to test navigation (browser)
//rest:
log.debug("check if there is expected structure of the flow");
//first should be Cookie
//second Kerberos
//third Test Copy Of Browser Forms
//a) Username Password Form
//b) OTP Form
flowsPage.table().clickLevelDownButton("Cookie");
assertEquals("Success! Priority lowered", flowsPage.getSuccessMessage());
flowsPage.table().clickLevelUpButton("Test Copy Of Browser Forms");
assertEquals("Success! Priority raised", flowsPage.getSuccessMessage());
flowsPage.table().clickLevelUpButton("OTP Forms");
assertEquals("Success! Priority raised", flowsPage.getSuccessMessage());
//rest:check if navigation was changed properly
}
@Test
public void requirementTest() {
//rest: add or copy flow to test navigation (browser), add reset, password
flowsPage.table().changeRequirement("Cookie", FlowsTable.RequirementOption.DISABLED);
flowsPage.table().changeRequirement("Kerberos", FlowsTable.RequirementOption.ALTERNATIVE);
flowsPage.table().changeRequirement("Copy Of Browser Forms", FlowsTable.RequirementOption.REQUIRED);
flowsPage.table().changeRequirement("Reset Password", FlowsTable.RequirementOption.REQUIRED);
//rest:check
}
@Test
public void actionsTest() {
//rest: add or copy flow to test navigation (browser)
flowsPage.table().performAction("Kerberos", FlowsTable.Action.DELETE);
flowsPage.table().performAction("Copy Of Browser Forms", FlowsTable.Action.ADD_FLOW);
createFlowPage.form().setValues("nestedFlow", "", CreateFlowForm.FlowType.CLIENT);
//todo: perform all remaining actions
//rest: check
}
}