Skip to content

Commit d5b9b4a

Browse files
author
Hryhorii Hevorkian
committed
Merge branch 'feature/11.x/SSE_Send_specific_PSU_message_in_response_in_case_of_Decoupled_ScaApproach' into 'develop'
#1659 Send specific PSU message in response in case of Decoupled ScaApproach See merge request adorsys/xs2a/xs2a-connector-examples!699
2 parents 45952d8 + 86dd1ce commit d5b9b4a

File tree

4 files changed

+118
-1
lines changed

4 files changed

+118
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
= Release notes v.11.12
2+
3+
== Table of Contents
4+
5+
* Migrated onto new XS2A version
6+
7+
* Added specific PSU Message to response in case of Decoupled SCA approach
8+
9+
== Migrated onto new XS2A version
10+
11+
From now on, Connector uses XS2A version 11.12.
12+
13+
== Added specific PSU Message to response in case of Decoupled SCA approach
14+
15+
From now on, specific PSU message "Please check your app to continue..." is sent after authorisation start
16+
in case of `Decoupled` SCA approach

xs2a-connector/src/main/java/de/adorsys/aspsp/xs2a/connector/spi/impl/SpiMockData.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class SpiMockData {
3737
public static final List<SpiAuthenticationObject> SCA_METHODS = buildScaMethods();
3838
public static final String PSU_MESSAGE = "mocked PSU message from the bank";
3939
public static final String PSU_MESSAGE_START_AUTHORISATION = "Start authorisation mocked PSU message from the bank";
40+
public static final String DECOUPLED_PSU_MESSAGE = "Please check your app to continue...";
4041
public static final boolean FUNDS_AVAILABLE = true;
4142

4243
private static SpiLinks buildSpiLinks() {

xs2a-connector/src/main/java/de/adorsys/aspsp/xs2a/connector/spi/impl/authorisation/AbstractAuthorisationSpi.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@ public SpiResponse<SpiStartAuthorisationResponse> startAuthorisation(@NotNull Sp
9393
@NotNull String authorisationId,
9494
T businessObject,
9595
@NotNull SpiAspspConsentDataProvider aspspConsentDataProvider) {
96+
String psuMessage = (scaApproach == ScaApproach.DECOUPLED)
97+
? SpiMockData.DECOUPLED_PSU_MESSAGE
98+
: SpiMockData.PSU_MESSAGE_START_AUTHORISATION;
9699
return SpiResponse.<SpiStartAuthorisationResponse>builder()
97-
.payload(new SpiStartAuthorisationResponse(scaApproach, scaStatus, SpiMockData.PSU_MESSAGE_START_AUTHORISATION, SpiMockData.TPP_MESSAGES_START_AUTHORISATION))
100+
.payload(new SpiStartAuthorisationResponse(scaApproach, scaStatus, psuMessage, SpiMockData.TPP_MESSAGES_START_AUTHORISATION))
98101
.build();
99102
}
100103

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Copyright 2018-2021 adorsys GmbH & Co KG
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package de.adorsys.aspsp.xs2a.connector.spi.impl.authorisation;
18+
19+
import de.adorsys.aspsp.xs2a.connector.spi.impl.SpiMockData;
20+
import de.adorsys.psd2.xs2a.core.profile.ScaApproach;
21+
import de.adorsys.psd2.xs2a.core.sca.ScaStatus;
22+
import de.adorsys.psd2.xs2a.core.tpp.TppInfo;
23+
import de.adorsys.psd2.xs2a.spi.domain.SpiAspspConsentDataProvider;
24+
import de.adorsys.psd2.xs2a.spi.domain.SpiContextData;
25+
import de.adorsys.psd2.xs2a.spi.domain.authorisation.SpiStartAuthorisationResponse;
26+
import de.adorsys.psd2.xs2a.spi.domain.psu.SpiPsuData;
27+
import de.adorsys.psd2.xs2a.spi.domain.response.SpiResponse;
28+
import org.junit.jupiter.api.Test;
29+
import org.junit.jupiter.api.extension.ExtendWith;
30+
import org.mockito.Mock;
31+
import org.mockito.Mockito;
32+
import org.mockito.junit.jupiter.MockitoExtension;
33+
34+
import java.util.UUID;
35+
36+
import static org.junit.jupiter.api.Assertions.assertEquals;
37+
import static org.junit.jupiter.api.Assertions.assertNotNull;
38+
39+
@ExtendWith(MockitoExtension.class)
40+
class AbstractAuthorisationSpiTest {
41+
private static final String PSU_ID = "anton.brueckner";
42+
private static final String AUTHORISATION_ID = "authorisation Id";
43+
private static final ScaApproach DECOUPLED_APPROACH = ScaApproach.DECOUPLED;
44+
private static final ScaApproach NON_DECOUPLED_APPROACH = ScaApproach.EMBEDDED;
45+
private static final ScaStatus SCA_STATUS = ScaStatus.PSUAUTHENTICATED;
46+
private static final SpiPsuData PSU_ID_DATA_1 = SpiPsuData.builder()
47+
.psuId(PSU_ID)
48+
.psuIdType("2")
49+
.psuCorporateId("3")
50+
.psuCorporateIdType("4")
51+
.psuIpAddress("5")
52+
.psuIpPort("6")
53+
.psuUserAgent("7")
54+
.psuGeoLocation("8")
55+
.psuAccept("9")
56+
.psuAcceptCharset("10")
57+
.psuAcceptEncoding("11")
58+
.psuAcceptLanguage("12")
59+
.psuHttpMethod("13")
60+
.psuDeviceId(UUID.randomUUID())
61+
.build();
62+
private static final String ACCESS_TOKEN = "access_token";
63+
private static final SpiContextData SPI_CONTEXT_DATA = new SpiContextData(PSU_ID_DATA_1, new TppInfo(), UUID.randomUUID(), UUID.randomUUID(), ACCESS_TOKEN, null, null, null, null);
64+
65+
private final AbstractAuthorisationSpi authorisationSpi = Mockito.mock(AbstractAuthorisationSpi.class, Mockito.CALLS_REAL_METHODS);
66+
67+
@Mock
68+
private SpiAspspConsentDataProvider spiAspspConsentDataProvider;
69+
70+
@Test
71+
void startAuthorisation_decoupledApproach() {
72+
//Given
73+
String expected = SpiMockData.DECOUPLED_PSU_MESSAGE;
74+
75+
//When
76+
SpiResponse<SpiStartAuthorisationResponse> actual =
77+
authorisationSpi.startAuthorisation(SPI_CONTEXT_DATA, DECOUPLED_APPROACH, SCA_STATUS, AUTHORISATION_ID, null, spiAspspConsentDataProvider);
78+
79+
//Then
80+
assertNotNull(actual.getPayload());
81+
assertEquals(expected, actual.getPayload().getPsuMessage());
82+
}
83+
84+
@Test
85+
void startAuthorisation_nonDecoupledApproach() {
86+
//Given
87+
String expected = SpiMockData.PSU_MESSAGE_START_AUTHORISATION;
88+
89+
//When
90+
SpiResponse<SpiStartAuthorisationResponse> actual =
91+
authorisationSpi.startAuthorisation(SPI_CONTEXT_DATA, NON_DECOUPLED_APPROACH, SCA_STATUS, AUTHORISATION_ID, null, spiAspspConsentDataProvider);
92+
93+
//Then
94+
assertNotNull(actual.getPayload());
95+
assertEquals(expected, actual.getPayload().getPsuMessage());
96+
}
97+
}

0 commit comments

Comments
 (0)