-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from ADORSYS-GIS/ensure-that-OB-can-access-the…
…-module-ledger-bank-account-rest-api Ensure that ob can access the module ledger bank account rest api
- Loading branch information
Showing
28 changed files
with
3,367 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
obs/obs-rest-server/src/test/java/com/adorsys/webank/obs/Config/WebConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.adorsys.webank.obs.Config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class WebConfig { | ||
|
||
@Bean | ||
public WebMvcConfigurer corsConfigurer() { | ||
return new WebMvcConfigurer() { | ||
@Override | ||
public void addCorsMappings(CorsRegistry registry) { | ||
registry.addMapping("/**") // Applies to all endpoints | ||
.allowedOrigins("http://localhost:5173") // Replace with your frontend URL | ||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") | ||
.allowedHeaders("*") | ||
.allowCredentials(true); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +0,0 @@ | ||
package com.adorsys.webank.obs.resource; | ||
|
||
import com.adorsys.webank.obs.dto.RegistrationRequest; | ||
import com.adorsys.webank.obs.service.RegistrationServiceApi; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class RegistrationResourceTest { | ||
|
||
@InjectMocks | ||
private RegistrationResource registrationResource; // Class under test | ||
|
||
@Mock | ||
private RegistrationServiceApi registrationService; // Mocked dependency | ||
|
||
@BeforeEach | ||
void setUp() { | ||
MockitoAnnotations.openMocks(this); | ||
} | ||
|
||
@Test | ||
void registerAccount_ShouldReturnSuccessfulResponse() { | ||
// Arrange | ||
RegistrationRequest registrationRequest = new RegistrationRequest(); | ||
registrationRequest.setPhoneNumber(1234567890); | ||
registrationRequest.setPublicKey("testPublicKey"); | ||
|
||
String expectedResponse = "Registration successful"; | ||
when(registrationService.registerAccount(registrationRequest)).thenReturn(expectedResponse); | ||
|
||
// Act | ||
ResponseEntity<String> responseEntity = registrationResource.registerAccount(registrationRequest); | ||
|
||
// Assert | ||
assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); | ||
assertEquals(expectedResponse, responseEntity.getBody()); | ||
} | ||
} | ||
16 changes: 16 additions & 0 deletions
16
obs/obs-rest-server/src/test/java/com/adorsys/webank/obs/resource/StarterIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.adorsys.webank.obs.resource; | ||
|
||
import | ||
org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest(classes = TestOnlineBankingApplication.class) | ||
public class StarterIT { | ||
|
||
@Test | ||
|
||
void start() { | ||
assert true; | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
...st-server/src/test/java/com/adorsys/webank/obs/resource/TestOnlineBankingApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.adorsys.webank.obs.resource; | ||
|
||
import com.adorsys.webank.obs.EnableObsServiceimpl; | ||
|
||
|
||
import de.adorsys.ledgers.postings.impl.EnablePostingService; | ||
import de.adorsys.webank.bank.api.service.BankAccountInitService; | ||
import de.adorsys.webank.bank.api.service.EnableBankAccountService; | ||
import de.adorsys.webank.bank.server.utils.client.ExchangeRateClient; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; | ||
import org.springframework.boot.context.event.ApplicationReadyEvent; | ||
import org.springframework.cloud.openfeign.EnableFeignClients; | ||
import org.springframework.context.ApplicationListener; | ||
|
||
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class}) | ||
@EnableBankAccountService | ||
@EnableObsServiceimpl | ||
@EnablePostingService | ||
@EnableFeignClients(basePackageClasses = ExchangeRateClient.class) | ||
public class TestOnlineBankingApplication implements ApplicationListener<ApplicationReadyEvent> { | ||
|
||
private final BankAccountInitService bankInitService; | ||
|
||
@Autowired | ||
public TestOnlineBankingApplication(BankAccountInitService bankInitService) { | ||
this.bankInitService = bankInitService; | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(TestOnlineBankingApplication.class, args); | ||
} | ||
|
||
@Override | ||
public void onApplicationEvent(@NotNull ApplicationReadyEvent event) { | ||
bankInitService.initConfigData(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
obs/obs-rest-server/src/test/java/com/adorsys/webank/obs/resource/mockbank/Config.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2018-2024 adorsys GmbH and Co. KG | ||
* All rights are reserved. | ||
*/ | ||
|
||
package com.adorsys.webank.obs.resource.mockbank; | ||
|
||
@org.springframework.context.annotation.Configuration | ||
public class Config { | ||
@org.springframework.context.annotation.Bean | ||
public MockBankConfigSource configSource() { | ||
return new MockBankConfigSource(); | ||
} | ||
|
||
@org.springframework.context.annotation.Bean | ||
public java.security.Principal getPrincipal(){ | ||
return () -> "anonymous"; | ||
} | ||
|
||
@org.springframework.context.annotation.Bean | ||
public com.fasterxml.jackson.databind.ObjectMapper objectMapper() { | ||
return new com.fasterxml.jackson.databind.ObjectMapper() | ||
.configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | ||
|
||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...t-server/src/test/java/com/adorsys/webank/obs/resource/mockbank/MockBankConfigSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2018-2024 adorsys GmbH and Co. KG | ||
* All rights are reserved. | ||
*/ | ||
|
||
package com.adorsys.webank.obs.resource.mockbank; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | ||
import de.adorsys.webank.bank.api.service.domain.ASPSPConfigData; | ||
import de.adorsys.webank.bank.api.service.domain.ASPSPConfigSource; | ||
import de.adorsys.webank.bank.api.service.domain.LedgerAccountModel; | ||
|
||
|
||
//@Component | ||
public class MockBankConfigSource implements ASPSPConfigSource { | ||
private ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); | ||
|
||
@Override | ||
public ASPSPConfigData aspspConfigData() { | ||
java.io.InputStream inputStream = MockBankConfigSource.class.getResourceAsStream("aspsps-config.yml"); | ||
try { | ||
return mapper.readValue(inputStream,ASPSPConfigData.class); | ||
} catch (java.io.IOException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public java.util.List<LedgerAccountModel> chartOfAccount(String coaFile) { | ||
java.io.InputStream inputStream = MockBankConfigSource.class.getResourceAsStream(coaFile); | ||
LedgerAccountModel[] ledgerAccounts; | ||
try { | ||
ledgerAccounts = mapper.readValue(inputStream, LedgerAccountModel[].class); | ||
} catch (java.io.IOException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
return java.util.Arrays.asList(ledgerAccounts); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
obs/obs-rest-server/src/test/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# H2 Database Configuration | ||
spring.h2.console.enabled=true | ||
spring.datasource.url=jdbc:h2:mem:testdb | ||
|
||
# Swagger Configuration | ||
springdoc.api-docs.path=/api-docs | ||
springdoc.swagger-ui.path=/swagger-ui.html | ||
|
||
# Additional Settings (if needed) | ||
spring.datasource.driver-class-name=org.h2.Driver | ||
spring.datasource.username=sa | ||
spring.datasource.password= | ||
|
||
# Hibernate DDL auto (update, create-drop, validate, etc.) | ||
spring.jpa.hibernate.ddl-auto=update |
46 changes: 46 additions & 0 deletions
46
...rest-server/src/test/resources/com/adorsys/webank/obs/resource/mockbank/aspsps-config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: mockbank | ||
ledger: mockbank | ||
coaFile: sample_coa_banking.yml | ||
coaExtensions: | ||
### Hello Bank | ||
- shortDesc: Hello Bank | ||
name: 11240 | ||
parent: 1124 | ||
### Clearing account as subaccount of Deposits with Centralbank - Non-Interest bearing | ||
- shortDesc: SEPA-Clearing Account (sepa-credit-transfers) | ||
name: 11031 | ||
parent: 1103 | ||
- shortDesc: INSTANT_SEPA-Clearing Account (instant-sepa-credit-transfers) | ||
name: 11032 | ||
parent: 1103 | ||
- shortDesc: TARGET2-Clearing Account (target-2-payments) | ||
name: 11033 | ||
parent: 1103 | ||
- shortDesc: CROSS_BORDER-Clearing Account (cross-border-credit-transfers) | ||
name: 11034 | ||
parent: 1103 | ||
### Sample Bank Account Bank account Natural persons (households), residents, Interest bearing | ||
- shortDesc: Bank Account Marion Mueller | ||
name: DE69760700240340283600 | ||
parent: 2332 | ||
- shortDesc: Bank Account Anton Brueckner | ||
name: DE80760700240271232400 | ||
parent: 2332 | ||
- shortDesc: Bank Account Max Musterman | ||
name: DE38760700240320465700 | ||
parent: 2332 | ||
### Payment products supported. | ||
clearingAccounts: | ||
- paymentProduct: SEPA | ||
accountNbr: 11031 | ||
- paymentProduct: INSTANT_SEPA | ||
accountNbr: 11032 | ||
- paymentProduct: TARGET2 | ||
accountNbr: 11033 | ||
- paymentProduct: CROSS_BORDER | ||
accountNbr: 11034 | ||
bankParentAccount: 2332 | ||
|
||
|
||
### Marker used to prevent repeated processing of this config file. | ||
updateMarkerAccountNbr: 2320 |
Oops, something went wrong.