From 113b29e65cb5c2c2d7859411c0c665a11c5663df Mon Sep 17 00:00:00 2001 From: ashitsalesforce Date: Sun, 29 Sep 2024 21:25:57 -0700 Subject: [PATCH] minor changes to unit test for OAuth properties minor changes to unit test for OAuth properties --- .../dataloader/config/ConfigTest.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/salesforce/dataloader/config/ConfigTest.java b/src/test/java/com/salesforce/dataloader/config/ConfigTest.java index 12a6390f..6745b9ed 100644 --- a/src/test/java/com/salesforce/dataloader/config/ConfigTest.java +++ b/src/test/java/com/salesforce/dataloader/config/ConfigTest.java @@ -30,6 +30,9 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + import javax.xml.parsers.FactoryConfigurationError; import org.apache.logging.log4j.LogManager; @@ -38,6 +41,7 @@ import com.salesforce.dataloader.ConfigTestBase; import com.salesforce.dataloader.exception.ConfigInitializationException; +import com.salesforce.dataloader.util.AppUtil; public class ConfigTest extends ConfigTestBase { private static Logger logger = LogManager.getLogger(ConfigTest.class); @@ -102,12 +106,11 @@ public void testProperty_OAUTH_SERVER() { Config config = Config.getInstance(getTestConfig()); config.setOAuthEnvironment(Config.PROD_ENVIRONMENT_VAL); String configuredOAuthServer = config.getString(Config.OAUTH_SERVER); - String expectedOAuthServer = System.getProperty("test.endpoint"); + String expectedOAuthServer = getProperty("test.endpoint"); if (expectedOAuthServer == null || expectedOAuthServer.isBlank()) { - config = Config.getInstance(null); - expectedOAuthServer = "https://testendpoint"; logger.info("Expected prefix is " + expectedOAuthServer); - logger.info("Actual prefix is " + configuredOAuthServer); } + logger.info("Actual prefix is " + configuredOAuthServer); + } assertTrue(configuredOAuthServer.startsWith(expectedOAuthServer)); config.setOAuthEnvironment(Config.SB_ENVIRONMENT_VAL); @@ -125,12 +128,12 @@ public void testProperty_OAUTH_SERVER() { @Test public void testProperty_OAUTH_REDIRECTURI() { try { - Config config = Config.getInstance(getTestConfig()); + Map testConfigMap = getTestConfig(); + Config config = Config.getInstance(testConfigMap); config.setOAuthEnvironment(Config.PROD_ENVIRONMENT_VAL); String configuredOAuthRedirectURI = config.getString(Config.OAUTH_REDIRECTURI); - String expectedOAuthRedirectURIPrefix = System.getProperty("test.endpoint"); + String expectedOAuthRedirectURIPrefix = getProperty("test.endpoint"); if (expectedOAuthRedirectURIPrefix == null || expectedOAuthRedirectURIPrefix.isBlank()) { - expectedOAuthRedirectURIPrefix = "https://testendpoint"; logger.info("Expected prefix is " + expectedOAuthRedirectURIPrefix); logger.info("Actual prefix is " + configuredOAuthRedirectURI); }