Avoid deprecated API usage in testsuite/integration-arquillian/tests/base (#24904)

- Removed unused imports
- Avoided deprecated junit/hamcrest API
- Avoid usage of JDK API scheduled for removal

This should reduce the number of compiler warnings in the logs quite a bit

closes #24995 

Signed-off-by: Thomas Darimont <thomas.darimont@googlemail.com>
This commit is contained in:
Thomas Darimont 2023-11-24 09:37:34 +01:00 committed by GitHub
parent 68b33be655
commit 8888e3d41c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
179 changed files with 180 additions and 425 deletions

View file

@ -17,7 +17,6 @@
package org.keycloak.testsuite.adapter.page;
import java.net.MalformedURLException;
import java.net.URL;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;

View file

@ -21,7 +21,6 @@ import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.keycloak.testsuite.page.AbstractPageWithInjectedUrl;
import jakarta.ws.rs.core.UriBuilder;
import java.net.URI;
import java.net.URL;

View file

@ -21,7 +21,6 @@ import org.keycloak.admin.client.resource.AuthorizationResource;
import org.keycloak.admin.client.resource.ClientResource;
import org.keycloak.admin.client.resource.ClientScopeResource;
import org.keycloak.admin.client.resource.GroupResource;
import org.keycloak.admin.client.resource.GroupsResource;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.RoleResource;
import org.keycloak.admin.client.resource.UserResource;
@ -42,7 +41,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD;
/**

View file

@ -16,7 +16,6 @@
*/
package org.keycloak.testsuite.arquillian.annotation;
import org.keycloak.common.Profile;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

View file

@ -25,7 +25,6 @@ import java.nio.file.Files;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.management.remote.JMXServiceURL;

View file

@ -123,7 +123,7 @@ final class SecurityActions {
final T obj;
try {
Constructor<T> constructor = getConstructor(implClass, argumentTypes);
if (!constructor.isAccessible()) {
if (!constructor.canAccess(null)) {
constructor.setAccessible(true);
}
obj = constructor.newInstance(arguments);
@ -183,7 +183,7 @@ final class SecurityActions {
@Override
public Void run() throws Exception {
Field field = source.getDeclaredField(fieldName);
if (!field.isAccessible()) {
if (!field.canAccess(target)) {
field.setAccessible(true);
}
field.set(target, value);

View file

@ -19,7 +19,6 @@ package org.keycloak.testsuite.arquillian.jmx;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Level;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;

View file

@ -24,7 +24,6 @@ import org.jboss.arquillian.core.api.Instance;
import org.jboss.arquillian.core.api.annotation.Inject;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.logging.Logger;
import org.jboss.logging.Logger.Level;
import org.keycloak.testsuite.arquillian.SuiteContext;
import org.keycloak.testsuite.arquillian.TestContext;
import org.keycloak.testsuite.arquillian.annotation.AppServerBrowserContext;
@ -36,12 +35,10 @@ import java.lang.annotation.Annotation;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.keycloak.testsuite.arquillian.ContainerInfo;
import org.keycloak.testsuite.util.ServerURLs;
import org.keycloak.testsuite.util.URLUtils;
import static org.keycloak.testsuite.util.ServerURLs.APP_SERVER_HOST;
import static org.keycloak.testsuite.util.ServerURLs.APP_SERVER_PORT;

View file

@ -1,7 +1,6 @@
package org.keycloak.testsuite.auth.page.login;
import org.keycloak.authentication.requiredactions.DeleteAccount;
import org.keycloak.testsuite.auth.page.AuthRealm;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

View file

@ -21,7 +21,6 @@ import org.keycloak.testsuite.util.URLUtils;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;
import static org.keycloak.testsuite.util.UIUtils.getTextFromElement;

View file

@ -3,20 +3,7 @@ package org.keycloak.testsuite.cli;
import org.keycloak.testsuite.cli.exec.AbstractExec;
import org.keycloak.testsuite.cli.exec.AbstractExecBuilder;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.InterruptedIOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>

View file

@ -17,8 +17,6 @@
package org.keycloak.testsuite.client;
import jakarta.ws.rs.core.Response;
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
@ -33,11 +31,8 @@ import org.keycloak.testsuite.runonserver.*;
import org.keycloak.testsuite.util.AdminClientUtil;
import org.keycloak.util.JsonSerialization;
import java.util.List;
import java.util.Set;
import static org.junit.Assert.assertEquals;
/**
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
*/

View file

@ -26,7 +26,6 @@ import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
/**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>

View file

@ -24,7 +24,6 @@ import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.keycloak.exportimport.Strategy;
/**

View file

@ -18,7 +18,6 @@
package org.keycloak.testsuite.page;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.logging.Logger;
import org.keycloak.testsuite.util.DroneUtils;
import org.keycloak.testsuite.util.URLUtils;

View file

@ -20,7 +20,6 @@ package org.keycloak.testsuite.page;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.junit.Assert;
import org.keycloak.testsuite.pages.PageUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

View file

@ -17,13 +17,9 @@
package org.keycloak.testsuite.pages;
import org.keycloak.OAuth2Constants;
import org.keycloak.protocol.oidc.OIDCLoginProtocolService;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import jakarta.ws.rs.core.UriBuilder;
import static org.keycloak.testsuite.util.UIUtils.clickLink;
import static org.keycloak.testsuite.util.ServerURLs.removeDefaultPorts;

View file

@ -16,7 +16,6 @@
*/
package org.keycloak.testsuite.pages;
import org.apache.commons.lang.StringEscapeUtils;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.keycloak.testsuite.util.OAuthClient;
import org.keycloak.testsuite.util.UIUtils;

View file

@ -22,7 +22,6 @@ import java.util.stream.Collectors;
import org.junit.Assert;
import org.keycloak.common.util.Retry;
import org.keycloak.testsuite.util.UIUtils;
import org.keycloak.testsuite.util.WaitUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;

View file

@ -20,7 +20,6 @@ import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

View file

@ -19,7 +19,6 @@
package org.keycloak.testsuite.pages.x509;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.keycloak.testsuite.pages.AbstractPage;
import org.keycloak.testsuite.pages.LanguageComboboxAwarePage;
import org.keycloak.testsuite.util.OAuthClient;
import org.openqa.selenium.WebElement;

View file

@ -45,7 +45,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
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;

View file

@ -150,7 +150,7 @@ public class AdminClientUtil {
throw new RuntimeException("Truststore file not found: " + file.getAbsolutePath());
}
SSLContext theContext = SSLContexts.custom()
.useProtocol("TLS")
.setProtocol("TLS")
.loadTrustMaterial(file, password == null ? null : password.toCharArray())
.build();
return theContext;

View file

@ -78,7 +78,7 @@ public final class DroneUtils {
if (f.getAnnotation(Page.class) != null
&& AbstractPage.class.isAssignableFrom(f.getType())) {
try {
if (!f.isAccessible())
if (!f.canAccess(target))
f.setAccessible(true);
Object o = f.get(target);
AbstractPage page = (AbstractPage) o;
@ -89,7 +89,7 @@ public final class DroneUtils {
}
} else if (f.getName().equals("driver") && WebDriver.class.isAssignableFrom(f.getType())) {
try {
if (!f.isAccessible())
if (!f.canAccess(target))
f.setAccessible(true);
f.set(target, driver);
@ -99,7 +99,7 @@ public final class DroneUtils {
}
} else if (f.getName().equals("oauth") && OAuthClient.class.isAssignableFrom(f.getType())) {
try {
if (!f.isAccessible())
if (!f.canAccess(target))
f.setAccessible(true);
Object o = f.get(target);
((OAuthClient) o).setDriver(driver);

View file

@ -21,7 +21,6 @@ import org.keycloak.dom.saml.v2.protocol.AuthnRequestType;
import org.keycloak.dom.saml.v2.protocol.LogoutRequestType;
import org.keycloak.dom.saml.v2.protocol.ResponseType;
import org.keycloak.dom.saml.v2.protocol.StatusResponseType;
import org.keycloak.testsuite.util.matchers.SamlResponseTypeMatcher;
import org.keycloak.saml.common.constants.JBossSAMLURIConstants;
import org.keycloak.testsuite.util.matchers.*;

View file

@ -1408,7 +1408,7 @@ public class OAuthClient {
public Map<String, String> getCurrentQuery() {
Map<String, String> m = new HashMap<>();
List<NameValuePair> pairs = URLEncodedUtils.parse(getCurrentUri(), "UTF-8");
List<NameValuePair> pairs = URLEncodedUtils.parse(getCurrentUri(), StandardCharsets.UTF_8);
for (NameValuePair p : pairs) {
m.put(p.getName(), p.getValue());
}

View file

@ -81,6 +81,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.security.KeyManagementException;
import java.security.PrivateKey;
@ -661,7 +662,7 @@ public class SamlClient {
* @return
*/
public static String extractRelayStateFromRedirect(String responseUri) {
List<NameValuePair> params = URLEncodedUtils.parse(URI.create(responseUri), "UTF-8");
List<NameValuePair> params = URLEncodedUtils.parse(URI.create(responseUri), StandardCharsets.UTF_8);
return params.stream().filter(nameValuePair -> nameValuePair.getName().equals(RELAY_STATE))
.findFirst().map(NameValuePair::getValue).orElse(null);

View file

@ -18,7 +18,6 @@ package org.keycloak.testsuite.util;
import org.keycloak.dom.saml.v2.SAML2Object;
import org.keycloak.saml.processing.core.saml.v2.common.SAMLDocumentHolder;
import org.keycloak.testsuite.client.KeycloakTestingClient;
import org.keycloak.testsuite.page.AbstractPage;
import org.keycloak.testsuite.util.SamlClient.Binding;
import org.keycloak.testsuite.util.SamlClient.DoNotFollowRedirectStep;
@ -43,7 +42,6 @@ import java.util.function.Function;
import jakarta.ws.rs.core.Response.Status;
import org.apache.http.client.methods.HttpUriRequest;
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;

View file

@ -1,6 +1,5 @@
package org.keycloak.testsuite.util;
import org.jboss.logging.Logger;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.logging.LogEntries;
import org.openqa.selenium.logging.LogEntry;

View file

@ -1,7 +1,6 @@
package org.keycloak.testsuite.util.javascript;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

View file

@ -1,6 +1,5 @@
package org.keycloak.testsuite.util.javascript;
import org.keycloak.models.KeycloakSession;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

View file

@ -2,7 +2,6 @@ package org.keycloak.testsuite.util.javascript;
import org.jboss.logging.Logger;
import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.services.managers.AuthenticationManager;
import org.keycloak.testsuite.auth.page.login.OIDCLogin;
import org.keycloak.testsuite.pages.LogoutConfirmPage;
import org.keycloak.testsuite.util.WaitUtils;

View file

@ -1,8 +1,5 @@
package org.keycloak.testsuite.util.javascript;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import java.io.Serializable;
import java.util.Map;

View file

@ -1,6 +1,5 @@
package org.keycloak.testsuite.util.saml;
import com.google.common.base.Charsets;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
@ -13,23 +12,16 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.jboss.logging.Logger;
import org.keycloak.protocol.saml.ArtifactResolver;
import org.keycloak.protocol.saml.ArtifactResolverProcessingException;
import org.keycloak.protocol.saml.DefaultSamlArtifactResolver;
import org.keycloak.protocol.saml.SamlProtocolUtils;
import org.keycloak.saml.common.constants.GeneralConstants;
import org.keycloak.saml.common.exceptions.ProcessingException;
import org.keycloak.testsuite.util.SamlClient;
import org.keycloak.testsuite.util.SamlClientBuilder;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Base64;
import java.util.LinkedList;
import java.util.List;

View file

@ -11,7 +11,6 @@ import org.apache.http.util.EntityUtils;
import org.keycloak.common.util.KeyUtils;
import org.keycloak.dom.saml.v2.assertion.NameIDType;
import org.keycloak.dom.saml.v2.protocol.ArtifactResolveType;
import org.keycloak.models.SingleUseObjectProvider;
import org.keycloak.protocol.saml.SamlProtocol;
import org.keycloak.protocol.saml.SamlService;
import org.keycloak.protocol.saml.profile.util.Soap;

View file

@ -28,6 +28,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@ -168,7 +169,7 @@ public class ModifySamlResponseStepBuilder extends SamlDocumentStepBuilder<SAML2
String location = currentResponse.getFirstHeader("Location").getValue();
URI locationUri = URI.create(location);
params = URLEncodedUtils.parse(locationUri, "UTF-8");
params = URLEncodedUtils.parse(locationUri, StandardCharsets.UTF_8);
for (Iterator<NameValuePair> it = params.iterator(); it.hasNext();) {
NameValuePair param = it.next();
if ("SAMLResponse".equals(param.getName()) || "SAMLRequest".equals(param.getName())) {

View file

@ -37,7 +37,6 @@ import org.keycloak.testsuite.util.SamlClient.Step;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.function.Consumer;
import java.util.logging.Level;
import javax.xml.stream.XMLStreamWriter;
import org.jboss.logging.Logger;
import org.junit.Assert;

View file

@ -68,7 +68,7 @@ import org.keycloak.testsuite.util.TestEventsLogger;
import org.openqa.selenium.WebDriver;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.core.UriBuilder;
import java.io.IOException;
import java.io.InputStream;
import java.io.PipedInputStream;

View file

@ -40,6 +40,8 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.hamcrest.Matchers.emptyOrNullString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.util.ServerURLs.getAuthServerContextRoot;
@ -94,7 +96,7 @@ public class AssertEvents implements TestRule {
}
public ExpectedEvent expectRequiredAction(EventType event) {
return expectLogin().event(event).removeDetail(Details.CONSENT).session(Matchers.isEmptyOrNullString());
return expectLogin().event(event).removeDetail(Details.CONSENT).session(is(emptyOrNullString()));
}
public ExpectedEvent expectLogin() {

View file

@ -42,8 +42,6 @@ import org.keycloak.testsuite.util.ClientBuilder;
import org.keycloak.testsuite.util.TokenUtil;
import org.keycloak.testsuite.util.UserBuilder;
import jakarta.ws.rs.core.UriBuilder;
/**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
*/

View file

@ -25,7 +25,6 @@ import org.keycloak.testsuite.util.UserBuilder;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
/**
*

View file

@ -17,7 +17,6 @@
package org.keycloak.testsuite.actions;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@ -26,7 +25,6 @@ import jakarta.mail.Address;
import jakarta.mail.Message;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.MimeMessage;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.jboss.arquillian.graphene.page.Page;
import org.junit.Assert;

View file

@ -62,7 +62,6 @@ import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.arquillian.annotation.DisableFeature;
import org.keycloak.testsuite.auth.page.AuthRealm;
import org.keycloak.testsuite.pages.LogoutConfirmPage;
import org.keycloak.testsuite.util.SecondBrowser;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.auth.page.login.OIDCLogin;
import org.keycloak.testsuite.util.DroneUtils;

View file

@ -16,12 +16,10 @@
*/
package org.keycloak.testsuite.adapter.example.hal;
import static org.junit.Assert.assertTrue;
import static org.keycloak.testsuite.utils.io.IOUtil.loadRealm;
import static org.keycloak.testsuite.util.ServerURLs.getAuthServerContextRoot;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import java.util.concurrent.TimeoutException;

View file

@ -23,8 +23,6 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.keycloak.testsuite.admin.ApiUtil.getCreatedId;
import static org.keycloak.testsuite.auth.page.AuthRealm.SAMLSERVLETDEMO;

View file

@ -21,7 +21,6 @@ import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest;
import org.keycloak.testsuite.adapter.page.CustomerPortal;
import org.keycloak.testsuite.adapter.spi.TestSessionIdMapper;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.auth.page.login.OIDCLogin;
import org.keycloak.testsuite.util.JavascriptBrowser;
import org.keycloak.testsuite.utils.annotation.UseServletFilter;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;

View file

@ -101,6 +101,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@ -861,7 +862,7 @@ public class DemoServletsAdapterTest extends AbstractServletsAdapterTest {
private static Map<String, String> getQueryFromUrl(String url) {
try {
return URLEncodedUtils.parse(new URI(url), "UTF-8").stream()
return URLEncodedUtils.parse(new URI(url), StandardCharsets.UTF_8).stream()
.collect(Collectors.toMap(p -> p.getName(), p -> p.getValue()));
} catch (URISyntaxException e) {
return null;

View file

@ -9,9 +9,7 @@ import org.keycloak.testsuite.adapter.page.SerializationServletPage;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
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.hamcrest.MatcherAssert.assertThat;

View file

@ -24,11 +24,9 @@ import org.jboss.arquillian.container.test.api.Deployer;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.Test;
import org.keycloak.adapters.rotation.PublicKeyLocator;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.adapter.AbstractServletsAdapterTest;
import org.keycloak.testsuite.adapter.filter.AdapterActionsFilter;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.util.SamlClientBuilder;

View file

@ -1,6 +1,5 @@
package org.keycloak.testsuite.adapter.servlet;
import org.jboss.arquillian.test.spi.execution.SkippedTestExecutionException;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
@ -9,7 +8,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.util.ContainerAssume;
import org.keycloak.testsuite.util.ServerURLs;
import org.keycloak.testsuite.utils.annotation.UseServletFilter;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;

View file

@ -1,6 +1,5 @@
package org.keycloak.testsuite.adapter.servlet;
import org.apache.http.util.EntityUtils;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.shrinkwrap.api.spec.WebArchive;
@ -19,7 +18,6 @@ import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.updaters.RealmAttributeUpdater;
import org.keycloak.testsuite.util.Matchers;
import org.keycloak.testsuite.util.SamlClient;
import org.keycloak.testsuite.util.SamlClientBuilder;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import javax.xml.datatype.XMLGregorianCalendar;

View file

@ -21,9 +21,7 @@ package org.keycloak.testsuite.adapter.servlet;
import static org.hamcrest.Matchers.containsString;
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;
import static org.keycloak.testsuite.util.ServerURLs.AUTH_SERVER_SSL_REQUIRED;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWithLoginUrlOf;

View file

@ -17,6 +17,7 @@
package org.keycloak.testsuite.adapter.servlet;
import org.hamcrest.MatcherAssert;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.Page;
@ -105,7 +106,7 @@ public class SessionServletAdapterTest extends AbstractServletsAdapterTest {
driver2.findElement(By.id("password")).submit();
assertCurrentUrlEquals(sessionPortalPage, driver2);
String pageSource = driver2.getPageSource();
assertThat(pageSource, containsString("Counter=1"));
MatcherAssert.assertThat(pageSource, containsString("Counter=1"));
// Counter increased now
driver2.navigate().to(sessionPortalPage.toString());
pageSource = driver2.getPageSource();
@ -129,7 +130,7 @@ public class SessionServletAdapterTest extends AbstractServletsAdapterTest {
driver2.navigate().to(sessionPortalPage.toString());
assertCurrentUrlEquals(sessionPortalPage, driver2);
pageSource = driver2.getPageSource();
assertThat(pageSource, containsString("Counter=3"));
MatcherAssert.assertThat(pageSource, containsString("Counter=3"));
// Logout in driver2
driver2.navigate().to(logoutUri);

View file

@ -22,7 +22,6 @@ import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.keycloak.OAuth2Constants;
import org.keycloak.common.Profile.Feature;
import org.keycloak.common.util.MultivaluedHashMap;
import org.keycloak.models.ClientModel;

View file

@ -18,7 +18,6 @@ package org.keycloak.testsuite.adapter.servlet.cluster;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals;
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
@ -38,12 +37,10 @@ import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Before;
import org.junit.Test;
import org.keycloak.OAuth2Constants;
import org.keycloak.common.util.Retry;
import org.keycloak.protocol.oidc.OIDCLoginProtocolService;
import org.keycloak.representations.idm.ClientRepresentation;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.Assert;
import org.keycloak.testsuite.adapter.AbstractAdapterClusteredTest;
import org.keycloak.testsuite.adapter.page.SessionPortalDistributable;
import org.keycloak.testsuite.adapter.servlet.SessionServlet;
@ -51,7 +48,6 @@ import org.keycloak.testsuite.arquillian.annotation.AppServerContainer;
import org.keycloak.testsuite.pages.InfoPage;
import org.keycloak.testsuite.pages.LogoutConfirmPage;
import org.keycloak.testsuite.util.ServerURLs;
import org.keycloak.testsuite.util.WaitUtils;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.auth.page.AuthRealm;
import org.keycloak.testsuite.auth.page.login.OIDCLogin;

View file

@ -30,9 +30,10 @@ import org.keycloak.testsuite.arquillian.annotation.InitialDcState;
import org.keycloak.testsuite.utils.arquillian.ContainerConstants;
import org.keycloak.testsuite.crossdc.ServerSetup;
import static org.hamcrest.Matchers.isEmptyString;
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.keycloak.testsuite.adapter.AbstractServletsAdapterTest.samlServletDeployment;
import org.keycloak.testsuite.arquillian.containers.InfinispanServerDeployableContainer;
/**
@ -46,7 +47,7 @@ public class SAMLAdapterCrossDCTest extends AbstractSAMLAdapterClusteredTest {
@BeforeClass
public static void checkCrossDcTest() {
Assume.assumeThat("Seems not to be running cross-DC tests", System.getProperty("cache.server"), not(isEmptyString()));
Assume.assumeThat("Seems not to be running cross-DC tests", System.getProperty("cache.server"), not(is(emptyString())));
Assume.assumeFalse(String.format("%s not supported with `cache-auth` profile.", SAMLAdapterCrossDCTest.class),
InfinispanServerDeployableContainer.CACHE_SERVER_AUTH);
}

View file

@ -24,7 +24,6 @@ import jakarta.ws.rs.core.Response;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.resource.ClientResource;
import org.keycloak.admin.client.resource.RealmResource;
@ -64,10 +63,6 @@ public class AdminClientTest extends AbstractKeycloakTest {
@Rule
public AssertEvents events = new AssertEvents(this);
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Override
public void beforeAbstractKeycloakTest() throws Exception {
super.beforeAbstractKeycloakTest();

View file

@ -1,6 +1,5 @@
package org.keycloak.testsuite.admin;
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.junit.After;
@ -8,7 +7,6 @@ import org.junit.Before;
import org.junit.Test;
import org.keycloak.TokenVerifier;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.broker.provider.util.SimpleHttp;
import org.keycloak.crypto.Algorithm;
import org.keycloak.representations.AccessToken;
import org.keycloak.representations.AccessTokenResponse;

View file

@ -548,7 +548,7 @@ public class ClientTest extends AbstractAdminTest {
realm.users().get(userId).resetPassword(CredentialBuilder.create().password("password").build());
Map<String, Long> offlineSessionCount = realm.clients().get(id).getOfflineSessionCount();
assertEquals(new Long(0), offlineSessionCount.get("count"));
assertEquals(Long.valueOf(0), offlineSessionCount.get("count"));
List<UserSessionRepresentation> userSessions = realm.users().get(userId).getOfflineSessions(id);
assertEquals("There should be no offline sessions", 0, userSessions.size());
@ -561,7 +561,7 @@ public class ClientTest extends AbstractAdminTest {
assertEquals(200, accessTokenResponse.getStatusCode());
offlineSessionCount = realm.clients().get(id).getOfflineSessionCount();
assertEquals(new Long(1), offlineSessionCount.get("count"));
assertEquals(Long.valueOf(1), offlineSessionCount.get("count"));
List<UserSessionRepresentation> offlineUserSessions = realm.clients().get(id).getOfflineUserSessions(0, 100);
assertEquals(1, offlineUserSessions.size());

View file

@ -50,7 +50,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

View file

@ -34,11 +34,9 @@ import org.keycloak.testsuite.util.AdminClientUtil;
import org.keycloak.testsuite.util.UserBuilder;
import org.keycloak.userprofile.DeclarativeUserProfileProvider;
import org.keycloak.userprofile.UserProfileProvider;
import org.keycloak.utils.StringUtil;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

View file

@ -72,6 +72,8 @@ import java.util.stream.Collectors;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.oneOf;
import static org.keycloak.testsuite.admin.ImpersonationDisabledTest.IMPERSONATION_DISABLED;
import static org.keycloak.testsuite.auth.page.AuthRealm.TEST;
import static org.keycloak.testsuite.util.ServerURLs.getAuthServerContextRoot;
@ -1142,10 +1144,10 @@ public class FineGrainAdminUnitTest extends AbstractKeycloakTest {
List<ClientRepresentation> result = client.realm("test").clients().findAll(null, true, false, 0, 1);
Assert.assertEquals(1, result.size());
assertThat(result, Matchers.hasItem(Matchers.hasProperty("clientId", Matchers.is("client-search-09"))));
assertThat(result, Matchers.hasItem(Matchers.hasProperty("clientId", is("client-search-09"))));
result = client.realm("test").clients().findAll(null, true, false, 1, 1);
assertThat(result, Matchers.hasItem(Matchers.hasProperty("clientId", Matchers.is("client-search-10"))));
assertThat(result, Matchers.hasItem(Matchers.hasProperty("clientId", is("client-search-10"))));
Assert.assertEquals(1, result.size());
@ -1196,7 +1198,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());
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()), is(Arrays.asList("client-search-09",
"client-search-10",
"client-search-11",
"client-search-12",
@ -1210,7 +1212,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());
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()), is(Arrays.asList("client-search-19",
"client-search-20",
"client-search-21",
"client-search-22",
@ -1225,7 +1227,7 @@ public class FineGrainAdminUnitTest extends AbstractKeycloakTest {
clients.addAll(result);
Assert.assertEquals(1, result.size());
assertThat(result, Matchers.hasItems(
Matchers.hasProperty("clientId", Matchers.isOneOf("client-search-29"))));
Matchers.hasProperty("clientId", is(oneOf("client-search-29")))));
}
}
@ -1279,7 +1281,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());
assertThat(result.stream().map(rep -> rep.getClientId()).collect(Collectors.toList()), Matchers.is(Arrays.asList(
assertThat(result.stream().map(rep -> rep.getClientId()).collect(Collectors.toList()), is(Arrays.asList(
"client-search-15",
"client-search-16",
"client-search-17",
@ -1294,7 +1296,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());
assertThat(result.stream().map(rep -> rep.getClientId()).collect(Collectors.toList()), Matchers.is(Arrays.asList(
assertThat(result.stream().map(rep -> rep.getClientId()).collect(Collectors.toList()), is(Arrays.asList(
"client-search-25",
"client-search-26",
"client-search-27",

View file

@ -1149,7 +1149,7 @@ public class IdentityProviderTest extends AbstractAdminTest {
X509Certificate activeX509SigCert = XMLSignatureUtil.getX509CertificateFromKeyInfoString(activeSigCert);
assertThat("KeyName matches subject DN",
keyNameElement.getTextContent().trim(), equalTo(activeX509SigCert.getSubjectDN().getName()));
keyNameElement.getTextContent().trim(), equalTo(activeX509SigCert.getSubjectX500Principal().getName()));
assertThat("Signing cert matches active realm cert",
x509CertificateElement.getTextContent().trim(), equalTo(Base64.getEncoder().encodeToString(activeX509SigCert.getEncoded())));

View file

@ -64,9 +64,9 @@ public class InitialAccessTokenResourceTest extends AbstractAdminTest {
assertAdminEvents.assertEvent(realmId, OperationType.CREATE, AdminEventPaths.clientInitialAccessPath(response.getId()), rep, ResourceType.CLIENT_INITIAL_ACCESS_MODEL);
assertNotNull(response.getId());
assertEquals(new Integer(2), response.getCount());
assertEquals(new Integer(2), response.getRemainingCount());
assertEquals(new Integer(100), response.getExpiration());
assertEquals(Integer.valueOf(2), response.getCount());
assertEquals(Integer.valueOf(2), response.getRemainingCount());
assertEquals(Integer.valueOf(100), response.getExpiration());
assertThat(response.getTimestamp(), allOf(greaterThanOrEqualTo(time), lessThanOrEqualTo(Time.currentTime())));
assertNotNull(response.getToken());

View file

@ -28,6 +28,7 @@ import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.common.Profile;
import org.keycloak.models.AdminRoles;
import org.keycloak.models.Constants;
import org.keycloak.models.UserModel;
import org.keycloak.models.credential.OTPCredentialModel;
import org.keycloak.representations.KeyStoreConfig;
import org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation;
@ -1546,7 +1547,7 @@ public class PermissionsTest extends AbstractKeycloakTest {
}, Resource.USER, true);
invoke(new Invocation() {
public void invoke(RealmResource realm) {
realm.users().get(user.getId()).resetPasswordEmail();
realm.users().get(user.getId()).executeActionsEmail(List.of(UserModel.RequiredAction.UPDATE_PASSWORD.name()));
}
}, Resource.USER, true);
invoke(new Invocation() {

View file

@ -32,7 +32,6 @@ import org.keycloak.testsuite.AbstractKeycloakTest;
import org.keycloak.testsuite.Assert;
import org.keycloak.testsuite.util.KeyUtils;
import org.keycloak.testsuite.util.KeystoreUtils;
import org.keycloak.testsuite.util.WaitUtils;
import java.util.List;
import java.util.Map;

View file

@ -16,13 +16,10 @@
*/
package org.keycloak.testsuite.admin;
import org.keycloak.Config;
import org.keycloak.common.util.Time;
import org.keycloak.events.Event;
import org.keycloak.events.EventStoreProvider;
import org.keycloak.events.EventStoreSpi;
import org.keycloak.events.EventType;
import org.keycloak.events.jpa.JpaEventStoreProviderFactory;
import org.keycloak.models.RealmModel;
import org.junit.Test;

View file

@ -64,11 +64,9 @@ import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.idm.RequiredActionProviderRepresentation;
import org.keycloak.representations.idm.RoleRepresentation;
import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.services.resources.RealmsResource;
import org.keycloak.storage.StorageId;
import org.keycloak.storage.UserStorageProvider;
import org.keycloak.testsuite.ProfileAssume;
import org.keycloak.testsuite.arquillian.annotation.DisableFeature;
import org.keycloak.testsuite.federation.DummyUserFederationProviderFactory;
import org.keycloak.testsuite.federation.UserMapStorageFactory;
import org.keycloak.testsuite.page.LoginPasswordUpdatePage;

View file

@ -17,7 +17,6 @@
package org.keycloak.testsuite.admin.concurrency;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.junit.Test;
import org.keycloak.admin.client.Keycloak;

View file

@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -42,7 +43,6 @@ import org.apache.http.util.EntityUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import org.keycloak.Config;
@ -71,9 +71,7 @@ import org.apache.http.impl.client.BasicCookieStore;
import org.hamcrest.Matchers;
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;
/**
@ -333,7 +331,7 @@ public class ConcurrentLoginTest extends AbstractConcurrencyTest {
}
private static Map<String, String> getQueryFromUrl(String url) throws URISyntaxException {
return URLEncodedUtils.parse(new URI(url), "UTF-8").stream()
return URLEncodedUtils.parse(new URI(url), StandardCharsets.UTF_8).stream()
.collect(Collectors.toMap(p -> p.getName(), p -> p.getValue()));
}

View file

@ -17,14 +17,11 @@
package org.keycloak.testsuite.admin.event;
import org.junit.Before;
import org.junit.Rule;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.representations.idm.RealmEventsConfigRepresentation;
import org.keycloak.testsuite.AbstractAuthTest;
import org.keycloak.testsuite.util.TestCleanup;
import java.util.Collections;
import static org.keycloak.testsuite.auth.page.AuthRealm.MASTER;
/**
*

View file

@ -24,10 +24,8 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.common.Profile;
import org.keycloak.events.email.EmailEventListenerProviderFactory;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.arquillian.annotation.DisableFeature;
import org.keycloak.testsuite.util.GreenMailRule;
import org.keycloak.testsuite.util.UserBuilder;

View file

@ -1135,9 +1135,9 @@ public class GroupTest extends AbstractGroupTest {
assertEquals(0, noResultSearch.size());
// Count
assertEquals(new Long(allGroups.size()), realm.groups().count().get("count"));
assertEquals(new Long(search.size()), realm.groups().count("group1").get("count"));
assertEquals(new Long(noResultSearch.size()), realm.groups().count("abcd").get("count"));
assertEquals(Long.valueOf(allGroups.size()), realm.groups().count().get("count"));
assertEquals(Long.valueOf(search.size()), realm.groups().count("group1").get("count"));
assertEquals(Long.valueOf(noResultSearch.size()), realm.groups().count("abcd").get("count"));
// Add a subgroup for onlyTopLevel flag testing
GroupRepresentation level2Group = new GroupRepresentation();
@ -1146,8 +1146,8 @@ public class GroupTest extends AbstractGroupTest {
response.close();
assertAdminEvents.assertEvent(testRealmId, OperationType.CREATE, AdminEventPaths.groupSubgroupsPath(firstGroupId), level2Group, ResourceType.GROUP);
assertEquals(new Long(allGroups.size()), realm.groups().count(true).get("count"));
assertEquals(new Long(allGroups.size() + 1), realm.groups().count(false).get("count"));
assertEquals(Long.valueOf(allGroups.size()), realm.groups().count(true).get("count"));
assertEquals(Long.valueOf(allGroups.size() + 1), realm.groups().count(false).get("count"));
//add another subgroup
GroupRepresentation level2Group2 = new GroupRepresentation();
level2Group2.setName("group111111");

View file

@ -76,6 +76,7 @@ import jakarta.ws.rs.BadRequestException;
import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.core.Response;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -641,7 +642,7 @@ public class RealmTest extends AbstractAdminTest {
@Test
public void convertOIDCClientDescription() throws IOException {
String description = IOUtils.toString(getClass().getResourceAsStream("/client-descriptions/client-oidc.json"));
String description = IOUtils.toString(getClass().getResourceAsStream("/client-descriptions/client-oidc.json"), Charset.defaultCharset());
ClientRepresentation converted = realm.convertClientDescription(description);
assertEquals(1, converted.getRedirectUris().size());
@ -650,7 +651,7 @@ public class RealmTest extends AbstractAdminTest {
@Test
public void convertSAMLClientDescription() throws IOException {
String description = IOUtils.toString(getClass().getResourceAsStream("/client-descriptions/saml-entity-descriptor.xml"));
String description = IOUtils.toString(getClass().getResourceAsStream("/client-descriptions/saml-entity-descriptor.xml"), Charset.defaultCharset());
ClientRepresentation converted = realm.convertClientDescription(description);
assertEquals("loadbalancer-9.siroe.com", converted.getClientId());

View file

@ -26,7 +26,6 @@ import static org.junit.Assert.assertTrue;
import static org.keycloak.userprofile.DeclarativeUserProfileProvider.REALM_USER_PROFILE_ENABLED;
import static org.keycloak.userprofile.config.UPConfigUtils.readDefaultConfig;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

View file

@ -1,13 +1,11 @@
package org.keycloak.testsuite.authz;
import org.junit.BeforeClass;
import org.keycloak.common.Profile;
import org.keycloak.jose.jws.JWSInput;
import org.keycloak.jose.jws.JWSInputException;
import org.keycloak.representations.AccessToken;
import org.keycloak.testsuite.AbstractKeycloakTest;
import org.keycloak.testsuite.ProfileAssume;
import org.keycloak.testsuite.arquillian.annotation.EnableFeature;
import static org.keycloak.common.Profile.Feature.AUTHORIZATION;

View file

@ -2,11 +2,12 @@ package org.keycloak.testsuite.authz;
import java.io.ByteArrayInputStream;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.EnvironmentVariables;
import org.junit.rules.ExpectedException;
import org.keycloak.authorization.client.AuthzClient;
public class AuthzClientTest {
@ -14,30 +15,29 @@ public class AuthzClientTest {
@Rule
public final EnvironmentVariables envVars = new EnvironmentVariables();
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Test
public void testCreateWithEnvVars() {
envVars.set("KEYCLOAK_REALM", "test");
envVars.set("KEYCLOAK_AUTH_SERVER", "http://test");
expectedException.expect(RuntimeException.class);
expectedException.expectMessage(Matchers.containsString("Could not obtain configuration from server"));
RuntimeException runtimeException = Assert.assertThrows(RuntimeException.class, () -> {
AuthzClient.create(new ByteArrayInputStream(("{\n"
+ " \"realm\": \"${env.KEYCLOAK_REALM}\",\n"
+ " \"auth-server-url\": \"${env.KEYCLOAK_AUTH_SERVER}\",\n"
+ " \"ssl-required\": \"external\",\n"
+ " \"enable-cors\": true,\n"
+ " \"resource\": \"my-server\",\n"
+ " \"credentials\": {\n"
+ " \"secret\": \"${env.KEYCLOAK_SECRET}\"\n"
+ " },\n"
+ " \"confidential-port\": 0,\n"
+ " \"policy-enforcer\": {\n"
+ " \"enforcement-mode\": \"ENFORCING\"\n"
+ " }\n"
+ "}").getBytes()));
AuthzClient.create(new ByteArrayInputStream(("{\n"
+ " \"realm\": \"${env.KEYCLOAK_REALM}\",\n"
+ " \"auth-server-url\": \"${env.KEYCLOAK_AUTH_SERVER}\",\n"
+ " \"ssl-required\": \"external\",\n"
+ " \"enable-cors\": true,\n"
+ " \"resource\": \"my-server\",\n"
+ " \"credentials\": {\n"
+ " \"secret\": \"${env.KEYCLOAK_SECRET}\"\n"
+ " },\n"
+ " \"confidential-port\": 0,\n"
+ " \"policy-enforcer\": {\n"
+ " \"enforcement-mode\": \"ENFORCING\"\n"
+ " }\n"
+ "}").getBytes()));
});
MatcherAssert.assertThat(runtimeException.getMessage(), Matchers.containsString("Could not obtain configuration from server"));
}
}

View file

@ -24,7 +24,6 @@ import static org.junit.Assert.assertNull;
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;
import jakarta.ws.rs.core.Response;
import java.io.IOException;

View file

@ -35,7 +35,6 @@ import org.keycloak.admin.client.resource.ClientsResource;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.authorization.client.AuthorizationDeniedException;
import org.keycloak.authorization.client.AuthzClient;
import org.keycloak.authorization.model.Resource;
import org.keycloak.protocol.oidc.OIDCLoginProtocol;
import org.keycloak.protocol.oidc.mappers.GroupMembershipMapper;
import org.keycloak.protocol.oidc.mappers.OIDCAttributeMapperHelper;

View file

@ -37,7 +37,6 @@ import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
import org.keycloak.models.UserModel;
import org.keycloak.models.utils.KeycloakModelUtils;
import org.keycloak.models.utils.RepresentationToModel;
import org.keycloak.protocol.oidc.OIDCLoginProtocol;
import org.keycloak.protocol.oidc.mappers.GroupMembershipMapper;
import org.keycloak.protocol.oidc.mappers.OIDCAttributeMapperHelper;

View file

@ -21,13 +21,9 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.locks.LockSupport.parkNanos;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.LockSupport;
import java.util.function.BiConsumer;
import javax.script.ScriptContext;
import org.junit.Test;
import org.keycloak.authorization.policy.provider.js.ScriptCache;

View file

@ -21,7 +21,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.keycloak.testsuite.AssertEvents.isUUID;
import java.util.Arrays;
import java.util.ArrayList;

View file

@ -45,7 +45,6 @@ import org.keycloak.authorization.model.Policy;
import org.keycloak.authorization.model.Resource;
import org.keycloak.authorization.model.ResourceServer;
import org.keycloak.authorization.store.PolicyStore;
import org.keycloak.common.Profile;
import org.keycloak.models.ClientModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;

View file

@ -19,7 +19,6 @@ package org.keycloak.testsuite.authz.adapter.example;
import org.jboss.arquillian.container.test.api.Deployer;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.junit.Before;
import org.junit.BeforeClass;
import org.keycloak.admin.client.resource.AuthorizationResource;
import org.keycloak.admin.client.resource.ClientResource;
@ -31,7 +30,6 @@ import org.keycloak.representations.idm.authorization.ResourceServerRepresentati
import org.keycloak.representations.idm.authorization.UserPolicyRepresentation;
import org.keycloak.testsuite.ProfileAssume;
import org.keycloak.testsuite.adapter.AbstractExampleAdapterTest;
import org.keycloak.testsuite.arquillian.annotation.EnableFeature;
import org.keycloak.testsuite.pages.InfoPage;
import org.keycloak.testsuite.pages.LogoutConfirmPage;
import org.keycloak.testsuite.util.UIUtils;

View file

@ -18,7 +18,6 @@ package org.keycloak.testsuite.authz.admin;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

View file

@ -29,8 +29,6 @@ import jakarta.ws.rs.NotFoundException;
import jakarta.ws.rs.core.Response;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.List;

View file

@ -37,7 +37,6 @@ import jakarta.ws.rs.core.Response;
import java.net.URI;
import java.util.Arrays;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

View file

@ -6,7 +6,6 @@ import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import org.junit.Assert;
import org.junit.Before;
import org.keycloak.admin.client.CreatedResponseUtil;
import org.keycloak.broker.provider.ConfigConstants;

View file

@ -18,8 +18,6 @@ package org.keycloak.testsuite.broker;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.keycloak.authentication.authenticators.broker.IdpAutoLinkAuthenticatorFactory;
import org.keycloak.authentication.authenticators.browser.OTPFormAuthenticatorFactory;
import org.keycloak.authentication.authenticators.browser.PasswordFormFactory;

View file

@ -17,7 +17,6 @@
package org.keycloak.testsuite.broker;
import org.junit.Assert;
import org.junit.Test;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.admin.client.resource.UserResource;

View file

@ -5,7 +5,6 @@ import org.keycloak.models.IdentityProviderModel;
import org.keycloak.models.IdentityProviderSyncMode;
import org.keycloak.protocol.ProtocolMapperUtils;
import org.keycloak.protocol.oidc.OIDCAdvancedConfigWrapper;
import org.keycloak.protocol.oidc.OIDCConfigAttributes;
import org.keycloak.protocol.oidc.OIDCLoginProtocol;
import org.keycloak.protocol.oidc.mappers.HardcodedClaim;
import org.keycloak.protocol.oidc.mappers.OIDCAttributeMapperHelper;

View file

@ -17,7 +17,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.keycloak.representations.idm.ClientRepresentation;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.Assert;
import org.keycloak.testsuite.util.ReverseProxy;
public final class KcOidcBrokerFrontendUrlTest extends AbstractBrokerTest {

View file

@ -23,7 +23,6 @@ import static org.junit.Assert.assertFalse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import com.google.common.collect.ImmutableMap;
@ -43,7 +42,6 @@ import org.keycloak.models.IdentityProviderMapperModel;
import org.keycloak.models.IdentityProviderMapperSyncMode;
import org.keycloak.models.utils.DefaultKeyProviders;
import org.keycloak.protocol.ProtocolMapperUtils;
import org.keycloak.protocol.oidc.OIDCAdvancedConfigWrapper;
import org.keycloak.protocol.oidc.OIDCConfigAttributes;
import org.keycloak.protocol.oidc.OIDCLoginProtocol;
import org.keycloak.protocol.oidc.mappers.HardcodedClaim;

View file

@ -3,8 +3,7 @@ package org.keycloak.testsuite.broker;
import java.util.List;
import java.util.Map;
import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
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.BrokerTestConstants.USER_EMAIL;

View file

@ -87,7 +87,6 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.keycloak.testsuite.broker.BrokerTestConstants.CLIENT_ID;
import static org.keycloak.testsuite.broker.BrokerTestConstants.REALM_CONS_NAME;
import static org.keycloak.testsuite.broker.BrokerTestConstants.REALM_PROV_NAME;
import static org.keycloak.testsuite.broker.BrokerTestTools.getConsumerRoot;

View file

@ -19,7 +19,7 @@ package org.keycloak.testsuite.broker;
import java.io.Closeable;
import jakarta.ws.rs.core.Response;
import org.hamcrest.Matchers;
import org.junit.Assert;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Test;
import org.keycloak.broker.saml.SAMLIdentityProviderConfig;

View file

@ -14,7 +14,6 @@ import org.keycloak.representations.idm.ClientRepresentation;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.saml.common.constants.JBossSAMLURIConstants;
import org.keycloak.saml.processing.core.saml.v2.common.SAMLDocumentHolder;
import org.keycloak.testsuite.Assert;
import org.keycloak.testsuite.AssertEvents;
import org.keycloak.testsuite.util.Matchers;
import org.keycloak.testsuite.util.ReverseProxy;

View file

@ -38,6 +38,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@ -94,7 +95,7 @@ public class KcSamlIdPInitiatedSsoTest extends AbstractKeycloakTest {
private RealmRepresentation loadFromClasspath(String fileName, Properties properties) {
InputStream is = KcSamlIdPInitiatedSsoTest.class.getResourceAsStream(fileName);
try {
String template = StreamUtil.readString(is);
String template = StreamUtil.readString(is, Charset.defaultCharset());
String realmString = StringPropertyReplacer.replaceProperties(template, properties);
return IOUtil.loadRealm(new ByteArrayInputStream(realmString.getBytes("UTF-8")));
} catch (IOException ex) {

View file

@ -13,7 +13,6 @@ import org.keycloak.testsuite.util.SamlClientBuilder;
import java.io.Closeable;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

View file

@ -42,7 +42,6 @@ import javax.xml.namespace.QName;
import org.apache.http.HttpResponse;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;

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