Skip to content

Commit 27e59ba

Browse files
authored
feat: remove path for accounts v1
* chore: rename file with oidc prefix Signed-off-by: Nicklas Jannesson <extern.nicklas.jannesson@digg.se> * feat: remove /accounts/v1 api path Signed-off-by: Nicklas Jannesson <extern.nicklas.jannesson@digg.se> --------- Signed-off-by: Nicklas Jannesson <extern.nicklas.jannesson@digg.se>
1 parent c00167b commit 27e59ba

File tree

7 files changed

+19
-27
lines changed

7 files changed

+19
-27
lines changed

src/main/java/se/digg/wallet/gateway/application/controller/AccountController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import se.digg.wallet.gateway.domain.service.account.AccountService;
2020

2121
@RestController
22-
@RequestMapping({"/accounts", "/accounts/v1"})
22+
@RequestMapping("/accounts")
2323
public class AccountController {
2424
private final AccountService accountService;
2525
private final ApiKeyVerifier apiKeyVerifier;

src/main/java/se/digg/wallet/gateway/application/controller/oidc/AccountControllerV1.java renamed to src/main/java/se/digg/wallet/gateway/application/controller/oidc/OidcAccountController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
@Deprecated(forRemoval = true)
2828
@RestController
2929
@RequestMapping("/oidc/accounts/v1")
30-
public class AccountControllerV1 {
30+
public class OidcAccountController {
3131
private final AccountService accountService;
3232
private final String personalIdentityNumberClaim;
3333

34-
public AccountControllerV1(AccountService accountService, ApplicationConfig applicationConfig) {
34+
public OidcAccountController(AccountService accountService, ApplicationConfig applicationConfig) {
3535
this.accountService = accountService;
3636
this.personalIdentityNumberClaim = applicationConfig.oidcClaims().personalIdentityNumber();
3737
}

src/main/resources/application.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ properties:
1212
- "/public/**"
1313
- "/wua"
1414
- "/accounts"
15-
- "/accounts/v1"
1615
walletprovider:
1716
baseurl: http://
1817
wua-path: /wallet-unit-attestation

src/test/java/se/digg/wallet/gateway/application/controller/AccountControllerIntegrationTest.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313

1414
import com.github.tomakehurst.wiremock.WireMockServer;
1515

16-
import java.util.List;
1716
import java.util.UUID;
18-
import org.junit.jupiter.params.ParameterizedTest;
19-
import org.junit.jupiter.params.provider.FieldSource;
17+
18+
import org.junit.jupiter.api.Test;
2019
import org.springframework.beans.factory.annotation.Autowired;
2120
import org.springframework.beans.factory.annotation.Value;
2221
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureRestTestClient;
@@ -38,8 +37,6 @@
3837
@AutoConfigureRestTestClient
3938
class AccountControllerIntegrationTest {
4039

41-
public static final List<String> ACCOUNTS_PATH = List.of("accounts", "accounts/v1");
42-
4340
@Autowired
4441
private RestTestClient restClient;
4542

@@ -58,9 +55,8 @@ class AccountControllerIntegrationTest {
5855
@InjectWireMock(WalletAccountMock.NAME)
5956
private WireMockServer server;
6057

61-
@ParameterizedTest
62-
@FieldSource("ACCOUNTS_PATH")
63-
void testCreateAccount(String path) throws Exception {
58+
@Test
59+
void testCreateAccount() throws Exception {
6460
var generatedAccountId = UUID.randomUUID();
6561
var jwkString = objectMapper.writeValueAsString(JwkDtoTestBuilder.withDefaults().build());
6662

@@ -90,7 +86,7 @@ void testCreateAccount(String path) throws Exception {
9086

9187
var requestBody = CreateAccountRequestDtoTestBuilder.withDefaults().build();
9288
var response = restClient.post()
93-
.uri(path)
89+
.uri("accounts")
9490
.header(SecurityConfig.API_KEY_HEADER, applicationConfig.apisecret())
9591
.body(requestBody)
9692
.exchange();
@@ -105,16 +101,15 @@ void testCreateAccount(String path) throws Exception {
105101
""".formatted(generatedAccountId));
106102
}
107103

108-
@ParameterizedTest
109-
@FieldSource("ACCOUNTS_PATH")
110-
void testAccountReturns500IfAccountServiceRespondsWith404(String path) {
104+
@Test
105+
void testAccountReturns500IfAccountServiceRespondsWith404() {
111106
server.stubFor(post("/account")
112107
.willReturn(aResponse()
113108
.withStatus(404)));
114109

115110
var requestBody = CreateAccountRequestDtoTestBuilder.withDefaults().build();
116111
var response = restClient.post()
117-
.uri(path)
112+
.uri("accounts")
118113
.header(SecurityConfig.API_KEY_HEADER, applicationConfig.apisecret())
119114
.body(requestBody)
120115
.exchange();
@@ -123,14 +118,13 @@ void testAccountReturns500IfAccountServiceRespondsWith404(String path) {
123118
.isEqualTo(500);
124119
}
125120

126-
@ParameterizedTest
127-
@FieldSource("ACCOUNTS_PATH")
128-
void testValidation(String path) {
121+
@Test
122+
void testValidation() {
129123
var requestBody = CreateAccountRequestDtoTestBuilder.withDefaults()
130124
.emailAdress(null)
131125
.build();
132126
var response = restClient.post()
133-
.uri(path)
127+
.uri("accounts")
134128
.header(SecurityConfig.API_KEY_HEADER, applicationConfig.apisecret())
135129
.body(requestBody)
136130
.exchange();

src/test/java/se/digg/wallet/gateway/application/controller/AccountControllerV1Test.java renamed to src/test/java/se/digg/wallet/gateway/application/controller/OidcAccountControllerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
import se.digg.wallet.gateway.application.config.ApplicationConfig;
2626
import se.digg.wallet.gateway.application.config.ApplicationConfig.OidcClaims;
2727
import se.digg.wallet.gateway.application.controller.exception.BadRequestException;
28-
import se.digg.wallet.gateway.application.controller.oidc.AccountControllerV1;
28+
import se.digg.wallet.gateway.application.controller.oidc.OidcAccountController;
2929
import se.digg.wallet.gateway.application.model.CreateAccountRequestDtoTestBuilder;
3030
import se.digg.wallet.gateway.domain.service.account.AccountService;
3131

3232
@ExtendWith(MockitoExtension.class)
33-
public class AccountControllerV1Test {
33+
public class OidcAccountControllerTest {
3434

35-
private AccountControllerV1 controller;
35+
private OidcAccountController controller;
3636

3737
private AccountService service;
3838
private ApplicationConfig config;
@@ -44,7 +44,7 @@ public void beforeEach() {
4444
when(config.oidcClaims())
4545
.thenReturn(new OidcClaims("pnr"));
4646

47-
controller = new AccountControllerV1(service, config);
47+
controller = new OidcAccountController(service, config);
4848
}
4949

5050
@Test

src/test/java/se/digg/wallet/gateway/application/controller/oidc/AccountControllerV1IntegrationTest.java renamed to src/test/java/se/digg/wallet/gateway/application/controller/oidc/OidcAccountControllerIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
@Testcontainers
4343
@ActiveProfiles("test")
4444
@AutoConfigureRestTestClient
45-
class AccountControllerV1IntegrationTest {
45+
class OidcAccountControllerIntegrationTest {
4646

4747
@Container
4848
@ServiceConnection

src/test/resources/application-test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ properties:
1717
- "/public/**"
1818
- "/wua"
1919
- "/accounts"
20-
- "/accounts/v1"
2120
walletprovider:
2221
baseurl: http://localhost:${wiremock.provider.port}
2322
wua-path: /wallet-provider/wallet-unit-attestation

0 commit comments

Comments
 (0)