DataBridgeApp { @SuppressWarnings("PMD.SystemPrintln") @SuppressFBWarnings(value = "VA_FORMAT_STRING_USES_NEWLINE", justification = "We will use the standard carriage return character.") protected ReturnValue parseCommandLineArguments(String[] args, ApplicationContext applicationContext) { ArgumentParser argParser = getArgumentParser(); try { s3AccessKeyOpt = argParser.addArgument("a", "s3AccessKey", true, "S3 access key.", false); s3SecretKeyOpt = argParser.addArgument("p", "s3SecretKey", true, "S3 secret key.", false); s3EndpointOpt = argParser.addArgument("e", "s3Endpoint", true, "S3 endpoint.", false); localPathOpt = argParser.addArgument("l", "localPath", true, "The path to files on your local file system.", true); manifestPathOpt = argParser.addArgument("m", "manifestPath", true, "Local path to the manifest file.", true); regServerHostOpt = argParser.addArgument("H", "regServerHost", true, "Registration Service hostname.", false); regServerPortOpt = argParser.addArgument("P", "regServerPort", true, "Registration Service port.", false); dmRegServerHostOpt = argParser.addArgument("Y", "dmRegServerHost", true, "Registration Service hostname (deprecated - use regServerHost).", false); dmRegServerPortOpt = argParser.addArgument("Z", "dmRegServerPort", true, "Registration Service port (deprecated - use regServerPort.", false); sslOpt = argParser.addArgument("s", "ssl", true, "Enable or disable SSL (HTTPS).", false); usernameOpt = argParser.addArgument("u", "username", true, "The username for HTTPS client authentication.", false); passwordOpt = argParser.addArgument("w", "password", true, "The password used for HTTPS client authentication.", false); enableEnvVariablesOpt = argParser.addArgument("E", "enableEnvVariables", true, "The enableEnvVariables used for HTTPS client authentication through environment provided variable.", false); trustSelfSignedCertificateOpt = argParser.addArgument("C", "trustSelfSignedCertificate", true, "If set to true, makes HTTPS client trust self-signed certificate.", false); disableHostnameVerificationOpt = argParser.addArgument("d", "disableHostnameVerification", true, "If set to true, turns off hostname verification.", false); helpOpt = argParser.addArgument("h", "help", false, "Display usage information and exit.", false); versionOpt = argParser.addArgument("v", "version", false, "Display version information and exit.", false); httpProxyHostOpt = argParser.addArgument("n", "httpProxyHost", true, "HTTP proxy host.", false); httpProxyPortOpt = argParser.addArgument("o", "httpProxyPort", true, "HTTP proxy port.", false); maxThreadsOpt = argParser.addArgument("t", "maxThreads", true, "Maximum number of threads.", false); socketTimeoutOpt = argParser.addArgument("c", "socketTimeout", true, "The socket timeout in milliseconds. 0 indicates no timeout. Default 50000.", false); argParser.parseArguments(args, false); if (argParser.getBooleanValue(helpOpt)) { System.out.println(argParser.getUsageInformation()); return ReturnValue.SUCCESS; } if (argParser.getBooleanValue(versionOpt)) { BuildInformation buildInformation = applicationContext.getBean(BuildInformation.class); System.out.println(String .format(BUILD_INFO_STRING_FORMAT, buildInformation.getBuildDate(), buildInformation.getBuildNumber(), buildInformation.getBuildOs(), buildInformation.getBuildUser())); return ReturnValue.SUCCESS; } argParser.parseArguments(args, true); useSsl = argParser.getStringValueAsBoolean(sslOpt, false); trustSelfSignedCertificate = argParser.getStringValueAsBoolean(trustSelfSignedCertificateOpt, false); disableHostnameVerification = argParser.getStringValueAsBoolean(disableHostnameVerificationOpt, false); if (useSsl) { if (StringUtils.isBlank(argParser.getStringValue(usernameOpt))) { throw new ParseException("Username is required when SSL is enabled."); } ToolsArgumentHelper.validateCliEnvArgument(argParser, passwordOpt, enableEnvVariablesOpt); } if (StringUtils.isNotBlank(argParser.getStringValue(s3SecretKeyOpt)) && StringUtils.isBlank(argParser.getStringValue(s3AccessKeyOpt))) { throw new ParseException("S3 access key must be specified when S3 secret key is present."); } if (StringUtils.isNotBlank(argParser.getStringValue(s3AccessKeyOpt)) && StringUtils.isBlank(argParser.getStringValue(s3SecretKeyOpt))) { throw new ParseException("S3 secret key must be specified when S3 access key is present."); } regServerHost = argParser.getStringValue(regServerHostOpt); if (StringUtils.isBlank(regServerHost)) { regServerHost = argParser.getStringValue(dmRegServerHostOpt); if (StringUtils.isBlank(regServerHost)) { throw new ParseException("A registration host must be specified."); } } else { if (StringUtils.isNotBlank(argParser.getStringValue(dmRegServerHostOpt))) { throw new ParseException("The regServerHost and the dmRegServerHost options can't both be specified."); } } regServerPort = argParser.getIntegerValue(regServerPortOpt); if (regServerPort == null) { regServerPort = argParser.getIntegerValue(dmRegServerPortOpt); if (regServerPort == null) { throw new ParseException("A registration port must be specified."); } } else { if (argParser.getIntegerValue(dmRegServerPortOpt) != null) { throw new ParseException("The regServerPort and the dmRegServerPort options can't both be specified."); } } httpProxyPort = argParser.getIntegerValue(httpProxyPortOpt); maxThreads = argParser.getIntegerValue(maxThreadsOpt, ToolsCommonConstants.DEFAULT_THREADS); } catch (ParseException ex) { LOGGER.error("Error parsing command line arguments: " + ex.getMessage() + "\n" + argParser.getUsageInformation()); return ReturnValue.FAILURE; } return null; }  abstract ArgumentParser getArgumentParser(); abstract ReturnValue go(String[] args); static final String BUILD_INFO_STRING_FORMAT; }
@Test public void testParseCommandLineArgumentsAssertErrorWhenBothRegServerHostAreProvided() { String[] arguments = {"-Y", WEB_SERVICE_HOSTNAME, "-H", WEB_SERVICE_HOSTNAME, "-a", S3_ACCESS_KEY, "-p", S3_SECRET_KEY, "-e", S3_ENDPOINT_US_STANDARD, "-l", LOCAL_TEMP_PATH_INPUT.toString(), "-m", STRING_VALUE, "-P", WEB_SERVICE_HTTPS_PORT.toString(), "-n", HTTP_PROXY_HOST, "-o", HTTP_PROXY_PORT.toString()}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }
@Test public void testParseCommandLineArgumentsAssertErrorWhenBothRegServerHostNotProvided() { String[] arguments = {"-a", S3_ACCESS_KEY, "-p", S3_SECRET_KEY, "-e", S3_ENDPOINT_US_STANDARD, "-l", LOCAL_TEMP_PATH_INPUT.toString(), "-m", STRING_VALUE, "-P", WEB_SERVICE_HTTPS_PORT.toString(), "-n", HTTP_PROXY_HOST, "-o", HTTP_PROXY_PORT.toString()}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }
@Test public void testParseCommandLineArgumentsAssertErrorWhenBothRegServerPortAreNotProvided() { String[] arguments = {"-a", S3_ACCESS_KEY, "-p", S3_SECRET_KEY, "-e", S3_ENDPOINT_US_STANDARD, "-l", LOCAL_TEMP_PATH_INPUT.toString(), "-m", STRING_VALUE, "-H", WEB_SERVICE_HOSTNAME, "-n", HTTP_PROXY_HOST, "-o", HTTP_PROXY_PORT.toString()}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }
@Test public void testParseCommandLineArgumentsAssertErrorWhenBothRegServerPortAreProvided() { String[] arguments = {"-a", S3_ACCESS_KEY, "-p", S3_SECRET_KEY, "-e", S3_ENDPOINT_US_STANDARD, "-l", LOCAL_TEMP_PATH_INPUT.toString(), "-m", STRING_VALUE, "-H", WEB_SERVICE_HOSTNAME, "-P", WEB_SERVICE_HTTPS_PORT.toString(), "-Z", WEB_SERVICE_HTTPS_PORT.toString(), "-n", HTTP_PROXY_HOST, "-o", HTTP_PROXY_PORT.toString()}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }
@Test public void testParseCommandLineArgumentsAssertNoErrorWhenSslTrueAndUserPwdProvided() { String[] arguments = {"-s", Boolean.TRUE.toString(), "-u", "username", "-w", "password", "-C", "true", "-d", "true", "-e", S3_ENDPOINT_US_STANDARD, "-l", LOCAL_TEMP_PATH_INPUT.toString(), "-m", STRING_VALUE, "-H", WEB_SERVICE_HOSTNAME, "-P", WEB_SERVICE_HTTPS_PORT.toString(), "-n", HTTP_PROXY_HOST, "-o", HTTP_PROXY_PORT.toString()}; assertNull(dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }
@Test public void testParseCommandLineArgumentsAssertRegServerHostFallbackToLegacyWhenNotProvided() { String expectedRegServerHost = WEB_SERVICE_HOSTNAME; String[] arguments = {"-a", S3_ACCESS_KEY, "-p", S3_SECRET_KEY, "-e", S3_ENDPOINT_US_STANDARD, "-l", LOCAL_TEMP_PATH_INPUT.toString(), "-m", STRING_VALUE, "-Y", expectedRegServerHost, "-P", WEB_SERVICE_HTTPS_PORT.toString(), "-n", HTTP_PROXY_HOST, "-o", HTTP_PROXY_PORT.toString()}; assertNull(dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); assertEquals(expectedRegServerHost, dataBridgeApp.regServerHost); }
@Test public void testParseCommandLineArgumentsAssertRegServerPortFallbackToLegacyWhenNotProvided() { String[] arguments = {"-a", S3_ACCESS_KEY, "-p", S3_SECRET_KEY, "-e", S3_ENDPOINT_US_STANDARD, "-l", LOCAL_TEMP_PATH_INPUT.toString(), "-m", STRING_VALUE, "-H", WEB_SERVICE_HOSTNAME, "-Z", WEB_SERVICE_HTTPS_PORT.toString(), "-n", HTTP_PROXY_HOST, "-o", HTTP_PROXY_PORT.toString()}; assertNull(dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); assertEquals(WEB_SERVICE_HTTPS_PORT, dataBridgeApp.regServerPort); }
@Test public void testParseCommandLineArgumentsHelpOpt() { String output = runTestGetSystemOut(() -> { String[] arguments = {"--help"}; assertEquals(ReturnValue.SUCCESS, dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }); assertTrue("Incorrect usage information returned.", output.startsWith("usage: " + MockDataBridgeApp.TEST_APPLICATION_NAME)); }
@Test public void testParseCommandLineArgumentsMissingPassword() { String[] arguments = {"--s3AccessKey", S3_ACCESS_KEY, "--s3SecretKey", S3_SECRET_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "--ssl", "true", "-u", WEB_SERVICE_HTTPS_USERNAME, "--trustSelfSignedCertificate", "true", "--disableHostnameVerification", "true"}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }
@Test public void testParseCommandLineArgumentsEnabledEnvVarFalse() { environmentVariables.set("HERD_PASSWORD", WEB_SERVICE_HTTPS_PASSWORD); String[] arguments = {"--s3AccessKey", S3_ACCESS_KEY, "--s3SecretKey", S3_SECRET_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "--ssl", "true", "-u", WEB_SERVICE_HTTPS_USERNAME, "-w", "", "--enableEnvVariables", "false", "--trustSelfSignedCertificate", "true", "--disableHostnameVerification", "true"}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); environmentVariables.clear("HERD_PASSWORD"); }
@Test public void testParseCommandLineArgumentsCliPassword() { String[] arguments = {"--s3AccessKey", S3_ACCESS_KEY, "--s3SecretKey", S3_SECRET_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "--ssl", "true", "-u", WEB_SERVICE_HTTPS_USERNAME, "-w", WEB_SERVICE_HTTPS_PASSWORD, "--trustSelfSignedCertificate", "true", "--disableHostnameVerification", "true"}; assertNull(dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }
@Test public void testParseCommandLineArgumentsBlankEnvPassword() { String[] argumentsWithEnvPassword = {"--s3AccessKey", S3_ACCESS_KEY, "--s3SecretKey", S3_SECRET_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "--ssl", "true", "-u", WEB_SERVICE_HTTPS_USERNAME, "-E", "true", "--trustSelfSignedCertificate", "true", "--disableHostnameVerification", "true"}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(argumentsWithEnvPassword, applicationContext)); environmentVariables.set("HERD_PASSWORD", ""); String[] argumentsWithBlankEnvPwd = {"--s3AccessKey", S3_ACCESS_KEY, "--s3SecretKey", S3_SECRET_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "--ssl", "true", "-u", WEB_SERVICE_HTTPS_USERNAME, "-E", "true", "--trustSelfSignedCertificate", "true", "--disableHostnameVerification", "true"}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(argumentsWithBlankEnvPwd, applicationContext)); environmentVariables.clear("HERD_PASSWORD"); }
@Test public void testParseCommandLineArgumentsValidEnvPassword() { environmentVariables.set("HERD_PASSWORD", WEB_SERVICE_HTTPS_PASSWORD); String[] arguments = {"--s3AccessKey", S3_ACCESS_KEY, "--s3SecretKey", S3_SECRET_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "--ssl", "true", "-u", WEB_SERVICE_HTTPS_USERNAME, "--enableEnvVariables", "true", "--trustSelfSignedCertificate", "true", "--disableHostnameVerification", "true"}; assertNull(dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); environmentVariables.clear("HERD_PASSWORD"); }
@Test public void testParseCommandLineArgumentsMissingUsername() { String[] arguments = {"--s3AccessKey", S3_ACCESS_KEY, "--s3SecretKey", S3_SECRET_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "--ssl", "true", "-w", WEB_SERVICE_HTTPS_PASSWORD, "--trustSelfSignedCertificate", "true", "--disableHostnameVerification", "true"}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }
@Test public void testParseCommandLineArgumentsNone() { assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(new String[] {}, applicationContext)); }
@Test public void testParseCommandLineArgumentsOptionalParameters() { String[] arguments = {"-a", S3_ACCESS_KEY, "-p", S3_SECRET_KEY, "-l", LOCAL_TEMP_PATH_INPUT.toString(), "-m", STRING_VALUE, "-H", WEB_SERVICE_HOSTNAME, "-P", WEB_SERVICE_HTTPS_PORT.toString(), "-n", HTTP_PROXY_HOST, "-o", HTTP_PROXY_PORT.toString()}; assertNull(dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }
@Test public void testParseCommandLineArgumentsParseException() { String[] arguments = {}; ReturnValue returnValue = dataBridgeApp.parseCommandLineArguments(arguments, applicationContext); assertEquals("returnValue", ReturnValue.FAILURE, returnValue); }
@Test public void testParseCommandLineArgumentsS3SecretAndAccessKeys() { String[] argumentsNoKeys = {"--s3AccessKey", S3_ACCESS_KEY, "--s3SecretKey", S3_SECRET_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "--ssl", "true", "-u", WEB_SERVICE_HTTPS_USERNAME, "-w", WEB_SERVICE_HTTPS_PASSWORD, "--trustSelfSignedCertificate", "true", "--disableHostnameVerification", "true"}; assertNull(dataBridgeApp.parseCommandLineArguments(argumentsNoKeys, applicationContext)); String[] argumentsMissingSecretKey = {"--s3AccessKey", S3_ACCESS_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "--ssl", "true", "-u", WEB_SERVICE_HTTPS_USERNAME, "-w", WEB_SERVICE_HTTPS_PASSWORD, "--trustSelfSignedCertificate", "true", "--disableHostnameVerification", "true"}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(argumentsMissingSecretKey, applicationContext)); String[] argumentsMissingAccessKeyKey = {"--s3SecretKey", S3_SECRET_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "--ssl", "true", "-u", WEB_SERVICE_HTTPS_USERNAME, "-w", WEB_SERVICE_HTTPS_PASSWORD, "--trustSelfSignedCertificate", "true", "--disableHostnameVerification", "true"}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(argumentsMissingAccessKeyKey, applicationContext)); }
@Test public void testParseCommandLineArgumentsVersionOpt() { String output = runTestGetSystemOut(() -> { String[] arguments = {"--version"}; assertEquals(ReturnValue.SUCCESS, dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }); BuildInformation buildInformation = applicationContext.getBean(BuildInformation.class); assertEquals("output", String .format(DataBridgeApp.BUILD_INFO_STRING_FORMAT, buildInformation.getBuildDate(), buildInformation.getBuildNumber(), buildInformation.getBuildOs(), buildInformation.getBuildUser()), output); }
@Test public void testParseCommandLineInvalidDisableHostnameVerificationValue() { String[] arguments = {"--s3AccessKey", S3_ACCESS_KEY, "--s3SecretKey", S3_SECRET_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "-s", "true", "-u", WEB_SERVICE_HTTPS_USERNAME, "-w", WEB_SERVICE_HTTPS_PASSWORD, "--trustSelfSignedCertificate", "true", "--disableHostnameVerification", "INVALID_BOOLEAN_VALUE"}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }
@Test public void testParseCommandLineInvalidSslValue() { String[] arguments = {"--s3AccessKey", S3_ACCESS_KEY, "--s3SecretKey", S3_SECRET_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "--ssl", "INVALID_BOOLEAN_VALUE", "-u", WEB_SERVICE_HTTPS_USERNAME, "-w", WEB_SERVICE_HTTPS_PASSWORD, "--trustSelfSignedCertificate", "true", "--disableHostnameVerification", "true"}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }
@Test public void testParseCommandLineInvalidTrustSelfSignedCertificateValue() { String[] arguments = {"--s3AccessKey", S3_ACCESS_KEY, "--s3SecretKey", S3_SECRET_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "-s", "true", "-u", WEB_SERVICE_HTTPS_USERNAME, "-w", WEB_SERVICE_HTTPS_PASSWORD, "--trustSelfSignedCertificate", "INVALID_BOOLEAN_VALUE", "--disableHostnameVerification", "true"}; assertEquals(ReturnValue.FAILURE, dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }
@Test public void testParseLongCommandLineArgumentsSuccess() { String[] arguments = {"--s3AccessKey", S3_ACCESS_KEY, "--s3SecretKey", S3_SECRET_KEY, "--s3Endpoint", S3_ENDPOINT_US_STANDARD, "--localPath", LOCAL_TEMP_PATH_INPUT.toString(), "--manifestPath", STRING_VALUE, "--regServerHost", WEB_SERVICE_HOSTNAME, "--regServerPort", WEB_SERVICE_HTTPS_PORT.toString(), "--httpProxyHost", HTTP_PROXY_HOST, "--httpProxyPort", HTTP_PROXY_PORT.toString(), "--ssl", "true", "-u", WEB_SERVICE_HTTPS_USERNAME, "-w", WEB_SERVICE_HTTPS_PASSWORD, "--trustSelfSignedCertificate", "true", "--disableHostnameVerification", "true"}; assertNull(dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }
@Test public void testParseShortCommandLineArgumentsSuccess() { String[] arguments = {"-a", S3_ACCESS_KEY, "-p", S3_SECRET_KEY, "-e", S3_ENDPOINT_US_STANDARD, "-l", LOCAL_TEMP_PATH_INPUT.toString(), "-m", STRING_VALUE, "-H", WEB_SERVICE_HOSTNAME, "-P", WEB_SERVICE_HTTPS_PORT.toString(), "-n", HTTP_PROXY_HOST, "-o", HTTP_PROXY_PORT.toString(), "-s", "true", "-u", WEB_SERVICE_HTTPS_USERNAME, "-w", WEB_SERVICE_HTTPS_PASSWORD, "-C", "true", "-d", "true"}; assertNull(dataBridgeApp.parseCommandLineArguments(arguments, applicationContext)); }