Implemented test with multiple required user actions
This commit is contained in:
parent
85568f80b2
commit
ea8e7cd86c
2 changed files with 59 additions and 38 deletions
|
@ -21,62 +21,39 @@
|
||||||
*/
|
*/
|
||||||
package org.keycloak.testsuite;
|
package org.keycloak.testsuite;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
|
|
||||||
import org.jboss.arquillian.container.test.api.Deployment;
|
import org.jboss.arquillian.container.test.api.Deployment;
|
||||||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
|
||||||
import org.jboss.arquillian.graphene.page.Page;
|
import org.jboss.arquillian.graphene.page.Page;
|
||||||
import org.jboss.arquillian.junit.Arquillian;
|
import org.jboss.arquillian.junit.Arquillian;
|
||||||
|
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.keycloak.testsuite.pages.AppPage;
|
import org.keycloak.testsuite.pages.LoginPasswordUpdatePage;
|
||||||
import org.keycloak.testsuite.pages.LoginPage;
|
import org.keycloak.testsuite.pages.LoginUpdateProfilePage;
|
||||||
import org.keycloak.testsuite.pages.RegisterPage;
|
|
||||||
import org.keycloak.testsuite.pages.TotpPage;
|
|
||||||
import org.openqa.selenium.WebDriver;
|
|
||||||
import org.picketlink.idm.credential.util.TimeBasedOTP;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||||
*/
|
*/
|
||||||
@RunWith(Arquillian.class)
|
@RunWith(Arquillian.class)
|
||||||
public class RequiredActionMultipleActionsTest {
|
public class RequiredActionMultipleActionsTest extends AbstractDroneTest {
|
||||||
|
|
||||||
@Deployment(name = "app", testable = false, order = 2)
|
@Deployment(name = "properties", testable = false, order = 1)
|
||||||
public static WebArchive appDeployment() {
|
public static WebArchive propertiesDeployment() {
|
||||||
return Deployments.appDeployment();
|
return ShrinkWrap.create(WebArchive.class, "properties.war").addClass(SystemPropertiesSetter.class)
|
||||||
|
.addAsWebInfResource("web-properties-email-verfication.xml", "web.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deployment(name = "auth-server", testable = false, order = 1)
|
@Rule
|
||||||
public static WebArchive deployment() {
|
public GreenMailRule greenMail = new GreenMailRule();
|
||||||
return Deployments.deployment().addAsResource("testrealm-totp.json", "META-INF/testrealm.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Page
|
@Page
|
||||||
protected AppPage appPage;
|
protected LoginPasswordUpdatePage changePasswordPage;
|
||||||
|
|
||||||
@Drone
|
|
||||||
protected WebDriver browser;
|
|
||||||
|
|
||||||
@Page
|
@Page
|
||||||
protected TotpPage totpPage;
|
protected LoginUpdateProfilePage updateProfilePage;
|
||||||
|
|
||||||
@Page
|
|
||||||
protected LoginPage loginPage;
|
|
||||||
|
|
||||||
@Page
|
|
||||||
protected RegisterPage registerPage;
|
|
||||||
|
|
||||||
protected TimeBasedOTP totp;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void before() throws MalformedURLException {
|
|
||||||
totp = new TimeBasedOTP();
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void after() {
|
public void after() {
|
||||||
|
@ -87,8 +64,38 @@ public class RequiredActionMultipleActionsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setupTotp() {
|
public void updateProfileAndPassword() {
|
||||||
Assert.fail("Not implemented");
|
appPage.open();
|
||||||
|
|
||||||
|
Assert.assertTrue(loginPage.isCurrent());
|
||||||
|
|
||||||
|
loginPage.login("multiple@actions.com", "temp-password");
|
||||||
|
|
||||||
|
if (changePasswordPage.isCurrent()) {
|
||||||
|
updatePassword();
|
||||||
|
|
||||||
|
Assert.assertTrue(updateProfilePage.isCurrent());
|
||||||
|
updateProfile();
|
||||||
|
} else if (updateProfilePage.isCurrent()) {
|
||||||
|
updateProfile();
|
||||||
|
|
||||||
|
Assert.assertTrue(changePasswordPage.isCurrent());
|
||||||
|
updatePassword();
|
||||||
|
} else {
|
||||||
|
Assert.fail("Expected to update password and profile before login");
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.assertTrue(appPage.isCurrent());
|
||||||
|
Assert.assertEquals("multiple@actions.com", appPage.getUser());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePassword() {
|
||||||
|
changePasswordPage.changePassword("new-password", "new-password");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateProfile() {
|
||||||
|
updateProfilePage.update("New first", "New last", "new@email.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,16 @@
|
||||||
"value" : "password" }
|
"value" : "password" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"username" : "multiple@actions.com",
|
||||||
|
"enabled": true,
|
||||||
|
"requiredActions" : [ "UPDATE_PROFILE", "UPDATE_PASSWORD" ],
|
||||||
|
"email" : "multiple@actions.com",
|
||||||
|
"credentials" : [
|
||||||
|
{ "type" : "password",
|
||||||
|
"value" : "temp-password" }
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"username" : "third-party",
|
"username" : "third-party",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
|
@ -76,6 +86,10 @@
|
||||||
"username": "updateprof@pass.com",
|
"username": "updateprof@pass.com",
|
||||||
"roles": ["user"]
|
"roles": ["user"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"username": "multiple@actions.com",
|
||||||
|
"roles": ["user"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"username": "third-party",
|
"username": "third-party",
|
||||||
"roles": ["KEYCLOAK_IDENTITY_REQUESTER"]
|
"roles": ["KEYCLOAK_IDENTITY_REQUESTER"]
|
||||||
|
|
Loading…
Reference in a new issue