14
14
import org .junit .jupiter .api .Assertions ;
15
15
import org .junit .jupiter .api .Test ;
16
16
import org .junit .jupiter .api .extension .ExtendWith ;
17
+ import org .junit .jupiter .api .extension .ExtensionContext ;
17
18
import org .junit .jupiter .api .io .TempDir ;
18
19
20
+ import java .io .IOException ;
21
+ import java .nio .file .Files ;
19
22
import java .nio .file .Path ;
20
23
import java .time .Duration ;
21
24
import java .time .Instant ;
22
25
import java .util .Map ;
23
26
24
27
import static com .aws .greengrass .localdebugconsole .SimpleHttpServer .DEBUG_PASSWORD_NAMESPACE ;
25
28
import static com .aws .greengrass .localdebugconsole .SimpleHttpServer .EXPIRATION_NAMESPACE ;
29
+ import static com .aws .greengrass .testcommons .testutilities .ExceptionLogProtector .ignoreExceptionOfType ;
26
30
import static org .junit .jupiter .api .Assertions .assertFalse ;
27
31
import static org .junit .jupiter .api .Assertions .assertNull ;
28
32
import static org .junit .jupiter .api .Assertions .assertTrue ;
@@ -43,7 +47,8 @@ void after() {
43
47
}
44
48
45
49
@ 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 );
47
52
kernel = new Kernel ();
48
53
kernel .parseArgs ("-r" , rootDir .toAbsolutePath ().toString ());
49
54
@@ -66,6 +71,11 @@ void GIVEN_server_WHEN_authenticate_THEN_cleans_storage() {
66
71
http .getRuntimeConfig ().remove (); // remove runtime config so that the password is lost
67
72
kernel .getContext ().waitForPublishQueueToClear ();
68
73
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 ());
69
79
}
70
80
71
81
@ Test
0 commit comments