[java-idp-integration-tests] branch main updated: Support multiple client IP ranges for Sauce Labs browser tests
Tom Zeller
tzeller at dragonacea.biz
Mon Jun 7 22:20:06 UTC 2021
This is an automated email from the git hooks/post-receive script.
tzeller pushed a commit to branch main
in repository java-idp-integration-tests.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-integration-tests.git;a=commit;h=2efc48cbe5a274902298fbf29ea87e9e240329c3
The following commit(s) were added to refs/heads/main by this push:
new 2efc48c Support multiple client IP ranges for Sauce Labs browser tests
2efc48c is described below
commit 2efc48cbe5a274902298fbf29ea87e9e240329c3
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Mon Jun 7 17:18:21 2021 -0500
Support multiple client IP ranges for Sauce Labs browser tests
---
.../shibboleth/idp/test/BaseIntegrationTest.java | 33 ++++++++++++++++++----
.../test/saml2/AbstractSAML2IntegrationTest.java | 4 ++-
.../saml2/SAML2AttributeQueryIntegrationTest.java | 4 ++-
3 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java b/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
index 1a69fdd..a265bfa 100644
--- a/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/test/BaseIntegrationTest.java
@@ -31,6 +31,7 @@ import java.nio.file.StandardCopyOption;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -185,7 +186,7 @@ public abstract class BaseIntegrationTest
@Nonnull public final static String SELENIUM_IS_REMOTE = "SELENIUM_IS_REMOTE";
/** IP range of Sauce Labs. */
- @Nonnull public final static String SAUCE_LABS_IP_RANGE = "162.222.73.0/24";
+ @Nonnull public final static List<String> SAUCE_LABS_IP_RANGES = Arrays.asList("162.222.72.0/21", "66.85.48.0/21", "185.94.24.0/22");
/** Name of property defining the port that the test directory server listens on. */
@Nonnull public final static String TEST_LDAP_PORT_PROPERTY = "test.ldap.port";
@@ -275,7 +276,7 @@ public abstract class BaseIntegrationTest
@Nonnull protected boolean useSecureBaseURL = true;
/** Client IP range to allow access from. Defaults to "127.0.0.1/32". */
- @Nonnull protected String clientIPRange = "127.0.0.1/32";
+ @Nonnull protected List<String> clientIPRanges = new ArrayList<>(Arrays.asList("127.0.0.1/32"));
/** Path to idp.home. */
@NonnullAfterInit protected Path pathToIdPHome;
@@ -718,9 +719,29 @@ public abstract class BaseIntegrationTest
// Access control from non-localhost.
- if (!clientIPRange.equalsIgnoreCase("127.0.0.1/32")) {
- replaceIdPHomeFile(Paths.get("conf", "access-control.xml"), "127\\.0\\.0\\.1/32", clientIPRange);
+ // Add public server addresses if not localhost
+ if (address != "localhost") {
+ clientIPRanges.add(address + "/32");
}
+ if (secureAddress != "localhost") {
+ clientIPRanges.add(secureAddress + "/32");
+ }
+ // Add private server addresses if not localhost
+ if (privateAddress != "localhost") {
+ clientIPRanges.add(privateAddress + "/32");
+ }
+ if (privateSecureAddress != "localhost") {
+ clientIPRanges.add(privateSecureAddress + "/32");
+ }
+
+ final List<String> escapedClientIPRanges = new ArrayList<>();
+ for(final String clientIPRange : clientIPRanges) {
+ escapedClientIPRanges.add("'" + clientIPRange + "'");
+ }
+ String newClientIPRange = String.join(" , ", escapedClientIPRanges);
+
+ log.debug("setUpEndpoints newClientIPRange {}", newClientIPRange);
+ replaceIdPHomeFile(Paths.get("conf", "access-control.xml"), "'127\\.0\\.0\\.1/32'", newClientIPRange);
// LDAP port.
replaceLDAPProperty("idp.authn.LDAP.ldapURL", "ldap://localhost:" + ldapPort);
@@ -1477,8 +1498,8 @@ public abstract class BaseIntegrationTest
@BeforeClass(enabled = true)
public void setUpSauceLabsClientIPRange() {
if (BaseIntegrationTest.isRemote()) {
- clientIPRange = SAUCE_LABS_IP_RANGE;
- log.debug("Setting client IP range to '{}'", clientIPRange);
+ clientIPRanges.addAll(SAUCE_LABS_IP_RANGES);
+ log.debug("Setting client IP range to '{}'", clientIPRanges);
}
}
diff --git a/src/test/java/net/shibboleth/idp/test/saml2/AbstractSAML2IntegrationTest.java b/src/test/java/net/shibboleth/idp/test/saml2/AbstractSAML2IntegrationTest.java
index 02fa67f..c80dfe8 100644
--- a/src/test/java/net/shibboleth/idp/test/saml2/AbstractSAML2IntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/test/saml2/AbstractSAML2IntegrationTest.java
@@ -106,7 +106,9 @@ public abstract class AbstractSAML2IntegrationTest extends BaseIntegrationTest {
validator.spCredential = getSPCredential();
validator.authnContextClassRef = AuthnContext.PPT_AUTHN_CTX;
if (BaseIntegrationTest.isRemote()) {
- validator.subjectConfirmationDataAddressRange = IPRange.parseCIDRBlock(SAUCE_LABS_IP_RANGE);
+ for (final String ipRange : SAUCE_LABS_IP_RANGES) {
+ validator.subjectConfirmationDataAddressRanges.add(IPRange.parseCIDRBlock(ipRange));
+ }
}
}
diff --git a/src/test/java/net/shibboleth/idp/test/saml2/SAML2AttributeQueryIntegrationTest.java b/src/test/java/net/shibboleth/idp/test/saml2/SAML2AttributeQueryIntegrationTest.java
index 5ceda81..afea0f8 100644
--- a/src/test/java/net/shibboleth/idp/test/saml2/SAML2AttributeQueryIntegrationTest.java
+++ b/src/test/java/net/shibboleth/idp/test/saml2/SAML2AttributeQueryIntegrationTest.java
@@ -114,7 +114,9 @@ public class SAML2AttributeQueryIntegrationTest extends AbstractSAML2Integration
ssoValidator.spCredential = getSPCredential();
ssoValidator.authnContextClassRef = AuthnContext.PPT_AUTHN_CTX;
if (BaseIntegrationTest.isRemote()) {
- ssoValidator.subjectConfirmationDataAddressRange = IPRange.parseCIDRBlock(SAUCE_LABS_IP_RANGE);
+ for (final String ipRange : SAUCE_LABS_IP_RANGES) {
+ ssoValidator.subjectConfirmationDataAddressRanges.add(IPRange.parseCIDRBlock(ipRange));
+ }
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list