From cfc61fa2626971ad475eef437375895b27eb838d Mon Sep 17 00:00:00 2001 From: Vlasta Ramik Date: Mon, 29 Feb 2016 15:08:19 +0100 Subject: [PATCH] KEYCLOAK-2565 - Add assert check to testsuite for KEYCLOAK-2554 and KEYCLOAK-2555 --- .../main/java/org/keycloak/testsuite/admin/ApiUtil.java | 7 +++++++ .../org/keycloak/testsuite/account/RegistrationTest.java | 6 +++++- .../keycloak/testsuite/account/ResetCredentialsTest.java | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/admin/ApiUtil.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/admin/ApiUtil.java index 275fd9ca63..99fda364fe 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/admin/ApiUtil.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/admin/ApiUtil.java @@ -30,6 +30,8 @@ import java.net.URI; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.Response.StatusType; import org.apache.commons.lang.builder.EqualsBuilder; import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD; @@ -44,6 +46,11 @@ public class ApiUtil { public static String getCreatedId(Response response) { URI location = response.getLocation(); + if (!response.getStatusInfo().equals(Status.CREATED)) { + StatusType statusInfo = response.getStatusInfo(); + throw new RuntimeException("Create method returned status " + + statusInfo.getReasonPhrase() + " (Code: " + statusInfo.getStatusCode() + "); expected status: Created (201)"); + } if (location == null) { return null; } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/RegistrationTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/RegistrationTest.java index a49d823202..1e3e916638 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/RegistrationTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/RegistrationTest.java @@ -17,10 +17,13 @@ package org.keycloak.testsuite.account; import org.jboss.arquillian.graphene.page.Page; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import org.junit.Test; import org.keycloak.testsuite.auth.page.login.Registration; -import static org.junit.Assert.*; import org.junit.Before; import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD; import org.keycloak.representations.idm.RealmRepresentation; @@ -58,6 +61,7 @@ public class RegistrationTest extends AbstractAccountManagementTest { setPasswordFor(newUser, PASSWORD); testRealmAccountManagementPage.navigateTo(); + assertTrue("Registration should be allowed.", testRealmResource().toRepresentation().isRegistrationAllowed()); testRealmLoginPage.form().register(); } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/ResetCredentialsTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/ResetCredentialsTest.java index 00c0549bcb..83a4b0c223 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/ResetCredentialsTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/ResetCredentialsTest.java @@ -19,6 +19,7 @@ package org.keycloak.testsuite.account; import org.jboss.arquillian.graphene.page.Page; import org.junit.AfterClass; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import org.keycloak.representations.idm.RealmRepresentation; @@ -61,6 +62,7 @@ public class ResetCredentialsTest extends AbstractAccountManagementTest { } testRealmAccountManagementPage.navigateTo(); + assertTrue("Reset password should be allowed.", testRealmResource().toRepresentation().isResetPasswordAllowed()); testRealmLoginPage.form().forgotPassword(); }