Skip to content

Commit

Permalink
allow authurl to get picked up by the command line args mechanism, ad…
Browse files Browse the repository at this point in the history
…d tests
  • Loading branch information
jmartin-sul committed May 18, 2017
1 parent 6518b54 commit aa6384b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/edu/stanford/dlss/was/WasapiDownloaderSettings.java
Expand Up @@ -23,6 +23,7 @@ public class WasapiDownloaderSettings {
// * add an accessor method (preferably with a name corresponding to the setting name)
// * add to the tests to make sure it shows up in the usage info and settings dump
public static final String BASE_URL_PARAM_NAME = "baseurl";
public static final String AUTH_URL_PARAM_NAME = "authurl";
public static final String USERNAME_PARAM_NAME = "username";
public static final String PASSWORD_PARAM_NAME = "password";
public static final String HELP_PARAM_NAME = "help";
Expand All @@ -40,6 +41,7 @@ public class WasapiDownloaderSettings {
private static Option[] optList = {
Option.builder("h").longOpt(HELP_PARAM_NAME).desc("print this message (which describes expected arguments and dumps current config)").build(),
buildArgOption(BASE_URL_PARAM_NAME, "the base URL of the WASAPI server from which to pull WARC files"),
buildArgOption(AUTH_URL_PARAM_NAME, "the WASAPI server URL at which login credentials are passed"),
buildArgOption(USERNAME_PARAM_NAME, "the username for WASAPI server login"),
buildArgOption(PASSWORD_PARAM_NAME, "the password for WASAPI server login"),
buildArgOption(COLLECTION_ID_PARAM_NAME, "a collection from which to download crawl files"),
Expand Down Expand Up @@ -79,7 +81,7 @@ public String baseUrlString() {
}

public String authUrlString() {
return settings.getProperty("authurl");
return settings.getProperty(AUTH_URL_PARAM_NAME);
}

public String username() {
Expand Down
3 changes: 3 additions & 0 deletions test/edu/stanford/dlss/was/TestWasapiDownloaderSettings.java
Expand Up @@ -22,6 +22,7 @@ public void constructor_readsPropertiesFileAndArgs() throws SettingsLoadExceptio
WasapiDownloaderSettings settings = new WasapiDownloaderSettings(WasapiDownloader.SETTINGS_FILE_LOCATION, args);

assertEquals("baseurl value should have come from settings file", settings.baseUrlString(), "http://example.org");
assertEquals("authurl value should have come from settings file", settings.authUrlString(), "http://example.org/login");
assertEquals("username value should have come from settings file", settings.username(), "user");
assertEquals("password value should have come from settings file", settings.password(), "pass");
assertEquals("outputBaseDir value should have come from settings file", settings.outputBaseDir(), "/var/downloadedWarcFiles");
Expand All @@ -42,6 +43,7 @@ public void getHelpAndSettingsMessage_containsUsageAndSettingsInfo() throws Sett

assertThat("helpAndSettingsMsg has a usage example", helpAndSettingsMsg, containsString("usage: bin/wasapi-downloader"));
assertThat("helpAndSettingsMsg lists baseurl arg", helpAndSettingsMsg, containsString("--baseurl <arg>"));
assertThat("helpAndSettingsMsg lists authurl arg", helpAndSettingsMsg, containsString("--authurl <arg>"));
assertThat("helpAndSettingsMsg lists username arg", helpAndSettingsMsg, containsString("--username <arg>"));
assertThat("helpAndSettingsMsg lists password arg", helpAndSettingsMsg, containsString("--password <arg>"));
assertThat("helpAndSettingsMsg lists collectionId arg", helpAndSettingsMsg, containsString("--collectionId <arg>"));
Expand All @@ -57,6 +59,7 @@ public void getHelpAndSettingsMessage_containsUsageAndSettingsInfo() throws Sett
assertThat("helpAndSettingsMsg lists jobId value", helpAndSettingsMsg, containsString("jobId : 456"));
assertThat("helpAndSettingsMsg lists collectionId value", helpAndSettingsMsg, containsString("collectionId : 123"));
assertThat("helpAndSettingsMsg lists baseurl value", helpAndSettingsMsg, containsString("baseurl : http://example.org"));
assertThat("helpAndSettingsMsg lists authurl value", helpAndSettingsMsg, containsString("authurl : http://example.org/login"));
assertThat("helpAndSettingsMsg lists username value", helpAndSettingsMsg, containsString("username : user"));
}

Expand Down

0 comments on commit aa6384b

Please sign in to comment.