diff --git a/events_test/src/main/java/com/adobe/aio/event/management/RegistrationServiceTester.java b/events_test/src/main/java/com/adobe/aio/event/management/RegistrationServiceTester.java
index a492ce65..4216a700 100644
--- a/events_test/src/main/java/com/adobe/aio/event/management/RegistrationServiceTester.java
+++ b/events_test/src/main/java/com/adobe/aio/event/management/RegistrationServiceTester.java
@@ -15,7 +15,6 @@
import com.adobe.aio.event.management.model.EventsOfInterestInputModel;
import com.adobe.aio.event.management.model.Registration;
import com.adobe.aio.event.management.model.RegistrationCreateModel;
-import com.adobe.aio.event.management.model.RegistrationUpdateModel;
import com.adobe.aio.util.WorkspaceUtil;
import com.adobe.aio.workspace.Workspace;
import java.net.MalformedURLException;
diff --git a/events_test/src/test/java/com/adobe/aio/event/management/ProviderServiceIntegrationTest.java b/events_test/src/test/java/com/adobe/aio/event/management/ProviderServiceIntegrationTest.java
index 3aa81039..917da2e8 100644
--- a/events_test/src/test/java/com/adobe/aio/event/management/ProviderServiceIntegrationTest.java
+++ b/events_test/src/test/java/com/adobe/aio/event/management/ProviderServiceIntegrationTest.java
@@ -11,12 +11,10 @@
*/
package com.adobe.aio.event.management;
-import com.adobe.aio.event.management.model.ProviderInputModel;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
-import com.adobe.aio.event.management.feign.ConflictException;
import com.adobe.aio.event.management.model.EventMetadata;
import com.adobe.aio.event.management.model.Provider;
import com.adobe.aio.util.WorkspaceUtil;
diff --git a/ims/src/main/java/com/adobe/aio/util/WorkspaceUtil.java b/ims/src/main/java/com/adobe/aio/util/WorkspaceUtil.java
index d087798c..7462525f 100644
--- a/ims/src/main/java/com/adobe/aio/util/WorkspaceUtil.java
+++ b/ims/src/main/java/com/adobe/aio/util/WorkspaceUtil.java
@@ -29,6 +29,17 @@ public class WorkspaceUtil {
private WorkspaceUtil() {
}
+ /**
+ * Loads configurations for a Workspace from either one and only one of the following
+ * sources, probing them first to check that all the required properties are given,
+ * in order:
+ *
+ * - System Properties
+ * - Environment Variables
+ * - classpath:{@link WorkspaceUtil#DEFAULT_TEST_PROPERTIES}
+ *
+ * @return a Workspace.Builder loaded with the provided config
+ */
public static Workspace.Builder getSystemWorkspaceBuilder() {
if (StringUtils.isNoneBlank(
System.getProperty(PrivateKeyBuilder.AIO_ENCODED_PKCS_8),
@@ -47,6 +58,23 @@ public static Workspace.Builder getSystemWorkspaceBuilder() {
return Workspace.builder()
.properties(System.getProperties())
.privateKey(privateKey);
+ } else if (StringUtils.isNoneBlank(
+ System.getenv(PrivateKeyBuilder.AIO_ENCODED_PKCS_8),
+ System.getenv(Workspace.API_KEY),
+ System.getenv(Workspace.WORKSPACE_ID),
+ System.getenv(Workspace.CLIENT_SECRET),
+ System.getenv(Workspace.CONSUMER_ORG_ID),
+ System.getenv(Workspace.CREDENTIAL_ID),
+ System.getenv(Workspace.IMS_ORG_ID),
+ System.getenv(Workspace.META_SCOPES),
+ System.getenv(Workspace.PROJECT_ID),
+ System.getenv(Workspace.TECHNICAL_ACCOUNT_ID))) {
+ logger.debug("loading test Workspace from JVM System Properties");
+ PrivateKey privateKey =
+ new PrivateKeyBuilder()
+ .encodedPkcs8Key(System.getenv(PrivateKeyBuilder.AIO_ENCODED_PKCS_8))
+ .build();
+ return Workspace.builder().systemEnv().privateKey(privateKey);
} else {
/**
* WARNING: don't push back your workspace secrets to github
@@ -60,15 +88,30 @@ public static String getSystemProperty(String key) {
return getSystemProperty(key,DEFAULT_TEST_PROPERTIES);
}
+ /**
+ * Loads a property from either one of the following sources, probing it first to
+ * check that the required property is given, in order:
+ *
+ * - System Properties
+ * - Environment Variables
+ * - classpath:{@code propertyClassPath}
+ *
+ *
+ * @param key the property name
+ * @param propertyClassPath the classpath of the property file
+ * @return the value of the property
+ */
public static String getSystemProperty(String key, String propertyClassPath) {
- String value = System.getProperty(key);
- if (StringUtils.isBlank(value)) {
- logger.debug("loading property `{}` from classpath `{}`", key, propertyClassPath);
- value = FileUtil.readPropertiesFromClassPath(propertyClassPath).getProperty(key);
- } else {
+ if (StringUtils.isNotBlank(System.getProperty(key))) {
logger.debug("loading property `{}`from JVM System Properties", key);
+ return System.getProperty(key);
+ } if (StringUtils.isNotBlank(System.getenv(key))) {
+ logger.debug("loading property `{}` from Environment Variables", key);
+ return System.getenv(key);
+ } else {
+ logger.debug("loading property `{}` from classpath `{}`", key, propertyClassPath);
+ return FileUtil.readPropertiesFromClassPath(propertyClassPath).getProperty(key);
}
- return value;
}
private static Workspace.Builder getWorkspaceBuilder(String propertyFileClassPath) {