1616import com .fasterxml .jackson .databind .ObjectWriter ;
1717import com .nimbusds .jwt .SignedJWT ;
1818import java .util .List ;
19- import java .util .UUID ;
2019import org .junit .jupiter .params .ParameterizedTest ;
2120import org .junit .jupiter .params .provider .FieldSource ;
2221import org .springframework .beans .factory .annotation .Autowired ;
@@ -60,7 +59,7 @@ void assertThatPostWalletUnitAttestation_givenPublicKeyAndNonce_shouldReturnOk(S
6059 """ ;
6160 String nonce = "123123123123" ;
6261 WalletUnitAttestationDto input =
63- new WalletUnitAttestationDto (UUID . randomUUID (), jwk , nonce );
62+ new WalletUnitAttestationDto (jwk , nonce );
6463
6564 mockMvc
6665 .perform (
@@ -71,6 +70,34 @@ void assertThatPostWalletUnitAttestation_givenPublicKeyAndNonce_shouldReturnOk(S
7170 .andExpect (content ().string (expectedJwt ));
7271 }
7372
73+ @ ParameterizedTest
74+ @ FieldSource ("PATHS" )
75+ void assertThatPostWalletUnitAttestation_givenIncorrectDatatype_shouldReturnBadRequest (
76+ String path )
77+ throws Exception {
78+
79+ String jsonString = """
80+ {
81+ "jwk":{
82+ "kty": "EC",
83+ "use": "sig",
84+ "crv": "P-256",
85+ "x": "18wHLeIgW9wVN6VD1Txgpqy2LszYkMf6J8njVAibvhM",
86+ "y": "-V4dS4UaLMgP_4fY4j8ir7cl1TXlFdAgcx55o7TkcSA"
87+ },
88+ "nonce":"123123123",
89+ "walletId":"abc"
90+ }
91+ """ ;
92+
93+ mockMvc
94+ .perform (
95+ post (path )
96+ .contentType (MediaType .APPLICATION_JSON )
97+ .content (jsonString ))
98+ .andExpect (status ().isBadRequest ());
99+ }
100+
74101 @ ParameterizedTest
75102 @ FieldSource ("PATHS" )
76103 void assertThatPostWalletUnitAttestation_givenPublicKeyAndEmptyNonce_shouldReturnOk (String path )
@@ -91,7 +118,7 @@ void assertThatPostWalletUnitAttestation_givenPublicKeyAndEmptyNonce_shouldRetur
91118 """ ;
92119 String nonce = "" ;
93120 WalletUnitAttestationDto input =
94- new WalletUnitAttestationDto (UUID . randomUUID (), jwk , nonce );
121+ new WalletUnitAttestationDto (jwk , nonce );
95122
96123 mockMvc
97124 .perform (
@@ -122,7 +149,7 @@ void assertThatPostWalletUnitAttestation_givenPublicKeyAndNullNonce_shouldReturn
122149 """ ;
123150
124151 WalletUnitAttestationDto input =
125- new WalletUnitAttestationDto (UUID . randomUUID (), jwk , null );
152+ new WalletUnitAttestationDto (jwk , null );
126153
127154 mockMvc
128155 .perform (
0 commit comments