From 3e1267cde3c064d1d1b36f31f7fe456bae77832b Mon Sep 17 00:00:00 2001 From: Maxim Grischenko Date: Wed, 23 Jun 2021 11:45:40 +0200 Subject: [PATCH] OBG-1234 fix ui-tests --- .../consent-initiate.component.ts | 3 +- .../list-accounts/list-accounts.component.ts | 76 ++++++++++--------- .../list.accounts.component.spec.ts | 4 +- .../list-transactions.component.ts | 15 +++- .../list.transactions.component.spec.ts | 4 +- .../src/app/bank/services/ais.service.spec.ts | 11 ++- .../src/app/bank/services/ais.service.ts | 10 ++- .../app/bank/settings/settings.component.ts | 2 +- 8 files changed, 76 insertions(+), 49 deletions(-) diff --git a/consent-ui/src/app/ais/entry-page/initiation/consent-initiate/consent-initiate.component.ts b/consent-ui/src/app/ais/entry-page/initiation/consent-initiate/consent-initiate.component.ts index 9ced3c1027..99ae94c8b8 100644 --- a/consent-ui/src/app/ais/entry-page/initiation/consent-initiate/consent-initiate.component.ts +++ b/consent-ui/src/app/ais/entry-page/initiation/consent-initiate/consent-initiate.component.ts @@ -57,8 +57,7 @@ export class ConsentInitiateComponent implements OnInit { this.sessionService.setRedirectCode(authorizationId, res.headers.get(ApiHeaders.REDIRECT_CODE)); - let consent = {"consent":{"access":{"allPsd2":"ALL_ACCOUNTS_WITH_BALANCES"},"frequencyPerDay":4,"validUntil":"2021-06-18","recurringIndicator":true,"combinedServiceIndicator":false}}; - this.sessionService.setConsentObject(authorizationId, consent); + this.sessionService.setConsentObject(authorizationId, res.body); this.navigate(authorizationId, res.body); }); } diff --git a/fintech-examples/fintech-ui/src/app/bank/list-accounts/list-accounts.component.ts b/fintech-examples/fintech-ui/src/app/bank/list-accounts/list-accounts.component.ts index 577b02cc31..0ac7709281 100644 --- a/fintech-examples/fintech-ui/src/app/bank/list-accounts/list-accounts.component.ts +++ b/fintech-examples/fintech-ui/src/app/bank/list-accounts/list-accounts.component.ts @@ -1,12 +1,11 @@ import { Component, OnInit } from '@angular/core'; -import {AccountDetails, AisAccountAccessInfo, AisConsentRequest} from '../../api'; +import { AccountDetails, AisAccountAccessInfo, AisConsentRequest } from '../../api'; import { ActivatedRoute, Router } from '@angular/router'; import { AisService } from '../services/ais.service'; import { AccountStruct, RedirectStruct, RedirectType } from '../redirect-page/redirect-struct'; import { Consts, HeaderConfig } from '../../models/consts'; import { StorageService } from '../../services/storage.service'; import AllPsd2Enum = AisAccountAccessInfo.AllPsd2Enum; -import AvailableAccountsEnum = AisAccountAccessInfo.AvailableAccountsEnum; @Component({ selector: 'app-list-accounts', @@ -38,7 +37,7 @@ export class ListAccountsComponent implements OnInit { const online = !this.storageService.isAfterRedirect() && !settings.cacheLoa; this.storageService.setAfterRedirect(false); - let consent: AisConsentRequest = { + const consent: AisConsentRequest = { access: { allPsd2: AllPsd2Enum.ACCOUNTSWITHBALANCES }, @@ -46,37 +45,46 @@ export class ListAccountsComponent implements OnInit { validUntil: settings.validUntil, recurringIndicator: settings.recurringIndicator, combinedServiceIndicator: settings.combinedServiceIndicator - } + }; - this.aisService.getAccounts(this.bankId, settings.loa, JSON.stringify(consent), settings.withBalance, online, settings.consentRequiresAuthentication).subscribe((response) => { - switch (response.status) { - case 202: - this.storageService.setRedirect( - response.headers.get(HeaderConfig.HEADER_FIELD_REDIRECT_CODE), - response.headers.get(HeaderConfig.HEADER_FIELD_AUTH_ID), - response.headers.get(HeaderConfig.HEADER_FIELD_X_XSRF_TOKEN), - parseInt(response.headers.get(HeaderConfig.HEADER_FIELD_REDIRECT_X_MAX_AGE), 0), - RedirectType.AIS - ); - const r = new RedirectStruct(); - r.redirectUrl = encodeURIComponent(response.headers.get(HeaderConfig.HEADER_FIELD_LOCATION)); - r.redirectCode = response.headers.get(HeaderConfig.HEADER_FIELD_REDIRECT_CODE); - r.bankId = this.bankId; - r.bankName = this.storageService.getBankName(); - this.router.navigate(['redirect', JSON.stringify(r)], { relativeTo: this.route }); - break; - case 200: - // this is added to register url where to forward - // if LoT is cancelled after redirect page is displayed - // to be removed when issue https://github.com/adorsys/open-banking-gateway/issues/848 is resolved - // or Fintech UI refactored - this.accounts = response.body.accounts; - const loa = []; - for (const accountDetail of this.accounts) { - loa.push(new AccountStruct(accountDetail.resourceId, accountDetail.iban, accountDetail.name)); - } - this.storageService.setLoa(this.bankId, loa); - } - }); + this.aisService + .getAccounts( + this.bankId, + settings.loa, + JSON.stringify(consent), + settings.withBalance, + online, + settings.consentRequiresAuthentication + ) + .subscribe((response) => { + switch (response.status) { + case 202: + this.storageService.setRedirect( + response.headers.get(HeaderConfig.HEADER_FIELD_REDIRECT_CODE), + response.headers.get(HeaderConfig.HEADER_FIELD_AUTH_ID), + response.headers.get(HeaderConfig.HEADER_FIELD_X_XSRF_TOKEN), + parseInt(response.headers.get(HeaderConfig.HEADER_FIELD_REDIRECT_X_MAX_AGE), 0), + RedirectType.AIS + ); + const r = new RedirectStruct(); + r.redirectUrl = encodeURIComponent(response.headers.get(HeaderConfig.HEADER_FIELD_LOCATION)); + r.redirectCode = response.headers.get(HeaderConfig.HEADER_FIELD_REDIRECT_CODE); + r.bankId = this.bankId; + r.bankName = this.storageService.getBankName(); + this.router.navigate(['redirect', JSON.stringify(r)], { relativeTo: this.route }); + break; + case 200: + // this is added to register url where to forward + // if LoT is cancelled after redirect page is displayed + // to be removed when issue https://github.com/adorsys/open-banking-gateway/issues/848 is resolved + // or Fintech UI refactored + this.accounts = response.body.accounts; + const loa = []; + for (const accountDetail of this.accounts) { + loa.push(new AccountStruct(accountDetail.resourceId, accountDetail.iban, accountDetail.name)); + } + this.storageService.setLoa(this.bankId, loa); + } + }); } } diff --git a/fintech-examples/fintech-ui/src/app/bank/list-accounts/list.accounts.component.spec.ts b/fintech-examples/fintech-ui/src/app/bank/list-accounts/list.accounts.component.spec.ts index dd673815f4..e0401a07a8 100644 --- a/fintech-examples/fintech-ui/src/app/bank/list-accounts/list.accounts.component.spec.ts +++ b/fintech-examples/fintech-ui/src/app/bank/list-accounts/list.accounts.component.spec.ts @@ -55,10 +55,10 @@ describe('ListAccountsComponent', () => { const mockAccounts: HttpResponse = {} as HttpResponse; spyOn(aisService, 'getAccounts') - .withArgs(bankId, loaRetrievalInformation, false, true, true) + .withArgs(bankId, loaRetrievalInformation, '', false, true, true) .and.returnValue(of(mockAccounts)); expect(component.bankId).toEqual(bankId); - aisService.getAccounts(bankId, loaRetrievalInformation, false, true, true).subscribe((res) => { + aisService.getAccounts(bankId, loaRetrievalInformation, '', false, true, true).subscribe((res) => { expect(res).toEqual(mockAccounts); }); }); diff --git a/fintech-examples/fintech-ui/src/app/bank/list-transactions/list-transactions.component.ts b/fintech-examples/fintech-ui/src/app/bank/list-transactions/list-transactions.component.ts index c1d2b92d09..951ce48613 100644 --- a/fintech-examples/fintech-ui/src/app/bank/list-transactions/list-transactions.component.ts +++ b/fintech-examples/fintech-ui/src/app/bank/list-transactions/list-transactions.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { AisService } from '../services/ais.service'; -import {AccountReport, AisAccountAccessInfo, AisConsentRequest} from '../../api'; +import { AccountReport, AisAccountAccessInfo, AisConsentRequest } from '../../api'; import { RedirectStruct, RedirectType } from '../redirect-page/redirect-struct'; import { Consts, HeaderConfig } from '../../models/consts'; import { StorageService } from '../../services/storage.service'; @@ -39,7 +39,7 @@ export class ListTransactionsComponent implements OnInit { const settings = this.storageService.getSettings(); const online = !this.storageService.isAfterRedirect() && !settings.cacheLot; - let consent: AisConsentRequest = { + const consent: AisConsentRequest = { access: { allPsd2: AllPsd2Enum.ACCOUNTSWITHBALANCES }, @@ -47,10 +47,17 @@ export class ListTransactionsComponent implements OnInit { validUntil: settings.validUntil, recurringIndicator: settings.recurringIndicator, combinedServiceIndicator: settings.combinedServiceIndicator - } + }; this.aisService - .getTransactions(this.bankId, this.accountId, settings.lot, JSON.stringify(consent), online, settings.consentRequiresAuthentication) + .getTransactions( + this.bankId, + this.accountId, + settings.lot, + JSON.stringify(consent), + online, + settings.consentRequiresAuthentication + ) .subscribe((response) => { switch (response.status) { case 202: diff --git a/fintech-examples/fintech-ui/src/app/bank/list-transactions/list.transactions.component.spec.ts b/fintech-examples/fintech-ui/src/app/bank/list-transactions/list.transactions.component.spec.ts index 3b140b5301..92364b5f24 100644 --- a/fintech-examples/fintech-ui/src/app/bank/list-transactions/list.transactions.component.spec.ts +++ b/fintech-examples/fintech-ui/src/app/bank/list-transactions/list.transactions.component.spec.ts @@ -62,10 +62,10 @@ describe('ListTransactionsComponent', () => { const loTRetrievalInformation: LoTRetrievalInformation = LoTRetrievalInformation.FROM_TPP_WITH_AVAILABLE_CONSENT; spyOn(aisService, 'getTransactions') - .withArgs(bankId, accountId, loTRetrievalInformation, true, true) + .withArgs(bankId, accountId, loTRetrievalInformation, '', true, true) .and.returnValue(of(mockTransactions)); expect(component.bankId).toEqual(bankId); - aisService.getTransactions(bankId, accountId, loTRetrievalInformation, true, true).subscribe((res) => { + aisService.getTransactions(bankId, accountId, loTRetrievalInformation, '', true, true).subscribe((res) => { expect(res).toEqual(mockTransactions); }); }); diff --git a/fintech-examples/fintech-ui/src/app/bank/services/ais.service.spec.ts b/fintech-examples/fintech-ui/src/app/bank/services/ais.service.spec.ts index cbc14076f1..7a968c541c 100644 --- a/fintech-examples/fintech-ui/src/app/bank/services/ais.service.spec.ts +++ b/fintech-examples/fintech-ui/src/app/bank/services/ais.service.spec.ts @@ -26,13 +26,20 @@ describe('AisService', () => { it('should get accounts', () => { const getAccountsSpy = spyOn(aisService, 'getAccounts'); - aisService.getAccounts('1234', LoARetrievalInformation.FROM_TPP_WITH_AVAILABLE_CONSENT, true, false, true); + aisService.getAccounts('1234', LoARetrievalInformation.FROM_TPP_WITH_AVAILABLE_CONSENT, '', true, false, true); expect(getAccountsSpy).toHaveBeenCalled(); }); it('should get transactions', () => { const getTransactionsSpy = spyOn(aisService, 'getTransactions'); - aisService.getTransactions('1234', 'xxxxxxxxxx', LoTRetrievalInformation.FROM_TPP_WITH_AVAILABLE_CONSENT, false, true); + aisService.getTransactions( + '1234', + 'xxxxxxxxxx', + LoTRetrievalInformation.FROM_TPP_WITH_AVAILABLE_CONSENT, + '', + false, + true + ); expect(getTransactionsSpy).toHaveBeenCalled(); }); }); diff --git a/fintech-examples/fintech-ui/src/app/bank/services/ais.service.ts b/fintech-examples/fintech-ui/src/app/bank/services/ais.service.ts index f7c73d2ef9..ee76b2fea3 100644 --- a/fintech-examples/fintech-ui/src/app/bank/services/ais.service.ts +++ b/fintech-examples/fintech-ui/src/app/bank/services/ais.service.ts @@ -12,8 +12,14 @@ export class AisService { return toConvert.toISOString().split('T')[0]; } - getAccounts(bankId: string, loARetrievalInformation: LoARetrievalInformation, createConsentIfNone: string, withBalance: boolean, online: boolean, - authenticatePsu: boolean) { + getAccounts( + bankId: string, + loARetrievalInformation: LoARetrievalInformation, + createConsentIfNone: string, + withBalance: boolean, + online: boolean, + authenticatePsu: boolean + ) { const okurl = window.location.pathname; const notOkUrl = okurl.replace(/account.*/, ''); diff --git a/fintech-examples/fintech-ui/src/app/bank/settings/settings.component.ts b/fintech-examples/fintech-ui/src/app/bank/settings/settings.component.ts index bccaf80bbd..bf5e282bec 100644 --- a/fintech-examples/fintech-ui/src/app/bank/settings/settings.component.ts +++ b/fintech-examples/fintech-ui/src/app/bank/settings/settings.component.ts @@ -4,7 +4,7 @@ import { Location } from '@angular/common'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { LoARetrievalInformation, LoTRetrievalInformation } from '../../models/consts'; import { StorageService } from '../../services/storage.service'; -import { FinTechAccountInformationService} from "../../api"; +import { FinTechAccountInformationService } from '../../api'; @Component({ selector: 'app-settings',