Skip to content

Commit 1a37c68

Browse files
committed
adding 2 new fat tests to ensure the change in 33607 does not regress
1 parent 786821a commit 1a37c68

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

dev/com.ibm.ws.security.utility_fat/fat/src/com/ibm/ws/security/utility/test/SecurityUtilityCreateLTPAKeysTest.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,4 +758,61 @@ public void testCreateLTPAKeysExclusiveArgs() throws Exception {
758758
assertEquals("createLTPAKeys command should fail with exclusive arguments",
759759
FAILURE_RC, commandOutput.getReturnCode());
760760
}
761+
@Test
762+
public void testCreateLTPAKeysWithPasswordEncodingAndNotNormalizedKey() throws Exception {
763+
String key = "not//normalized//key";
764+
// Run createLTPAKeys with passwordEncoding=aes for the test server
765+
ProgramOutput commandOutput = testMachine.execute(
766+
securityUtilityPath,
767+
new String[] {
768+
"createLTPAKeys",
769+
"--password=" + ltpaPassword,
770+
"--passwordEncoding=aes",
771+
"--server=" + LTPA_TEST_SERVER_NAME,
772+
"--passwordKey=" + key
773+
},
774+
libertyInstallRoot,
775+
testEnvironment);
776+
assertEquals("createLTPAKeys should succeed", SUCCESS_RC, commandOutput.getReturnCode());
777+
778+
// Build server.xml using the snippet
779+
String ltpaSnippet = getLtpaOverride(commandOutput,
780+
"<variable name=\"wlp.password.encryption.key\" value=\"" + key + "\" />");
781+
writeStringToServerOverride(ltpaSnippet, ltpaTestServer);
782+
// Start the server
783+
ltpaTestServer.startServer();
784+
785+
// Verify startup log contains LTPA initialization
786+
assertNotNull("Expected LTPA configuration ready message not found in the log.",
787+
ltpaTestServer.waitForStringInLogUsingMark("CWWKS4105I", 5000));
788+
ltpaTestServer.stopServer();
789+
}
790+
@Test
791+
public void testCreateLTPAKeysWithPasswordEncodingAndNotNormalizedBase64Key() throws Exception {
792+
String key = "3ORhx1L0ME//P2JDl1elDjOqhhagCoMAZ4XFbhQxJoM=";
793+
// Run createLTPAKeys with passwordEncoding=aes for the test server
794+
ProgramOutput commandOutput = testMachine.execute(
795+
securityUtilityPath,
796+
new String[] {
797+
"createLTPAKeys",
798+
"--password=" + ltpaPassword,
799+
"--passwordEncoding=aes",
800+
"--server=" + LTPA_TEST_SERVER_NAME,
801+
"--passwordBase64Key=" + key
802+
},
803+
libertyInstallRoot,
804+
testEnvironment);
805+
assertEquals("createLTPAKeys should succeed", SUCCESS_RC, commandOutput.getReturnCode());
806+
807+
// Build server.xml using the snippet
808+
String ltpaSnippet = getLtpaOverride(commandOutput, key);
809+
writeStringToServerOverride(ltpaSnippet, ltpaTestServer);
810+
// Start the server
811+
ltpaTestServer.startServer();
812+
813+
// Verify startup log contains LTPA initialization
814+
assertNotNull("Expected LTPA configuration ready message not found in the log.",
815+
ltpaTestServer.waitForStringInLogUsingMark("CWWKS4105I", 5000));
816+
ltpaTestServer.stopServer();
817+
}
761818
}

0 commit comments

Comments
 (0)