Search in sources :

Example 26 with RealmAttributeUpdater

use of org.keycloak.testsuite.updaters.RealmAttributeUpdater in project keycloak by keycloak.

the class RegisterTest method registerExistingUser_emailAsUsername.

@Test
public void registerExistingUser_emailAsUsername() throws IOException {
    try (RealmAttributeUpdater rau = configureRealmRegistrationEmailAsUsername(true).update()) {
        loginPage.open();
        loginPage.clickRegister();
        registerPage.assertCurrent();
        registerPage.registerWithEmailAsUsername("firstName", "lastName", "test-user@localhost", "password", "password");
        registerPage.assertCurrent();
        assertEquals("Email already exists.", registerPage.getInputAccountErrors().getEmailError());
        events.expectRegister("test-user@localhost", "test-user@localhost").user((String) null).error("email_in_use").assertEvent();
    }
}
Also used : RealmAttributeUpdater(org.keycloak.testsuite.updaters.RealmAttributeUpdater) Test(org.junit.Test) AbstractTestRealmKeycloakTest(org.keycloak.testsuite.AbstractTestRealmKeycloakTest)

Example 27 with RealmAttributeUpdater

use of org.keycloak.testsuite.updaters.RealmAttributeUpdater in project keycloak by keycloak.

the class ArtifactBindingTest method testArtifactBindingTimesOutAfterCodeToTokenLifespan.

/**
 ********************** LOGIN TESTS ***********************
 */
@Test
public void testArtifactBindingTimesOutAfterCodeToTokenLifespan() throws Exception {
    getCleanup().addCleanup(new RealmAttributeUpdater(adminClient.realm(REALM_NAME)).setAccessCodeLifespan(1).update());
    SAMLDocumentHolder response = new SamlClientBuilder().authnRequest(getAuthServerSamlEndpoint(REALM_NAME), SAML_CLIENT_ID_SALES_POST, SAML_ASSERTION_CONSUMER_URL_SALES_POST, SamlClient.Binding.POST).setProtocolBinding(JBossSAMLURIConstants.SAML_HTTP_ARTIFACT_BINDING.getUri()).build().login().user(bburkeUser).build().handleArtifact(getAuthServerSamlEndpoint(REALM_NAME), SAML_CLIENT_ID_SALES_POST).setBeforeStepChecks(// Move in time before resolving the artifact
    () -> setTimeOffset(1000)).build().doNotFollowRedirects().executeAndTransform(this::getArtifactResponse);
    assertThat(response.getSamlObject(), instanceOf(ArtifactResponseType.class));
    ArtifactResponseType artifactResponse = (ArtifactResponseType) response.getSamlObject();
    assertThat(artifactResponse, isSamlStatusResponse(JBossSAMLURIConstants.STATUS_SUCCESS));
    assertThat(artifactResponse.getAny(), nullValue());
}
Also used : SAMLDocumentHolder(org.keycloak.saml.processing.core.saml.v2.common.SAMLDocumentHolder) SamlClientBuilder(org.keycloak.testsuite.util.SamlClientBuilder) RealmAttributeUpdater(org.keycloak.testsuite.updaters.RealmAttributeUpdater) ArtifactResponseType(org.keycloak.dom.saml.v2.protocol.ArtifactResponseType) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)27 RealmAttributeUpdater (org.keycloak.testsuite.updaters.RealmAttributeUpdater)27 AbstractTestRealmKeycloakTest (org.keycloak.testsuite.AbstractTestRealmKeycloakTest)15 Matchers.containsString (org.hamcrest.Matchers.containsString)10 List (java.util.List)5 AuthServerContainerExclude (org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude)5 WebAuthnRealmAttributeUpdater (org.keycloak.testsuite.webauthn.updaters.WebAuthnRealmAttributeUpdater)5 Closeable (java.io.Closeable)4 Arrays (java.util.Arrays)4 HashMap (java.util.HashMap)4 Set (java.util.Set)4 Response (javax.ws.rs.core.Response)4 Matchers.equalTo (org.hamcrest.Matchers.equalTo)4 Assert.assertFalse (org.junit.Assert.assertFalse)4 IOException (java.io.IOException)3 URISyntaxException (java.net.URISyntaxException)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 UUID (java.util.UUID)3 MimeMessage (javax.mail.internet.MimeMessage)3