Avoid using deprecated junit APIs in tests

- Replaced usage of Assert.assertThat with static import
- Replaced static import org.junit.Assert.assertThat with org.hamcrest.MatcherAssert.assertThat

Fixes: #22111
This commit is contained in:
Thomas Darimont 2023-07-31 10:08:19 +02:00 committed by Alexander Schwartz
parent d80da5a497
commit 82269f789a
178 changed files with 688 additions and 610 deletions

View file

@ -21,7 +21,7 @@ import java.net.URI;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
*

View file

@ -11,6 +11,8 @@ import org.keycloak.common.crypto.CryptoIntegration;
import org.keycloak.common.util.KeystoreUtil;
import org.keycloak.rule.CryptoInitRule;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
@ -22,7 +24,7 @@ public class DefaultKeyStoreTypesTest {
@Test
public void testKeystoreFormats() {
Set<KeystoreUtil.KeystoreFormat> supportedKeystoreFormats = CryptoIntegration.getProvider().getSupportedKeyStoreTypes().collect(Collectors.toSet());
Assert.assertThat(supportedKeystoreFormats, Matchers.containsInAnyOrder(
assertThat(supportedKeystoreFormats, Matchers.containsInAnyOrder(
KeystoreUtil.KeystoreFormat.JKS,
KeystoreUtil.KeystoreFormat.PKCS12,
KeystoreUtil.KeystoreFormat.BCFKS));

View file

@ -30,6 +30,8 @@ import org.keycloak.common.crypto.CryptoIntegration;
import org.keycloak.common.util.KeystoreUtil;
import org.keycloak.rule.CryptoInitRule;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
@ -42,7 +44,7 @@ public class ElytronKeyStoreTypesTest {
@Test
public void testKeystoreFormats() {
Set<KeystoreUtil.KeystoreFormat> supportedKeystoreFormats = CryptoIntegration.getProvider().getSupportedKeyStoreTypes().collect(Collectors.toSet());
Assert.assertThat(supportedKeystoreFormats, Matchers.containsInAnyOrder(
assertThat(supportedKeystoreFormats, Matchers.containsInAnyOrder(
KeystoreUtil.KeystoreFormat.JKS,
KeystoreUtil.KeystoreFormat.PKCS12
));

View file

@ -15,6 +15,8 @@ import org.keycloak.common.util.Environment;
import org.keycloak.common.util.KeystoreUtil;
import org.keycloak.rule.CryptoInitRule;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
@ -33,7 +35,7 @@ public class FIPS1402KeystoreTypesTest {
public void testKeystoreFormatsInNonApprovedMode() {
Assume.assumeFalse(CryptoServicesRegistrar.isInApprovedOnlyMode());
Set<KeystoreUtil.KeystoreFormat> supportedKeystoreFormats = CryptoIntegration.getProvider().getSupportedKeyStoreTypes().collect(Collectors.toSet());
Assert.assertThat(supportedKeystoreFormats, Matchers.containsInAnyOrder(
assertThat(supportedKeystoreFormats, Matchers.containsInAnyOrder(
KeystoreUtil.KeystoreFormat.PKCS12,
KeystoreUtil.KeystoreFormat.BCFKS));
}
@ -43,7 +45,7 @@ public class FIPS1402KeystoreTypesTest {
public void testKeystoreFormatsInApprovedMode() {
Assume.assumeTrue(CryptoServicesRegistrar.isInApprovedOnlyMode());
Set<KeystoreUtil.KeystoreFormat> supportedKeystoreFormats = CryptoIntegration.getProvider().getSupportedKeyStoreTypes().collect(Collectors.toSet());
Assert.assertThat(supportedKeystoreFormats, Matchers.containsInAnyOrder(
assertThat(supportedKeystoreFormats, Matchers.containsInAnyOrder(
KeystoreUtil.KeystoreFormat.BCFKS));
}
}

View file

@ -21,6 +21,7 @@ import org.keycloak.rule.CryptoInitRule;
import org.keycloak.rule.RunInThreadRule;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
@ -109,7 +110,7 @@ public class FIPS1402Pbkdf2PasswordPaddingTest {
}
logger.infof("Before password verification. BC FIPS approved mode: %b, password: %s", CryptoServicesRegistrar.isInApprovedOnlyMode(), password);
Assert.assertThat(true, is(pbkdf2HashProvider.verify(password, passwordCred)));
assertThat(true, is(pbkdf2HashProvider.verify(password, passwordCred)));
}

View file

@ -28,6 +28,7 @@ import org.keycloak.common.util.Environment;
import org.keycloak.rule.CryptoInitRule;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
@ -144,9 +145,9 @@ public class FIPS1402SslTest {
logger.infof("Enabled ciphersuites: %s", enabledCipherSuites.size());
logger.infof("Supported protocols: %s", supportedProtocols);
logger.infof("Supported ciphers size: %d", supportedCiphers.size());
Assert.assertThat(enabledCipherSuites.size(), greaterThan(0));
Assert.assertThat(supportedProtocols.size(), greaterThan(0));
Assert.assertThat(supportedCiphers.size(), greaterThan(0));
assertThat(enabledCipherSuites.size(), greaterThan(0));
assertThat(supportedProtocols.size(), greaterThan(0));
assertThat(supportedCiphers.size(), greaterThan(0));
SSLSessionContext sslServerCtx = context.getServerSessionContext();
Assert.assertNotNull(sslServerCtx);

View file

@ -21,6 +21,7 @@ import org.junit.Assert;
import org.junit.Test;
import org.keycloak.migration.ModelVersion;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.storage.datastore.LegacyMigrationManager.RHSSO_VERSION_7_0_KEYCLOAK_VERSION;
import static org.keycloak.storage.datastore.LegacyMigrationManager.RHSSO_VERSION_7_1_KEYCLOAK_VERSION;
import static org.keycloak.storage.datastore.LegacyMigrationManager.RHSSO_VERSION_7_2_KEYCLOAK_VERSION;
@ -39,33 +40,33 @@ public class LegacyMigrationManagerTest {
@Test
public void testRHSSOVersionToKeycloakVersionConversion() {
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.0.0.GA"), is(equalTo(RHSSO_VERSION_7_0_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.0.1.GA"), is(equalTo(RHSSO_VERSION_7_0_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.0.2.GA"), is(equalTo(RHSSO_VERSION_7_0_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.0.0.GA"), is(equalTo(RHSSO_VERSION_7_0_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.0.1.GA"), is(equalTo(RHSSO_VERSION_7_0_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.0.2.GA"), is(equalTo(RHSSO_VERSION_7_0_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.1.0.GA"), is(equalTo(RHSSO_VERSION_7_1_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.1.1.GA"), is(equalTo(RHSSO_VERSION_7_1_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.1.2.GA"), is(equalTo(RHSSO_VERSION_7_1_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.1.0.GA"), is(equalTo(RHSSO_VERSION_7_1_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.1.1.GA"), is(equalTo(RHSSO_VERSION_7_1_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.1.2.GA"), is(equalTo(RHSSO_VERSION_7_1_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.2.0.GA"), is(equalTo(RHSSO_VERSION_7_2_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.2.1.GA"), is(equalTo(RHSSO_VERSION_7_2_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.2.2.GA"), is(equalTo(RHSSO_VERSION_7_2_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.2.0.GA"), is(equalTo(RHSSO_VERSION_7_2_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.2.1.GA"), is(equalTo(RHSSO_VERSION_7_2_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.2.2.GA"), is(equalTo(RHSSO_VERSION_7_2_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.3.0.GA"), is(equalTo(RHSSO_VERSION_7_3_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.3.1.GA"), is(equalTo(RHSSO_VERSION_7_3_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.3.2.GA"), is(equalTo(RHSSO_VERSION_7_3_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.3.10.GA"), is(equalTo(RHSSO_VERSION_7_3_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.3.0.GA"), is(equalTo(RHSSO_VERSION_7_3_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.3.1.GA"), is(equalTo(RHSSO_VERSION_7_3_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.3.2.GA"), is(equalTo(RHSSO_VERSION_7_3_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.3.10.GA"), is(equalTo(RHSSO_VERSION_7_3_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.4.0.GA"), is(equalTo(RHSSO_VERSION_7_4_KEYCLOAK_VERSION)));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.4.15.GA"), is(equalTo(RHSSO_VERSION_7_4_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.4.0.GA"), is(equalTo(RHSSO_VERSION_7_4_KEYCLOAK_VERSION)));
assertThat(convertRHSSOVersionToKeycloakVersion("7.4.15.GA"), is(equalTo(RHSSO_VERSION_7_4_KEYCLOAK_VERSION)));
// check the conversion doesn't change version for keycloak
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7.0.0"), is(nullValue()));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("8.0.0"), is(nullValue()));
assertThat(convertRHSSOVersionToKeycloakVersion("7.0.0"), is(nullValue()));
assertThat(convertRHSSOVersionToKeycloakVersion("8.0.0"), is(nullValue()));
// check for CD releases
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("6"), is(equalTo(new ModelVersion("6.0.0"))));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("7"), is(equalTo(new ModelVersion("7.0.0"))));
Assert.assertThat(convertRHSSOVersionToKeycloakVersion("10"), is(equalTo(new ModelVersion("10.0.0"))));
assertThat(convertRHSSOVersionToKeycloakVersion("6"), is(equalTo(new ModelVersion("6.0.0"))));
assertThat(convertRHSSOVersionToKeycloakVersion("7"), is(equalTo(new ModelVersion("7.0.0"))));
assertThat(convertRHSSOVersionToKeycloakVersion("10"), is(equalTo(new ModelVersion("10.0.0"))));
}
}

View file

@ -27,7 +27,7 @@ import org.junit.Test;
import org.junit.Before;
import org.w3c.dom.Element;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Test class for SAML AttributeQuery parser.

View file

@ -26,7 +26,7 @@ import org.junit.Test;
import org.junit.Before;
import org.w3c.dom.Element;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Test class for SAML AuthNRequest parser.

View file

@ -105,7 +105,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
/**
* Test class for SAML parser.

View file

@ -27,7 +27,7 @@ import org.junit.Test;
import org.junit.Before;
import org.w3c.dom.Element;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Test class for SAML SLO parser.

View file

@ -22,7 +22,7 @@ import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.xml.sax.SAXException;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
*

View file

@ -31,7 +31,7 @@ import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* Tests for {@link ProxyMappings}.

View file

@ -20,7 +20,7 @@ import org.hamcrest.Matchers;
import org.junit.Test;
import org.keycloak.utils.JsonUtils;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
*

View file

@ -22,7 +22,7 @@ import java.util.UUID;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
public class SamlProtocolUtilsTest {

View file

@ -29,7 +29,7 @@ import org.keycloak.saml.processing.core.parsers.saml.SAMLParser;
import java.io.InputStream;
import org.hamcrest.CoreMatchers;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>

View file

@ -5,7 +5,7 @@ import org.junit.Test;
import java.util.Arrays;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* <a href="mailto:external.benjamin.weimer@bosch-si.com">Benjamin Weimer</a>,

View file

@ -9,7 +9,7 @@ import java.nio.file.Paths;
import java.util.Arrays;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertThrows;
import static org.keycloak.vault.SecretContains.secretContains;

View file

@ -11,7 +11,7 @@ import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.vault.SecretContains.secretContains;
/**

View file

@ -51,7 +51,7 @@ import java.util.regex.Pattern;
import java.util.stream.Stream;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
*

View file

@ -31,7 +31,7 @@ import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author mhajas

View file

@ -45,6 +45,8 @@ import jakarta.ws.rs.core.Response;
import org.hamcrest.Matchers;
import org.jboss.logging.Logger;
import org.junit.Assert;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.admin.ApiUtil.getCreatedId;
/**
@ -112,7 +114,7 @@ public class Creator<T> implements AutoCloseable {
public static Creator<IdentityProviderResource> create(RealmResource realmResource, IdentityProviderRepresentation rep) {
final IdentityProvidersResource res = realmResource.identityProviders();
Assert.assertThat("Identity provider alias must be specified", rep.getAlias(), Matchers.notNullValue());
assertThat("Identity provider alias must be specified", rep.getAlias(), Matchers.notNullValue());
try (Response response = res.create(rep)) {
String createdId = getCreatedId(response);
final IdentityProviderResource r = res.get(rep.getAlias());

View file

@ -14,7 +14,7 @@ import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.updaters.ServerResourceUpdater.updateViaAddRemove;
/**

View file

@ -96,7 +96,7 @@ import java.util.concurrent.TimeUnit;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.keycloak.saml.common.constants.GeneralConstants.RELAY_STATE;
import static org.keycloak.testsuite.util.Matchers.statusCodeIsHC;

View file

@ -46,6 +46,7 @@ import org.hamcrest.Matcher;
import org.junit.Assert;
import org.w3c.dom.Document;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.util.saml.SamlDocumentStepBuilder.saml2Object2String;
/**
@ -128,7 +129,7 @@ public class SamlClientBuilder {
public SamlClientBuilder assertResponse(Matcher<? super CloseableHttpResponse> matcher) {
steps.add((client, currentURI, currentResponse, context) -> {
Assert.assertThat(currentResponse, matcher);
assertThat(currentResponse, matcher);
return null;
});
return this;
@ -264,8 +265,8 @@ public class SamlClientBuilder {
return
doNotFollowRedirects()
.addStep((client, currentURI, currentResponse, context) -> {
Assert.assertThat(currentResponse, Matchers.statusCodeIsHC(Status.FOUND));
Assert.assertThat("Location header not found", currentResponse.getFirstHeader("Location"), notNullValue());
assertThat(currentResponse, Matchers.statusCodeIsHC(Status.FOUND));
assertThat("Location header not found", currentResponse.getFirstHeader("Location"), notNullValue());
return new HttpGet(currentResponse.getFirstHeader("Location").getValue());
});
}

View file

@ -27,7 +27,7 @@ import org.keycloak.dom.saml.v2.protocol.ResponseType.RTChoiceType;
import java.util.Objects;
import java.util.stream.Stream;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
*

View file

@ -41,7 +41,7 @@ import org.hamcrest.Matchers;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.admin.Users.getPasswordOf;
import static org.keycloak.testsuite.util.Matchers.statusCodeIsHC;

View file

@ -55,7 +55,7 @@ import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.util.Matchers.statusCodeIsHC;

View file

@ -38,7 +38,7 @@ import org.apache.http.util.EntityUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.util.Matchers.statusCodeIsHC;
/**

View file

@ -18,7 +18,7 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
public class SessionStateChecker implements Runnable {

View file

@ -42,7 +42,7 @@ import org.jboss.logging.Logger;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.util.Matchers.statusCodeIsHC;
/**

View file

@ -41,6 +41,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.util.ServerURLs.getAuthServerContextRoot;
/**
@ -363,13 +364,13 @@ public class AssertEvents implements TestRule {
if (expected.getError() != null && ! expected.getType().toString().endsWith("_ERROR")) {
expected.setType(expected.getType() + "_ERROR");
}
Assert.assertThat("type", actual.getType(), is(expected.getType()));
Assert.assertThat("realm ID", actual.getRealmId(), is(realmId));
Assert.assertThat("client ID", actual.getClientId(), is(expected.getClientId()));
Assert.assertThat("error", actual.getError(), is(expected.getError()));
Assert.assertThat("ip address", actual.getIpAddress(), ipAddress);
Assert.assertThat("user ID", actual.getUserId(), is(userId));
Assert.assertThat("session ID", actual.getSessionId(), is(sessionId));
assertThat("type", actual.getType(), is(expected.getType()));
assertThat("realm ID", actual.getRealmId(), is(realmId));
assertThat("client ID", actual.getClientId(), is(expected.getClientId()));
assertThat("error", actual.getError(), is(expected.getError()));
assertThat("ip address", actual.getIpAddress(), ipAddress);
assertThat("user ID", actual.getUserId(), is(userId));
assertThat("session ID", actual.getSessionId(), is(sessionId));
if (details == null || details.isEmpty()) {
// Assert.assertNull(actual.getDetails());
@ -381,7 +382,7 @@ public class AssertEvents implements TestRule {
Assert.fail(d.getKey() + " missing");
}
Assert.assertThat("Unexpected value for " + d.getKey(), actualValue, is(d.getValue()));
assertThat("Unexpected value for " + d.getKey(), actualValue, is(d.getValue()));
}
/*
for (String k : actual.getDetails().keySet()) {

View file

@ -34,7 +34,7 @@ import java.io.IOException;
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>

View file

@ -35,6 +35,7 @@ import org.keycloak.testsuite.admin.ApiUtil;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@ -98,7 +99,7 @@ public class AccountRestServiceReadOnlyAttributesTest extends AbstractRestServic
private void testAccountUpdateAttributeExpectFailure(String attrName, boolean deniedForAdminAsWell) throws IOException {
// Attribute not yet supposed to be on the user
UserRepresentation user = SimpleHttp.doGet(getAccountUrl(null), httpClient).auth(tokenUtil.getToken()).asJson(UserRepresentation.class);
Assert.assertThat(user.getAttributes().keySet(), not(contains(attrName)));
assertThat(user.getAttributes().keySet(), not(contains(attrName)));
// Assert not possible to add the attribute to the user
user.singleAttribute(attrName, "foo");
@ -146,7 +147,7 @@ public class AccountRestServiceReadOnlyAttributesTest extends AbstractRestServic
private void testAccountUpdateAttributeExpectSuccess(String attrName) throws IOException {
// Attribute not yet supposed to be on the user
UserRepresentation user = SimpleHttp.doGet(getAccountUrl(null), httpClient).auth(tokenUtil.getToken()).asJson(UserRepresentation.class);
Assert.assertThat(user.getAttributes().keySet(), not(contains(attrName)));
assertThat(user.getAttributes().keySet(), not(contains(attrName)));
// Assert not possible to add the attribute to the user
user.singleAttribute(attrName, "foo");

View file

@ -869,7 +869,7 @@ public class AccountRestServiceTest extends AbstractRestServiceTest {
assertFalse(applications.isEmpty());
Map<String, ClientRepresentation> apps = applications.stream().collect(Collectors.toMap(x -> x.getClientId(), x -> x));
Assert.assertThat(apps.keySet(), containsInAnyOrder("in-use-client", "always-display-client", "direct-grant"));
assertThat(apps.keySet(), containsInAnyOrder("in-use-client", "always-display-client", "direct-grant"));
assertClientRep(apps.get("in-use-client"), "In Use Client", null, false, true, false, null, inUseClientAppUri);
assertClientRep(apps.get("always-display-client"), "Always Display Client", null, false, false, false, null, alwaysDisplayClientAppUri);
@ -893,7 +893,7 @@ public class AccountRestServiceTest extends AbstractRestServiceTest {
assertFalse(applications.isEmpty());
Map<String, ClientRepresentation> apps = applications.stream().collect(Collectors.toMap(x -> x.getClientId(), x -> x));
Assert.assertThat(apps.keySet(), containsInAnyOrder("in-use-client"));
assertThat(apps.keySet(), containsInAnyOrder("in-use-client"));
assertClientRep(apps.get("in-use-client"), "In Use Client", null, false, true, false, null, inUseClientAppUri);
}
@ -919,7 +919,7 @@ public class AccountRestServiceTest extends AbstractRestServiceTest {
assertFalse(applications.isEmpty());
Map<String, ClientRepresentation> apps = applications.stream().collect(Collectors.toMap(x -> x.getClientId(), x -> x));
Assert.assertThat(apps.keySet(), containsInAnyOrder("offline-client", "offline-client-without-base-url", "always-display-client", "direct-grant"));
assertThat(apps.keySet(), containsInAnyOrder("offline-client", "offline-client-without-base-url", "always-display-client", "direct-grant"));
assertClientRep(apps.get("offline-client"), "Offline Client", null, false, true, true, null, offlineClientAppUri);
assertClientRep(apps.get("offline-client-without-base-url"), "Offline Client Without Base URL", null, false, true, true, null, null);
@ -969,7 +969,7 @@ public class AccountRestServiceTest extends AbstractRestServiceTest {
.asResponse();
Map<String, ClientRepresentation> apps = applications.stream().collect(Collectors.toMap(x -> x.getClientId(), x -> x));
Assert.assertThat(apps.keySet(), containsInAnyOrder(appId, "always-display-client", "direct-grant"));
assertThat(apps.keySet(), containsInAnyOrder(appId, "always-display-client", "direct-grant"));
ClientRepresentation app = apps.get(appId);
assertClientRep(app, null, "A third party application", true, false, false, null, "http://localhost:8180/auth/realms/master/app/auth");
@ -1001,7 +1001,7 @@ public class AccountRestServiceTest extends AbstractRestServiceTest {
assertFalse(applications.isEmpty());
Map<String, ClientRepresentation> apps = applications.stream().collect(Collectors.toMap(x -> x.getClientId(), x -> x));
Assert.assertThat(apps.keySet(), containsInAnyOrder("root-url-client", "always-display-client", "direct-grant"));
assertThat(apps.keySet(), containsInAnyOrder("root-url-client", "always-display-client", "direct-grant"));
assertClientRep(apps.get("root-url-client"), null, null, false, true, false, "http://localhost:8180/foo/bar", "/baz");
}
@ -1449,7 +1449,7 @@ public class AccountRestServiceTest extends AbstractRestServiceTest {
assertFalse(applications.isEmpty());
Map<String, ClientRepresentation> apps = applications.stream().collect(Collectors.toMap(x -> x.getClientId(), x -> x));
Assert.assertThat(apps.keySet(), containsInAnyOrder("offline-client", "always-display-client", "direct-grant"));
assertThat(apps.keySet(), containsInAnyOrder("offline-client", "always-display-client", "direct-grant"));
assertClientRep(apps.get("offline-client"), "Offline Client", null, false, true, false, null, offlineClientAppUri);
}

View file

@ -20,7 +20,7 @@ import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

View file

@ -857,7 +857,7 @@ public class RequiredActionEmailVerificationTest extends AbstractTestRealmKeyclo
// email should be verified and required actions empty
UserRepresentation user = testRealm().users().get(testUserId).toRepresentation();
Assert.assertTrue(user.isEmailVerified());
Assert.assertThat(user.getRequiredActions(), Matchers.empty());
assertThat(user.getRequiredActions(), Matchers.empty());
}
@Test
@ -896,7 +896,7 @@ public class RequiredActionEmailVerificationTest extends AbstractTestRealmKeyclo
// email should be verified and required actions empty
UserRepresentation user = testRealm().users().get(testUserId).toRepresentation();
Assert.assertTrue(user.isEmailVerified());
Assert.assertThat(user.getRequiredActions(), Matchers.empty());
assertThat(user.getRequiredActions(), Matchers.empty());
}
@Test
@ -940,7 +940,7 @@ public class RequiredActionEmailVerificationTest extends AbstractTestRealmKeyclo
// email should be verified and required actions empty
UserRepresentation user = testRealm().users().get(testUserId).toRepresentation();
Assert.assertTrue(user.isEmailVerified());
Assert.assertThat(user.getRequiredActions(), Matchers.empty());
assertThat(user.getRequiredActions(), Matchers.empty());
// after refresh in the first browser the app should be shown
driver.navigate().refresh();

View file

@ -18,7 +18,7 @@ package org.keycloak.testsuite.adapter;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.admin.Users.setPasswordFor;
import static org.keycloak.testsuite.auth.page.AuthRealm.DEMO;
import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm;

View file

@ -17,7 +17,7 @@
package org.keycloak.testsuite.adapter.example.fuse;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.keycloak.testsuite.auth.page.AuthRealm.DEMO;
import static org.keycloak.testsuite.utils.fuse.FuseUtils.assertCommand;

View file

@ -122,7 +122,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.keycloak.testsuite.auth.page.AuthRealm.DEMO;
import static org.keycloak.testsuite.util.AdminClientUtil.NUMBER_OF_CONNECTIONS;
@ -1197,19 +1197,19 @@ public class DemoServletsAdapterTest extends AbstractServletsAdapterTest {
// Redirect client to login page if it's not an XHR
response = target.request().header("X-Requested-With", "Dont-Know").header(HttpHeaders.ACCEPT, "*/*").get();
Assert.assertEquals(302, response.getStatus());
Assert.assertThat(response.getHeaderString(HttpHeaders.LOCATION), containsString("response_type=code"));
assertThat(response.getHeaderString(HttpHeaders.LOCATION), containsString("response_type=code"));
response.close();
// Redirect client to login page if client explicitely understands HTML responses
response = target.request().header(HttpHeaders.ACCEPT, "text/html,application/xhtml+xml,application/xml;q=0.9").get();
Assert.assertEquals(302, response.getStatus());
Assert.assertThat(response.getHeaderString(HttpHeaders.LOCATION), containsString("response_type=code"));
assertThat(response.getHeaderString(HttpHeaders.LOCATION), containsString("response_type=code"));
response.close();
// Redirect client to login page if client understands all response types
response = target.request().header(HttpHeaders.ACCEPT, "*/*").get();
Assert.assertEquals(302, response.getStatus());
Assert.assertThat(response.getHeaderString(HttpHeaders.LOCATION), containsString("response_type=code"));
assertThat(response.getHeaderString(HttpHeaders.LOCATION), containsString("response_type=code"));
response.close();
client.close();
}

View file

@ -13,7 +13,7 @@ import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
@AppServerContainer(ContainerConstants.APP_SERVER_UNDERTOW)

View file

@ -39,6 +39,8 @@ import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import org.jboss.arquillian.graphene.page.Page;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.adapter.AbstractServletsAdapterTest.samlServletDeployment;
import org.keycloak.testsuite.adapter.page.SalesPostClockSkewServlet;
import static org.keycloak.testsuite.util.SamlClient.Binding.POST;
@ -89,7 +91,7 @@ public class SAMLClockSkewAdapterTest extends AbstractSAMLServletAdapterTest {
return doc;
}).build().executeAndTransform(resp -> EntityUtils.toString(resp.getEntity()));
Assert.assertThat(resultPage, matcher);
assertThat(resultPage, matcher);
} finally {
setAdapterAndServerTimeOffset(0, salesPostClockSkewServletPage.toString());
}

View file

@ -40,7 +40,7 @@ import java.util.Map;
import java.util.Set;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.admin.ApiUtil.getCreatedId;
import static org.keycloak.testsuite.saml.AbstractSamlTest.REALM_PRIVATE_KEY;
import static org.keycloak.testsuite.saml.AbstractSamlTest.REALM_PUBLIC_KEY;
@ -105,8 +105,8 @@ public class SAMLLoginResponseHandlingTest extends AbstractSAMLServletAdapterTes
.build()
.navigateTo(employee2ServletPage.getUriBuilder().clone().path("getAttributes").build())
.execute(response -> {
Assert.assertThat(response, statusCodeIsHC(Response.Status.OK));
Assert.assertThat(response, bodyHC(containsString("attribute-with-null-attribute-value: <br />")));
assertThat(response, statusCodeIsHC(Response.Status.OK));
assertThat(response, bodyHC(containsString("attribute-with-null-attribute-value: <br />")));
}
);
}
@ -122,7 +122,7 @@ public class SAMLLoginResponseHandlingTest extends AbstractSAMLServletAdapterTes
new SamlClientBuilder()
.addStep((client, currentURI, currentResponse, context) ->
SamlClient.Binding.REDIRECT.createSamlUnsignedResponse(URI.create(employeeSigServletPage.toString() + "/saml"), null, document))
.execute(closeableHttpResponse -> Assert.assertThat(closeableHttpResponse, bodyHC(containsString("INVALID_SIGNATURE"))));
.execute(closeableHttpResponse -> assertThat(closeableHttpResponse, bodyHC(containsString("INVALID_SIGNATURE"))));
}
@Test
@ -136,7 +136,7 @@ public class SAMLLoginResponseHandlingTest extends AbstractSAMLServletAdapterTes
new SamlClientBuilder()
.addStep((client, currentURI, currentResponse, context) ->
SamlClient.Binding.REDIRECT.createSamlSignedResponse(URI.create(employeeSigServletPage.toString() + "/saml"), null, document, REALM_PRIVATE_KEY, REALM_PUBLIC_KEY))
.execute(closeableHttpResponse -> Assert.assertThat(closeableHttpResponse, bodyHC(containsString("ERROR_STATUS"))));
.execute(closeableHttpResponse -> assertThat(closeableHttpResponse, bodyHC(containsString("ERROR_STATUS"))));
}
@Test

View file

@ -35,7 +35,7 @@ import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.adapter.AbstractServletsAdapterTest.samlServletDeployment;
import static org.keycloak.testsuite.adapter.servlet.SAMLServletAdapterTest.FORBIDDEN_TEXT;
import static org.keycloak.testsuite.adapter.servlet.SAMLServletAdapterTest.WEBSPHERE_FORBIDDEN_TEXT;

View file

@ -619,9 +619,9 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
.navigateTo(employeeAcsServletPage.buildUri())
.getSamlResponse(Binding.POST);
Assert.assertThat(samlResponse.getSamlObject(), instanceOf(AuthnRequestType.class));
Assert.assertThat(((AuthnRequestType) samlResponse.getSamlObject()).getAssertionConsumerServiceURL(), notNullValue());
Assert.assertThat(((AuthnRequestType) samlResponse.getSamlObject()).getAssertionConsumerServiceURL().getPath(), is("/employee-acs/a/different/endpoint/for/saml"));
assertThat(samlResponse.getSamlObject(), instanceOf(AuthnRequestType.class));
assertThat(((AuthnRequestType) samlResponse.getSamlObject()).getAssertionConsumerServiceURL(), notNullValue());
assertThat(((AuthnRequestType) samlResponse.getSamlObject()).getAssertionConsumerServiceURL().getPath(), is("/employee-acs/a/different/endpoint/for/saml"));
assertSuccessfulLogin(employeeAcsServletPage, bburkeUser, testRealmSAMLPostLoginPage, "principal=bburke");
}
@ -897,8 +897,8 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
.processSamlResponse(Binding.POST).build()
.execute(r -> {
Assert.assertThat(r, statusCodeIsHC(Response.Status.OK));
Assert.assertThat(r, bodyHC(containsString("urn:oasis:names:tc:SAML:2.0:status:RequestDenied"))); // TODO: revisit - should the HTTP status be 403 too?
assertThat(r, statusCodeIsHC(Response.Status.OK));
assertThat(r, bodyHC(containsString("urn:oasis:names:tc:SAML:2.0:status:RequestDenied"))); // TODO: revisit - should the HTTP status be 403 too?
});
} finally {
salesPostEncServletPage.logout();
@ -918,8 +918,8 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
.processSamlResponse(Binding.POST).build()
.execute(r -> {
Assert.assertThat(r, statusCodeIsHC(Response.Status.OK));
Assert.assertThat(r, bodyHC(containsString("urn:oasis:names:tc:SAML:2.0:status:RequestDenied"))); // TODO: revisit - should the HTTP status be 403 too?
assertThat(r, statusCodeIsHC(Response.Status.OK));
assertThat(r, bodyHC(containsString("urn:oasis:names:tc:SAML:2.0:status:RequestDenied"))); // TODO: revisit - should the HTTP status be 403 too?
});
} finally {
salesPostServletPage.logout();
@ -976,8 +976,8 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
UserRepresentation storedUser = u.resource().toRepresentation();
Assert.assertThat(storedUser, notNullValue());
Assert.assertThat("Database seems to be unable to store Unicode for username. Refer to KEYCLOAK-3439 and related issues.", storedUser.getUsername(), equalToIgnoringCase(username));
assertThat(storedUser, notNullValue());
assertThat("Database seems to be unable to store Unicode for username. Refer to KEYCLOAK-3439 and related issues.", storedUser.getUsername(), equalToIgnoringCase(username));
assertSuccessfulLogin(salesPostSigServletPage, user, testRealmSAMLPostLoginPage, "principal=" + storedUser.getUsername());
@ -1001,8 +1001,8 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
UserRepresentation storedUser = u.resource().toRepresentation();
Assert.assertThat(storedUser, notNullValue());
Assert.assertThat("Database seems to be unable to store Unicode for username. Refer to KEYCLOAK-3439 and related issues.", storedUser.getUsername(), equalToIgnoringCase(username));
assertThat(storedUser, notNullValue());
assertThat("Database seems to be unable to store Unicode for username. Refer to KEYCLOAK-3439 and related issues.", storedUser.getUsername(), equalToIgnoringCase(username));
assertSuccessfulLogin(employeeSigServletPage, user, testRealmSAMLRedirectLoginPage, "principal=" + storedUser.getUsername());
@ -1027,14 +1027,14 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
.login().user(user).build()
.processSamlResponse(Binding.POST)
.transformString(s -> {
Assert.assertThat(s, containsString(">bburke@redhat.com.additional.domain<"));
assertThat(s, containsString(">bburke@redhat.com.additional.domain<"));
s = s.replaceAll("bburke@redhat.com.additional.domain", "bburke@redhat.com<!-- comment -->.additional.domain");
return s;
})
.build()
.executeAndTransform(resp -> EntityUtils.toString(resp.getEntity()));
Assert.assertThat(resultPage, containsString("principal=bburke@redhat.com.additional.domain"));
assertThat(resultPage, containsString("principal=bburke@redhat.com.additional.domain"));
}
@Test
@ -1048,14 +1048,14 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
.login().user(user).build()
.processSamlResponse(Binding.POST)
.transformString(s -> {
Assert.assertThat(s, containsString(">bburke@redhat.com.additional.domain<"));
assertThat(s, containsString(">bburke@redhat.com.additional.domain<"));
s = s.replaceAll("bburke@redhat.com.additional.domain", "bburke@redhat.com");
return s;
})
.build()
.executeAndTransform(resp -> EntityUtils.toString(resp.getEntity()));
Assert.assertThat(resultPage, anyOf(
assertThat(resultPage, anyOf(
containsString("INVALID_SIGNATURE"),
containsString("Error 403: SRVE0295E: Error reported: 403") //WAS
));
@ -1132,7 +1132,7 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
assertCurrentUrlStartsWith(testRealmSAMLPostLoginPage);
testRealmLoginPage.form().login("bburke@redhat.com", "password");
Assert.assertThat(URI.create(driver.getCurrentUrl()).getPath(), endsWith("secured/post"));
assertThat(URI.create(driver.getCurrentUrl()).getPath(), endsWith("secured/post"));
waitUntilElement(By.xpath("//body")).text().contains("parameter=hello");
// test that user principal and KeycloakSecurityContext available
@ -1163,7 +1163,7 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
samlidpInitiatedLoginPage.form().login(bburkeUser);
assertCurrentUrlStartsWith(salesPost2ServletPage);
Assert.assertThat(URI.create(driver.getCurrentUrl()).getPath(), endsWith("foo"));
assertThat(URI.create(driver.getCurrentUrl()).getPath(), endsWith("foo"));
waitUntilElement(By.xpath("//body")).text().contains("principal=bburke");
salesPost2ServletPage.logout();
checkLoggedOut(salesPost2ServletPage, testRealmSAMLPostLoginPage);
@ -1204,8 +1204,8 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
assertCurrentUrlStartsWith(employeeServletPage);
waitForPageToLoad();
String pageSource = driver.getPageSource();
Assert.assertThat(pageSource, containsString("Relay state: " + SamlSPFacade.RELAY_STATE));
Assert.assertThat(pageSource, not(containsString("SAML response: null")));
assertThat(pageSource, containsString("Relay state: " + SamlSPFacade.RELAY_STATE));
assertThat(pageSource, not(containsString("SAML response: null")));
}
private static String[] parseCommaSeparatedAttributes(String body, String attribute) {
@ -1458,8 +1458,8 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
.navigateTo(employee2ServletPage.getUriBuilder().clone().path("getAttributes").build())
.execute(r -> {
Assert.assertThat(r, statusCodeIsHC(Response.Status.OK));
Assert.assertThat(r, bodyHC(containsString("boolean-attribute: true")));
assertThat(r, statusCodeIsHC(Response.Status.OK));
assertThat(r, bodyHC(containsString("boolean-attribute: true")));
});
}
@ -1476,7 +1476,7 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
XPathExpression expr = xpath.compile("//*[local-name()='NameID']");
NodeList nodeList = (NodeList) expr.evaluate(responseDoc, XPathConstants.NODESET);
Assert.assertThat(nodeList.getLength(), is(1));
assertThat(nodeList.getLength(), is(1));
final Node nameIdNode = nodeList.item(0);
nameIdNode.getParentNode().removeChild(nameIdNode);
@ -1488,8 +1488,8 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
.navigateTo(employee2ServletPage.toString())
.execute(r -> {
Assert.assertThat(r, statusCodeIsHC(Response.Status.OK));
Assert.assertThat(r, bodyHC(containsString("principal=")));
assertThat(r, statusCodeIsHC(Response.Status.OK));
assertThat(r, bodyHC(containsString("principal=")));
});
}
@ -1509,8 +1509,8 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
.navigateTo(employee2ServletPage.toString())
.execute(r -> {
Assert.assertThat(r, statusCodeIsHC(Response.Status.OK));
Assert.assertThat(r, bodyHC(containsString("principal=")));
assertThat(r, statusCodeIsHC(Response.Status.OK));
assertThat(r, bodyHC(containsString("principal=")));
});
}
@ -1536,13 +1536,13 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
HttpUriRequest post = SamlClient.Binding.POST.createSamlUnsignedResponse(getAppServerSamlEndpoint(salesPostSigEmailServletPage), null, responseDoc);
response = client.execute(post, context);
System.out.println(EntityUtils.toString(response.getEntity()));
Assert.assertThat(response, statusCodeIsHC(Response.Status.FOUND));
assertThat(response, statusCodeIsHC(Response.Status.FOUND));
response.close();
HttpGet get = new HttpGet(salesPostSigEmailServletPage.toString());
response = client.execute(get);
Assert.assertThat(response, statusCodeIsHC(Response.Status.OK));
Assert.assertThat(response, bodyHC(containsString("principal=bburke")));
assertThat(response, statusCodeIsHC(Response.Status.OK));
assertThat(response, bodyHC(containsString("principal=bburke")));
} catch (Exception ex) {
throw new RuntimeException(ex);
} finally {
@ -1558,8 +1558,8 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
public void testDifferentCookieName() {
assertSuccessfulLogin(differentCookieNameServletPage, bburkeUser, testRealmSAMLPostLoginPage, "principal=bburke");
Assert.assertThat(driver.manage().getCookieNamed("DIFFERENT_SESSION_ID"), notNullValue());
Assert.assertThat(driver.manage().getCookieNamed("JSESSIONID"), nullValue());
assertThat(driver.manage().getCookieNamed("DIFFERENT_SESSION_ID"), notNullValue());
assertThat(driver.manage().getCookieNamed("JSESSIONID"), nullValue());
salesPost2ServletPage.logout();
checkLoggedOut(differentCookieNameServletPage, testRealmSAMLPostLoginPage);
@ -1628,11 +1628,11 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
SOAPHeaderElement ecpRequestHeader = (SOAPHeaderElement)it.next();
NodeList idpList = ecpRequestHeader.getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:protocol", "IDPList");
Assert.assertThat("No IDPList returned from Service Provider", idpList.getLength(), is(1));
assertThat("No IDPList returned from Service Provider", idpList.getLength(), is(1));
NodeList idpEntries = idpList.item(0).getChildNodes();
Assert.assertThat("No IDPEntry returned from Service Provider", idpEntries.getLength(), is(1));
assertThat("No IDPEntry returned from Service Provider", idpEntries.getLength(), is(1));
String singleSignOnService = null;
@ -1644,7 +1644,7 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
singleSignOnService = location.getNodeValue();
}
Assert.assertThat("Could not obtain SSO Service URL", singleSignOnService, notNullValue());
assertThat("Could not obtain SSO Service URL", singleSignOnService, notNullValue());
Document authenticationRequest = authnRequestMessage.getSOAPBody().getFirstChild().getOwnerDocument();
String username = "pedroigor";
@ -1656,7 +1656,7 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
.header(HttpHeaders.AUTHORIZATION, authHeader)
.post(Entity.entity(DocumentUtil.asString(authenticationRequest), "text/xml"));
Assert.assertThat(authenticationResponse.getStatus(), is(OK.getStatusCode()));
assertThat(authenticationResponse.getStatus(), is(OK.getStatusCode()));
SOAPMessage responseMessage = MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(authenticationResponse.readEntity(byte[].class)));
@ -1666,19 +1666,19 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
NodeList ecpResponse = responseMessageHeaders.getElementsByTagNameNS(JBossSAMLURIConstants.ECP_PROFILE.get(), JBossSAMLConstants.RESPONSE__ECP.get());
Assert.assertThat("No ECP Response", ecpResponse.getLength(), is(1));
assertThat("No ECP Response", ecpResponse.getLength(), is(1));
Node samlResponse = responseMessage.getSOAPBody().getFirstChild();
Assert.assertThat(samlResponse, notNullValue());
assertThat(samlResponse, notNullValue());
ResponseType responseType = (ResponseType) SAMLParser.getInstance().parse(samlResponse);
StatusCodeType statusCode = responseType.getStatus().getStatusCode();
Assert.assertThat(statusCode.getValue().toString(), is(JBossSAMLURIConstants.STATUS_SUCCESS.get()));
Assert.assertThat(responseType.getDestination(), is(ecpSPPage.toString()));
Assert.assertThat(responseType.getSignature(), notNullValue());
Assert.assertThat(responseType.getAssertions().size(), is(1));
assertThat(statusCode.getValue().toString(), is(JBossSAMLURIConstants.STATUS_SUCCESS.get()));
assertThat(responseType.getDestination(), is(ecpSPPage.toString()));
assertThat(responseType.getSignature(), notNullValue());
assertThat(responseType.getAssertions().size(), is(1));
SOAPMessage samlResponseRequest = MessageFactory.newInstance().createMessage();
@ -1700,7 +1700,7 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
}
Response resourceResponse = resourceRequest.get();
Assert.assertThat(resourceResponse.readEntity(String.class), containsString("pedroigor"));
assertThat(resourceResponse.readEntity(String.class), containsString("pedroigor"));
}
@Test
@ -1719,11 +1719,11 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
jakarta.xml.soap.Node ecpRequestHeader = it.next();
NodeList idpList = ((SOAPHeaderElement)ecpRequestHeader).getElementsByTagNameNS("urn:oasis:names:tc:SAML:2.0:protocol", "IDPList");
Assert.assertThat("No IDPList returned from Service Provider", idpList.getLength(), is(1));
assertThat("No IDPList returned from Service Provider", idpList.getLength(), is(1));
NodeList idpEntries = idpList.item(0).getChildNodes();
Assert.assertThat("No IDPEntry returned from Service Provider", idpEntries.getLength(), is(1));
assertThat("No IDPEntry returned from Service Provider", idpEntries.getLength(), is(1));
String singleSignOnService = null;
@ -1735,7 +1735,7 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
singleSignOnService = location.getNodeValue();
}
Assert.assertThat("Could not obtain SSO Service URL", singleSignOnService, notNullValue());
assertThat("Could not obtain SSO Service URL", singleSignOnService, notNullValue());
Document authenticationRequest = authnRequestMessage.getSOAPBody().getFirstChild().getOwnerDocument();
String username = "pedroigor";
@ -1747,17 +1747,17 @@ public class SAMLServletAdapterTest extends AbstractSAMLServletAdapterTest {
.header(HttpHeaders.AUTHORIZATION, authHeader)
.post(Entity.entity(DocumentUtil.asString(authenticationRequest), "application/soap+xml"));
Assert.assertThat(authenticationResponse.getStatus(), is(OK.getStatusCode()));
assertThat(authenticationResponse.getStatus(), is(OK.getStatusCode()));
SOAPMessage responseMessage = MessageFactory.newInstance().createMessage(null, new ByteArrayInputStream(authenticationResponse.readEntity(byte[].class)));
Node samlResponse = responseMessage.getSOAPBody().getFirstChild();
Assert.assertThat(samlResponse, notNullValue());
assertThat(samlResponse, notNullValue());
StatusResponseType responseType = (StatusResponseType) SAMLParser.getInstance().parse(samlResponse);
StatusCodeType statusCode = responseType.getStatus().getStatusCode();
Assert.assertThat(statusCode.getStatusCode().getValue().toString(), is(not(JBossSAMLURIConstants.STATUS_SUCCESS.get())));
assertThat(statusCode.getStatusCode().getValue().toString(), is(not(JBossSAMLURIConstants.STATUS_SUCCESS.get())));
}
/**

View file

@ -30,7 +30,7 @@ import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.saml.AbstractSamlTest.REALM_NAME;
import static org.keycloak.testsuite.util.Matchers.bodyHC;

View file

@ -63,7 +63,7 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.saml.common.constants.JBossSAMLURIConstants.ASSERTION_NSURI;
import static org.keycloak.saml.common.constants.JBossSAMLURIConstants.PROTOCOL_NSURI;
import static org.keycloak.testsuite.adapter.AbstractServletsAdapterTest.samlServletDeployment;

View file

@ -20,7 +20,7 @@ package org.keycloak.testsuite.adapter.servlet;
import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.arquillian.AppServerTestEnricher.CURRENT_APP_SERVER;
import static org.keycloak.testsuite.arquillian.AppServerTestEnricher.enableHTTPSForAppServer;
import static org.keycloak.testsuite.util.ServerURLs.APP_SERVER_SSL_REQUIRED;

View file

@ -19,7 +19,7 @@ package org.keycloak.testsuite.adapter.servlet.cluster;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
import static org.keycloak.testsuite.util.WaitUtils.waitForPageToLoad;

View file

@ -14,7 +14,7 @@ import java.io.IOException;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
public class AdminHeadersTest extends AbstractAdminTest {

View file

@ -29,7 +29,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

View file

@ -70,7 +70,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import static org.hamcrest.Matchers.hasItem;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.admin.ImpersonationDisabledTest.IMPERSONATION_DISABLED;
import static org.keycloak.testsuite.auth.page.AuthRealm.TEST;
@ -1010,7 +1010,7 @@ public class FineGrainAdminUnitTest extends AbstractKeycloakTest {
List<UserRepresentation> result = client.realm("test").users().search(null, "test", null, null, -1, 20);
Assert.assertEquals(20, result.size());
Assert.assertThat(result, Matchers.everyItem(Matchers.hasProperty("username", Matchers.startsWith("b"))));
assertThat(result, Matchers.everyItem(Matchers.hasProperty("username", Matchers.startsWith("b"))));
result = client.realm("test").users().search(null, "test", null, null, 20, 40);
@ -1023,12 +1023,12 @@ public class FineGrainAdminUnitTest extends AbstractKeycloakTest {
List<UserRepresentation> result = client.realm("test").users().search(null, "test", null, null, -1, 20);
Assert.assertEquals(20, result.size());
Assert.assertThat(result, Matchers.everyItem(Matchers.hasProperty("username", Matchers.startsWith("a"))));
assertThat(result, Matchers.everyItem(Matchers.hasProperty("username", Matchers.startsWith("a"))));
client.realm("test").users().search(null, null, null, null, -1, -1);
Assert.assertEquals(20, result.size());
Assert.assertThat(result, Matchers.everyItem(Matchers.hasProperty("username", Matchers.startsWith("a"))));
assertThat(result, Matchers.everyItem(Matchers.hasProperty("username", Matchers.startsWith("a"))));
}
try (Keycloak client = Keycloak.getInstance(getAuthServerContextRoot() + "/auth",
@ -1037,12 +1037,12 @@ public class FineGrainAdminUnitTest extends AbstractKeycloakTest {
List<UserRepresentation> result = client.realm("test").users().search(null, null, null, null, -1, 20);
Assert.assertEquals(20, result.size());
Assert.assertThat(result, Matchers.everyItem(Matchers.hasProperty("username", Matchers.startsWith("b"))));
assertThat(result, Matchers.everyItem(Matchers.hasProperty("username", Matchers.startsWith("b"))));
result = client.realm("test").users().search("test", -1, 20, false);
Assert.assertEquals(20, result.size());
Assert.assertThat(result, Matchers.everyItem(Matchers.hasProperty("username", Matchers.startsWith("b"))));
assertThat(result, Matchers.everyItem(Matchers.hasProperty("username", Matchers.startsWith("b"))));
result = client.realm("test").users().search("a", -1, 20, false);
@ -1142,10 +1142,10 @@ public class FineGrainAdminUnitTest extends AbstractKeycloakTest {
List<ClientRepresentation> result = client.realm("test").clients().findAll(null, true, false, 0, 1);
Assert.assertEquals(1, result.size());
Assert.assertThat(result, Matchers.hasItem(Matchers.hasProperty("clientId", Matchers.is("client-search-09"))));
assertThat(result, Matchers.hasItem(Matchers.hasProperty("clientId", Matchers.is("client-search-09"))));
result = client.realm("test").clients().findAll(null, true, false, 1, 1);
Assert.assertThat(result, Matchers.hasItem(Matchers.hasProperty("clientId", Matchers.is("client-search-10"))));
assertThat(result, Matchers.hasItem(Matchers.hasProperty("clientId", Matchers.is("client-search-10"))));
Assert.assertEquals(1, result.size());
@ -1196,7 +1196,7 @@ public class FineGrainAdminUnitTest extends AbstractKeycloakTest {
List<ClientRepresentation> result = client.realm("test").clients().findAll("client-search-", true, true, 0, 10);
clients.addAll(result);
Assert.assertEquals(10, result.size());
Assert.assertThat(result.stream().map(rep -> rep.getClientId()).collect(Collectors.toList()), Matchers.is(Arrays.asList("client-search-09",
assertThat(result.stream().map(rep -> rep.getClientId()).collect(Collectors.toList()), Matchers.is(Arrays.asList("client-search-09",
"client-search-10",
"client-search-11",
"client-search-12",
@ -1210,7 +1210,7 @@ public class FineGrainAdminUnitTest extends AbstractKeycloakTest {
result = client.realm("test").clients().findAll("client-search-", true, true, 10, 10);
clients.addAll(result);
Assert.assertEquals(10, result.size());
Assert.assertThat(result.stream().map(rep -> rep.getClientId()).collect(Collectors.toList()), Matchers.is(Arrays.asList("client-search-19",
assertThat(result.stream().map(rep -> rep.getClientId()).collect(Collectors.toList()), Matchers.is(Arrays.asList("client-search-19",
"client-search-20",
"client-search-21",
"client-search-22",
@ -1224,7 +1224,7 @@ public class FineGrainAdminUnitTest extends AbstractKeycloakTest {
result = client.realm("test").clients().findAll("client-search-", true, true, 20, 10);
clients.addAll(result);
Assert.assertEquals(1, result.size());
Assert.assertThat(result, Matchers.hasItems(
assertThat(result, Matchers.hasItems(
Matchers.hasProperty("clientId", Matchers.isOneOf("client-search-29"))));
}
}
@ -1279,7 +1279,7 @@ public class FineGrainAdminUnitTest extends AbstractKeycloakTest {
List<ClientRepresentation> result = client.realm("test").clients().findAll("client-search-", true, true, 0, 10);
clients.addAll(result);
Assert.assertEquals(10, result.size());
Assert.assertThat(result.stream().map(rep -> rep.getClientId()).collect(Collectors.toList()), Matchers.is(Arrays.asList(
assertThat(result.stream().map(rep -> rep.getClientId()).collect(Collectors.toList()), Matchers.is(Arrays.asList(
"client-search-15",
"client-search-16",
"client-search-17",
@ -1294,7 +1294,7 @@ public class FineGrainAdminUnitTest extends AbstractKeycloakTest {
result = client.realm("test").clients().findAll("client-search-", true, true, 10, 10);
clients.addAll(result);
Assert.assertEquals(5, result.size());
Assert.assertThat(result.stream().map(rep -> rep.getClientId()).collect(Collectors.toList()), Matchers.is(Arrays.asList(
assertThat(result.stream().map(rep -> rep.getClientId()).collect(Collectors.toList()), Matchers.is(Arrays.asList(
"client-search-25",
"client-search-26",
"client-search-27",

View file

@ -98,7 +98,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.keycloak.saml.common.constants.JBossSAMLURIConstants.XMLDSIG_NSURI;
@ -1108,32 +1108,32 @@ public class IdentityProviderTest extends AbstractAdminTest {
Document document = DocumentUtil.getDocument(body);
Element signatureElement = DocumentUtil.getDirectChildElement(document.getDocumentElement(), XMLDSIG_NSURI.get(), "Signature");
Assert.assertThat("Signature not null", signatureElement, notNullValue());
assertThat("Signature not null", signatureElement, notNullValue());
Element keyInfoElement = DocumentUtil.getDirectChildElement(signatureElement, XMLDSIG_NSURI.get(), "KeyInfo");
Assert.assertThat("KeyInfo not null", keyInfoElement, notNullValue());
assertThat("KeyInfo not null", keyInfoElement, notNullValue());
Element x509DataElement = DocumentUtil.getDirectChildElement(keyInfoElement, XMLDSIG_NSURI.get(), "X509Data");
Assert.assertThat("X509Data not null", x509DataElement, notNullValue());
assertThat("X509Data not null", x509DataElement, notNullValue());
Element x509CertificateElement = DocumentUtil.getDirectChildElement(x509DataElement, XMLDSIG_NSURI.get(), "X509Certificate");
Assert.assertThat("X509Certificate not null", x509CertificateElement, notNullValue());
assertThat("X509Certificate not null", x509CertificateElement, notNullValue());
Element keyNameElement = DocumentUtil.getDirectChildElement(keyInfoElement, XMLDSIG_NSURI.get(), "KeyName");
Assert.assertThat("KeyName not null", keyNameElement, notNullValue());
assertThat("KeyName not null", keyNameElement, notNullValue());
String activeSigCert = KeyUtils.findActiveSigningKey(realm, Constants.DEFAULT_SIGNATURE_ALGORITHM).getCertificate();
Assert.assertThat("activeSigCert not null", activeSigCert, notNullValue());
assertThat("activeSigCert not null", activeSigCert, notNullValue());
X509Certificate activeX509SigCert = XMLSignatureUtil.getX509CertificateFromKeyInfoString(activeSigCert);
Assert.assertThat("KeyName matches subject DN",
assertThat("KeyName matches subject DN",
keyNameElement.getTextContent().trim(), equalTo(activeX509SigCert.getSubjectDN().getName()));
Assert.assertThat("Signing cert matches active realm cert",
assertThat("Signing cert matches active realm cert",
x509CertificateElement.getTextContent().trim(), equalTo(Base64.getEncoder().encodeToString(activeX509SigCert.getEncoded())));
PublicKey activePublicSigKey = activeX509SigCert.getPublicKey();
Assert.assertThat("Metadata signature is valid",
assertThat("Metadata signature is valid",
new SAML2Signature().validate(document, new HardcodedKeyLocator(activePublicSigKey)), is(true));
}
}

View file

@ -42,6 +42,7 @@ import java.util.List;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.auth.page.AuthRealm.TEST;
/**
@ -166,7 +167,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -176,7 +177,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -186,7 +187,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -196,7 +197,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -206,7 +207,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -216,7 +217,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -226,7 +227,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -236,7 +237,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -246,7 +247,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -256,7 +257,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -266,7 +267,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -276,7 +277,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -317,7 +318,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -327,7 +328,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -337,7 +338,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -347,7 +348,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -357,7 +358,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -367,7 +368,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -377,7 +378,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -387,7 +388,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -397,7 +398,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -407,7 +408,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -417,7 +418,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -427,7 +428,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm(TEST).users().get(realmUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
@ -468,7 +469,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -477,7 +478,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -486,7 +487,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -495,7 +496,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -504,7 +505,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -513,7 +514,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -522,7 +523,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -531,7 +532,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -540,7 +541,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -549,7 +550,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -558,7 +559,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -567,7 +568,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -576,7 +577,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -585,7 +586,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -594,7 +595,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
roles.clear();
@ -603,7 +604,7 @@ public class IllegalAdminUpgradeTest extends AbstractKeycloakTest {
realmClient.realm("master").users().get(masterUser.getId()).roles().clientLevel(client.getId()).add(roles);
Assert.fail("should fail with forbidden exception");
} catch (ClientErrorException e) {
Assert.assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
assertThat(Response.Status.fromStatusCode(e.getResponse().getStatus()),
is(equalTo(Response.Status.FORBIDDEN)));
}
}

View file

@ -38,7 +38,7 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>

View file

@ -80,6 +80,7 @@ import java.util.concurrent.atomic.AtomicReference;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import static org.keycloak.services.resources.admin.AdminAuth.Resource.AUTHORIZATION;
import static org.keycloak.services.resources.admin.AdminAuth.Resource.CLIENT;
@ -509,10 +510,10 @@ public class PermissionsTest extends AbstractKeycloakTest {
}
}, Resource.CLIENT, false, true);
List<ClientRepresentation> l = clients.get(AdminRoles.QUERY_CLIENTS).realm(REALM_NAME).clients().findAll();
Assert.assertThat(l, Matchers.empty());
assertThat(l, Matchers.empty());
l = clients.get(AdminRoles.VIEW_CLIENTS).realm(REALM_NAME).clients().findAll();
Assert.assertThat(l, Matchers.not(Matchers.empty()));
assertThat(l, Matchers.not(Matchers.empty()));
ClientRepresentation client = l.get(0);
invoke(new InvocationWithResponse() {

View file

@ -34,6 +34,8 @@ import org.keycloak.testsuite.util.LDAPRule;
import jakarta.ws.rs.BadRequestException;
import jakarta.ws.rs.core.Response;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
@ -145,7 +147,7 @@ public class UserFederationLdapConnectionTest extends AbstractAdminTest {
"false", null, "false", LDAPConstants.AUTH_TYPE_SIMPLE);
List<LDAPCapabilityRepresentation> ldapCapabilities = realm.ldapServerCapabilities(config);
Assert.assertThat(ldapCapabilities, Matchers.hasItem(new LDAPCapabilityRepresentation(PasswordModifyRequest.PASSWORD_MODIFY_OID, LDAPCapabilityRepresentation.CapabilityType.EXTENSION)));
assertThat(ldapCapabilities, Matchers.hasItem(new LDAPCapabilityRepresentation(PasswordModifyRequest.PASSWORD_MODIFY_OID, LDAPCapabilityRepresentation.CapabilityType.EXTENSION)));
// Query the rootDSE failure
try {

View file

@ -41,6 +41,7 @@ import java.util.List;
import java.util.Map;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
@ -96,7 +97,7 @@ public class ExecutionTest extends AbstractAuthenticationTest {
AuthenticatorConfigRepresentation updated = authMgmtResource.getAuthenticatorConfig(authConfigRep.getId());
Assert.assertThat(updated.getConfig().values(), hasItems("test-updated", "skip"));
assertThat(updated.getConfig().values(), hasItems("test-updated", "skip"));
}
@Test

View file

@ -56,6 +56,7 @@ import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import static org.keycloak.testsuite.util.Matchers.body;
import static org.keycloak.testsuite.util.Matchers.statusCodeIs;
@ -249,9 +250,9 @@ public class FlowTest extends AbstractAuthenticationTest {
// copy using existing alias as new name
Response response = authMgmtResource.copy("browser", params);
try {
Assert.assertThat("Copy flow using the new alias of existing flow should fail", response, statusCodeIs(Status.CONFLICT));
Assert.assertThat("Copy flow using the new alias of existing flow should fail", response, body(containsString("already exists")));
Assert.assertThat("Copy flow using the new alias of existing flow should fail", response, body(containsString("flow alias")));
assertThat("Copy flow using the new alias of existing flow should fail", response, statusCodeIs(Status.CONFLICT));
assertThat("Copy flow using the new alias of existing flow should fail", response, body(containsString("already exists")));
assertThat("Copy flow using the new alias of existing flow should fail", response, body(containsString("flow alias")));
} finally {
response.close();
}
@ -260,7 +261,7 @@ public class FlowTest extends AbstractAuthenticationTest {
params.clear();
response = authMgmtResource.copy("non-existent", params);
try {
Assert.assertThat("Copy non-existing flow", response, statusCodeIs(Status.NOT_FOUND));
assertThat("Copy non-existing flow", response, statusCodeIs(Status.NOT_FOUND));
} finally {
response.close();
}
@ -270,7 +271,7 @@ public class FlowTest extends AbstractAuthenticationTest {
response = authMgmtResource.copy("browser", params);
assertAdminEvents.assertEvent(testRealmId, OperationType.CREATE, AdminEventPaths.authCopyFlowPath("browser"), params, ResourceType.AUTH_FLOW);
try {
Assert.assertThat("Copy flow", response, statusCodeIs(Status.CREATED));
assertThat("Copy flow", response, statusCodeIs(Status.CREATED));
} finally {
response.close();
}

View file

@ -36,6 +36,7 @@ import java.util.List;
import java.util.Map;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
@ -239,7 +240,7 @@ public class ProvidersTest extends AbstractAuthenticationTest {
private void compareProviders(List<Map<String, Object>> expected, List<Map<String, Object>> actual) {
Assert.assertEquals("Providers count", expected.size(), actual.size());
// compare ignoring list and map impl types
Assert.assertThat(normalizeResults(actual), is(normalizeResults(expected)));
assertThat(normalizeResults(actual), is(normalizeResults(expected)));
}
private List<Map<String, Object>> normalizeResults(List<Map<String, Object>> list) {

View file

@ -45,7 +45,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import jakarta.ws.rs.NotFoundException;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.keycloak.common.Profile.Feature.AUTHORIZATION;
import static org.keycloak.testsuite.auth.page.AuthRealm.TEST;

View file

@ -78,6 +78,7 @@ import org.keycloak.util.JsonSerialization;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.util.ServerURLs.AUTH_SERVER_SSL_REQUIRED;
/**
* @author <a href="mailto:vramik@redhat.com">Vlastislav Ramik</a>
@ -166,7 +167,7 @@ public class ConcurrentLoginTest extends AbstractConcurrencyTest {
CookieStore cookieStore = new BasicCookieStore();
context.setCookieStore(cookieStore);
HttpUriRequest request = handleLogin(getPageContent(oauth.getLoginFormUrl(), httpClient, context), userName, password);
Assert.assertThat(parseAndCloseResponse(httpClient.execute(request, context)), containsString("<title>AUTH_RESPONSE</title>"));
assertThat(parseAndCloseResponse(httpClient.execute(request, context)), containsString("<title>AUTH_RESPONSE</title>"));
return context;
}
@ -267,8 +268,8 @@ public class ConcurrentLoginTest extends AbstractConcurrencyTest {
oauth1.idTokenHint(idTokenHint).openLogout();
// Code should be successfully exchanged for the token at max once. In some cases (EG. Cross-DC) it may not be even successfully exchanged
Assert.assertThat(codeToTokenSuccessCount.get(), Matchers.lessThanOrEqualTo(0));
Assert.assertThat(codeToTokenErrorsCount.get(), Matchers.greaterThanOrEqualTo(DEFAULT_THREADS));
assertThat(codeToTokenSuccessCount.get(), Matchers.lessThanOrEqualTo(0));
assertThat(codeToTokenErrorsCount.get(), Matchers.greaterThanOrEqualTo(DEFAULT_THREADS));
log.infof("Iteration %d passed successfully", i);
}
@ -408,9 +409,9 @@ public class ConcurrentLoginTest extends AbstractConcurrencyTest {
final HttpClientContext context = HttpClientContext.create();
context.setCookieStore(templateContext.getCookieStore());
String pageContent = getPageContent(oauth1.getLoginFormUrl(), httpClient, context);
Assert.assertThat(pageContent, Matchers.containsString("<title>AUTH_RESPONSE</title>"));
Assert.assertThat(context.getRedirectLocations(), Matchers.notNullValue());
Assert.assertThat(context.getRedirectLocations(), Matchers.not(Matchers.empty()));
assertThat(pageContent, Matchers.containsString("<title>AUTH_RESPONSE</title>"));
assertThat(context.getRedirectLocations(), Matchers.notNullValue());
assertThat(context.getRedirectLocations(), Matchers.not(Matchers.empty()));
String currentUrl = context.getRedirectLocations().get(0).toString();
Map<String, String> query = getQueryFromUrl(currentUrl);

View file

@ -26,6 +26,8 @@ import org.hamcrest.Matchers;
import org.keycloak.common.constants.ServiceAccountConstants;
import org.keycloak.representations.idm.UserRepresentation;
import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
@ -128,13 +130,13 @@ public class PartialExportTest extends AbstractAdminTest {
Assert.assertNull("Password should be null", serviceAccount.getCredentials());
if (rolesExpected) {
List<String> realmRoles = serviceAccount.getRealmRoles();
Assert.assertThat("Realm roles are OK", realmRoles, Matchers.containsInAnyOrder("uma_authorization", "user", "offline_access"));
assertThat("Realm roles are OK", realmRoles, Matchers.containsInAnyOrder("uma_authorization", "user", "offline_access"));
Map<String, List<String>> clientRoles = serviceAccount.getClientRoles();
Assert.assertNotNull("Client roles are exported", clientRoles);
Assert.assertThat("Client roles for test-app-service-account are OK", clientRoles.get("test-app-service-account"),
assertThat("Client roles for test-app-service-account are OK", clientRoles.get("test-app-service-account"),
Matchers.containsInAnyOrder("test-app-service-account", "test-app-service-account-parent"));
Assert.assertThat("Client roles for account are OK", clientRoles.get("account"),
assertThat("Client roles for account are OK", clientRoles.get("account"),
Matchers.containsInAnyOrder("manage-account", "view-profile"));
} else {
Assert.assertNull("Service account should be exported without realm roles", serviceAccount.getRealmRoles());
@ -254,7 +256,7 @@ public class PartialExportTest extends AbstractAdminTest {
Assert.assertTrue("Client role test-app-allowed-by-scope for test-app-scope", roles.containsKey("test-app-allowed-by-scope"));
roles = collectRoles(clientRoles.get("test-app-service-account"));
Assert.assertThat("Client roles are OK for test-app-service-account", roles.keySet(),
assertThat("Client roles are OK for test-app-service-account", roles.keySet(),
Matchers.containsInAnyOrder("test-app-service-account", "test-app-service-account-parent", "test-app-service-account-child"));
}

View file

@ -413,8 +413,8 @@ public class PartialImportTest extends AbstractAuthTest {
String id = result.getId();
UserResource userRsc = testRealmResource().users().get(id);
UserRepresentation user = userRsc.toRepresentation();
Assert.assertThat(user.getUsername(), startsWith(USER_PREFIX));
Assert.assertThat(userIds, hasItem(id));
assertThat(user.getUsername(), startsWith(USER_PREFIX));
assertThat(userIds, hasItem(id));
}
}

View file

@ -19,7 +19,7 @@ package org.keycloak.testsuite.authz;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

View file

@ -21,7 +21,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.keycloak.testsuite.AssertEvents.isUUID;

View file

@ -18,7 +18,7 @@ package org.keycloak.testsuite.authz;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

View file

@ -23,7 +23,7 @@ import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

View file

@ -22,7 +22,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.keycloak.testsuite.util.OAuthClient.AUTH_SERVER_ROOT;

View file

@ -18,7 +18,7 @@ package org.keycloak.testsuite.authz;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import java.util.Collection;

View file

@ -19,7 +19,7 @@ package org.keycloak.testsuite.authz.admin;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import java.util.Arrays;
import java.util.Collections;

View file

@ -47,7 +47,7 @@ import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.keycloak.testsuite.admin.ApiUtil.removeUserByUsername;
import static org.keycloak.testsuite.broker.BrokerRunOnServerUtil.configurePostBrokerLoginWithOTP;

View file

@ -42,7 +42,7 @@ import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.support.PageFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.keycloak.testsuite.broker.BrokerRunOnServerUtil.assertHardCodedSessionNote;
import static org.keycloak.testsuite.broker.BrokerRunOnServerUtil.configureAutoLinkFlow;

View file

@ -16,7 +16,7 @@ import java.util.stream.Collectors;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.admin.ApiUtil.createUserAndResetPasswordWithAdminClient;
/**

View file

@ -4,7 +4,7 @@ import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.broker.KcSamlBrokerConfiguration.ATTRIBUTE_TO_MAP_FRIENDLY_NAME;
import java.util.List;

View file

@ -1,7 +1,7 @@
package org.keycloak.testsuite.broker;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.broker.BrokerTestTools.waitForPage;
import static org.keycloak.testsuite.broker.KcOidcBrokerConfiguration.ATTRIBUTE_TO_MAP_NAME;

View file

@ -2,7 +2,7 @@ package org.keycloak.testsuite.broker;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.models.IdentityProviderMapperSyncMode.FORCE;
import static org.keycloak.models.IdentityProviderMapperSyncMode.IMPORT;

View file

@ -21,7 +21,7 @@ import java.util.HashMap;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.models.IdentityProviderMapperSyncMode.FORCE;
import static org.keycloak.models.IdentityProviderMapperSyncMode.IMPORT;
import static org.keycloak.models.IdentityProviderMapperSyncMode.LEGACY;

View file

@ -2,6 +2,7 @@ package org.keycloak.testsuite.broker;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.broker.BrokerTestConstants.IDP_OIDC_ALIAS;
import static org.keycloak.testsuite.broker.BrokerTestConstants.IDP_OIDC_PROVIDER_ID;
import static org.keycloak.testsuite.broker.BrokerTestTools.createIdentityProvider;
@ -53,16 +54,16 @@ public class KcOidcBrokerParameterForwardTest extends AbstractBrokerTest {
waitForPage(driver, "sign in to", true);
Assert.assertThat("Driver should be on the provider realm page right now",
assertThat("Driver should be on the provider realm page right now",
driver.getCurrentUrl(), containsString("/auth/realms/" + bc.providerRealmName() + "/"));
Assert.assertThat(FORWARDED_PARAMETER + "=" + FORWARDED_PARAMETER_VALUE + " should be part of the url",
assertThat(FORWARDED_PARAMETER + "=" + FORWARDED_PARAMETER_VALUE + " should be part of the url",
driver.getCurrentUrl(), containsString(FORWARDED_PARAMETER + "=" + FORWARDED_PARAMETER_VALUE));
Assert.assertThat("\"" + PARAMETER_NOT_SET + "\"" + " should NOT be part of the url",
assertThat("\"" + PARAMETER_NOT_SET + "\"" + " should NOT be part of the url",
driver.getCurrentUrl(), not(containsString(PARAMETER_NOT_SET)));
Assert.assertThat("\"" + PARAMETER_NOT_FORWARDED +"\"" + " should be NOT part of the url",
assertThat("\"" + PARAMETER_NOT_FORWARDED +"\"" + " should be NOT part of the url",
driver.getCurrentUrl(), not(containsString(PARAMETER_NOT_FORWARDED)));
loginPage.login(bc.getUserLogin(), bc.getUserPassword());
@ -70,7 +71,7 @@ public class KcOidcBrokerParameterForwardTest extends AbstractBrokerTest {
updateAccountInformationPage.assertCurrent();
Assert.assertThat("We must be on correct realm right now",
assertThat("We must be on correct realm right now",
driver.getCurrentUrl(), containsString("/auth/realms/" + bc.consumerRealmName() + "/"));
log.debug("Updating info on updateAccount page");

View file

@ -30,7 +30,7 @@ import org.keycloak.testsuite.AssertEvents;
import org.keycloak.testsuite.pages.AppPage;
import org.keycloak.testsuite.pages.LoginExpiredPage;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.broker.BrokerTestTools.waitForPage;
/**

View file

@ -12,6 +12,7 @@ import java.util.Map;
import static java.util.Locale.ENGLISH;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.OAuth2Constants.UI_LOCALES_PARAM;
import static org.keycloak.testsuite.broker.BrokerTestConstants.IDP_OIDC_ALIAS;
import static org.keycloak.testsuite.broker.BrokerTestConstants.IDP_OIDC_PROVIDER_ID;
@ -49,10 +50,10 @@ public class KcOidcBrokerUiLocalesDisabledTest extends AbstractBrokerTest {
waitForPage(driver, "sign in to", true);
Assert.assertThat("Driver should be on the provider realm page right now",
assertThat("Driver should be on the provider realm page right now",
driver.getCurrentUrl(), containsString("/auth/realms/" + bc.providerRealmName() + "/"));
Assert.assertThat(UI_LOCALES_PARAM + "=" + ENGLISH.toLanguageTag() + " should be part of the url",
assertThat(UI_LOCALES_PARAM + "=" + ENGLISH.toLanguageTag() + " should be part of the url",
driver.getCurrentUrl(), not(containsString(UI_LOCALES_PARAM + "=" + ENGLISH.toLanguageTag())));
loginPage.login(bc.getUserLogin(), bc.getUserPassword());
@ -60,7 +61,7 @@ public class KcOidcBrokerUiLocalesDisabledTest extends AbstractBrokerTest {
updateAccountInformationPage.assertCurrent();
Assert.assertThat("We must be on correct realm right now",
assertThat("We must be on correct realm right now",
driver.getCurrentUrl(), containsString("/auth/realms/" + bc.consumerRealmName() + "/"));
log.debug("Updating info on updateAccount page");

View file

@ -11,6 +11,7 @@ import java.util.Map;
import static java.util.Locale.ENGLISH;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.OAuth2Constants.UI_LOCALES_PARAM;
import static org.keycloak.testsuite.broker.BrokerTestConstants.IDP_OIDC_ALIAS;
import static org.keycloak.testsuite.broker.BrokerTestConstants.IDP_OIDC_PROVIDER_ID;
@ -48,10 +49,10 @@ public class KcOidcBrokerUiLocalesEnabledTest extends AbstractBrokerTest {
waitForPage(driver, "sign in to", true);
Assert.assertThat("Driver should be on the provider realm page right now",
assertThat("Driver should be on the provider realm page right now",
driver.getCurrentUrl(), containsString("/auth/realms/" + bc.providerRealmName() + "/"));
Assert.assertThat(UI_LOCALES_PARAM + "=" + ENGLISH.toLanguageTag() + " should be part of the url",
assertThat(UI_LOCALES_PARAM + "=" + ENGLISH.toLanguageTag() + " should be part of the url",
driver.getCurrentUrl(), containsString(UI_LOCALES_PARAM + "=" + ENGLISH.toLanguageTag()));
loginPage.login(bc.getUserLogin(), bc.getUserPassword());
@ -59,7 +60,7 @@ public class KcOidcBrokerUiLocalesEnabledTest extends AbstractBrokerTest {
updateAccountInformationPage.assertCurrent();
Assert.assertThat("We must be on correct realm right now",
assertThat("We must be on correct realm right now",
driver.getCurrentUrl(), containsString("/auth/realms/" + bc.consumerRealmName() + "/"));
log.debug("Updating info on updateAccount page");

View file

@ -11,6 +11,7 @@ import java.util.Locale;
import java.util.Map;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.OAuth2Constants.*;
import static org.keycloak.testsuite.broker.BrokerTestConstants.*;
import static org.keycloak.testsuite.broker.BrokerTestTools.*;
@ -45,21 +46,21 @@ public class KcOidcBrokerUiLocalesWithIdpHintTest extends AbstractBrokerTest {
waitForPage(driver, "belépés ide", true); // sign in to
Assert.assertThat("Driver should be on the provider realm page right now",
assertThat("Driver should be on the provider realm page right now",
driver.getCurrentUrl(), containsString("/auth/realms/" + bc.providerRealmName() + "/"));
Assert.assertThat(UI_LOCALES_PARAM + "=" + HUNGARIAN.toLanguageTag() + " should be part of the url",
assertThat(UI_LOCALES_PARAM + "=" + HUNGARIAN.toLanguageTag() + " should be part of the url",
driver.getCurrentUrl(), containsString(UI_LOCALES_PARAM + "=" + HUNGARIAN.toLanguageTag()));
Assert.assertThat("The provider realm should be in Hungarian because the ui_locales is passed",
assertThat("The provider realm should be in Hungarian because the ui_locales is passed",
driver.getPageSource(), containsString("Jelentkezzen be a fiókjába")); // Sign in to your account
loginPage.login(bc.getUserLogin(), bc.getUserPassword());
waitForPage(driver, "felhasználói fiók adatok módosítása", false); // update account information
Assert.assertThat("The consumer realm should be in Hungarian even after the redirect from the IDP.",
assertThat("The consumer realm should be in Hungarian even after the redirect from the IDP.",
driver.getPageSource(), containsString("Felhasználói fiók adatok módosítása"));// update account information
Assert.assertThat("We must be on correct realm right now",
assertThat("We must be on correct realm right now",
driver.getCurrentUrl(), containsString("/auth/realms/" + bc.consumerRealmName() + "/"));
log.debug("Updating info on updateAccount page");

View file

@ -20,7 +20,7 @@ import java.io.Closeable;
import jakarta.ws.rs.core.Response;
import org.hamcrest.Matchers;
import org.junit.Assert;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Test;
import org.keycloak.broker.saml.SAMLIdentityProviderConfig;
import org.keycloak.dom.saml.v2.protocol.AuthnRequestType;
@ -100,8 +100,8 @@ public class KcSamlBrokerAllowedClockSkewTest extends AbstractInitializedBaseBro
.getSamlResponse(SamlClient.Binding.POST); // Response from consumer IdP
Assert.assertThat(samlResponse, Matchers.notNullValue());
Assert.assertThat(samlResponse.getSamlObject(), isSamlResponse(JBossSAMLURIConstants.STATUS_SUCCESS));
assertThat(samlResponse, Matchers.notNullValue());
assertThat(samlResponse.getSamlObject(), isSamlResponse(JBossSAMLURIConstants.STATUS_SUCCESS));
}
}
}

View file

@ -15,7 +15,7 @@ import java.util.Set;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.broker.BrokerTestConstants.IDP_SAML_ALIAS;
import static org.keycloak.testsuite.broker.BrokerTestConstants.REALM_CONS_NAME;
import static org.keycloak.testsuite.broker.BrokerTestConstants.USER_EMAIL;

View file

@ -48,7 +48,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.saml.RoleMapperTest.ROLE_ATTRIBUTE_NAME;
import static org.keycloak.testsuite.util.Matchers.isSamlResponse;
import static org.keycloak.testsuite.util.Matchers.statusCodeIsHC;
@ -293,8 +293,8 @@ public final class KcSamlBrokerTest extends AbstractAdvancedBrokerTest {
.getSamlResponse(Binding.POST); // Response from consumer IdP
Assert.assertThat(samlResponse, Matchers.notNullValue());
Assert.assertThat(samlResponse.getSamlObject(), isSamlResponse(JBossSAMLURIConstants.STATUS_SUCCESS));
assertThat(samlResponse, Matchers.notNullValue());
assertThat(samlResponse.getSamlObject(), isSamlResponse(JBossSAMLURIConstants.STATUS_SUCCESS));
}
@Test
@ -343,8 +343,8 @@ public final class KcSamlBrokerTest extends AbstractAdvancedBrokerTest {
.getSamlResponse(Binding.POST); // Response from consumer IdP
Assert.assertThat(samlResponse, Matchers.notNullValue());
Assert.assertThat(samlResponse.getSamlObject(), isSamlResponse(JBossSAMLURIConstants.STATUS_SUCCESS));
assertThat(samlResponse, Matchers.notNullValue());
assertThat(samlResponse.getSamlObject(), isSamlResponse(JBossSAMLURIConstants.STATUS_SUCCESS));
Stream<AssertionType> assertionTypeStream = assertionsUnencrypted(samlResponse.getSamlObject());
Stream<AttributeType> attributeStatementTypeStream = attributesUnecrypted(attributeStatements(assertionTypeStream));
@ -389,8 +389,8 @@ public final class KcSamlBrokerTest extends AbstractAdvancedBrokerTest {
.getSamlResponse(Binding.POST); // Response from consumer IdP
Assert.assertThat(samlResponse, Matchers.notNullValue());
Assert.assertThat(samlResponse.getSamlObject(), isSamlResponse(JBossSAMLURIConstants.STATUS_SUCCESS));
assertThat(samlResponse, Matchers.notNullValue());
assertThat(samlResponse.getSamlObject(), isSamlResponse(JBossSAMLURIConstants.STATUS_SUCCESS));
}
}

View file

@ -63,7 +63,7 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.keycloak.testsuite.broker.BrokerTestConstants.REALM_CONS_NAME;
import static org.keycloak.testsuite.broker.BrokerTestConstants.REALM_PROV_NAME;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@ -148,7 +148,7 @@ public class KcSamlIdPInitiatedSsoTest extends AbstractKeycloakTest {
waitForPage("sign in to", true);
Assert.assertThat("Driver should be on the provider realm page right now",
assertThat("Driver should be on the provider realm page right now",
driver.getCurrentUrl(), containsString("/auth/realms/" + REALM_PROV_NAME + "/"));
log.debug("Logging in");
@ -157,7 +157,7 @@ public class KcSamlIdPInitiatedSsoTest extends AbstractKeycloakTest {
waitForPage("update account information", false);
Assert.assertTrue(updateAccountInformationPage.isCurrent());
Assert.assertThat("We must be on consumer realm right now",
assertThat("We must be on consumer realm right now",
driver.getCurrentUrl(), containsString("/auth/realms/" + REALM_CONS_NAME + "/"));
log.debug("Updating info on updateAccount page");
@ -173,7 +173,7 @@ public class KcSamlIdPInitiatedSsoTest extends AbstractKeycloakTest {
boolean isUserFound = users.stream().anyMatch(user -> user.getUsername().equals(CONSUMER_CHOSEN_USERNAME) && user.getEmail().equals("test@localhost"));
Assert.assertTrue("There must be user " + CONSUMER_CHOSEN_USERNAME + " in realm " + REALM_CONS_NAME, isUserFound);
Assert.assertThat(driver.findElement(By.tagName("a")).getAttribute("id"), containsString("account"));
assertThat(driver.findElement(By.tagName("a")).getAttribute("id"), containsString("account"));
}
private String getSamlIdpInitiatedUrl(String realmName, String samlIdpInitiatedSsoUrlName) {

View file

@ -17,7 +17,7 @@ import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.saml.common.constants.JBossSAMLURIConstants.AC_PASSWORD_PROTECTED_TRANSPORT;
import static org.keycloak.saml.common.constants.JBossSAMLURIConstants.ASSERTION_NSURI;
import static org.keycloak.saml.common.constants.JBossSAMLURIConstants.PROTOCOL_NSURI;
@ -55,7 +55,7 @@ public final class KcSamlRequestedAuthnContextBrokerTest extends AbstractBrokerT
// Find the RequestedAuthnContext element
Element requestedAuthnContextElement = DocumentUtil.getDirectChildElement(document.getDocumentElement(), PROTOCOL_NSURI.get(), "RequestedAuthnContext");
Assert.assertThat("RequestedAuthnContext element found in request document, but was not necessary as ClassRef/DeclRefs were not specified", requestedAuthnContextElement, Matchers.nullValue());
assertThat("RequestedAuthnContext element found in request document, but was not necessary as ClassRef/DeclRefs were not specified", requestedAuthnContextElement, Matchers.nullValue());
}
catch (Exception ex)
{
@ -90,7 +90,7 @@ public final class KcSamlRequestedAuthnContextBrokerTest extends AbstractBrokerT
// Find the RequestedAuthnContext element
Element requestedAuthnContextElement = DocumentUtil.getDirectChildElement(document.getDocumentElement(), PROTOCOL_NSURI.get(), "RequestedAuthnContext");
Assert.assertThat("RequestedAuthnContext element found in request document, but was not necessary as ClassRef/DeclRefs were not specified", requestedAuthnContextElement, Matchers.nullValue());
assertThat("RequestedAuthnContext element found in request document, but was not necessary as ClassRef/DeclRefs were not specified", requestedAuthnContextElement, Matchers.nullValue());
}
catch (Exception ex)
{
@ -126,17 +126,17 @@ public final class KcSamlRequestedAuthnContextBrokerTest extends AbstractBrokerT
// Find the RequestedAuthnContext element
Element requestedAuthnContextElement = DocumentUtil.getDirectChildElement(document.getDocumentElement(), PROTOCOL_NSURI.get(), "RequestedAuthnContext");
Assert.assertThat("RequestedAuthnContext element not found in request document", requestedAuthnContextElement, Matchers.notNullValue());
assertThat("RequestedAuthnContext element not found in request document", requestedAuthnContextElement, Matchers.notNullValue());
// Verify the ComparisonType attribute
Assert.assertThat("RequestedAuthnContext element not found in request document", requestedAuthnContextElement.getAttribute("Comparison"), Matchers.is(AuthnContextComparisonType.EXACT.value()));
assertThat("RequestedAuthnContext element not found in request document", requestedAuthnContextElement.getAttribute("Comparison"), Matchers.is(AuthnContextComparisonType.EXACT.value()));
// Find the RequestedAuthnContext/ClassRef element
Element requestedAuthnContextClassRefElement = DocumentUtil.getDirectChildElement(requestedAuthnContextElement, ASSERTION_NSURI.get(), "AuthnContextClassRef");
Assert.assertThat("RequestedAuthnContext/AuthnContextClassRef element not found in request document", requestedAuthnContextClassRefElement, Matchers.notNullValue());
assertThat("RequestedAuthnContext/AuthnContextClassRef element not found in request document", requestedAuthnContextClassRefElement, Matchers.notNullValue());
// Make sure the RequestedAuthnContext/ClassRef element has the requested value
Assert.assertThat("RequestedAuthnContext/AuthnContextClassRef element does not have the expected value", requestedAuthnContextClassRefElement.getTextContent(), Matchers.is(AC_PASSWORD_PROTECTED_TRANSPORT.get()));
assertThat("RequestedAuthnContext/AuthnContextClassRef element does not have the expected value", requestedAuthnContextClassRefElement.getTextContent(), Matchers.is(AC_PASSWORD_PROTECTED_TRANSPORT.get()));
}
catch (Exception ex)
{
@ -172,17 +172,17 @@ public final class KcSamlRequestedAuthnContextBrokerTest extends AbstractBrokerT
// Find the RequestedAuthnContext element
Element requestedAuthnContextElement = DocumentUtil.getDirectChildElement(document.getDocumentElement(), PROTOCOL_NSURI.get(), "RequestedAuthnContext");
Assert.assertThat("RequestedAuthnContext element not found in request document", requestedAuthnContextElement, Matchers.notNullValue());
assertThat("RequestedAuthnContext element not found in request document", requestedAuthnContextElement, Matchers.notNullValue());
// Verify the ComparisonType attribute
Assert.assertThat("RequestedAuthnContext element not found in request document", requestedAuthnContextElement.getAttribute("Comparison"), Matchers.is(AuthnContextComparisonType.MINIMUM.value()));
assertThat("RequestedAuthnContext element not found in request document", requestedAuthnContextElement.getAttribute("Comparison"), Matchers.is(AuthnContextComparisonType.MINIMUM.value()));
// Find the RequestedAuthnContext/DeclRef element
Element requestedAuthnContextDeclRefElement = DocumentUtil.getDirectChildElement(requestedAuthnContextElement, ASSERTION_NSURI.get(), "AuthnContextDeclRef");
Assert.assertThat("RequestedAuthnContext/AuthnContextDeclRef element not found in request document", requestedAuthnContextDeclRefElement, Matchers.notNullValue());
assertThat("RequestedAuthnContext/AuthnContextDeclRef element not found in request document", requestedAuthnContextDeclRefElement, Matchers.notNullValue());
// Make sure the RequestedAuthnContext/DeclRef element has the requested value
Assert.assertThat("RequestedAuthnContext/AuthnContextDeclRef element does not have the expected value", requestedAuthnContextDeclRefElement.getTextContent(), Matchers.is("secure/name/password/icmaolr/uri"));
assertThat("RequestedAuthnContext/AuthnContextDeclRef element does not have the expected value", requestedAuthnContextDeclRefElement.getTextContent(), Matchers.is("secure/name/password/icmaolr/uri"));
}
catch (Exception ex)
{
@ -217,17 +217,17 @@ public final class KcSamlRequestedAuthnContextBrokerTest extends AbstractBrokerT
// Find the RequestedAuthnContext element
Element requestedAuthnContextElement = DocumentUtil.getDirectChildElement(document.getDocumentElement(), PROTOCOL_NSURI.get(), "RequestedAuthnContext");
Assert.assertThat("RequestedAuthnContext element not found in request document", requestedAuthnContextElement, Matchers.notNullValue());
assertThat("RequestedAuthnContext element not found in request document", requestedAuthnContextElement, Matchers.notNullValue());
// Verify the ComparisonType attribute
Assert.assertThat("RequestedAuthnContext element not found in request document", requestedAuthnContextElement.getAttribute("Comparison"), Matchers.is(AuthnContextComparisonType.EXACT.value()));
assertThat("RequestedAuthnContext element not found in request document", requestedAuthnContextElement.getAttribute("Comparison"), Matchers.is(AuthnContextComparisonType.EXACT.value()));
// Find the RequestedAuthnContext/ClassRef element
Element requestedAuthnContextClassRefElement = DocumentUtil.getDirectChildElement(requestedAuthnContextElement, ASSERTION_NSURI.get(), "AuthnContextClassRef");
Assert.assertThat("RequestedAuthnContext/AuthnContextClassRef element not found in request document", requestedAuthnContextClassRefElement, Matchers.notNullValue());
assertThat("RequestedAuthnContext/AuthnContextClassRef element not found in request document", requestedAuthnContextClassRefElement, Matchers.notNullValue());
// Make sure the RequestedAuthnContext/ClassRef element has the requested value
Assert.assertThat("RequestedAuthnContext/AuthnContextClassRef element does not have the expected value", requestedAuthnContextClassRefElement.getTextContent(), Matchers.is(AC_PASSWORD_PROTECTED_TRANSPORT.get()));
assertThat("RequestedAuthnContext/AuthnContextClassRef element does not have the expected value", requestedAuthnContextClassRefElement.getTextContent(), Matchers.is(AC_PASSWORD_PROTECTED_TRANSPORT.get()));
}
catch (Exception ex)
{

View file

@ -53,7 +53,7 @@ import org.w3c.dom.NodeList;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.broker.BrokerTestTools.getConsumerRoot;
import static org.keycloak.testsuite.util.Matchers.bodyHC;
import static org.keycloak.testsuite.util.Matchers.isSamlResponse;
@ -68,13 +68,13 @@ public class KcSamlSignedBrokerTest extends AbstractBrokerTest {
KeysMetadataRepresentation providerKeysMetadata = adminClient.realm(bc.providerRealmName()).keys().getKeyMetadata();
String providerSigCert = KeyUtils.findActiveSigningKey(adminClient.realm(bc.providerRealmName()), Algorithm.RS256).getCertificate();
Assert.assertThat(providerSigCert, Matchers.notNullValue());
assertThat(providerSigCert, Matchers.notNullValue());
String consumerEncCert = KeyUtils.findActiveEncryptingKey(adminClient.realm(bc.consumerRealmName()), Algorithm.RSA_OAEP).getCertificate();
Assert.assertThat(consumerEncCert, Matchers.notNullValue());
assertThat(consumerEncCert, Matchers.notNullValue());
String consumerSigCert = KeyUtils.findActiveSigningKey(adminClient.realm(bc.consumerRealmName()), Algorithm.RS256).getCertificate();
Assert.assertThat(consumerSigCert, Matchers.notNullValue());
assertThat(consumerSigCert, Matchers.notNullValue());
try (Closeable idpUpdater = new IdentityProviderAttributeUpdater(identityProviderResource)
.setAttribute(SAMLIdentityProviderConfig.VALIDATE_SIGNATURE, Boolean.toString(signedAssertion || signedDocument))
@ -232,8 +232,8 @@ public class KcSamlSignedBrokerTest extends AbstractBrokerTest {
.getSamlResponse(Binding.POST); // Response from consumer IdP
Assert.assertThat(samlResponse, Matchers.notNullValue());
Assert.assertThat(samlResponse.getSamlObject(), isSamlResponse(JBossSAMLURIConstants.STATUS_SUCCESS));
assertThat(samlResponse, Matchers.notNullValue());
assertThat(samlResponse.getSamlObject(), isSamlResponse(JBossSAMLURIConstants.STATUS_SUCCESS));
}
@Test
@ -259,7 +259,7 @@ public class KcSamlSignedBrokerTest extends AbstractBrokerTest {
List<ClientRepresentation> clientRepresentationList = super.createProviderClients();
String consumerCert = KeyUtils.findActiveSigningKey(adminClient.realm(consumerRealmName()), Algorithm.RS256).getCertificate();
Assert.assertThat(consumerCert, Matchers.notNullValue());
assertThat(consumerCert, Matchers.notNullValue());
for (ClientRepresentation client : clientRepresentationList) {
client.setClientAuthenticatorType("client-secret");
@ -286,7 +286,7 @@ public class KcSamlSignedBrokerTest extends AbstractBrokerTest {
IdentityProviderRepresentation result = super.setUpIdentityProvider(syncMode);
String providerCert = KeyUtils.findActiveSigningKey(adminClient.realm(providerRealmName()), Algorithm.RS256).getCertificate();
Assert.assertThat(providerCert, Matchers.notNullValue());
assertThat(providerCert, Matchers.notNullValue());
Map<String, String> config = result.getConfig();
@ -440,10 +440,10 @@ public class KcSamlSignedBrokerTest extends AbstractBrokerTest {
// Verifies that an AuthnRequest contains the KeyInfo/X509Data element when
// client AuthnRequest signature is requested
String providerCert = KeyUtils.findActiveSigningKey(adminClient.realm(bc.providerRealmName()), Algorithm.RS256).getCertificate();
Assert.assertThat(providerCert, Matchers.notNullValue());
assertThat(providerCert, Matchers.notNullValue());
String consumerCert = KeyUtils.findActiveSigningKey(adminClient.realm(bc.consumerRealmName()), Algorithm.RS256).getCertificate();
Assert.assertThat(consumerCert, Matchers.notNullValue());
assertThat(consumerCert, Matchers.notNullValue());
try (Closeable idpUpdater = new IdentityProviderAttributeUpdater(identityProviderResource)
.setAttribute(SAMLIdentityProviderConfig.VALIDATE_SIGNATURE, Boolean.toString(true))
@ -474,15 +474,15 @@ public class KcSamlSignedBrokerTest extends AbstractBrokerTest {
{
// Find the Signature element
Element signatureElement = DocumentUtil.getDirectChildElement(document.getDocumentElement(), XMLSignature.XMLNS, "Signature");
Assert.assertThat("Signature element not found in request document", signatureElement, Matchers.notNullValue());
assertThat("Signature element not found in request document", signatureElement, Matchers.notNullValue());
// Find the KeyInfo element
Element keyInfoElement = DocumentUtil.getDirectChildElement(signatureElement, XMLSignature.XMLNS, "KeyInfo");
Assert.assertThat("KeyInfo element not found in request Signature element", keyInfoElement, Matchers.notNullValue());
assertThat("KeyInfo element not found in request Signature element", keyInfoElement, Matchers.notNullValue());
// Find the X509Data element
Element x509DataElement = DocumentUtil.getDirectChildElement(keyInfoElement, XMLSignature.XMLNS, "X509Data");
Assert.assertThat("X509Data element not found in request Signature/KeyInfo element", x509DataElement, Matchers.notNullValue());
assertThat("X509Data element not found in request Signature/KeyInfo element", x509DataElement, Matchers.notNullValue());
}
catch (Exception ex)
{

View file

@ -24,6 +24,7 @@ import org.w3c.dom.Document;
import java.util.Collections;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.broker.BrokerTestConstants.IDP_SAML_ALIAS;
import static org.keycloak.testsuite.broker.BrokerTestTools.getConsumerRoot;
@ -118,10 +119,10 @@ public class KcSamlXPathAttributeMapperTest extends AbstractInitializedBaseBroke
RealmResource realm = adminClient.realm(bc.consumerRealmName());
UserRepresentation user = realm.users().search(bc.getUserLogin()).get(0);
Assert.assertThat(user.getFirstName(), equalTo("Theo"));
Assert.assertThat(user.getLastName(), equalTo("Tester"));
Assert.assertThat(user.getEmail(), equalTo("test@example.org"));
Assert.assertThat(user.getAttributes().get("xml-output"), equalTo(Collections.singletonList("Some random text")));
assertThat(user.getFirstName(), equalTo("Theo"));
assertThat(user.getLastName(), equalTo("Tester"));
assertThat(user.getEmail(), equalTo("test@example.org"));
assertThat(user.getAttributes().get("xml-output"), equalTo(Collections.singletonList("Some random text")));
}
}

View file

@ -15,6 +15,7 @@ import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.admin.AbstractAdminTest.loadJson;
import static org.keycloak.testsuite.cli.KcAdmExec.execute;
@ -67,7 +68,7 @@ public class KcAdmSessionTest extends AbstractAdmCliTest {
assertExitCodeAndStdErrSize(exe, 0, 0);
List<ObjectNode> roles = loadJson(exe.stdout(), LIST_OF_JSON);
Assert.assertThat("expected three realm roles available", roles.size(), equalTo(3));
assertThat("expected three realm roles available", roles.size(), equalTo(3));
// create realm role
exe = execute("create roles --config '" + configFile.getName() + "' -s name=testrole -s 'description=Test role' -o");
@ -82,7 +83,7 @@ public class KcAdmSessionTest extends AbstractAdmCliTest {
assertExitCodeAndStdErrSize(exe, 0, 0);
roles = loadJson(exe.stdout(), LIST_OF_JSON);
Assert.assertThat("expected four realm roles available", roles.size(), equalTo(4));
assertThat("expected four realm roles available", roles.size(), equalTo(4));
// create client
exe = execute("create clients --config '" + configFile.getName() + "' -s clientId=testclient -i");
@ -102,7 +103,7 @@ public class KcAdmSessionTest extends AbstractAdmCliTest {
assertExitCodeAndStdErrSize(exe, 0, 0);
roles = loadJson(exe.stdout(), LIST_OF_JSON);
Assert.assertThat("expected one role", roles.size(), equalTo(1));
assertThat("expected one role", roles.size(), equalTo(1));
Assert.assertEquals("clientrole", roles.get(0).get("name").asText());
// add created role to user - we are realm admin so we can add role to ourself

View file

@ -20,6 +20,7 @@ import org.keycloak.broker.saml.SAMLIdentityProviderConfig;
import org.keycloak.broker.saml.SAMLIdentityProviderFactory;
import org.keycloak.representations.idm.IdentityProviderRepresentation;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.cli.KcAdmExec.CMD;
import static org.keycloak.testsuite.cli.KcAdmExec.execute;
import org.keycloak.testsuite.updaters.IdentityProviderCreator;
@ -61,7 +62,7 @@ public class KcAdmUpdateTest extends AbstractAdmCliTest {
assertExitCodeAndStdErrSize(exe, 0, 0);
}
Assert.assertThat(realmResource.identityProviders().get("idpAlias").toRepresentation().getDisplayName(), is(equalTo("SAML_UPDATED")));
assertThat(realmResource.identityProviders().get("idpAlias").toRepresentation().getDisplayName(), is(equalTo("SAML_UPDATED")));
}
}

View file

@ -31,6 +31,7 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.util.ServerURLs.AUTH_SERVER_SSL_REQUIRED;
import static org.keycloak.testsuite.cli.KcRegExec.execute;
@ -297,7 +298,7 @@ public class KcRegCreateTest extends AbstractRegCliTest {
Assert.assertNotNull("clientId", oidcClient.getClientId());
Assert.assertEquals("redirect_uris", Arrays.asList("http://localhost:8980/myapp5/*"), oidcClient.getRedirectUris());
Assert.assertThat("grant_types", oidcClient.getGrantTypes(), Matchers.containsInAnyOrder("authorization_code", "client_credentials", "refresh_token", OAuth2Constants.UMA_GRANT_TYPE));
assertThat("grant_types", oidcClient.getGrantTypes(), Matchers.containsInAnyOrder("authorization_code", "client_credentials", "refresh_token", OAuth2Constants.UMA_GRANT_TYPE));
Assert.assertEquals("response_types", Arrays.asList("code", "none"), oidcClient.getResponseTypes());
Assert.assertEquals("client_name", "My Reg Authz", oidcClient.getClientName());
Assert.assertEquals("client_uri", "http://localhost:8980/myapp5", oidcClient.getClientUri());

View file

@ -1397,7 +1397,7 @@ public class CIBATest extends AbstractClientPoliciesTest {
//clientResource = ApiUtil.findClientByClientId(adminClient.realm(TEST_REALM_NAME), TEST_CLIENT_NAME);
clientRep = clientResource.toRepresentation();
Assert.assertNull(clientRep.getAttributes().get(CibaConfig.OIDC_CIBA_GRANT_ENABLED));
Assert.assertThat(clientRep.getAttributes().get(CibaConfig.CIBA_BACKCHANNEL_AUTH_REQUEST_SIGNING_ALG), is(Algorithm.RS256));
assertThat(clientRep.getAttributes().get(CibaConfig.CIBA_BACKCHANNEL_AUTH_REQUEST_SIGNING_ALG), is(Algorithm.RS256));
// user Backchannel Authentication Request
AuthenticationRequestAcknowledgement response = oauth.doBackchannelAuthenticationRequest(TEST_CLIENT_NAME, TEST_CLIENT_PASSWORD, username, "gilwekDe3", "acr2");
@ -1416,8 +1416,8 @@ public class CIBATest extends AbstractClientPoliciesTest {
clientRep.setAttributes(attributes);
clientResource.update(clientRep);
clientRep = clientResource.toRepresentation();
Assert.assertThat(clientRep.getAttributes().get(CibaConfig.OIDC_CIBA_GRANT_ENABLED), is(Boolean.TRUE.toString()));
Assert.assertThat(clientRep.getAttributes().get(CibaConfig.CIBA_BACKCHANNEL_AUTH_REQUEST_SIGNING_ALG), is(Algorithm.ES256));
assertThat(clientRep.getAttributes().get(CibaConfig.OIDC_CIBA_GRANT_ENABLED), is(Boolean.TRUE.toString()));
assertThat(clientRep.getAttributes().get(CibaConfig.CIBA_BACKCHANNEL_AUTH_REQUEST_SIGNING_ALG), is(Algorithm.ES256));
// user Backchannel Authentication Request
response = doBackchannelAuthenticationRequest(TEST_CLIENT_NAME, TEST_CLIENT_PASSWORD, username, "Fkb4T3s");
@ -1439,8 +1439,8 @@ public class CIBATest extends AbstractClientPoliciesTest {
clientRep.setAttributes(attributes);
clientResource.update(clientRep);
clientRep = clientResource.toRepresentation();
Assert.assertThat(clientRep.getAttributes().get(CibaConfig.OIDC_CIBA_GRANT_ENABLED), is(Boolean.FALSE.toString()));
Assert.assertThat(clientRep.getAttributes().get(CibaConfig.CIBA_BACKCHANNEL_AUTH_REQUEST_SIGNING_ALG), is("none"));
assertThat(clientRep.getAttributes().get(CibaConfig.OIDC_CIBA_GRANT_ENABLED), is(Boolean.FALSE.toString()));
assertThat(clientRep.getAttributes().get(CibaConfig.CIBA_BACKCHANNEL_AUTH_REQUEST_SIGNING_ALG), is("none"));
// user Token Request
OAuthClient.AccessTokenResponse tokenRes = oauth.doBackchannelAuthenticationTokenRequest(SECOND_TEST_CLIENT_NAME, SECOND_TEST_CLIENT_SECRET, response.getAuthReqId());
@ -1467,7 +1467,7 @@ public class CIBATest extends AbstractClientPoliciesTest {
rep = getClientDynamically(clientId);
Assert.assertTrue(rep.getGrantTypes().contains(OAuth2Constants.CIBA_GRANT_TYPE));
Assert.assertThat(rep.getBackchannelAuthenticationRequestSigningAlg(), is(Algorithm.PS256));
assertThat(rep.getBackchannelAuthenticationRequestSigningAlg(), is(Algorithm.PS256));
}
@Test
@ -2458,9 +2458,9 @@ public class CIBATest extends AbstractClientPoliciesTest {
// user Backchannel Authentication Request
AuthenticationRequestAcknowledgement response = oauth.doBackchannelAuthenticationRequest(clientId, clientSecret, null, null, null);
Assert.assertThat(response.getStatusCode(), is(equalTo(statusCode)));
Assert.assertThat(response.getError(), is(error));
Assert.assertThat(response.getErrorDescription(), is(errorDescription));
assertThat(response.getStatusCode(), is(equalTo(statusCode)));
assertThat(response.getError(), is(error));
assertThat(response.getErrorDescription(), is(errorDescription));
} finally {
revertCIBASettings(clientResource, clientRep);
}
@ -2519,8 +2519,8 @@ public class CIBATest extends AbstractClientPoliciesTest {
// user Authentication Channel Request
TestAuthenticationChannelRequest testRequest = doAuthenticationChannelRequest(bindingMessage);
AuthenticationChannelRequest authenticationChannelReq = testRequest.getRequest();
Assert.assertThat(authenticationChannelReq.getBindingMessage(), is(equalTo(bindingMessage)));
Assert.assertThat(authenticationChannelReq.getScope(), is(containsString(OAuth2Constants.SCOPE_OPENID)));
assertThat(authenticationChannelReq.getBindingMessage(), is(equalTo(bindingMessage)));
assertThat(authenticationChannelReq.getScope(), is(containsString(OAuth2Constants.SCOPE_OPENID)));
// user Authentication Channel completed
EventRepresentation loginEvent = doAuthenticationChannelCallback(testRequest);

View file

@ -42,7 +42,7 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.util.Matchers.statusCodeIs;
/**

View file

@ -88,6 +88,7 @@ import java.util.function.Function;
import java.util.function.Supplier;
import static org.junit.Assert.assertEquals;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import static org.keycloak.testsuite.admin.AbstractAdminTest.loadJson;
import static org.keycloak.testsuite.util.ClientPoliciesUtil.ClientPoliciesBuilder;
@ -767,8 +768,8 @@ public class FAPI1Test extends AbstractClientPoliciesTest {
private void assertSuccessfulTokenResponse(OAuthClient.AccessTokenResponse tokenResponse) {
assertEquals(200, tokenResponse.getStatusCode());
Assert.assertThat(tokenResponse.getIdToken(), Matchers.notNullValue());
Assert.assertThat(tokenResponse.getAccessToken(), Matchers.notNullValue());
assertThat(tokenResponse.getIdToken(), Matchers.notNullValue());
assertThat(tokenResponse.getAccessToken(), Matchers.notNullValue());
// Scope parameter must be present per FAPI
Assert.assertNotNull(tokenResponse.getScope());

View file

@ -43,7 +43,7 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertTrue;
import static org.keycloak.testsuite.auth.page.AuthRealm.TEST;

View file

@ -39,6 +39,7 @@ import jakarta.ws.rs.core.UriBuilder;
import java.util.HashSet;
import java.util.Set;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.admin.AbstractAdminTest.loadJson;
/**
@ -94,7 +95,7 @@ public class AuthenticationSessionClusterTest extends AbstractClusterTest {
driver.navigate().to(testAppLoginNode1URL);
String authSessionCookie = AuthenticationSessionFailoverClusterTest.getAuthSessionCookieValue(driver);
Assert.assertThat(authSessionCookie.length(), Matchers.greaterThan(36));
assertThat(authSessionCookie.length(), Matchers.greaterThan(36));
String route = authSessionCookie.substring(37);
visitedRoutes.add(route);
@ -102,7 +103,7 @@ public class AuthenticationSessionClusterTest extends AbstractClusterTest {
driver.manage().deleteAllCookies();
}
Assert.assertThat(visitedRoutes, Matchers.containsInAnyOrder(Matchers.startsWith("node1"), Matchers.startsWith("node2")));
assertThat(visitedRoutes, Matchers.containsInAnyOrder(Matchers.startsWith("node1"), Matchers.startsWith("node2")));
}

View file

@ -54,7 +54,7 @@ import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.keycloak.services.managers.AuthenticationManager.KEYCLOAK_IDENTITY_COOKIE;
import static org.keycloak.services.managers.AuthenticationManager.KEYCLOAK_SESSION_COOKIE;

View file

@ -38,6 +38,7 @@ import java.util.LinkedList;
import java.util.stream.Collectors;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.util.ServerURLs.AUTH_SERVER_HOST;
import org.junit.After;
@ -96,7 +97,7 @@ public class CookiesPathTest extends AbstractKeycloakTest {
// check cookie's path, for some reason IE adds extra slash to the beginning of the path
cookies.stream()
.filter(cookie -> KEYCLOAK_COOKIE_NAMES.contains(cookie.getName()))
.forEach(cookie -> Assert.assertThat(cookie.getPath(), Matchers.endsWith("/auth/realms/foo/")));
.forEach(cookie -> assertThat(cookie.getPath(), Matchers.endsWith("/auth/realms/foo/")));
// now navigate to realm which name overlaps the first realm and delete cookies for that realm (foobar)
navigateToLoginPage("foobar");
@ -115,7 +116,7 @@ public class CookiesPathTest extends AbstractKeycloakTest {
// check cookie's path, for some reason IE adds extra slash to the beginning of the path
cookies.stream()
.filter(cookie -> KEYCLOAK_COOKIE_NAMES.contains(cookie.getName()))
.forEach(cookie -> Assert.assertThat(cookie.getPath(), Matchers.endsWith("/auth/realms/foobar/")));
.forEach(cookie -> assertThat(cookie.getPath(), Matchers.endsWith("/auth/realms/foobar/")));
// lets back to "/realms/foo/account" to test the cookies for "foo" realm are still there and haven't been (correctly) sent to "foobar"
oauth.realm("foo");
@ -125,7 +126,7 @@ public class CookiesPathTest extends AbstractKeycloakTest {
Assert.assertTrue("There should be cookies sent!", cookies.size() > 0);
cookies.stream()
.filter(cookie -> KEYCLOAK_COOKIE_NAMES.contains(cookie.getName()))
.forEach(cookie -> Assert.assertThat(cookie.getPath(), Matchers.endsWith("/auth/realms/foo/")));
.forEach(cookie -> assertThat(cookie.getPath(), Matchers.endsWith("/auth/realms/foo/")));
}
@Test
@ -144,23 +145,23 @@ public class CookiesPathTest extends AbstractKeycloakTest {
CookieStore cookieStore = getCorrectCookies(oauth.getLoginFormUrl());
cookieStore.addCookie(wrongCookie);
Assert.assertThat(cookieStore.getCookies(), Matchers.hasSize(3));
assertThat(cookieStore.getCookies(), Matchers.hasSize(3));
login(oauth.getLoginFormUrl(), cookieStore);
// old cookie has been removed
// now we have AUTH_SESSION_ID, KEYCLOAK_IDENTITY, KEYCLOAK_SESSION
Assert.assertThat(cookieStore.getCookies().stream().map(org.apache.http.cookie.Cookie::getName).collect(Collectors.toList()),
assertThat(cookieStore.getCookies().stream().map(org.apache.http.cookie.Cookie::getName).collect(Collectors.toList()),
Matchers.hasItems("AUTH_SESSION_ID", "KEYCLOAK_IDENTITY", "KEYCLOAK_SESSION"));
// does each cookie's path end with "/"
cookieStore.getCookies().stream().filter(c -> !"OAuth_Token_Request_State".equals(c.getName())).map(org.apache.http.cookie.Cookie::getPath).forEach(path ->Assert.assertThat(path, Matchers.endsWith("/")));
cookieStore.getCookies().stream().filter(c -> !"OAuth_Token_Request_State".equals(c.getName())).map(org.apache.http.cookie.Cookie::getPath).forEach(path -> assertThat(path, Matchers.endsWith("/")));
// KEYCLOAK_SESSION should end by AUTH_SESSION_ID value
String authSessionId = cookieStore.getCookies().stream().filter(c -> "AUTH_SESSION_ID".equals(c.getName())).findFirst().get().getValue();
String KCSessionId = cookieStore.getCookies().stream().filter(c -> "KEYCLOAK_SESSION".equals(c.getName())).findFirst().get().getValue();
String KCSessionSuffix = KCSessionId.split("/")[2];
Assert.assertThat(authSessionId, Matchers.containsString(KCSessionSuffix));
assertThat(authSessionId, Matchers.containsString(KCSessionSuffix));
}
@Test
@ -176,7 +177,7 @@ public class CookiesPathTest extends AbstractKeycloakTest {
// add old cookie with wrong path
driver.manage().addCookie(wrongCookie);
Set<Cookie> cookies = driver.manage().getCookies();
Assert.assertThat(cookies, Matchers.hasSize(1));
assertThat(cookies, Matchers.hasSize(1));
driver.navigate().refresh();
loginPage.login("foo", "password");
@ -185,16 +186,16 @@ public class CookiesPathTest extends AbstractKeycloakTest {
cookies = driver.manage().getCookies().stream()
.filter(cookie -> KEYCLOAK_COOKIE_NAMES.contains(cookie.getName()))
.collect(Collectors.toSet());
Assert.assertThat(cookies, Matchers.hasSize(3));
assertThat(cookies, Matchers.hasSize(3));
// does each cookie's path end with "/"
cookies.stream().map(Cookie::getPath).forEach(path -> Assert.assertThat(path, Matchers.endsWith("/")));
cookies.stream().map(Cookie::getPath).forEach(path -> assertThat(path, Matchers.endsWith("/")));
// KEYCLOAK_SESSION should end by AUTH_SESSION_ID value
String authSessionId = cookies.stream().filter(c -> "AUTH_SESSION_ID".equals(c.getName())).findFirst().get().getValue();
String KCSessionId = cookies.stream().filter(c -> "KEYCLOAK_SESSION".equals(c.getName())).findFirst().get().getValue();
String KCSessionSuffix = KCSessionId.split("/")[2];
Assert.assertThat(authSessionId, Matchers.containsString(KCSessionSuffix));
assertThat(authSessionId, Matchers.containsString(KCSessionSuffix));
}
@Test
@ -213,23 +214,23 @@ public class CookiesPathTest extends AbstractKeycloakTest {
CookieStore cookieStore = getCorrectCookies(oauth.getLoginFormUrl());
cookieStore.addCookie(wrongCookie);
Assert.assertThat(cookieStore.getCookies(), Matchers.hasSize(3));
assertThat(cookieStore.getCookies(), Matchers.hasSize(3));
login(oauth.getLoginFormUrl(), cookieStore);
// old cookie has been removed
// now we have AUTH_SESSION_ID, KEYCLOAK_IDENTITY, KEYCLOAK_SESSION, OAuth_Token_Request_State
Assert.assertThat(cookieStore.getCookies().stream().map(org.apache.http.cookie.Cookie::getName).collect(Collectors.toList()),
assertThat(cookieStore.getCookies().stream().map(org.apache.http.cookie.Cookie::getName).collect(Collectors.toList()),
Matchers.hasItems("AUTH_SESSION_ID", "KEYCLOAK_IDENTITY", "KEYCLOAK_SESSION"));
// does each cookie's path end with "/"
cookieStore.getCookies().stream().filter(c -> !"OAuth_Token_Request_State".equals(c.getName())).map(org.apache.http.cookie.Cookie::getPath).forEach(path ->Assert.assertThat(path, Matchers.endsWith("/")));
cookieStore.getCookies().stream().filter(c -> !"OAuth_Token_Request_State".equals(c.getName())).map(org.apache.http.cookie.Cookie::getPath).forEach(path -> assertThat(path, Matchers.endsWith("/")));
// KEYCLOAK_SESSION should end by AUTH_SESSION_ID value
String authSessionId = cookieStore.getCookies().stream().filter(c -> "AUTH_SESSION_ID".equals(c.getName())).findFirst().get().getValue();
String KCSessionId = cookieStore.getCookies().stream().filter(c -> "KEYCLOAK_SESSION".equals(c.getName())).findFirst().get().getValue();
String KCSessionSuffix = KCSessionId.split("/")[2];
Assert.assertThat(authSessionId, Matchers.containsString(KCSessionSuffix));
assertThat(authSessionId, Matchers.containsString(KCSessionSuffix));
}
/**
@ -318,7 +319,7 @@ public class CookiesPathTest extends AbstractKeycloakTest {
post.setEntity(new UrlEncodedFormEntity(params));
try (CloseableHttpResponse response = sendRequest(post, cookieStore, httpContext)) {
Assert.assertThat("Expected successful login.", response.getStatusLine().getStatusCode(), is(equalTo(200)));
assertThat("Expected successful login.", response.getStatusLine().getStatusCode(), is(equalTo(200)));
}
}

Some files were not shown because too many files have changed in this diff Show more