1414import org .junit .jupiter .api .Assertions ;
1515import org .junit .jupiter .api .Test ;
1616import org .junit .jupiter .api .extension .ExtendWith ;
17+ import org .junit .jupiter .api .extension .ExtensionContext ;
1718import org .junit .jupiter .api .io .TempDir ;
1819
20+ import java .io .IOException ;
21+ import java .nio .file .Files ;
1922import java .nio .file .Path ;
2023import java .time .Duration ;
2124import java .time .Instant ;
2225import java .util .Map ;
2326
2427import static com .aws .greengrass .localdebugconsole .SimpleHttpServer .DEBUG_PASSWORD_NAMESPACE ;
2528import static com .aws .greengrass .localdebugconsole .SimpleHttpServer .EXPIRATION_NAMESPACE ;
29+ import static com .aws .greengrass .testcommons .testutilities .ExceptionLogProtector .ignoreExceptionOfType ;
2630import static org .junit .jupiter .api .Assertions .assertFalse ;
2731import static org .junit .jupiter .api .Assertions .assertNull ;
2832import static org .junit .jupiter .api .Assertions .assertTrue ;
@@ -43,7 +47,8 @@ void after() {
4347 }
4448
4549 @ Test
46- void GIVEN_server_WHEN_authenticate_THEN_cleans_storage () {
50+ void GIVEN_server_WHEN_authenticate_THEN_cleans_storage (ExtensionContext context ) throws IOException {
51+ ignoreExceptionOfType (context , IOException .class );
4752 kernel = new Kernel ();
4853 kernel .parseArgs ("-r" , rootDir .toAbsolutePath ().toString ());
4954
@@ -66,6 +71,11 @@ void GIVEN_server_WHEN_authenticate_THEN_cleans_storage() {
6671 http .getRuntimeConfig ().remove (); // remove runtime config so that the password is lost
6772 kernel .getContext ().waitForPublishQueueToClear ();
6873 assertTrue (http .initializeHttps ());
74+
75+ // Verify that corrupting the keystore is recoverable
76+ Files .write (kernel .getNucleusPaths ().workPath (SimpleHttpServer .AWS_GREENGRASS_DEBUG_SERVER )
77+ .resolve ("keystore.jks" ), new byte [1024 ]);
78+ assertTrue (http .initializeHttps ());
6979 }
7080
7181 @ Test
0 commit comments