@@ -78,13 +78,15 @@ private void verifyAuditLogFilledWithJwt(JwtValidationResponse response) {
7878 }
7979 Assertions .assertEquals (expectedJwtRoles , auditLogUserDetailsActual .getJsonArray ("jwt_roles" ));
8080 Assertions .assertEquals (response .getSubject (), auditLogUserDetailsActual .getString ("jwt_subject" ));
81+ Assertions .assertEquals (response .getJti (), auditLogUserDetailsActual .getString ("token_id" ));
8182
8283 }
8384
8485 @ Test
85- void trustedValidJwtNoRolesReturnsSuccess () throws JwtService .ValidationException {
86+ void trustedValidJwtNoJtiReturnsSuccess () throws JwtService .ValidationException {
8687 var attestationMiddleware = getAttestationMiddleware (true );
8788 JwtValidationResponse response = new JwtValidationResponse (true )
89+ .withRoles (Role .OPERATOR , Role .SUPER_USER , Role .OPTOUT )
8890 .withSubject (EXPECTED_OPERATOR_KEY_HASH_DIGEST );
8991 when (this .jwtService .validateJwt ("dummy jwt" , JWT_AUDIENCE , JWT_ISSUER )).thenReturn (response );
9092
@@ -95,12 +97,28 @@ void trustedValidJwtNoRolesReturnsSuccess() throws JwtService.ValidationExceptio
9597 verifyAuditLogFilledWithJwt (response );
9698 }
9799
100+ @ Test
101+ void trustedValidJwtNoRolesReturnsSuccess () throws JwtService .ValidationException {
102+ var attestationMiddleware = getAttestationMiddleware (true );
103+ JwtValidationResponse response = new JwtValidationResponse (true )
104+ .withSubject (EXPECTED_OPERATOR_KEY_HASH_DIGEST )
105+ .withJti ("dummyJti" );
106+ when (this .jwtService .validateJwt ("dummy jwt" , JWT_AUDIENCE , JWT_ISSUER )).thenReturn (response );
107+
108+ var handler = attestationMiddleware .handle (nextHandler );
109+ handler .handle (this .routingContext );
110+
111+ verify (nextHandler ).handle (routingContext );
112+ verifyAuditLogFilledWithJwt (response );
113+ }
114+
98115 @ Test
99116 void trustedValidJwtHasRequiredRoleReturnsSuccess () throws JwtService .ValidationException {
100117 var attestationMiddleware = getAttestationMiddleware (true );
101118 JwtValidationResponse response = new JwtValidationResponse (true )
102119 .withRoles (Role .OPERATOR , Role .SUPER_USER , Role .OPTOUT )
103- .withSubject (EXPECTED_OPERATOR_KEY_HASH_DIGEST );
120+ .withSubject (EXPECTED_OPERATOR_KEY_HASH_DIGEST )
121+ .withJti ("dummyJti" );
104122 when (this .jwtService .validateJwt ("dummy jwt" , JWT_AUDIENCE , JWT_ISSUER )).thenReturn (response );
105123
106124 var handler = attestationMiddleware .handle (nextHandler , Role .OPERATOR );
@@ -115,7 +133,8 @@ void trustedValidJwtHasMultipleRolesReturnsSuccess() throws JwtService.Validatio
115133 var attestationMiddleware = getAttestationMiddleware (true );
116134 JwtValidationResponse response = new JwtValidationResponse (true )
117135 .withRoles (Role .OPERATOR , Role .SUPER_USER , Role .OPTOUT )
118- .withSubject (EXPECTED_OPERATOR_KEY_HASH_DIGEST );
136+ .withSubject (EXPECTED_OPERATOR_KEY_HASH_DIGEST )
137+ .withJti ("dummyJti" );
119138 when (this .jwtService .validateJwt ("dummy jwt" , JWT_AUDIENCE , JWT_ISSUER )).thenReturn (response );
120139
121140 var handler = attestationMiddleware .handle (nextHandler , Role .OPERATOR , Role .SUPER_USER );
@@ -130,7 +149,8 @@ void trustedValidJwtMissingRequiredRoleReturns401() throws JwtService.Validation
130149 var attestationMiddleware = getAttestationMiddleware (true );
131150 JwtValidationResponse response = new JwtValidationResponse (true )
132151 .withRoles (Role .OPTOUT )
133- .withSubject (EXPECTED_OPERATOR_KEY_HASH_DIGEST );
152+ .withSubject (EXPECTED_OPERATOR_KEY_HASH_DIGEST )
153+ .withJti ("dummyJti" );
134154 when (this .jwtService .validateJwt ("dummy jwt" , JWT_AUDIENCE , JWT_ISSUER )).thenReturn (response );
135155
136156 var handler = attestationMiddleware .handle (nextHandler , Role .OPERATOR );
0 commit comments