Skip to content

Commit

Permalink
KNOX-1646 - Fix test assumptions
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Risden <[email protected]>
  • Loading branch information
risdenk committed Nov 30, 2018
1 parent 3760da5 commit 2190ce4
Showing 1 changed file with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -703,15 +703,14 @@ public void testExportCert() throws Exception {
KnoxCLI cli = new KnoxCLI();
cli.setConf( config );
String[] gwCreateArgs = {"create-cert", "--hostname", "hostname1", "--master", "master"};
int rc = 0;
int rc;
rc = cli.run(gwCreateArgs);
assertEquals(0, rc);
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("gateway-identity has been successfully " +
"created."));

outContent.reset();
String[] gwCreateArgs2 = {"export-cert", "--type", "PEM"};
rc = 0;
rc = cli.run(gwCreateArgs2);
assertEquals(0, rc);
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("Certificate gateway-identity has been successfully exported to"));
Expand All @@ -720,49 +719,43 @@ public void testExportCert() throws Exception {
// case insensitive
outContent.reset();
String[] gwCreateArgs2_6 = {"export-cert", "--type", "pem"};
rc = 0;
rc = cli.run(gwCreateArgs2_6);
assertEquals(0, rc);
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("Certificate gateway-identity has been successfully exported to"));
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("gateway-identity.pem"));

// pkcs12
outContent.reset();
String[] gwCreateArgs2_7 = {"export-cert", "--type", "pkcs12"};
rc = 0;
rc = cli.run(gwCreateArgs2_7);
String[] gwCreateArgs2_5 = {"export-cert"};
rc = cli.run(gwCreateArgs2_5);
assertEquals(0, rc);
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("Certificate gateway-identity has been successfully exported to"));
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("gateway-identity.pkcs12"));
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("gateway-identity.pem"));

// jceks
outContent.reset();
String[] gwCreateArgs2_8 = {"export-cert", "--type", "jceks"};
rc = 0;
rc = cli.run(gwCreateArgs2_8);
String[] gwCreateArgs3 = {"export-cert", "--type", "JKS"};
rc = cli.run(gwCreateArgs3);
assertEquals(0, rc);
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("Certificate gateway-identity has been successfully exported to"));
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("gateway-identity.jceks"));
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("gateway-client-trust.jks"));

// pkcs12
outContent.reset();
String[] gwCreateArgs2_5 = {"export-cert"};
rc = 0;
rc = cli.run(gwCreateArgs2_5);
String[] gwCreateArgs2_7 = {"export-cert", "--type", "pkcs12"};
rc = cli.run(gwCreateArgs2_7);
assertEquals(0, rc);
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("Certificate gateway-identity has been successfully exported to"));
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("gateway-identity.pem"));
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("gateway-client-trust.pkcs12"));

// jceks
outContent.reset();
String[] gwCreateArgs3 = {"export-cert", "--type", "JKS"};
rc = 0;
rc = cli.run(gwCreateArgs3);
String[] gwCreateArgs2_8 = {"export-cert", "--type", "jceks"};
rc = cli.run(gwCreateArgs2_8);
assertEquals(0, rc);
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("Certificate gateway-identity has been successfully exported to"));
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("gateway-client-trust.jks"));
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("gateway-client-trust.jceks"));

outContent.reset();
String[] gwCreateArgs4 = {"export-cert", "--type", "invalid"};
rc = 0;
rc = cli.run(gwCreateArgs4);
assertEquals(0, rc);
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("Invalid type for export file provided."));
Expand Down

0 comments on commit 2190ce4

Please sign in to comment.