From efb82cbafb64613e3dae4516e054698bf566be5d Mon Sep 17 00:00:00 2001 From: Tomas Kyjovsky Date: Wed, 20 Jan 2016 07:21:31 +0100 Subject: [PATCH] KEYCLOAK-2238 Added null check into AbstractAdapterTest --- .../adapter/AbstractAdapterTest.java | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/AbstractAdapterTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/AbstractAdapterTest.java index 11c17f0cd8..3fffb24768 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/AbstractAdapterTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/adapter/AbstractAdapterTest.java @@ -95,28 +95,32 @@ public abstract class AbstractAdapterTest extends AbstractAuthTest { } protected void modifyClientWebOrigins(RealmRepresentation realm, String regex, String replacement) { - for (ClientRepresentation client : realm.getClients()) { - List webOrigins = client.getWebOrigins(); - if (webOrigins != null) { - List newWebOrigins = new ArrayList<>(); - for (String uri : webOrigins) { - newWebOrigins.add(uri.replaceAll(regex, replacement)); + if (realm.getClients() != null) { + for (ClientRepresentation client : realm.getClients()) { + List webOrigins = client.getWebOrigins(); + if (webOrigins != null) { + List newWebOrigins = new ArrayList<>(); + for (String uri : webOrigins) { + newWebOrigins.add(uri.replaceAll(regex, replacement)); + } + client.setWebOrigins(newWebOrigins); } - client.setWebOrigins(newWebOrigins); } } } protected void modifySamlMasterURLs(RealmRepresentation realm, String regex, String replacement) { - for (ClientRepresentation client : realm.getClients()) { - if (client.getProtocol() != null && client.getProtocol().equals("saml")) { - log.info("Modifying master URL of SAML client: " + client.getClientId()); - String masterUrl = client.getAdminUrl(); - if (masterUrl == null) { - masterUrl = client.getBaseUrl(); + if (realm.getClients() != null) { + for (ClientRepresentation client : realm.getClients()) { + if (client.getProtocol() != null && client.getProtocol().equals("saml")) { + log.info("Modifying master URL of SAML client: " + client.getClientId()); + String masterUrl = client.getAdminUrl(); + if (masterUrl == null) { + masterUrl = client.getBaseUrl(); + } + masterUrl = masterUrl.replaceFirst(regex, replacement); + client.setAdminUrl(masterUrl); } - masterUrl = masterUrl.replaceFirst(regex, replacement); - client.setAdminUrl(masterUrl); } } }