Skip to content

Commit

Permalink
OBG-1234 add e2e test with consent from fintech
Browse files Browse the repository at this point in the history
  • Loading branch information
max402 committed Jul 14, 2021
1 parent 5686a79 commit a357286
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { Location } from '@angular/common';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { ConsentSettingType, LoARetrievalInformation, LoTRetrievalInformation } from '../../models/consts';
import { StorageService } from '../../services/storage.service';
import { AisConsentRequest, FinTechAccountInformationService } from '../../api';
import { AisAccountAccessInfo, AisConsentRequest, FinTechAccountInformationService } from '../../api';
import AllPsd2Enum = AisAccountAccessInfo.AllPsd2Enum;

@Component({
selector: 'app-settings',
Expand Down Expand Up @@ -67,7 +68,7 @@ export class SettingsComponent implements OnInit {
consent: JSON.parse(data.consent),
...(data.consentSettingType === this.consentTypeDefault && {
consent: {
access: {},
access: { allPsd2: AllPsd2Enum.ACCOUNTSWITHBALANCES },
combinedServiceIndicator: data.combinedServiceIndicator,
frequencyPerDay: data.frequencyPerDay,
recurringIndicator: data.recurringIndicator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,48 @@ public void testTransactionListWithConsentUsingRedirectUsingEndpointWithoutResou
);
}

@ParameterizedTest
@EnumSource(Approach.class)
public void testTransactionListWithConsentUsingRedirectUsingFintechConsentHeader(Approach expectedApproach, FirefoxDriver firefoxDriver) {

given()
.enabled_redirect_sandbox_mode()
.preferred_sca_approach_selected_for_all_banks_in_opba(expectedApproach)
.rest_assured_points_to_opba_server_with_fintech_signer_on_banking_api()
.user_registered_in_opba_with_credentials(OPBA_LOGIN, OPBA_PASSWORD);

when()
.fintech_calls_list_transactions_for_anton_brueckner_with_consent_header()
.and()
.user_logged_in_into_opba_as_opba_user_with_credentials_using_fintech_supplied_url(OPBA_LOGIN, OPBA_PASSWORD)
.and()
.user_anton_brueckner_provided_initial_parameters_to_list_transactions_no_consent()
.and()
.user_anton_brueckner_sees_that_he_needs_to_be_redirected_to_aspsp_and_redirects_to_aspsp()
.and()
.sandbox_anton_brueckner_navigates_to_bank_auth_page(firefoxDriver)
.and()
.sandbox_anton_brueckner_inputs_username_and_password(firefoxDriver)
.and()
.sandbox_anton_brueckner_confirms_consent_information(firefoxDriver)
.and()
.sandbox_anton_brueckner_selects_sca_method(firefoxDriver)
.and()
.sandbox_anton_brueckner_provides_sca_challenge_result(firefoxDriver)
.and()
.sandbox_anton_brueckner_clicks_redirect_back_to_tpp_button_api_localhost_cookie_only(firefoxDriver);

AccountInformationResult<? extends AccountInformationResult<?>> accountsResult = then()
.open_banking_has_consent_for_anton_brueckner_transaction_list()
.fintech_calls_consent_activation_for_current_authorization_id()
.open_banking_can_read_anton_brueckner_account_data_using_consent_bound_to_service_session(false);
String accountResourceId = JsonPath.parse(accountsResult.getResponseContent()).read("$.accounts[0].resourceId");
then()
.open_banking_reads_anton_brueckner_transactions_using_consent_bound_to_service_session_data_validated_by_iban(
accountResourceId, DATE_FROM, DATE_TO, BOTH_BOOKING
);
}

@ParameterizedTest
@EnumSource(Approach.class)
void testAccountsListWithConsentUsingEmbedded(Approach expectedApproach) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import static de.adorsys.opba.protocol.xs2a.tests.e2e.stages.StagesCommonUtil.withDefaultHeaders;
import static de.adorsys.opba.protocol.xs2a.tests.e2e.stages.StagesCommonUtil.withTransactionsHeaders;
import static de.adorsys.opba.restapi.shared.HttpHeaders.SERVICE_SESSION_ID;
import static de.adorsys.opba.restapi.shared.HttpHeaders.X_CREATE_CONSENT_IF_NONE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.http.HttpStatus.ACCEPTED;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
Expand Down Expand Up @@ -170,6 +171,22 @@ public SELF fintech_calls_list_transactions_for_anton_brueckner() {
return self();
}

public SELF fintech_calls_list_transactions_for_anton_brueckner_with_consent_header() {
ExtractableResponse<Response> response = withTransactionsHeaders(ANTON_BRUECKNER)
.header(SERVICE_SESSION_ID, UUID.randomUUID().toString())
.header(X_CREATE_CONSENT_IF_NONE, "{\"recurringIndicator\": true, \"combinedServiceIndicator\": false, \"access\": {\"transactions\": [{\"iban\": \"DE80760700240271232400\", \"currency\": \"EUR\"}]}, \"frequencyPerDay\": 12, \"validUntil\": \"2030-01-31\"}")
.when()
.get(AIS_TRANSACTIONS_WITHOUT_RESOURCE_ID_ENDPOINT)
.then()
.statusCode(ACCEPTED.value())
.extract();

updateServiceSessionId(response);
updateRedirectCode(response);
updateNextConsentAuthorizationUrl(response);
return self();
}

public SELF fintech_calls_list_transactions_for_anton_brueckner(String resourceId) {
return fintech_calls_list_transactions_for_user(ANTON_BRUECKNER, resourceId);
}
Expand Down Expand Up @@ -328,6 +345,15 @@ public SELF user_anton_brueckner_provided_initial_parameters_to_list_transaction
return self();
}

public SELF user_anton_brueckner_provided_initial_parameters_to_list_transactions_no_consent() {
startInitialInternalConsentAuthorization(
AUTHORIZE_CONSENT_ENDPOINT,
readResource("restrecord/tpp-ui-input/params/anton-brueckner-transactions-no-consent.json")
);

return self();
}

public SELF user_provided_initial_parameters_to_list_transactions_with_single_account_consent(String user) {
startInitialInternalConsentAuthorization(
AUTHORIZE_CONSENT_ENDPOINT,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extras": {
"PSU_ID": "anton.brueckner"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class HttpHeaders {
public static final String COOKIE_TTL = "Cookie-TTL";
public static final String COMPUTE_PSU_IP_ADDRESS = "Compute-PSU-IP-Address";
public static final String X_XSRF_TOKEN = "X-XSRF-TOKEN";
public static final String X_CREATE_CONSENT_IF_NONE = "X-Create-Consent-If-None";

@UtilityClass
public class UserAgentContext {
Expand Down

0 comments on commit a357286

Please sign in to comment.