Skip to content

Commit c296d50

Browse files
chore: remove walletId from WalletUnitAttestationDto (#43)
Signed-off-by: Erik Eriksson <erik.eriksson@digg.se>
1 parent 267ae4b commit c296d50

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

src/main/java/se/digg/wallet/provider/application/model/WalletUnitAttestationDto.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@
44

55
package se.digg.wallet.provider.application.model;
66

7-
import java.util.UUID;
8-
9-
public record WalletUnitAttestationDto(UUID walletId, String jwk, String nonce) {
7+
public record WalletUnitAttestationDto(String jwk, String nonce) {
108
}

src/test/java/se/digg/wallet/provider/application/controller/WalletUnitAttestationControllerTest.java

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import com.fasterxml.jackson.databind.ObjectWriter;
1717
import com.nimbusds.jwt.SignedJWT;
1818
import java.util.List;
19-
import java.util.UUID;
2019
import org.junit.jupiter.params.ParameterizedTest;
2120
import org.junit.jupiter.params.provider.FieldSource;
2221
import 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(

src/test/java/se/digg/wallet/provider/application/service/WalletUnitAttestationServiceTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ private static void verifyAttestedKeysClaim(SignedJWT jwt, ECKey jwk) throws Par
6767
assertEquals(jwk.getCurve().toString(), attestedKey.get("crv"));
6868
}
6969

70-
@SuppressWarnings("unchecked")
7170
@Test
7271
void assertThatCreateWalletUnitAttestation_givenValidJwk_shouldSucceed() throws Exception {
7372
ECKey jwk = createJWK();

0 commit comments

Comments
 (0)