Skip to content

Commit

Permalink
Added support for displaying Saucelabs configuration in the build inf…
Browse files Browse the repository at this point in the history
…o screen.
  • Loading branch information
wakaleo committed Feb 13, 2015
1 parent 56f672a commit e78dd2c
Showing 1 changed file with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.thucydides.core.guice.Injectors;
import net.thucydides.core.guice.ThucydidesModule;
import net.thucydides.core.util.EnvironmentVariables;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;
Expand All @@ -32,6 +33,7 @@ public BuildProperties getBuildProperties() {
generalProperties.put("Default Driver",ThucydidesSystemProperty.DRIVER.from(environmentVariables,"firefox"));
generalProperties.put("Operating System",System.getProperty("os.name") + " version " + System.getProperty("os.version"));
addRemoteDriverPropertiesTo(generalProperties);
addSaucelabsPropertiesTo(generalProperties);
addCustomPropertiesTo(generalProperties);

List<String> drivers = driverCapabilityRecord.getDrivers();
Expand All @@ -43,11 +45,39 @@ public BuildProperties getBuildProperties() {
private void addRemoteDriverPropertiesTo(Map<String, String> buildProperties) {
if (ThucydidesSystemProperty.WEBDRIVER_REMOTE_DRIVER.isDefinedIn(environmentVariables)) {
buildProperties.put("Remote driver", ThucydidesSystemProperty.WEBDRIVER_REMOTE_DRIVER.from(environmentVariables));
buildProperties.put("Remote browser version", ThucydidesSystemProperty.WEBDRIVER_REMOTE_BROWSER_VERSION.from(environmentVariables));
buildProperties.put("Remote OS", ThucydidesSystemProperty.WEBDRIVER_REMOTE_OS.from(environmentVariables));
if (ThucydidesSystemProperty.WEBDRIVER_REMOTE_BROWSER_VERSION.from(environmentVariables) != null) {
buildProperties.put("Remote browser version", ThucydidesSystemProperty.WEBDRIVER_REMOTE_BROWSER_VERSION.from(environmentVariables));
}
if (ThucydidesSystemProperty.WEBDRIVER_REMOTE_OS.from(environmentVariables) != null) {
buildProperties.put("Remote OS", ThucydidesSystemProperty.WEBDRIVER_REMOTE_OS.from(environmentVariables));
}
}
}

private void addSaucelabsPropertiesTo(Map<String, String> buildProperties) {
if (ThucydidesSystemProperty.SAUCELABS_URL.isDefinedIn(environmentVariables)) {
buildProperties.put("Saucelabs URL", maskAPIKey(ThucydidesSystemProperty.SAUCELABS_URL.from(environmentVariables)));
if (ThucydidesSystemProperty.SAUCELABS_USER_ID.from(environmentVariables) != null) {
buildProperties.put("Saucelabs user", ThucydidesSystemProperty.SAUCELABS_USER_ID.from(environmentVariables));
}
if (ThucydidesSystemProperty.SAUCELABS_TARGET_PLATFORM.from(environmentVariables) != null) {
buildProperties.put("Saucelabs target platform", ThucydidesSystemProperty.SAUCELABS_TARGET_PLATFORM.from(environmentVariables));
}
if (ThucydidesSystemProperty.SAUCELABS_DRIVER_VERSION.from(environmentVariables) != null) {
buildProperties.put("Saucelabs driver version", ThucydidesSystemProperty.SAUCELABS_DRIVER_VERSION.from(environmentVariables));
}
if (ThucydidesSystemProperty.WEBDRIVER_REMOTE_OS.from(environmentVariables) != null) {
buildProperties.put("Remote OS", ThucydidesSystemProperty.WEBDRIVER_REMOTE_OS.from(environmentVariables));
}
}
}

private String maskAPIKey(String url) {
int apiKeyStart = url.indexOf(":");
int apiKeyEnd = url.indexOf("@");
return url.substring(0,apiKeyStart + 3) + "XXXXXXXXXXXXXXXX" + url.substring(apiKeyEnd);
}

private void addCustomPropertiesTo(Map<String, String> buildProperties) {

List<String> sysInfoKeys = filter(startsWith("sysinfo."), environmentVariables.getKeys());
Expand Down

0 comments on commit e78dd2c

Please sign in to comment.