55import ch .qos .logback .core .read .ListAppender ;
66import com .uid2 .operator .service .ShutdownService ;
77import com .uid2 .operator .vertx .OperatorShutdownHandler ;
8+ import com .uid2 .shared .attest .AttestationResponseCode ;
89import io .vertx .core .Vertx ;
910import io .vertx .junit5 .VertxExtension ;
1011import io .vertx .junit5 .VertxTestContext ;
@@ -51,17 +52,18 @@ void afterEach() throws Exception {
5152 }
5253
5354 @ Test
54- void shutdownOnAttest401 (VertxTestContext testContext ) {
55+ void shutdownOnAttestFailure (VertxTestContext testContext ) {
5556 ListAppender <ILoggingEvent > logWatcher = new ListAppender <>();
5657 logWatcher .start ();
5758 ((Logger ) LoggerFactory .getLogger (OperatorShutdownHandler .class )).addAppender (logWatcher );
5859
5960 // Revoke auth
6061 try {
61- this .operatorShutdownHandler .handleAttestResponse (Pair .of (401 , "Unauthorized" ));
62+ this .operatorShutdownHandler .handleAttestResponse (Pair .of (AttestationResponseCode . AttestationFailure , "Unauthorized" ));
6263 } catch (RuntimeException e ) {
6364 verify (shutdownService ).Shutdown (1 );
64- Assertions .assertTrue (logWatcher .list .get (0 ).getFormattedMessage ().contains ("core attestation failed with 401, shutting down operator, core response: " ));
65+ String message = logWatcher .list .get (0 ).getFormattedMessage ();
66+ Assertions .assertEquals ("core attestation failed with AttestationFailure, shutting down operator, core response: Unauthorized" , logWatcher .list .get (0 ).getFormattedMessage ());
6567 testContext .completeNow ();
6668 }
6769 }
@@ -72,11 +74,11 @@ void shutdownOnAttestFailedTooLong(VertxTestContext testContext) {
7274 logWatcher .start ();
7375 ((Logger ) LoggerFactory .getLogger (OperatorShutdownHandler .class )).addAppender (logWatcher );
7476
75- this .operatorShutdownHandler .handleAttestResponse (Pair .of (500 , "" ));
77+ this .operatorShutdownHandler .handleAttestResponse (Pair .of (AttestationResponseCode . RetryableFailure , "" ));
7678
7779 when (clock .instant ()).thenAnswer (i -> Instant .now ().plus (12 , ChronoUnit .HOURS ).plusSeconds (60 ));
7880 try {
79- this .operatorShutdownHandler .handleAttestResponse (Pair .of (500 , "" ));
81+ this .operatorShutdownHandler .handleAttestResponse (Pair .of (AttestationResponseCode . RetryableFailure , "" ));
8082 } catch (RuntimeException e ) {
8183 verify (shutdownService ).Shutdown (1 );
8284 Assertions .assertTrue (logWatcher .list .get (0 ).getFormattedMessage ().contains ("core attestation has been in failed state for too long. shutting down operator" ));
@@ -90,13 +92,13 @@ void attestRecoverOnSuccess(VertxTestContext testContext) {
9092 logWatcher .start ();
9193 ((Logger ) LoggerFactory .getLogger (OperatorShutdownHandler .class )).addAppender (logWatcher );
9294
93- this .operatorShutdownHandler .handleAttestResponse (Pair .of (500 , "" ));
95+ this .operatorShutdownHandler .handleAttestResponse (Pair .of (AttestationResponseCode . RetryableFailure , "" ));
9496 when (clock .instant ()).thenAnswer (i -> Instant .now ().plus (6 , ChronoUnit .HOURS ));
95- this .operatorShutdownHandler .handleAttestResponse (Pair .of (200 , "" ));
97+ this .operatorShutdownHandler .handleAttestResponse (Pair .of (AttestationResponseCode . Success , "" ));
9698
9799 when (clock .instant ()).thenAnswer (i -> Instant .now ().plus (12 , ChronoUnit .HOURS ));
98100 assertDoesNotThrow (() -> {
99- this .operatorShutdownHandler .handleAttestResponse (Pair .of (500 , "" ));
101+ this .operatorShutdownHandler .handleAttestResponse (Pair .of (AttestationResponseCode . RetryableFailure , "" ));
100102 });
101103 verify (shutdownService , never ()).Shutdown (anyInt ());
102104 testContext .completeNow ();
0 commit comments