Skip to content

Commit dbef9be

Browse files
committed
add proxy url to the curl command (when fetching the browserstack report link) if PROXY_URL is set as a system property or an env variable
1 parent f2a2937 commit dbef9be

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/main/java/com/cucumber/listener/CucumberScenarioListener.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.appium.manager.AppiumServerManager;
1010
import com.appium.manager.DeviceAllocationManager;
1111
import com.appium.utils.CommandPrompt;
12+
import com.appium.utils.OverriddenVariable;
1213
import com.context.SessionContext;
1314
import com.context.TestExecutionContext;
1415
import com.epam.reportportal.service.ReportPortal;
@@ -21,6 +22,7 @@
2122
import io.cucumber.plugin.event.TestRunFinished;
2223
import io.cucumber.plugin.event.TestRunStarted;
2324
import org.apache.log4j.Logger;
25+
import org.jetbrains.annotations.NotNull;
2426
import org.json.JSONObject;
2527

2628
import java.io.File;
@@ -261,7 +263,7 @@ private static String getReportLinkFromBrowserStack(String sessionId) {
261263
String reportLink = "";
262264
String cloudUser = getOverriddenStringValue("CLOUD_USER");
263265
String cloudPassword = getOverriddenStringValue("CLOUD_KEY");
264-
String curlCommand = "curl --insecure -u \"" + cloudUser + ":" + cloudPassword + "\" -X GET \"https://api-cloud.browserstack.com/app-automate/sessions/" + sessionId + ".json\"";
266+
String curlCommand = "curl --insecure " + getCurlProxyCommand() + " -u \"" + cloudUser + ":" + cloudPassword + "\" -X GET \"https://api-cloud.browserstack.com/app-automate/sessions/" + sessionId + ".json\"";
265267
LOGGER.debug(String.format("Curl command: '%s'", curlCommand));
266268
CommandPrompt cmd = new CommandPrompt();
267269
String resultStdOut = null;
@@ -279,6 +281,15 @@ private static String getReportLinkFromBrowserStack(String sessionId) {
279281
return reportLink;
280282
}
281283

284+
@NotNull
285+
static String getCurlProxyCommand() {
286+
String curlProxyCommand = "";
287+
if (null != OverriddenVariable.getOverriddenStringValue("PROXY_URL")) {
288+
curlProxyCommand = " --proxy " + System.getProperty("PROXY_URL");
289+
}
290+
return curlProxyCommand;
291+
}
292+
282293
private void runFinishedHandler(TestRunFinished event) {
283294
LOGGER.info("runFinishedHandler: " + event.getResult().toString());
284295
LOGGER.info(String.format("ThreadID: %d: afterSuite: %n", Thread.currentThread().getId()));

0 commit comments

Comments
 (0)