Skip to content

Commit

Permalink
Merge pull request #1291 from ashitsalesforce/master
Browse files Browse the repository at this point in the history
minor changes to unit test for OAuth properties
  • Loading branch information
ashitsalesforce authored Sep 30, 2024
2 parents 69daf68 + 113b29e commit 75bb50e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/test/java/com/salesforce/dataloader/config/ConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -125,12 +128,12 @@ public void testProperty_OAUTH_SERVER() {
@Test
public void testProperty_OAUTH_REDIRECTURI() {
try {
Config config = Config.getInstance(getTestConfig());
Map<String, String> 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);
}
Expand Down

0 comments on commit 75bb50e

Please sign in to comment.