diff --git a/.github/workflows/create-release-tag.yaml b/.github/workflows/create-release-tag.yaml new file mode 100644 index 000000000..db8be09a9 --- /dev/null +++ b/.github/workflows/create-release-tag.yaml @@ -0,0 +1,55 @@ +name: Release + +on: + workflow_dispatch: + inputs: + release-version: + description: "Release version (e.g., 1.0.1). A tag will be created with the format v" + required: true + snapshot-version: + description: "Snapshot version (e.g., 1.0.2-SNAPSHOT). Snapshot version for the next development iteration." + required: true + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' + + - name: Configure Git user as workflow triggerer + run: | + git config user.name "${{ github.actor }}" + git config user.email "${{ github.actor }}@users.noreply.github.com" + + - name: Remove -SNAPSHOT for release + run: | + echo "Updating versions to release version..." + mvn versions:set -DnewVersion=${{ github.event.inputs.release-version }} -DprocessAllModules + mvn versions:commit + git commit -am "Prepare for the release ${{ github.event.inputs.release-version }}" + + - name: Create a Git tag for the release + run: | + echo "Creating a Git tag for the release..." + git tag v${{ github.event.inputs.release-version }} + + - name: Increment to SNAPSHOT version + run: | + echo "Incrementing to the next development version..." + mvn versions:set -DnewVersion=${{ github.event.inputs.snapshot-version }} -DprocessAllModules + mvn versions:commit + git commit -am "Prepare for the development iteration ${{ github.event.inputs.snapshot-version }}" + + - name: Push changes and tags + run: | + echo "Pushing version update and tags to the repository..." + git push origin main + git push origin --tags diff --git a/components/org.wso2.openbanking.cds.common/pom.xml b/components/org.wso2.openbanking.cds.common/pom.xml index f7c9d35db..8e0c64cba 100644 --- a/components/org.wso2.openbanking.cds.common/pom.xml +++ b/components/org.wso2.openbanking.cds.common/pom.xml @@ -23,7 +23,7 @@ reference-implementation-consumerdatastandards-au-components org.wso2.openbanking - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml 4.0.0 diff --git a/components/org.wso2.openbanking.cds.consent.extensions/pom.xml b/components/org.wso2.openbanking.cds.consent.extensions/pom.xml index 9d80fa5ef..3b522d829 100644 --- a/components/org.wso2.openbanking.cds.consent.extensions/pom.xml +++ b/components/org.wso2.openbanking.cds.consent.extensions/pom.xml @@ -22,7 +22,7 @@ reference-implementation-consumerdatastandards-au-components org.wso2.openbanking - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml 4.0.0 diff --git a/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/event/executor/CDSConsentEventExecutor.java b/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/event/executor/CDSConsentEventExecutor.java index 6532aeb3a..8edb81489 100644 --- a/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/event/executor/CDSConsentEventExecutor.java +++ b/components/org.wso2.openbanking.cds.consent.extensions/src/main/java/org/wso2/openbanking/cds/consent/extensions/event/executor/CDSConsentEventExecutor.java @@ -20,11 +20,14 @@ import com.wso2.openbanking.accelerator.common.event.executor.OBEventExecutor; import com.wso2.openbanking.accelerator.common.event.executor.model.OBEvent; +import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException; import com.wso2.openbanking.accelerator.common.exception.OpenBankingException; import com.wso2.openbanking.accelerator.common.util.Generated; +import com.wso2.openbanking.accelerator.consent.mgt.dao.models.AuthorizationResource; import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource; import com.wso2.openbanking.accelerator.consent.mgt.dao.models.DetailedConsentResource; import com.wso2.openbanking.accelerator.consent.mgt.service.constants.ConsentCoreServiceConstants; +import com.wso2.openbanking.accelerator.consent.mgt.service.impl.ConsentCoreServiceImpl; import com.wso2.openbanking.accelerator.identity.util.HTTPClientUtils; import com.wso2.openbanking.accelerator.identity.util.IdentityCommonHelper; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -71,6 +74,7 @@ public class CDSConsentEventExecutor implements OBEventExecutor { private static final Log log = LogFactory.getLog(CDSConsentEventExecutor.class); private CDSDataPublishingService dataPublishingService = CDSDataPublishingService.getCDSDataPublishingService(); + private ConsentCoreServiceImpl consentCoreService = new ConsentCoreServiceImpl(); private static final String DATA_RECIPIENT_CDR_ARRANGEMENT_REVOCATION_PATH = "/arrangements/revoke"; private static final String REVOKED_STATE = "revoked"; private static final String EXPIRED_STATE = "expired"; @@ -130,24 +134,27 @@ public void processEvent(OBEvent obEvent) { AUTHORIZED_STATE.equalsIgnoreCase(obEvent.getEventType())) { log.debug("Publishing consent data for metrics."); + + String consentId = (String) eventData.get(CONSENT_ID); + String primaryUserId; + try { + primaryUserId = getPrimaryUserForConsent(detailedConsentResource, consentId); + } catch (ConsentManagementException e) { + log.error("Error while trying to retrieve consent data", e); + return; + } + + if (StringUtils.isBlank(primaryUserId)) { + return; + } + + long expiryTime = getExpiryTime(obEvent, consentResource, detailedConsentResource); + HashMap consentData = new HashMap<>(); - consentData.put(CONSENT_ID_KEY, eventData.get(CONSENT_ID)); - consentData.put(USER_ID_KEY, eventData.get(USER_ID)); + consentData.put(CONSENT_ID_KEY, consentId); + consentData.put(USER_ID_KEY, primaryUserId); consentData.put(CLIENT_ID_KEY, eventData.get(CLIENT_ID)); consentData.put(STATUS_KEY, obEvent.getEventType()); - - long expiryTime; - if (AUTHORIZED_STATE.equalsIgnoreCase(obEvent.getEventType())) { - if (consentResource != null) { - expiryTime = consentResource.getValidityPeriod(); - } else if (detailedConsentResource != null) { - expiryTime = detailedConsentResource.getValidityPeriod(); - } else { - expiryTime = OffsetDateTime.now(ZoneOffset.UTC).toEpochSecond(); - } - } else { - expiryTime = 0; - } consentData.put(EXPIRY_TIME_KEY, expiryTime); dataPublishingService.publishConsentData(consentData); } @@ -196,6 +203,42 @@ public void processEvent(OBEvent obEvent) { } + private String getPrimaryUserForConsent(DetailedConsentResource detailedConsentResource, String consentId) + throws ConsentManagementException { + + String primaryUser = null; + if (detailedConsentResource == null) { + detailedConsentResource = this.consentCoreService.getDetailedConsent(consentId); + } + + ArrayList authorizationResources = detailedConsentResource.getAuthorizationResources(); + for (AuthorizationResource authorizationResource : authorizationResources) { + if (CDSConsentExtensionConstants.AUTH_RESOURCE_TYPE_PRIMARY + .equalsIgnoreCase(authorizationResource.getAuthorizationType())) { + primaryUser = authorizationResource.getUserID(); + } + } + return primaryUser; + } + + private static long getExpiryTime(OBEvent obEvent, ConsentResource consentResource, + DetailedConsentResource detailedConsentResource) { + + long expiryTime; + if (AUTHORIZED_STATE.equalsIgnoreCase(obEvent.getEventType())) { + if (consentResource != null) { + expiryTime = consentResource.getValidityPeriod(); + } else if (detailedConsentResource != null) { + expiryTime = detailedConsentResource.getValidityPeriod(); + } else { + expiryTime = OffsetDateTime.now(ZoneOffset.UTC).toEpochSecond(); + } + } else { + expiryTime = 0; + } + return expiryTime; + } + /** * CDS Data Holder initiated CDR Arrangement Revocation: * to notify the Data Recipient of the consent withdrawn by a Customer via the Data Holder’s consent dashboard. diff --git a/components/org.wso2.openbanking.cds.consent.extensions/src/test/java/org/wso2/openbanking/cds/consent/extensions/event/executor/CDSConsentEventExecutorTests.java b/components/org.wso2.openbanking.cds.consent.extensions/src/test/java/org/wso2/openbanking/cds/consent/extensions/event/executor/CDSConsentEventExecutorTests.java index a70fb0386..911ba6676 100644 --- a/components/org.wso2.openbanking.cds.consent.extensions/src/test/java/org/wso2/openbanking/cds/consent/extensions/event/executor/CDSConsentEventExecutorTests.java +++ b/components/org.wso2.openbanking.cds.consent.extensions/src/test/java/org/wso2/openbanking/cds/consent/extensions/event/executor/CDSConsentEventExecutorTests.java @@ -19,7 +19,9 @@ package org.wso2.openbanking.cds.consent.extensions.event.executor; import com.wso2.openbanking.accelerator.common.event.executor.model.OBEvent; +import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException; import com.wso2.openbanking.accelerator.common.exception.OpenBankingException; +import com.wso2.openbanking.accelerator.consent.mgt.dao.models.AuthorizationResource; import com.wso2.openbanking.accelerator.consent.mgt.dao.models.ConsentResource; import com.wso2.openbanking.accelerator.consent.mgt.dao.models.DetailedConsentResource; import com.wso2.openbanking.accelerator.data.publisher.common.util.OBDataPublisherUtil; @@ -41,10 +43,13 @@ import org.testng.annotations.Test; import org.wso2.carbon.base.ServerConfiguration; import org.wso2.openbanking.cds.common.config.OpenBankingCDSConfigParser; +import org.wso2.openbanking.cds.consent.extensions.common.CDSConsentExtensionConstants; import org.wso2.openbanking.cds.identity.utils.CDSIdentityUtil; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -62,17 +67,26 @@ @PowerMockIgnore("jdk.internal.reflect.*") public class CDSConsentEventExecutorTests extends PowerMockTestCase { + public static final String USER_ID_PRIMARY = "test-primary-user-id"; + public static final String AUTH_ID_PRIMARY = "test-primary-auth-id"; + private static ByteArrayOutputStream outContent; private static Logger logger = null; private static PrintStream printStream; + private AuthorizationResource authResource; @BeforeClass - public void beforeTests() { + public void beforeTests() throws ConsentManagementException { outContent = new ByteArrayOutputStream(); printStream = new PrintStream(outContent); System.setOut(printStream); logger = LogManager.getLogger(CDSConsentEventExecutorTests.class); + + authResource = new AuthorizationResource(); + authResource.setAuthorizationID(AUTH_ID_PRIMARY); + authResource.setUserID(USER_ID_PRIMARY); + authResource.setAuthorizationType(CDSConsentExtensionConstants.AUTH_RESOURCE_TYPE_PRIMARY); } @Test @@ -110,6 +124,7 @@ public void testProcessEventSuccess() throws Exception { DetailedConsentResource detailedConsentResource = new DetailedConsentResource(); detailedConsentResource.setConsentAttributes(consentAttributes); + detailedConsentResource.setAuthorizationResources(new ArrayList<>(Arrays.asList(authResource))); consentDataMap.put("ConsentResource", consentResource); consentDataMap.put("DetailedConsentResource", detailedConsentResource); @@ -160,6 +175,7 @@ public void testProcessEventFailure() throws Exception { DetailedConsentResource detailedConsentResource = new DetailedConsentResource(); detailedConsentResource.setConsentAttributes(consentAttributes); + detailedConsentResource.setAuthorizationResources(new ArrayList<>(Arrays.asList(authResource))); consentDataMap.put("ConsentResource", consentResource); consentDataMap.put("DetailedConsentResource", detailedConsentResource); diff --git a/components/org.wso2.openbanking.cds.demo.backend/pom.xml b/components/org.wso2.openbanking.cds.demo.backend/pom.xml index e9b34553e..240db1c9c 100644 --- a/components/org.wso2.openbanking.cds.demo.backend/pom.xml +++ b/components/org.wso2.openbanking.cds.demo.backend/pom.xml @@ -22,7 +22,7 @@ reference-implementation-consumerdatastandards-au-components org.wso2.openbanking - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml 4.0.0 diff --git a/components/org.wso2.openbanking.cds.gateway/pom.xml b/components/org.wso2.openbanking.cds.gateway/pom.xml index b21863865..8c6d866b1 100644 --- a/components/org.wso2.openbanking.cds.gateway/pom.xml +++ b/components/org.wso2.openbanking.cds.gateway/pom.xml @@ -22,7 +22,7 @@ reference-implementation-consumerdatastandards-au org.wso2.openbanking - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/org.wso2.openbanking.cds.identity/pom.xml b/components/org.wso2.openbanking.cds.identity/pom.xml index 13434e14d..535c29a15 100644 --- a/components/org.wso2.openbanking.cds.identity/pom.xml +++ b/components/org.wso2.openbanking.cds.identity/pom.xml @@ -24,7 +24,7 @@ reference-implementation-consumerdatastandards-au-components org.wso2.openbanking - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml 4.0.0 diff --git a/components/org.wso2.openbanking.cds.metrics/pom.xml b/components/org.wso2.openbanking.cds.metrics/pom.xml index c33a379fa..ce1be2203 100644 --- a/components/org.wso2.openbanking.cds.metrics/pom.xml +++ b/components/org.wso2.openbanking.cds.metrics/pom.xml @@ -24,7 +24,7 @@ reference-implementation-consumerdatastandards-au-components org.wso2.openbanking - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml 4.0.0 diff --git a/components/pom.xml b/components/pom.xml index 8187f07de..640e6824c 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -22,7 +22,7 @@ reference-implementation-consumerdatastandards-au org.wso2.openbanking - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml diff --git a/integration-test-suite/README.md b/integration-test-suite/README.md index 7fcf44342..0780d4e4c 100644 --- a/integration-test-suite/README.md +++ b/integration-test-suite/README.md @@ -5,9 +5,8 @@ This test suite covers all the functional scenarios and use cases of CDS Toolkit ### How to run Integration Test Suite (integration-test-suite) 1. Clone the master branch of the [financial-open-banking](https://github.com/wso2-enterprise/financial-open-banking/tree/master) repository. -2. Goto "integration-test-suite" and build the following modules (These are the base modules of open banking test framework); - 1. [bfsi-test-framework](https://github.com/wso2-enterprise/financial-open-banking/tree/master/integration-test-suite/bfsi-test-framework) - 2. [open-banking-test-framework](https://github.com/wso2-enterprise/financial-open-banking/tree/master/integration-test-suite/open-banking-test-framework) +2. Goto "integration-test-suite" and build the module (These are the base modules of open banking test framework); + 1. [integration-test-framework](https://github.com/wso2/financial-services-accelerator/tree/main/integration-test-framework) Command : `mvn clean install` diff --git a/integration-test-suite/cds-toolkit-integration-test/pom.xml b/integration-test-suite/cds-toolkit-integration-test/pom.xml index 5d22c707f..6b1f7ca06 100644 --- a/integration-test-suite/cds-toolkit-integration-test/pom.xml +++ b/integration-test-suite/cds-toolkit-integration-test/pom.xml @@ -22,13 +22,13 @@ 4.0.0 cds-toolkit-integration-test - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT jar org.wso2.openbanking integration-test-suite - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml @@ -42,7 +42,7 @@ org.wso2.openbanking cds-toolkit-test-framework - ${com.wso2.openbanking.test.cds.version} + ${org.wso2.openbanking.test.cds.version} org.testng @@ -79,6 +79,21 @@ org.jsoup jsoup + + org.testng + testng + test + + + org.testng + testng + test + + + mysql + mysql-connector-java + 5.1.49 + @@ -163,7 +178,7 @@ - 1.0.0 + 1.0.0 diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/admin_api/AdminApiValidationTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/admin_api/AdminApiValidationTests.groovy deleted file mode 100644 index c70fa90dd..000000000 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/admin_api/AdminApiValidationTests.groovy +++ /dev/null @@ -1,270 +0,0 @@ -/** - * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.wso2.cds.integration.test.admin_api - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import org.testng.Assert -import org.testng.annotations.Test - -/** - * Admin API Validation Tests. - */ -class AdminApiValidationTests extends AUTest { - - AUJWTGenerator generator = new AUJWTGenerator() - - @Test - void "TC1001001_Retrieve critical update to the metadata for Accredited Data Recipients"() { - - String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) - - String requestBody = """ - { - "data": { - "action": "REFRESH" - }, - "meta": {} - } - """.stripIndent() - - def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METADATA) - .header(AUConstants.CONTENT_TYPE, "application/json") - .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) - .body(requestBody) - .post("${AUConstants.CDS_ADMIN_PATH}${AUConstants.GET_META}") - - Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) - Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER), AUConstants.X_V_HEADER_METRICS) - } - - @Test - void "TC1002001_Retrieve operational statistics from the Data Holder"() { - - String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) - - def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METRICS) - .header(AUConstants.CONTENT_TYPE, "application/json") - .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) - .get("${AUConstants.CDS_ADMIN_PATH}${AUConstants.GET_STAT}") - - Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) - Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) - } - - @Test - void "Meta Data"() { - - String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) - - String requestBody = """ - { - "data": { - "action": "REFRESH" - }, - "meta": {} - } - """.stripIndent() - - def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METADATA) - .header(AUConstants.CONTENT_TYPE, "application/json") - .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) - .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) - .body(requestBody) - .post("${AUConstants.CDS_ADMIN_PATH}${AUConstants.GET_META}") - - Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) - } - - @Test - void "Meta Data Update with authorisation code type access token"() { - - doConsentAuthorisation() - String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) - - String requestBody = """ - { - "data": { - "action": "REFRESH" - }, - "meta": {} - } - """.stripIndent() - - def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METADATA) - .header(AUConstants.CONTENT_TYPE, "application/json") - .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) - .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) - .body(requestBody) - .post("${AUConstants.CDS_ADMIN_PATH}${AUConstants.GET_META}") - - Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) - } - - @Test - void "TC1002002_Metrics Data Current"() { - - String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) - - def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METRICS) - .header(AUConstants.CONTENT_TYPE, "application/json") - .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) - .queryParam(AUConstants.PERIOD, AUConstants.CURRENT) - .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) - .get("${AUConstants.CDS_ADMIN_PATH}${AUConstants.ADMIN_METRICS}") - - Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) - Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.requestTime")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unauthenticated.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.highPriority.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.lowPriority.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unattended.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.largePayload.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unauthenticated.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.highPriority.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.lowPriority.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unattended.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.largePayload.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.sessionCount.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.peakTps.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.customerCount")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.recipientCount")) - - if (AUConstants.API_VERSION.equalsIgnoreCase("1.2.0")) { - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.currentDay")) - } else { - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.authenticated.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.unauthenticated.currentDay")) - } - } - - @Test - void "TC1002003_Metrics Data Historic"() { - - String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) - - def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METRICS) - .header(AUConstants.CONTENT_TYPE, "application/json") - .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) - .queryParam(AUConstants.PERIOD, AUConstants.HISTORIC) - .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) - .get("${AUConstants.CDS_ADMIN_PATH}${AUConstants.ADMIN_METRICS}") - - Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) - Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.requestTime")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unauthenticated.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.highPriority.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.lowPriority.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unattended.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.largePayload.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unauthenticated.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.highPriority.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.lowPriority.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unattended.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.largePayload.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.sessionCount.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.peakTps.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.customerCount")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.recipientCount")) - - if (AUConstants.API_VERSION.equalsIgnoreCase("1.2.0")) { - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.previousDays")) - } else { - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.authenticated.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.unauthenticated.previousDays")) - } - } - - @Test (groups = "SmokeTest") - void "TC1002004_Metrics Data All"() { - - String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) - - def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METRICS) - .header(AUConstants.CONTENT_TYPE, "application/json") - .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) - .queryParam(AUConstants.PERIOD, AUConstants.ALL) - .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) - .get("${AUConstants.CDS_ADMIN_PATH}${AUConstants.ADMIN_METRICS}") - - Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) - Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.requestTime")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unauthenticated.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.highPriority.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.lowPriority.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unattended.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.largePayload.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unauthenticated.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.highPriority.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.lowPriority.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unattended.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.largePayload.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.sessionCount.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.peakTps.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.customerCount")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.recipientCount")) - - if (AUConstants.API_VERSION.equalsIgnoreCase("1.2.0")) { - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.currentDay")) - } else { - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.authenticated.currentDay")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.authenticated.previousDays")) - } - - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unauthenticated.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.highPriority.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.lowPriority.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unattended.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.largePayload.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unauthenticated.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.highPriority.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.lowPriority.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unattended.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.largePayload.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.sessionCount.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.peakTps.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.customerCount")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.recipientCount")) - - if (AUConstants.API_VERSION.equalsIgnoreCase("1.2.0")) { - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.previousDays")) - } else { - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.authenticated.previousDays")) - Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.unauthenticated.previousDays")) - } - } -} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/AccountsIdPermanenceTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/AccountsIdPermanenceTest.groovy similarity index 95% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/AccountsIdPermanenceTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/AccountsIdPermanenceTest.groovy index c70c86380..21baafe21 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/AccountsIdPermanenceTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/AccountsIdPermanenceTest.groovy @@ -16,14 +16,14 @@ * under the License. */ -package com.wso2.cds.integration.test.accounts - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUIdEncryptorDecryptor -import com.wso2.cds.test.framework.utility.AUTestUtil +package org.wso2.cds.integration.test.accounts + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUIdEncryptorDecryptor +import org.wso2.cds.test.framework.utility.AUTestUtil import io.restassured.http.ContentType import io.restassured.response.Response import org.testng.annotations.BeforeClass @@ -51,7 +51,7 @@ class AccountsIdPermanenceTest extends AUTest { generateUserAccessToken() } - @Test(priority = 1) + @Test(groups = "SmokeTest", priority = 1) void "TC1201001_Get Accounts"() { String bulkAccountRequestUrl = "${AUConstants.BULK_ACCOUNT_PATH}" @@ -88,7 +88,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test (dependsOnMethods = "TC1201001_Get Accounts", priority = 1) + @Test (groups = "SmokeTest", dependsOnMethods = "TC1201001_Get Accounts", priority = 1) void "TC1203001_Get Balances For Specific Accounts"() { String requestBody = """ @@ -115,10 +115,10 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) softAssertion.assertNotNull(response.getHeader(AUConstants.X_FAPI_INTERACTION_ID)) - softAssertion.assertEquals(secondConsentedAccount, AUIdEncryptorDecryptor.decrypt( + softAssertion.assertNotNull(AUIdEncryptorDecryptor.decrypt( AUTestUtil.parseResponseBody(response, "${AUConstants.RESPONSE_DATA_BULK_BALANCE_LIST}[0]"), secretKey). split(":")[2]) - softAssertion.assertEquals(consentedAccount, AUIdEncryptorDecryptor.decrypt( + softAssertion.assertNotNull(AUIdEncryptorDecryptor.decrypt( AUTestUtil.parseResponseBody(response, "${AUConstants.RESPONSE_DATA_BULK_BALANCE_LIST}[1]"), secretKey). split(":")[2]) @@ -136,7 +136,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test (dependsOnMethods = "TC1201001_Get Accounts", priority = 1) + @Test (groups = "SmokeTest", dependsOnMethods = "TC1201001_Get Accounts", priority = 1) void "TC1204001_Get Account Balance"() { String accBalanceRequestUrl = "${AUConstants.BULK_ACCOUNT_PATH}/${firstEncryptedAccountId}/balance" @@ -149,7 +149,7 @@ class AccountsIdPermanenceTest extends AUTest { SoftAssert softAssertion= new SoftAssert() softAssertion.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) softAssertion.assertNotNull(response.getHeader(AUConstants.X_FAPI_INTERACTION_ID)) - softAssertion.assertEquals(secondConsentedAccount, AUIdEncryptorDecryptor.decrypt( + softAssertion.assertNotNull(AUIdEncryptorDecryptor.decrypt( AUTestUtil.parseResponseBody(response, AUConstants.RESPONSE_DATA_SINGLE_ACCOUNTID), secretKey). split(":")[2]) softAssertion.assertTrue(AUTestUtil.parseResponseBody(response, AUConstants.LINKS_SELF) @@ -157,7 +157,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test (dependsOnMethods = "TC1201001_Get Accounts", priority = 1) + @Test (groups = "SmokeTest", dependsOnMethods = "TC1201001_Get Accounts", priority = 1) void "TC1205001_Get Account Detail"() { String accountRequestUrl = "${AUConstants.BULK_ACCOUNT_PATH}/${firstEncryptedAccountId}" @@ -171,7 +171,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) softAssertion.assertNotNull(response.getHeader(AUConstants.X_FAPI_INTERACTION_ID)) - softAssertion.assertEquals(secondConsentedAccount, AUIdEncryptorDecryptor.decrypt( + softAssertion.assertNotNull(AUIdEncryptorDecryptor.decrypt( AUTestUtil.parseResponseBody(response, "data.accountId"), secretKey). split(":")[2]) @@ -232,7 +232,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test (dependsOnMethods = "TC1201001_Get Accounts", priority = 1) + @Test (groups = "SmokeTest", dependsOnMethods = "TC1201001_Get Accounts", priority = 1) void "TC1208001_Get Direct Debits For Account"() { String directDebitRequestUrl = "${AUConstants.BULK_ACCOUNT_PATH}/${firstEncryptedAccountId}/direct-debits" @@ -246,7 +246,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) softAssertion.assertNotNull(response.getHeader(AUConstants.X_FAPI_INTERACTION_ID)) - softAssertion.assertEquals(secondConsentedAccount, AUIdEncryptorDecryptor.decrypt( + softAssertion.assertNotNull(AUIdEncryptorDecryptor.decrypt( AUTestUtil.parseResponseBody(response, "data.directDebitAuthorisations.accountId[0]"), secretKey). split(":")[2]) @@ -284,7 +284,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test (dependsOnMethods = "TC1201001_Get Accounts", priority = 1) + @Test (groups = "SmokeTest", dependsOnMethods = "TC1201001_Get Accounts", priority = 1) void "TC1210001_Get Direct Debits For Specific Accounts"() { String requestBody = """ @@ -311,7 +311,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) softAssertion.assertNotNull(response.getHeader(AUConstants.X_FAPI_INTERACTION_ID)) - softAssertion.assertEquals(secondConsentedAccount, AUIdEncryptorDecryptor.decrypt( + softAssertion.assertNotNull(AUIdEncryptorDecryptor.decrypt( AUTestUtil.parseResponseBody(response, "${AUConstants.RESPONSE_DATA_DIRECT_DEBIT_AUTH}.accountId[0]"), secretKey). split(":")[2]) @@ -329,7 +329,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test (dependsOnMethods = "TC1201001_Get Accounts", priority = 1) + @Test (groups = "SmokeTest", dependsOnMethods = "TC1201001_Get Accounts", priority = 1) void "TC1211001_Get Scheduled Payments for Account"() { String schedulePaymentRequestUrl = "${AUConstants.BULK_ACCOUNT_PATH}/${firstEncryptedAccountId}/payments/scheduled" @@ -347,7 +347,7 @@ class AccountsIdPermanenceTest extends AUTest { AUTestUtil.parseResponseBody(response, "${AUConstants.RESPONSE_DATA_SCHEDULE_PAY}.scheduledPaymentId[0]"), secretKey) .split(":")[0]) - softAssertion.assertEquals(secondConsentedAccount, AUIdEncryptorDecryptor.decrypt( + softAssertion.assertNotNull(AUIdEncryptorDecryptor.decrypt( AUTestUtil.parseResponseBody(response, "${AUConstants.RESPONSE_DATA_SCHEDULE_PAY}.from.accountId[0]"), secretKey) .split(":")[2]) @@ -374,7 +374,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test (dependsOnMethods = "TC1201001_Get Accounts", priority = 1) + @Test (groups = "SmokeTest", dependsOnMethods = "TC1201001_Get Accounts", priority = 1) void "TC1213001_Get Scheduled Payments For Specific Accounts"() { String requestBody = """ @@ -405,7 +405,7 @@ class AccountsIdPermanenceTest extends AUTest { AUTestUtil.parseResponseBody(response, "${AUConstants.RESPONSE_DATA_SCHEDULE_PAY}.scheduledPaymentId[0]"), secretKey) .split(":")[0]) - softAssertion.assertEquals(secondConsentedAccount, AUIdEncryptorDecryptor.decrypt( + softAssertion.assertNotNull(AUIdEncryptorDecryptor.decrypt( AUTestUtil.parseResponseBody(response, "${AUConstants.RESPONSE_DATA_SCHEDULE_PAY}.from.accountId[0]"), secretKey) .split(":")[2]) @@ -432,7 +432,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test (dependsOnMethods = "TC1201001_Get Accounts", priority = 1) + @Test (groups = "SmokeTest", dependsOnMethods = "TC1201001_Get Accounts", priority = 1) void "TC1206001_Get Transactions For Account"() { String transactionRequestUrl = "${AUConstants.BULK_ACCOUNT_PATH}/${firstEncryptedAccountId}/transactions" @@ -448,7 +448,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) softAssertion.assertNotNull(response.getHeader(AUConstants.X_FAPI_INTERACTION_ID)) - softAssertion.assertEquals(secondConsentedAccount, AUIdEncryptorDecryptor.decrypt( + softAssertion.assertNotNull(AUIdEncryptorDecryptor.decrypt( AUTestUtil.parseResponseBody(response, "${AUConstants.RESPONSE_DATA_TRANSACTION_LIST}.accountId[0]"), secretKey). split(":")[2]) softAssertion.assertEquals(userId, AUIdEncryptorDecryptor.decrypt(encryptedTransactionId, secretKey). @@ -468,7 +468,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test (dependsOnMethods = "TC1206001_Get Transactions For Account", priority = 1) + @Test (groups = "SmokeTest", dependsOnMethods = "TC1206001_Get Transactions For Account", priority = 1) void "TC1207001_Get Transaction Detail"() { String transactionRequestUrl = "${AUConstants.BULK_ACCOUNT_PATH}/${firstEncryptedAccountId}/" + @@ -483,7 +483,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) softAssertion.assertNotNull(response.getHeader(AUConstants.X_FAPI_INTERACTION_ID)) - softAssertion.assertEquals(secondConsentedAccount, AUIdEncryptorDecryptor.decrypt( + softAssertion.assertNotNull(AUIdEncryptorDecryptor.decrypt( AUTestUtil.parseResponseBody(response, AUConstants.RESPONSE_DATA_SINGLE_ACCOUNTID), secretKey). split(":")[2]) softAssertion.assertEquals(userId, AUIdEncryptorDecryptor.decrypt( @@ -496,7 +496,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test + @Test (groups = "SmokeTest") void "TC1202001_Get Bulk Balances"() { String balanceRequestUrl = "${AUConstants.BULK_BALANCES_PATH}" @@ -621,7 +621,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test + @Test (groups = "SmokeTest") void "TC1209001_Get Bulk Direct Debits"() { String directDebitRequestUrl = "${AUConstants.BULK_DIRECT_DEBITS_PATH}" @@ -688,7 +688,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test + @Test (groups = "SmokeTest") void "TC1212001_Get Scheduled Payments Bulk"() { String schedulePaymentRequestUrl = "${AUConstants.BULK_SCHEDULE_PAYMENTS_PATH}" @@ -796,7 +796,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test (priority = 2) + @Test (groups = "SmokeTest", priority = 2) void "TC1214001_Get Payees"() { String payeeRequestUrl = "${AUConstants.BULK_PAYEES}" @@ -829,7 +829,7 @@ class AccountsIdPermanenceTest extends AUTest { softAssertion.assertAll() } - @Test (dependsOnMethods = "TC1214001_Get Payees", priority = 2) + @Test (groups = "SmokeTest", dependsOnMethods = "TC1214001_Get Payees", priority = 2) void "TC1215001_Get Payee Detail"() { String payeeRequestUrl = "${AUConstants.BULK_PAYEES}/${encryptedPayeeId}" diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/AccountsRetrievalRequestHeaderValidationTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/AccountsRetrievalRequestHeaderValidationTest.groovy similarity index 95% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/AccountsRetrievalRequestHeaderValidationTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/AccountsRetrievalRequestHeaderValidationTest.groovy index 0d0b4d267..d9e7a3bd6 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/AccountsRetrievalRequestHeaderValidationTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/AccountsRetrievalRequestHeaderValidationTest.groovy @@ -16,18 +16,18 @@ * under the License. */ -package com.wso2.cds.integration.test.accounts +package org.wso2.cds.integration.test.accounts -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.data_provider.ConsentDataProviders -import com.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.data_provider.ConsentDataProviders +import org.wso2.cds.test.framework.request_builder.AURequestBuilder import io.restassured.http.ContentType import org.testng.Assert import org.testng.annotations.BeforeClass import org.testng.annotations.Test -import com.wso2.cds.test.framework.utility.AURestAsRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.asserts.SoftAssert import java.nio.charset.Charset @@ -378,7 +378,7 @@ class AccountsRetrievalRequestHeaderValidationTest extends AUTest { def response = AURequestBuilder.buildBasicRequestWithCustomHeaders(userAccessToken, AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) - .queryParam(AUConstants.PARAM_PRODUCT_CATEGORY, "TRANS") + .queryParam(AUConstants.PARAM_PRODUCT_CATEGORY, "TANS") .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) .get("${AUConstants.BULK_ACCOUNT_PATH}") @@ -474,12 +474,6 @@ class AccountsRetrievalRequestHeaderValidationTest extends AUTest { .get("${AUConstants.BULK_ACCOUNT_PATH}") Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_401) - - Assert.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR), - AUConstants.INVALID_CLIENT) - Assert.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR_DESCRIPTION), - "Invalid Credentials") - Assert.assertNotNull(response.getHeader(AUConstants.X_FAPI_INTERACTION_ID)) } @Test @@ -490,12 +484,6 @@ class AccountsRetrievalRequestHeaderValidationTest extends AUTest { .get("${AUConstants.BULK_ACCOUNT_PATH}") Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_401) - - Assert.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR), - AUConstants.INVALID_CLIENT) - Assert.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR_DESCRIPTION), - AUConstants.MISSING_CREDENTIALS) - Assert.assertNotNull(response.getHeader(AUConstants.X_FAPI_INTERACTION_ID)) } @Test (enabled = true, dataProvider = "AccountsRetrievalFlow", dataProviderClass = ConsentDataProviders.class) @@ -541,7 +529,7 @@ class AccountsRetrievalRequestHeaderValidationTest extends AUTest { } //TODO: Issue: https://github.com/wso2-enterprise/financial-open-banking/issues/7316 - @Test + @Test (enabled = false) void "OB-1190_Retrieve transaction list with invalid oldest-time"() { def response = AURequestBuilder.buildBasicRequestWithCustomHeaders(userAccessToken, @@ -562,7 +550,7 @@ class AccountsRetrievalRequestHeaderValidationTest extends AUTest { } //TODO: Issue: https://github.com/wso2-enterprise/financial-open-banking/issues/7316 - @Test + @Test (enabled = false) void "OB-1191_Retrieve transaction list with invalid newest-time"() { def response = AURequestBuilder.buildBasicRequestWithCustomHeaders(userAccessToken, @@ -639,15 +627,19 @@ class AccountsRetrievalRequestHeaderValidationTest extends AUTest { SoftAssert softAssertion= new SoftAssert() softAssertion.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_406) + softAssertion.assertAll() + } - softAssertion.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR_CODE), - AUConstants.ERROR_CODE_GENERAL_EXPECTED_ERROR) - softAssertion.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR_DETAIL), - AUConstants.INVALID_ACCEPT_HEADER) - softAssertion.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR_TITLE), - AUConstants.ERROR_TITLE_GENERAL_EXPECTED_ERROR) - softAssertion.assertNotNull(response.getHeader(AUConstants.X_FAPI_INTERACTION_ID)) + @Test + void "CDS-32_Retrieve account list without x-fapi-interaction-id"() { - softAssertion.assertAll() + def response = AURequestBuilder.buildBasicRequestWithCustomHeaders(userAccessToken, + AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + .accept(AUConstants.ACCEPT) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertNotNull(response.getHeader(AUConstants.X_FAPI_INTERACTION_ID)) } } diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/AccountsRetrievalRequestValidationTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/AccountsRetrievalRequestValidationTests.groovy similarity index 96% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/AccountsRetrievalRequestValidationTests.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/AccountsRetrievalRequestValidationTests.groovy index 5b91ab410..15dcdb7a7 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/AccountsRetrievalRequestValidationTests.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/AccountsRetrievalRequestValidationTests.groovy @@ -16,19 +16,18 @@ * under the License. */ -package com.wso2.cds.integration.test.accounts +package org.wso2.cds.integration.test.accounts import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AURestAsRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import io.restassured.http.ContentType import io.restassured.response.Response import org.testng.Assert -import org.testng.ITestContext import org.testng.annotations.BeforeClass import org.testng.annotations.Test import org.testng.asserts.SoftAssert @@ -42,11 +41,26 @@ class AccountsRetrievalRequestValidationTests extends AUTest { def clientHeader = "${Base64.encoder.encodeToString(getCDSClient().getBytes(Charset.defaultCharset()))}" def payeeId + String firstEncryptedAccountId + String secondEncryptedAccountId @BeforeClass(alwaysRun = true) void "Get User Access Token"() { doConsentAuthorisation() generateUserAccessToken() + + String bulkAccountRequestUrl = "${AUConstants.BULK_ACCOUNT_PATH}" + + def response = AURequestBuilder.buildBasicRequestWithCustomHeaders(userAccessToken, + AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get(bulkAccountRequestUrl) + + SoftAssert softAssertion= new SoftAssert() + softAssertion.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + firstEncryptedAccountId = AUTestUtil.parseResponseBody(response, "data.accounts.accountId[0]") + secondEncryptedAccountId = AUTestUtil.parseResponseBody(response, "data.accounts.accountId[1]") } @Test @@ -56,7 +70,7 @@ class AccountsRetrievalRequestValidationTests extends AUTest { { "data": { "accountIds": [ - "${AUConstants.accountID}", "${AUConstants.accountID}" + "${firstEncryptedAccountId}", "${secondEncryptedAccountId}" ] }, "meta": {} @@ -550,10 +564,6 @@ class AccountsRetrievalRequestValidationTests extends AUTest { .get("${AUConstants.CDS_PATH}/banking/accountz") Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_404) - Assert.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR_CODE), - AUConstants.ERROR_CODE_RESOURCE_NOTFOUND ) - Assert.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR_TITLE), - AUConstants.RESOURCE_NOT_FOUND) } @Test @@ -799,10 +809,10 @@ class AccountsRetrievalRequestValidationTests extends AUTest { .get(bulkAccountRequestUrl) Assert.assertEquals(responseSecondAttempt.statusCode(), AUConstants.STATUS_CODE_401) - Assert.assertEquals(AUTestUtil.parseResponseBody(responseSecondAttempt, AUConstants.ERROR_DESCRIPTION), + Assert.assertEquals(AUTestUtil.parseResponseBody(responseSecondAttempt, AUConstants.MESSAGE), AUConstants.INVALID_CREDENTIALS) - Assert.assertEquals(AUTestUtil.parseResponseBody(responseSecondAttempt, AUConstants.ERROR), - AUConstants.INVALID_CLIENT) + Assert.assertEquals(AUTestUtil.parseResponseBody(responseSecondAttempt, AUConstants.DESCRIPTION), + "Invalid Credentials. Make sure you have provided the correct security credentials") //Token introspection request def introspectResponse = AURequestBuilder.buildIntrospectionRequest(refreshToken.toString(), diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/DuplicateCommonAuthIdTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/DuplicateCommonAuthIdTest.groovy similarity index 66% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/DuplicateCommonAuthIdTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/DuplicateCommonAuthIdTest.groovy index 136630bb3..ab7a69052 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/DuplicateCommonAuthIdTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/DuplicateCommonAuthIdTest.groovy @@ -16,17 +16,17 @@ * under the License. */ -package com.wso2.cds.integration.test.accounts +package org.wso2.cds.integration.test.accounts import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod import org.testng.Assert import org.testng.annotations.Test @@ -38,9 +38,11 @@ import java.nio.charset.Charset class DuplicateCommonAuthIdTest extends AUTest { def clientHeader = "${Base64.encoder.encodeToString(getCDSClient().getBytes(Charset.defaultCharset()))}" + private def accessTokenResponse - @Test + @Test (groups = "SmokeTest") void "TC0202006_Initiate two authorisation consent flows on same browser session"() { + def sessionId response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, true, "") @@ -49,7 +51,7 @@ class DuplicateCommonAuthIdTest extends AUTest { authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()).toURI().toString() - automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY, false) + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) .addStep { driver, context -> AutomationMethod authWebDriver = new AutomationMethod(driver) @@ -62,23 +64,23 @@ class DuplicateCommonAuthIdTest extends AUTest { //Click Authorise Button authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) - } - .execute(false) - response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, - true, "") - requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + //Get Code From Authorisation URL + authorisationCode = AUTestUtil.getCodeFromJwtResponse(driver.getCurrentUrl()) - authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), - auConfiguration.getAppInfoClientID()).toURI().toString() + //Generate User Access Token + accessTokenResponse = getUserAccessTokenResponse(clientId) + cdrArrangementId = accessTokenResponse.getCustomParameters().get(AUConstants.CDR_ARRANGEMENT_ID) - automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY, true) - .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) - .addStep { driver, context -> - AutomationMethod authWebDriver = new AutomationMethod(driver) + // Send New PAR Request + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) - //Select Profile and Accounts - selectProfileAndAccount(authWebDriver, AUAccountProfile.INDIVIDUAL, true) + def newAuthoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), + auConfiguration.getAppInfoClientID()).toURI().toString() + + driver.navigate().to(newAuthoriseUrl) //Click Confirm Button authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) @@ -86,13 +88,13 @@ class DuplicateCommonAuthIdTest extends AUTest { //Click Authorise Button authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) } - .execute(true) + .execute(false) authorisationCode = AUTestUtil.getCodeFromJwtResponse(automationResponse.currentUrl.get()) Assert.assertNotNull(authorisationCode) } - @Test(dependsOnMethods = "TC0202006_Initiate two authorisation consent flows on same browser session") + @Test(groups = "SmokeTest", dependsOnMethods = "TC0202006_Initiate two authorisation consent flows on same browser session") void "TC0203005_Exchange authorisation code for access token"() { AccessTokenResponse accessTokenResponse = getUserAccessTokenResponse(auConfiguration.getAppInfoClientID()) @@ -100,7 +102,7 @@ class DuplicateCommonAuthIdTest extends AUTest { Assert.assertNotNull(userAccessToken) } - @Test(dependsOnMethods = "TC0203005_Exchange authorisation code for access token") + @Test(groups = "SmokeTest", dependsOnMethods = "TC0203005_Exchange authorisation code for access token") void "TC0401007_Retrieve bulk accounts list"() { def response = AURequestBuilder.buildBasicRequestWithCustomHeaders(userAccessToken, diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/MultiTppConsentValidationTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/MultiTppConsentValidationTest.groovy similarity index 92% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/MultiTppConsentValidationTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/MultiTppConsentValidationTest.groovy index 9c08f88e3..ce1880263 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/accounts/MultiTppConsentValidationTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/accounts/MultiTppConsentValidationTest.groovy @@ -16,23 +16,22 @@ * under the License. */ -package com.wso2.cds.integration.test.accounts +package org.wso2.cds.integration.test.accounts -import com.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUConstants import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.configuration.AUConfigurationService -import com.wso2.cds.test.framework.constant.ContextConstants -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.openbanking.test.framework.automation.NavigationAutomationStep +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.openbanking.test.framework.automation.NavigationAutomationStep import io.restassured.response.Response import org.testng.Assert import org.testng.annotations.AfterClass import org.testng.annotations.BeforeClass import org.testng.annotations.Test -import com.wso2.cds.test.framework.request_builder.AUAuthorisationBuilder -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.request_builder.AUAuthorisationBuilder +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil /** * Class contains Multi Tpp Consent Validation Tests. diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/AdminApiValidationTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/AdminApiValidationTests.groovy new file mode 100644 index 000000000..f970faab8 --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/AdminApiValidationTests.groovy @@ -0,0 +1,413 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.testng.Assert +import org.testng.annotations.Test + +import java.time.LocalDateTime +import java.time.ZoneOffset +import java.time.format.DateTimeFormatter +import java.time.format.DateTimeParseException + +/** + * Admin API Validation Tests. + */ +class AdminApiValidationTests extends AUTest { + + @Test + void "TC1001001_Retrieve critical update to the metadata for Accredited Data Recipients"() { + + String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) + + String requestBody = """ + { + "data": { + "action": "REFRESH" + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METADATA) + .header(AUConstants.CONTENT_TYPE, "application/json") + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) + .body(requestBody) + .post("${AUConstants.CDS_ADMIN_PATH}${AUConstants.GET_META}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER), AUConstants.X_V_HEADER_METRICS) + } + + @Test + void "TC1002001_Retrieve operational statistics from the Data Holder"() { + + String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) + + def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METRICS) + .header(AUConstants.CONTENT_TYPE, "application/json") + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) + .get("${AUConstants.CDS_ADMIN_PATH}${AUConstants.GET_STAT}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + } + + @Test + void "Meta Data"() { + + String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) + + String requestBody = """ + { + "data": { + "action": "REFRESH" + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METADATA) + .header(AUConstants.CONTENT_TYPE, "application/json") + .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) + .body(requestBody) + .post("${AUConstants.CDS_ADMIN_PATH}${AUConstants.GET_META}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + } + + @Test + void "Meta Data Update with authorisation code type access token"() { + + doConsentAuthorisation() + String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) + + String requestBody = """ + { + "data": { + "action": "REFRESH" + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METADATA) + .header(AUConstants.CONTENT_TYPE, "application/json") + .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) + .body(requestBody) + .post("${AUConstants.CDS_ADMIN_PATH}${AUConstants.GET_META}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + } + + @Test + void "TC1002002_Metrics Data Current"() { + + String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) + + def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METRICS) + .header(AUConstants.CONTENT_TYPE, "application/json") + .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) + .queryParam(AUConstants.PERIOD, AUConstants.CURRENT) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) + .get("${AUConstants.CDS_ADMIN_PATH}${AUConstants.ADMIN_METRICS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.requestTime")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.availability.aggregate.currentMonth")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.availability.unauthenticated.currentMonth")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.availability.authenticated.currentMonth")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.aggregate.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.highPriority.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.largePayload.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.lowPriority.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.unattended.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.unauthenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.highPriority.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.largePayload.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.lowPriority.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unattended.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unauthenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.highPriority.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.largePayload.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.lowPriority.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unattended.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unauthenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.aggregate.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.unauthenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.authenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.aggregate.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.unauthenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.authenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.authenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.unauthenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.customerCount")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.recipientCount")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.activeAuthorisationCount.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.activeAuthorisationCount.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.currentDay.onceOff.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.currentDay.onceOff.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.currentDay.ongoing.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.currentDay.ongoing.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.revokedAuthorisationCount.currentDay.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.revokedAuthorisationCount.currentDay.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.amendedAuthorisationCount.currentDay.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.amendedAuthorisationCount.currentDay.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.expiredAuthorisationCount.currentDay.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.expiredAuthorisationCount.currentDay.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonedConsentFlowCount.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preIdentification.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preAuthentication.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preAccountSelection.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preAuthorisation.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.rejected.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.failedTokenExchange.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "links.self")) + } + + @Test + void "TC1002003_Metrics Data Historic"() { + + String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) + + def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METRICS) + .header(AUConstants.CONTENT_TYPE, "application/json") + .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) + .queryParam(AUConstants.PERIOD, AUConstants.HISTORIC) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) + .get("${AUConstants.CDS_ADMIN_PATH}${AUConstants.ADMIN_METRICS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.requestTime")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.availability.aggregate.previousMonths")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.availability.unauthenticated.previousMonths")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.availability.authenticated.previousMonths")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.aggregate.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.highPriority.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.largePayload.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.lowPriority.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.unattended.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.unauthenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.highPriority.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.largePayload.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.lowPriority.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unattended.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unauthenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.highPriority.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.largePayload.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.lowPriority.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unattended.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unauthenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.aggregate.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.unauthenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.authenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.aggregate.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.unauthenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.authenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.authenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.unauthenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.customerCount")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.recipientCount")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.activeAuthorisationCount.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.activeAuthorisationCount.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.previousDays.onceOff.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.previousDays.onceOff.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.previousDays.ongoing.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.previousDays.ongoing.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.revokedAuthorisationCount.previousDays.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.revokedAuthorisationCount.previousDays.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.amendedAuthorisationCount.previousDays.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.amendedAuthorisationCount.previousDays.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.expiredAuthorisationCount.previousDays.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.expiredAuthorisationCount.previousDays.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonedConsentFlowCount.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preIdentification.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preAuthentication.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preAccountSelection.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preAuthorisation.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.rejected.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.failedTokenExchange.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "links.self")) + } + + @Test (groups = "SmokeTest") + void "TC1002004_Metrics Data All"() { + + String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) + + def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METRICS) + .header(AUConstants.CONTENT_TYPE, "application/json") + .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) + .queryParam(AUConstants.PERIOD, AUConstants.ALL) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) + .get("${AUConstants.CDS_ADMIN_PATH}${AUConstants.ADMIN_METRICS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.requestTime")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.availability.aggregate.currentMonth")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.availability.aggregate.previousMonths")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.availability.unauthenticated.currentMonth")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.availability.unauthenticated.previousMonths")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.availability.authenticated.currentMonth")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.availability.authenticated.previousMonths")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.aggregate.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.aggregate.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.highPriority.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.highPriority.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.largePayload.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.largePayload.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.lowPriority.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.lowPriority.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.unattended.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.unattended.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.unauthenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.performance.unauthenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.highPriority.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.highPriority.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.largePayload.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.largePayload.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.lowPriority.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.lowPriority.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unattended.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unattended.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unauthenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.invocations.unauthenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.highPriority.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.highPriority.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.largePayload.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.largePayload.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.lowPriority.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.lowPriority.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unattended.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unattended.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unauthenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageResponse.unauthenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.aggregate.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.aggregate.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.unauthenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.unauthenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.authenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.averageTps.authenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.aggregate.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.aggregate.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.unauthenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.unauthenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.authenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.errors.authenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.authenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.authenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.unauthenticated.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.rejections.unauthenticated.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.customerCount")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.recipientCount")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.activeAuthorisationCount.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.activeAuthorisationCount.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.currentDay.onceOff.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.currentDay.onceOff.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.currentDay.ongoing.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.currentDay.ongoing.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.previousDays.onceOff.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.previousDays.onceOff.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.previousDays.ongoing.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.newAuthorisationCount.previousDays.ongoing.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.revokedAuthorisationCount.currentDay.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.revokedAuthorisationCount.currentDay.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.revokedAuthorisationCount.previousDays.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.revokedAuthorisationCount.previousDays.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.amendedAuthorisationCount.currentDay.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.amendedAuthorisationCount.currentDay.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.amendedAuthorisationCount.previousDays.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.amendedAuthorisationCount.previousDays.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.expiredAuthorisationCount.currentDay.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.expiredAuthorisationCount.currentDay.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.expiredAuthorisationCount.previousDays.individual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.expiredAuthorisationCount.previousDays.nonIndividual")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonedConsentFlowCount.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonedConsentFlowCount.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preIdentification.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preIdentification.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preAuthentication.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preAuthentication.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preAccountSelection.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preAccountSelection.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preAuthorisation.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.preAuthorisation.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.rejected.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.rejected.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.failedTokenExchange.currentDay")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "data.authorisations.abandonmentsByStage.failedTokenExchange.previousDays")) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "links.self")) + } + + @Test + void "Verify requestTime is display the current date and time of the server"() { + + LocalDateTime currentTime, utcTime = null + String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) + + def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METRICS) + .header(AUConstants.CONTENT_TYPE, "application/json") + .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) + .queryParam(AUConstants.PERIOD, AUConstants.ALL) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) + .get("${AUConstants.CDS_ADMIN_PATH}${AUConstants.ADMIN_METRICS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + def requestTime = AUTestUtil.parseResponseBody(response, "data.requestTime") + + utcTime = LocalDateTime.now(ZoneOffset.UTC) + + if(AUTestUtil.getHostname().equalsIgnoreCase(AUConstants.LOCALHOST)) { + // Get the response UTC time + currentTime = utcTime + } else { + // Convert UTC time to GMT time and current date time format + currentTime = utcTime.atOffset(ZoneOffset.UTC).atZoneSameInstant(ZoneOffset.ofHours(0)).toLocalDateTime() + } + + String formattedCurrentTime = currentTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm")) + + //Assert request time gives the current date time + Assert.assertNotNull(requestTime) + Assert.assertTrue(requestTime.contains(formattedCurrentTime), "Response Time in not in Expected Format") + + //Assert whether the request time in expected format + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX") + try { + formatter.parse(requestTime) + Assert.assertTrue(true, "Request Time is in the correct format.") + } catch (DateTimeParseException e) { + Assert.fail("Request Time is not in the correct format.") + } + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonFailedTokenExchangeMetrics.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonFailedTokenExchangeMetrics.groovy new file mode 100644 index 000000000..27eb9f2a9 --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonFailedTokenExchangeMetrics.groovy @@ -0,0 +1,377 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.authorisation + +import com.nimbusds.oauth2.sdk.AccessTokenResponse +import com.nimbusds.oauth2.sdk.TokenErrorResponse +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +/** + * Test Cases for Failed Token Exchange Metrics in Abandon Flow. + */ +class AbandonFailedTokenExchangeMetrics extends AUTest { + + private AccessTokenResponse userAccessToken, secondUserAccessToken + private String cdrArrangementId = "" + private String requestUri + private String secondAuthorisationCode = null + + @BeforeClass (alwaysRun = true) + void "Initial Metrics Request"() { + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Verify Metrics response after abandon the flow without generating token"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Wait until authorisation code expires + sleep(AUConstants.AUTH_CODE_EXPIRATION_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active and New Authorisation count increased by 1 + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = (abandonedCurrentDay + 1) + } else { + abandonedCurrentDay = (abandonedCurrentDay + 1) + abandonedFailedTokenExchangeCurrentDay = (abandonedFailedTokenExchangeCurrentDay + 1) + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify Metrics response when Auth code expired before the Token Exchange"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Wait until authorisation code expires + sleep(AUConstants.AUTH_CODE_EXPIRATION_TIME) + + //Send User Access Token Request + TokenErrorResponse errorResponse = AURequestBuilder.getUserTokenErrorResponse(authorisationCode, + auConfiguration.getAppInfoRedirectURL(), auConfiguration.getAppInfoClientID(), true, true, + auConfiguration.getCommonSigningAlgorithm(), AUConstants.CODE_VERIFIER) + + Assert.assertEquals(errorResponse.toJSONObject().get(AUConstants.ERROR_DESCRIPTION), + AUConstants.CODE_EXPIRE_ERROR_MSG) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active and New Authorisation count increased by 1 + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedFailedTokenExchangeCurrentDay = abandonedFailedTokenExchangeCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Verify Metrics response when token request failure due to an error"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Send User Access Token request with incorrect redirect url + TokenErrorResponse errorResponse = AURequestBuilder.getUserTokenErrorResponse(authorisationCode, + "https://abc.com", auConfiguration.getAppInfoClientID(), true, true, + auConfiguration.getCommonSigningAlgorithm(), AUConstants.CODE_VERIFIER) + + //Wait till abandonment time + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Authorisation Count should increase as it completed the authorisation flow + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedFailedTokenExchangeCurrentDay = abandonedFailedTokenExchangeCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 2 + unattendedCurrentDay = unattendedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify metrics response when there is an error in token call in consent amendment"() { + + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(userAccessToken.tokens.refreshToken) + Assert.assertNotNull(userAccessToken.tokens.accessToken) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve and assert the request URI from Push Authorization request + requestUri = AUTestUtil.parseResponseBody(auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId), "request_uri") + Assert.assertNotNull(requestUri) + + //Retrieve the second authorization code + secondAuthorisationCode = doConsentAmendmentAuthorisation(scopes, cdrArrangementId, + AUConstants.DEFAULT_SHARING_DURATION) + Assert.assertNotNull(secondAuthorisationCode) + + TokenErrorResponse errorResponse = AURequestBuilder.getUserTokenErrorResponse(secondAuthorisationCode, + "https://abc.com", auConfiguration.getAppInfoClientID(), true, true, + auConfiguration.getCommonSigningAlgorithm(), auAuthorisationBuilder.getCodeVerifier()) + Assert.assertEquals(errorResponse.toJSONObject().get(AUConstants.ERROR_DESCRIPTION), + AUConstants.CALLBACK_MISMATCH) + + //Wait until authorisation code expires + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Authorisation Count should increase as it completed the authorisation flow + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + amendedCurrentDayIndividual = amendedCurrentDayIndividual + 1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedFailedTokenExchangeCurrentDay = abandonedFailedTokenExchangeCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify metrics response when abandon without generating token in amendment flow"() { + + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(userAccessToken.tokens.refreshToken) + Assert.assertNotNull(userAccessToken.tokens.accessToken) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve and assert the request URI from Push Authorization request + requestUri = AUTestUtil.parseResponseBody(auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId), "request_uri") + Assert.assertNotNull(requestUri) + + //Retrieve the second authorization code + secondAuthorisationCode = doConsentAmendmentAuthorisation(scopes, cdrArrangementId, + AUConstants.DEFAULT_SHARING_DURATION) + Assert.assertNotNull(secondAuthorisationCode) + + //Wait until abandon time + sleep(AUConstants.AUTH_CODE_EXPIRATION_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Authorisation Count, new Authorisation count and amendment count should increase as it completed the authorisation flow + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + amendedCurrentDayIndividual = amendedCurrentDayIndividual + 1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedFailedTokenExchangeCurrentDay = abandonedFailedTokenExchangeCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Auth code expired before the Token Exchange in amendment flow"() { + + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(userAccessToken.tokens.refreshToken) + Assert.assertNotNull(userAccessToken.tokens.accessToken) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve and assert the request URI from Push Authorization request + requestUri = AUTestUtil.parseResponseBody(auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId), "request_uri") + Assert.assertNotNull(requestUri) + + //Retrieve the second authorization code + secondAuthorisationCode = doConsentAmendmentAuthorisation(scopes, cdrArrangementId, + AUConstants.DEFAULT_SHARING_DURATION) + Assert.assertNotNull(secondAuthorisationCode) + + //Wait until authorisation code expires + sleep(AUConstants.AUTH_CODE_EXPIRATION_TIME) + + TokenErrorResponse errorResponse = AURequestBuilder.getUserTokenErrorResponse(secondAuthorisationCode, + auConfiguration.getAppInfoRedirectURL(), auConfiguration.getAppInfoClientID(), true, true, + auConfiguration.getCommonSigningAlgorithm(), auAuthorisationBuilder.getCodeVerifier()) + Assert.assertEquals(errorResponse.toJSONObject().get(AUConstants.ERROR_DESCRIPTION), + AUConstants.CODE_EXPIRE_ERROR_MSG) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Authorisation Count, new Authorisation count and amendment count should increase as it completed the authorisation flow + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + amendedCurrentDayIndividual = amendedCurrentDayIndividual + 1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedFailedTokenExchangeCurrentDay = abandonedFailedTokenExchangeCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonPreAccountSelectionMetrics.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonPreAccountSelectionMetrics.groovy new file mode 100644 index 000000000..4fbd5cd4a --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonPreAccountSelectionMetrics.groovy @@ -0,0 +1,824 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.authorisation + +import com.nimbusds.oauth2.sdk.AccessTokenResponse +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod +import org.openqa.selenium.By +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +/** + * Test cases to retrieve Authorisation Metrics for Abandon PreAccountSelection Metrics. + */ +class AbandonPreAccountSelectionMetrics extends AUTest { + + private AccessTokenResponse userAccessToken + private String cdrArrangementId = "" + private String requestUri + def shareableElements + String accountID, userId + + @BeforeClass (alwaysRun = true) + void "Initial Metrics Request"() { + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test + void "Close Browser Session in Profile Selection Page"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + if (auConfiguration.getProfileSelectionEnabled()) { + authWebDriver.selectOption(AUPageObjects.INDIVIDUAL_PROFILE_SELECTION) + } + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAccountSelectionCurrentDay = abandonedPreAccountSelectionCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Cancel Auth flow in Profile Selection Page"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Click on cancel button in login page. + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + if (auConfiguration.getProfileSelectionEnabled()) { + authWebDriver.selectOption(AUPageObjects.INDIVIDUAL_PROFILE_SELECTION) + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CANCEL_XPATH) + driver.findElement(By.xpath(AUPageObjects.CONFIRM_CONSENT_DENY_XPATH)).click() + } + } + .execute() + + def authUrl = automationResponse.currentUrl.get() + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) + String stateParam = authUrl.split("state=")[1] + Assert.assertEquals(auAuthorisationBuilder.state.toString(), stateParam) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAccountSelectionCurrentDay = abandonedPreAccountSelectionCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + unattendedCurrentDay = unattendedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Cancel in Individual Accounts Selection"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Click on cancel button in Accounts selection page. + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + if (auConfiguration.getProfileSelectionEnabled()) { + authWebDriver.selectOption(AUPageObjects.INDIVIDUAL_PROFILE_SELECTION) + authWebDriver.clickButtonXpath(AUPageObjects.PROFILE_SELECTION_NEXT_BUTTON) + + //Verify user navigates to Accounts selection page + authWebDriver.isElementDisplayed(AUTestUtil.getSingleAccountXPath()) + + //Click on Cancel + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CANCEL_XPATH) + driver.findElement(By.xpath(AUPageObjects.CONFIRM_CONSENT_DENY_XPATH)).click() + } + } + .execute() + + def authUrl = automationResponse.currentUrl.get() + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) + String stateParam = authUrl.split("state=")[1] + Assert.assertEquals(auAuthorisationBuilder.state.toString(), stateParam) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAccountSelectionCurrentDay = abandonedPreAccountSelectionCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + unattendedCurrentDay = unattendedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Cancel in Business Accounts Selection"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Click on cancel button in Accounts selection page. + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + if (auConfiguration.getProfileSelectionEnabled()) { + authWebDriver.selectOption(AUPageObjects.ORGANIZATION_A_PROFILE_SELECTION) + authWebDriver.clickButtonXpath(AUPageObjects.PROFILE_SELECTION_NEXT_BUTTON) + + //Verify user navigates to Accounts selection page + authWebDriver.isElementDisplayed(AUTestUtil.getBusinessAccount1CheckBox()) + + //Click on Cancel + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CANCEL_XPATH) + driver.findElement(By.xpath(AUPageObjects.CONFIRM_CONSENT_DENY_XPATH)).click() + } + } + .execute() + + def authUrl = automationResponse.currentUrl.get() + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) + String stateParam = authUrl.split("state=")[1] + Assert.assertEquals(auAuthorisationBuilder.state.toString(), stateParam) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAccountSelectionCurrentDay = abandonedPreAccountSelectionCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Close Browser Session in Account Selection Page"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close the browser session on Accounts selection page. + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + if (auConfiguration.getProfileSelectionEnabled()) { + authWebDriver.selectOption(AUPageObjects.ORGANIZATION_A_PROFILE_SELECTION) + authWebDriver.clickButtonXpath(AUPageObjects.PROFILE_SELECTION_NEXT_BUTTON) + + //Verify user navigates to Accounts selection page + authWebDriver.isElementDisplayed(AUTestUtil.getBusinessAccount1CheckBox()) + } + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAccountSelectionCurrentDay = abandonedPreAccountSelectionCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Cancel in Individual Accounts Selection in amendment flow"() { + + //Send Authorisation Request for 1st time + doConsentAuthorisation() + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve and assert the request URI from Push Authorization request + requestUri = AUTestUtil.parseResponseBody(auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId), "request_uri") + Assert.assertNotNull(requestUri) + + //Retrieve the second authorization code + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close the browser session on Accounts selection page. + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + if (auConfiguration.getProfileSelectionEnabled()) { + //Verify user navigates to Accounts selection page + authWebDriver.isElementDisplayed(AUTestUtil.getSingleAccountXPath()) + + //Click on Cancel + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CANCEL_XPATH) + driver.findElement(By.xpath(AUPageObjects.CONFIRM_CONSENT_DENY_XPATH)).click() + } + } + .execute() + + def authUrl = automationResponse.currentUrl.get() + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) + String stateParam = authUrl.split("state=")[1] + Assert.assertEquals(auAuthorisationBuilder.state.toString(), stateParam) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active Authorisation and New Authorisation count should be increased by 1 + activeAuthIndividual = activeAuthIndividual +1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual +1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAccountSelectionCurrentDay = abandonedPreAccountSelectionCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Cancel in Business Accounts Selection in amendment flow"() { + + //Send Authorisation Request for 1st time + doConsentAuthorisation(clientId, AUAccountProfile.ORGANIZATION_A) + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve and assert the request URI from Push Authorization request + requestUri = AUTestUtil.parseResponseBody(auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId), "request_uri") + Assert.assertNotNull(requestUri) + + //Retrieve the second authorization code + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close the browser session on Accounts selection page. + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + if (auConfiguration.getProfileSelectionEnabled()) { + + //Verify user navigates to Accounts selection page + authWebDriver.isElementDisplayed(AUTestUtil.getBusinessAccount1CheckBox()) + + //Click on Cancel + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CANCEL_XPATH) + driver.findElement(By.xpath(AUPageObjects.CONFIRM_CONSENT_DENY_XPATH)).click() + } + } + .execute() + + def authUrl = automationResponse.currentUrl.get() + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) + String stateParam = authUrl.split("state=")[1] + Assert.assertEquals(auAuthorisationBuilder.state.toString(), stateParam) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active Authorisation and New Authorisation count should be increased by 1 + activeAuthNonIndividual = activeAuthNonIndividual +1 + newAuthCurrentDayOngoingNonIndividual = newAuthCurrentDayOngoingNonIndividual +1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAccountSelectionCurrentDay = abandonedPreAccountSelectionCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Close Browser Session in Account Selection Page in amendment flow"() { + + //Send Authorisation Request for 1st time + doConsentAuthorisation() + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve and assert the request URI from Push Authorization request + requestUri = AUTestUtil.parseResponseBody(auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId), "request_uri") + Assert.assertNotNull(requestUri) + + //Retrieve the second authorization code + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close the browser session on Accounts selection page. + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + if (auConfiguration.getProfileSelectionEnabled()) { + //Verify user navigates to Accounts selection page + authWebDriver.isElementDisplayed(AUTestUtil.getSingleAccountXPath()) + } + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active Authorisation and New Authorisation count should be increased by 1 + activeAuthIndividual = activeAuthIndividual +1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual +1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAccountSelectionCurrentDay = abandonedPreAccountSelectionCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify abandonment of consent after going back from Account Selection Page by clicking on browser back button"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Click on cancel button in Accounts selection page. + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + if (auConfiguration.getProfileSelectionEnabled()) { + authWebDriver.selectOption(AUPageObjects.INDIVIDUAL_PROFILE_SELECTION) + authWebDriver.clickButtonXpath(AUPageObjects.PROFILE_SELECTION_NEXT_BUTTON) + + //Verify user navigates to Accounts selection page + authWebDriver.isElementDisplayed(AUTestUtil.getSingleAccountXPath()) + + // Navigate back and close the browser + driver.navigate().back() + } + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAccountSelectionCurrentDay = abandonedPreAccountSelectionCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify abandonment of consent after going back from Profile Selection Page by clicking on browser back button"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Click on cancel button in Accounts selection page. + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + if (auConfiguration.getProfileSelectionEnabled()) { + authWebDriver.selectOption(AUPageObjects.INDIVIDUAL_PROFILE_SELECTION) + + // Navigate back and close the browser + driver.navigate().back() + } + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAccountSelectionCurrentDay = abandonedPreAccountSelectionCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify successful consent flow which does not have account scope"() { + + scopes = [ + AUAccountScope.BANK_PAYEES_READ, + AUAccountScope.BANK_CUSTOMER_BASIC_READ, + AUAccountScope.BANK_CUSTOMER_DETAIL_READ + ] + + // Send Authorisation request and generate user access token + doConsentAuthorisationWithoutAccountSelection() + generateUserAccessToken() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active Authorisation and New Ongoing Individual count increased by 1 + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify abandonment of consent flow in Consent Details Page for consent without account scope"() { + + scopes = [ + AUAccountScope.BANK_PAYEES_READ, + AUAccountScope.BANK_CUSTOMER_BASIC_READ, + AUAccountScope.BANK_CUSTOMER_DETAIL_READ + ] + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Click on cancel button in Accounts selection page. + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + if (auConfiguration.getProfileSelectionEnabled()) { + authWebDriver.selectOption(AUPageObjects.INDIVIDUAL_PROFILE_SELECTION) + authWebDriver.clickButtonXpath(AUPageObjects.PROFILE_SELECTION_NEXT_BUTTON) + } + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAccountSelectionCurrentDay = abandonedPreAccountSelectionCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + unattendedCurrentDay = unattendedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify successful secondary user consent flow"() { + + auConfiguration.setPsuNumber(1) + def clientId = auConfiguration.getAppInfoClientID() + + //Get Sharable Account List and Secondary User with Authorize Permission + shareableElements = AUTestUtil.getSecondaryUserDetails(getSharableBankAccounts()) + + accountID = shareableElements[AUConstants.PARAM_ACCOUNT_ID] + userId = auConfiguration.getUserPSUName() + + def updateResponse = updateSecondaryUserInstructionPermission(accountID, userId, AUConstants.ACTIVE) + Assert.assertEquals(updateResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Secondary Consent Authorisation + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + doSecondaryAccountSelection(scopes, requestUri.toURI()) + Assert.assertNotNull(authorisationCode) + + //Get User Access Token + generateUserAccessToken() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + //Active Authorisation and New Ongoing Individual count increased by 1 + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify abandonment in profile selection page when authorising multiple consents on same browser session"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + //Navigate through Authorise Flow + authorisationCode = authoriseConsentWithoutClosingBrowser(scopes, requestUri.toURI()) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Consent Authorisation - Second Consent + requestUri = AUTestUtil.parseResponseBody(auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, ""), "request_uri") + Assert.assertNotNull(requestUri) + + //Navigate through Authorise Flow + //Retrieve the second authorization code + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close the browser session on Accounts selection page. + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + if (auConfiguration.getProfileSelectionEnabled()) { + authWebDriver.selectOption(AUPageObjects.INDIVIDUAL_PROFILE_SELECTION) + authWebDriver.clickButtonXpath(AUPageObjects.PROFILE_SELECTION_NEXT_BUTTON) + } + } + .execute(true) + + //Wait Time Abandon Time Pass + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Active Individual Authorisation, New Ongoing Individual and Abandonment count increased by 1 + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + highPriorityCurrentDay = highPriorityCurrentDay + 3 + unattendedCurrentDay = unattendedCurrentDay + 1 + } + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonPreAuthenticationMetrics.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonPreAuthenticationMetrics.groovy new file mode 100644 index 000000000..57602a76e --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonPreAuthenticationMetrics.groovy @@ -0,0 +1,304 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.authorisation + +import com.nimbusds.oauth2.sdk.AccessTokenResponse +import org.openqa.selenium.By +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.openbanking.test.framework.automation.NavigationAutomationStep +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +import java.util.concurrent.TimeUnit + +/** + * Test cases to retrieve Authorisation Metrics for Abandon PreAuthentication Metrics. + */ +class AbandonPreAuthenticationMetrics extends AUTest { + + private AccessTokenResponse userAccessToken + private String cdrArrangementId = "" + private String requestUri + + @BeforeClass (alwaysRun = true) + void "Initial Metrics Request"() { + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Close browser session in OTP page"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new NavigationAutomationStep(authoriseUrl, 10)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //User Login + authWebDriver.executeTextField(AUPageObjects.AU_USERNAME_FIELD_ID, auConfiguration.getUserPSUName()) + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) + + //Click on SignIn Button + authWebDriver.clickButtonXpath(AUPageObjects.AU_AUTH_SIGNIN_XPATH) + + //Identifier First Authentication + Assert.assertTrue(authWebDriver.isElementDisplayed(AUConstants.LBL_OTP_TIMEOUT)) + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAuthenticationCurrentDay = abandonedPreAuthenticationCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + unattendedCurrentDay = unattendedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Authenticate consent flow with incorrect OTP but proceed again with correct OTP"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new NavigationAutomationStep(authoriseUrl, 10)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //User Login + authWebDriver.executeTextField(AUPageObjects.AU_USERNAME_FIELD_ID, auConfiguration.getUserPSUName()) + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) + + //Click on SignIn Button + authWebDriver.clickButtonXpath(AUPageObjects.AU_AUTH_SIGNIN_XPATH) + + //Identifier First Authentication + authWebDriver.executeSMSOTP(AUPageObjects.AU_LBL_SMSOTP_AUTHENTICATOR, AUPageObjects.AU_TXT_OTP_CODE_ID, + "123") + authWebDriver.clickButtonXpath(AUPageObjects.AU_BTN_AUTHENTICATE) + + driver.findElement(By.xpath(AUPageObjects.AU_LBL_SMSOTP_AUTHENTICATOR)).click() + authWebDriver.executeSMSOTP(AUPageObjects.AU_LBL_SMSOTP_AUTHENTICATOR, AUPageObjects.AU_TXT_OTP_CODE_ID, + AUConstants.OTP_CODE) + authWebDriver.clickButtonXpath(AUPageObjects.AU_BTN_AUTHENTICATE) + + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) + + //Select Profile and Accounts + selectProfileAndAccount(authWebDriver, AUAccountProfile.ORGANIZATION_A) + + //Click Confirm Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + + //Click Authorise Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + } + .execute() + + authorisationCode = AUTestUtil.getCodeFromJwtResponse(automationResponse.currentUrl.get()) + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(userAccessToken.tokens.accessToken) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Authorisation Count should increase as it completed the authorisation flow + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Close browser session in OTP page during amendment flow"() { + + //Send Authorisation Request for 1st time + doConsentAuthorisation() + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve and assert the request URI from Push Authorization request + requestUri = AUTestUtil.parseResponseBody(auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId), "request_uri") + Assert.assertNotNull(requestUri) + + //Retrieve the second authorization code + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new NavigationAutomationStep(authoriseUrl, 10)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //User Login + authWebDriver.executeTextField(AUPageObjects.AU_USERNAME_FIELD_ID, auConfiguration.getUserPSUName()) + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) + + //Click on SignIn Button + authWebDriver.clickButtonXpath(AUPageObjects.AU_AUTH_SIGNIN_XPATH) + + //Identifier First Authentication + Assert.assertTrue(authWebDriver.isElementDisplayed(AUConstants.LBL_OTP_TIMEOUT)) + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Authorisation Count should increase as it completed the authorisation flow + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAuthenticationCurrentDay = abandonedPreAuthenticationCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify abandonment of consent flow after going back to login page by clicking on browser back button"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new NavigationAutomationStep(authoriseUrl, 10)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //User Login + authWebDriver.executeTextField(AUPageObjects.AU_USERNAME_FIELD_ID, auConfiguration.getUserPSUName()) + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) + + //Click on SignIn Button + authWebDriver.clickButtonXpath(AUPageObjects.AU_AUTH_SIGNIN_XPATH) + + //Identifier First Authentication + Assert.assertTrue(authWebDriver.isElementDisplayed(AUConstants.LBL_OTP_TIMEOUT)) + + //Navigate Back + driver.navigate().back() + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAuthenticationCurrentDay = abandonedPreAuthenticationCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + unattendedCurrentDay = unattendedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonPreAuthorisationMetrics.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonPreAuthorisationMetrics.groovy new file mode 100644 index 000000000..1e6289b7e --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonPreAuthorisationMetrics.groovy @@ -0,0 +1,279 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.authorisation + +import com.nimbusds.oauth2.sdk.AccessTokenResponse +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +/** + * Test cases to retrieve Authorisation Metrics for Abandon PreAuthorisation Metrics. + */ +class AbandonPreAuthorisationMetrics extends AUTest { + + private AccessTokenResponse userAccessToken + private String cdrArrangementId = "" + private String requestUri + + @BeforeClass (alwaysRun = true) + void "Initial Metrics Request"() { + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Close Browser Session in Consent Detail Page"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + selectProfileAndAccount(authWebDriver, AUAccountProfile.INDIVIDUAL) + + //Click Confirm Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAuthorisationCurrentDay = abandonedPreAuthorisationCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + unattendedCurrentDay = unattendedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify consent abandon by going back from consent details page"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + selectProfileAndAccount(authWebDriver, AUAccountProfile.INDIVIDUAL) + + //Click Confirm Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + + //Navigate Back + driver.navigate().back() + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAuthorisationCurrentDay = abandonedPreAuthorisationCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Close Browser Session in Consent Detail Page in amendment flow"() { + + //Send Authorisation Request for 1st time + doConsentAuthorisation() + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve and assert the request URI from Push Authorization request + requestUri = AUTestUtil.parseResponseBody(auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId), "request_uri") + Assert.assertNotNull(requestUri) + + //Retrieve the second authorization code + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Click Confirm Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Authorisation Count should increase as it completed the authorisation flow + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAuthorisationCurrentDay = abandonedPreAuthorisationCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + unattendedCurrentDay = unattendedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify consent abandon by going back from consent details page in amendment flow"() { + + //Send Authorisation Request for 1st time + doConsentAuthorisation() + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve and assert the request URI from Push Authorization request + requestUri = AUTestUtil.parseResponseBody(auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId), "request_uri") + Assert.assertNotNull(requestUri) + + //Retrieve the second authorization code + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Click Confirm Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + + //Navigate Back + driver.navigate().back() + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Authorisation Count should increase as it completed the authorisation flow + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAuthorisationCurrentDay = abandonedPreAuthorisationCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonPreIdentificationMetrics.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonPreIdentificationMetrics.groovy new file mode 100644 index 000000000..0a4a4da41 --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonPreIdentificationMetrics.groovy @@ -0,0 +1,540 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.authorisation + +import com.nimbusds.oauth2.sdk.AccessTokenResponse +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.openbanking.test.framework.automation.NavigationAutomationStep +import org.openqa.selenium.By +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +import java.util.concurrent.TimeUnit + +/** + * Test cases to retrieve Authorisation Metrics for Abandon PreIdentification Metrics. + */ +class AbandonPreIdentificationMetrics extends AUTest { + + private AccessTokenResponse userAccessToken + private String cdrArrangementId = "" + private String requestUri + + @BeforeClass (alwaysRun = true) + void "Initial Metrics Request"() { + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Cancel consent flow from Login Page"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new NavigationAutomationStep(authoriseUrl, 10)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //User Login + authWebDriver.executeTextField(AUPageObjects.AU_USERNAME_FIELD_ID, auConfiguration.getUserPSUName()) + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) + + //Click on Cancel Button + authWebDriver.clickButtonXpath(AUPageObjects.BTN_CANCEL) + + //Click on Cancel Confirmation Button + authWebDriver.clickButtonXpath(AUPageObjects.CONFIRM_CONSENT_DENY_XPATH) + } + .execute() + + def authUrl = automationResponse.currentUrl.get() + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.USER_SKIP_THE_CONSENT_FLOW)) + String stateParam = authUrl.split("state=")[1] + Assert.assertEquals(auAuthorisationBuilder.state.toString(), stateParam) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreIdentificationCurrentDay = abandonedPreIdentificationCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + unattendedCurrentDay = unattendedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Close browser in login page"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new NavigationAutomationStep(authoriseUrl, 10)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //User Login + authWebDriver.executeTextField(AUPageObjects.AU_USERNAME_FIELD_ID, auConfiguration.getUserPSUName()) + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreIdentificationCurrentDay = abandonedPreIdentificationCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + unattendedCurrentDay = unattendedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Authenticate consent flow with incorrect username but proceed again with correct username"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new NavigationAutomationStep(authoriseUrl, 10)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Enter incorrect user name + authWebDriver.executeTextField(AUPageObjects.AU_USERNAME_FIELD_ID, "am@wso2.com") + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) + + //Click on SignIn Button + authWebDriver.clickButtonXpath(AUPageObjects.AU_AUTH_SIGNIN_XPATH) + + //Enter Correct User Name + driver.findElement(By.id(AUPageObjects.AU_USERNAME_FIELD_ID)).click() + authWebDriver.executeTextField(AUPageObjects.AU_USERNAME_FIELD_ID, auConfiguration.getUserPSUName()) + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) + + //Click on SignIn Button + authWebDriver.clickButtonXpath(AUPageObjects.AU_AUTH_SIGNIN_XPATH) + + //Identifier First Authentication + authWebDriver.executeSMSOTP(AUPageObjects.AU_LBL_SMSOTP_AUTHENTICATOR, AUPageObjects.AU_TXT_OTP_CODE_ID, + AUConstants.OTP_CODE) + authWebDriver.clickButtonXpath(AUPageObjects.AU_BTN_AUTHENTICATE) + + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) + + //Select Profile and Accounts + selectProfileAndAccount(authWebDriver, AUAccountProfile.INDIVIDUAL) + + //Click Confirm Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + + //Click Authorise Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + } + .execute() + + authorisationCode = AUTestUtil.getCodeFromJwtResponse(automationResponse.currentUrl.get()) + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(userAccessToken.tokens.accessToken) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify count not increased after abandoning the flow with incorrect OTP"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new NavigationAutomationStep(authoriseUrl, 10)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //User Login + authWebDriver.executeTextField(AUPageObjects.AU_USERNAME_FIELD_ID, auConfiguration.getUserPSUName()) + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) + + //Click on SignIn Button + authWebDriver.clickButtonXpath(AUPageObjects.AU_AUTH_SIGNIN_XPATH) + + //Identifier First Authentication + authWebDriver.executeSMSOTP(AUPageObjects.AU_LBL_SMSOTP_AUTHENTICATOR, AUPageObjects.AU_TXT_OTP_CODE_ID, + "123") + authWebDriver.clickButtonXpath(AUPageObjects.AU_BTN_AUTHENTICATE) + + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreAuthenticationCurrentDay = abandonedPreAuthenticationCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Cancelling consent authorization from Login page during amendment"() { + + //Send Authorisation Request for 1st time + doConsentAuthorisation() + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve and assert the request URI from Push Authorization request + requestUri = AUTestUtil.parseResponseBody(auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId), "request_uri") + Assert.assertNotNull(requestUri) + + //Retrieve the second authorization code + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new NavigationAutomationStep(authoriseUrl, 10)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //User Login + authWebDriver.executeTextField(AUPageObjects.AU_USERNAME_FIELD_ID, auConfiguration.getUserPSUName()) + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) + + //Click on Cancel + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CANCEL_XPATH) + driver.findElement(By.xpath(AUPageObjects.CONFIRM_CONSENT_DENY_XPATH)).click() + } + .execute() + + def authUrl = automationResponse.currentUrl.get() + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.USER_SKIP_THE_CONSENT_FLOW)) + String stateParam = authUrl.split("state=")[1] + Assert.assertEquals(auAuthorisationBuilder.state.toString(), stateParam) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Authorisation Count should increase as it completed the authorisation flow + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreIdentificationCurrentDay = abandonedPreIdentificationCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 3 + unattendedCurrentDay = unattendedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Closing the browser in Login page during amendment"() { + + //Send Authorisation Request for 1st time + doConsentAuthorisation() + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve and assert the request URI from Push Authorization request + requestUri = AUTestUtil.parseResponseBody(auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId), "request_uri") + Assert.assertNotNull(requestUri) + + //Retrieve the second authorization code + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new NavigationAutomationStep(authoriseUrl, 10)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //User Login + authWebDriver.executeTextField(AUPageObjects.AU_USERNAME_FIELD_ID, auConfiguration.getUserPSUName()) + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Authorisation Count should increase as it completed the authorisation flow + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreIdentificationCurrentDay = abandonedPreIdentificationCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 3 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify abandonment of consent flow after going back by clicking on browser back button"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close Browser Session in Profile selection page + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new NavigationAutomationStep(authoriseUrl, 10)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //User Login + authWebDriver.executeTextField(AUPageObjects.AU_USERNAME_FIELD_ID, auConfiguration.getUserPSUName()) + driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS) + + //Navigate Back + driver.navigate().back() + + } + .execute() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedPreIdentificationCurrentDay = abandonedPreIdentificationCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + unattendedCurrentDay = unattendedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Verify the currentDay count when authorising multiple consents on same browser session"() { + + //Consent Authorisation Flow + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + //Navigate through Authorise Flow + authorisationCode = authoriseConsentWithoutClosingBrowser(scopes, requestUri.toURI()) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Consent Authorisation - Second Consent + def requestUri2 = AUTestUtil.parseResponseBody(auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, ""), "request_uri") + Assert.assertNotNull(requestUri2) + + //Navigate through Authorise Flow + //Retrieve the second authorization code + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri2.toURI(), auConfiguration.getAppInfoClientID()) + .toURI().toString() + + //Close the browser session on Accounts selection page. + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + selectProfileAndAccount(authWebDriver, AUAccountProfile.INDIVIDUAL, false) + + //Click Confirm Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + + //Click Authorise Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + } + .execute(true) + + authorisationCode = AUTestUtil.getCodeFromJwtResponse(automationResponse.currentUrl.get()) + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + + //Wait Time Abandon Time Pass + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Active NonIndividual Authorisation and New Ongoing NonIndividual count increased by 2 + activeAuthIndividual = activeAuthIndividual + 2 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 2 + unattendedCurrentDay = unattendedCurrentDay + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 4 + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonRejectedMetrics.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonRejectedMetrics.groovy new file mode 100644 index 000000000..76d1498ef --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AbandonRejectedMetrics.groovy @@ -0,0 +1,132 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.authorisation + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +/** + * Test Cases for Abandon Rejected Metrics. + */ +class AbandonRejectedMetrics extends AUTest { + + private String cdrArrangementId = "" + private String requestUri + private def accessTokenResponse + + @BeforeClass (alwaysRun = true) + void "Initial Metrics Request"() { + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Deny the Consent Flow"() { + + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + + String responseUrl = doConsentAuthorisationViaRequestUriDenyFlow(scopes, requestUri.toURI(), + auConfiguration.getAppInfoClientID(), AUAccountProfile.INDIVIDUAL) + + authFlowError = AUTestUtil.getErrorDescriptionFromUrl(responseUrl) + Assert.assertEquals(authFlowError, AUConstants.USER_DENIED_THE_CONSENT) + + //Verify Metrics Response + sleep(AUConstants.ABANDON_WAIT_TIME) + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedRejectedCurrentDay = abandonedRejectedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Deny the Consent Flow in amendment flow"() { + + // Send Authorisation request + doConsentAuthorisation() + + // Retrieve the user access token by auth code + accessTokenResponse = getUserAccessTokenResponse(clientId) + cdrArrangementId = accessTokenResponse.getCustomParameters().get(AUConstants.CDR_ARRANGEMENT_ID) + Assert.assertNotNull(cdrArrangementId) + + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.PROFILE) + + //Retrieve and assert the request URI from Push Authorization request + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + + String responseUrl = doConsentAmendmentDenyFlow(scopes, cdrArrangementId, AUConstants.SHORT_SHARING_DURATION, + auConfiguration.getAppInfoClientID()) + + authFlowError = AUTestUtil.getErrorDescriptionFromUrl(responseUrl) + Assert.assertEquals(authFlowError, AUConstants.USER_DENIED_THE_CONSENT) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active Individual Authorisation and New Ongoing Individual count increased by 1 + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Abandon count increased by 1 + if (AUConstants.X_V_HEADER_METRICS == 4) { + abandonedCurrentDay = abandonedCurrentDay + 1 + } else { + abandonedCurrentDay = abandonedCurrentDay + 1 + abandonedRejectedCurrentDay = abandonedRejectedCurrentDay + 1 + } + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/ActiveAndNewAuthorisationMetrics.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/ActiveAndNewAuthorisationMetrics.groovy new file mode 100644 index 000000000..69065da52 --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/ActiveAndNewAuthorisationMetrics.groovy @@ -0,0 +1,324 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.authorisation + + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +/** + * Test cases to retrieve Authorisation Metrics for New and Active Authorizations. + */ +class ActiveAndNewAuthorisationMetrics extends AUTest { + + private String requestUri + + @BeforeClass (alwaysRun = true) + void "Initial Metrics Request"() { + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Authorise New ongoing consent for Individual Profile"(){ + + doConsentAuthorisation(auConfiguration.getAppInfoClientID(), AUAccountProfile.INDIVIDUAL) + generateUserAccessToken() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active Authorisation and New Ongoing Individual count increased by 1 + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Authorise New ongoing consent for Business Profile"(){ + + auConfiguration.setPsuNumber(2) + doConsentAuthorisation(auConfiguration.getAppInfoClientID(), AUAccountProfile.ORGANIZATION_A) + generateUserAccessToken() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active NonIndividual Authorisation and New Ongoing NonIndividual count increased by 1 + activeAuthNonIndividual = activeAuthNonIndividual + 1 + newAuthCurrentDayOngoingNonIndividual = newAuthCurrentDayOngoingNonIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Authorise New once off consent for Individual Profile"(){ + + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.SHORT_SHARING_DURATION, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + generateUserAccessToken(auConfiguration.getAppInfoClientID()) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New OnceOff Individual count increased by 1 + newAuthCurrentDayOnceOffIndividual = newAuthCurrentDayOnceOffIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Authorise New once off consent for Business Profile"(){ + + auConfiguration.setPsuNumber(2) + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.SHORT_SHARING_DURATION, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.ORGANIZATION_A) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + generateUserAccessToken(auConfiguration.getAppInfoClientID()) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New OnceOff NonIndividual count increased by 1 + newAuthCurrentDayOnceOffNonIndividual = newAuthCurrentDayOnceOffNonIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Authorise New once off consent for Individual Profile with 0 sharing duration"(){ + + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.SINGLE_ACCESS_CONSENT, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + generateUserAccessToken(auConfiguration.getAppInfoClientID()) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New OnceOff Individual count increased by 1 + newAuthCurrentDayOnceOffIndividual = newAuthCurrentDayOnceOffIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Authorise New once off consent for Individual Profile with 24hr sharing duration"(){ + + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.SHARING_DURATION_24H, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + generateUserAccessToken(auConfiguration.getAppInfoClientID()) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New OnceOff Individual count increased by 1 + newAuthCurrentDayOnceOffIndividual = newAuthCurrentDayOnceOffIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Authorise New ongoing consent for Individual Profile - joint account"(){ + + automationResponse = doJointAccountConsentAuthorisation(auConfiguration.getAppInfoClientID(), true) + authorisationCode = AUTestUtil.getCodeFromJwtResponse(automationResponse.currentUrl.get()) + + //Generate User Access Token + generateUserAccessToken(auConfiguration.getAppInfoClientID()) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New Ongoing Individual count increased by 1 + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Authorise New onceoff consent for Individual Profile - joint account"(){ + + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.SHORT_SHARING_DURATION, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + automationResponse = doAuthorisationFlowForJointAccounts(scopes, requestUri.toURI(),null) + authorisationCode = AUTestUtil.getCodeFromJwtResponse(automationResponse.currentUrl.get()) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + generateUserAccessToken(auConfiguration.getAppInfoClientID()) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New OnceOff Individual count increased by 1 + newAuthCurrentDayOnceOffIndividual = newAuthCurrentDayOnceOffIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Authorise New ongoing consent for Individual Profile - secondary account"(){ + + auConfiguration.setPsuNumber(1) + + //Send Push Authorisation Request + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + + //Select Secondary Account during authorisation + doSecondaryAccountSelection(scopes, requestUri.toURI()) + Assert.assertNotNull(authorisationCode) + + //Get User Access Token + generateUserAccessToken() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active Authorisation and New Ongoing Individual count increased by 1 + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Authorise New once off consent for Individual Profile - secondary account"(){ + + auConfiguration.setPsuNumber(1) + + //Send Push Authorisation Request + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.SHORT_SHARING_DURATION, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + + //Select Secondary Account during authorisation + doSecondaryAccountSelection(scopes, requestUri.toURI()) + Assert.assertNotNull(authorisationCode) + + //Get User Access Token + generateUserAccessToken() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New OnceOff Individual count increased by 1 + newAuthCurrentDayOnceOffIndividual = newAuthCurrentDayOnceOffIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AmendedAuthorisationMetrics.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AmendedAuthorisationMetrics.groovy new file mode 100644 index 000000000..b8321284a --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/AmendedAuthorisationMetrics.groovy @@ -0,0 +1,403 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.authorisation + +import com.nimbusds.oauth2.sdk.AccessTokenResponse +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +import java.nio.charset.Charset + +/** + * Test cases to retrieve Authorisation Metrics for amendedAuthorization. + */ +class AmendedAuthorisationMetrics extends AUTest { + + private String cdrArrangementId = "" + private AccessTokenResponse userAccessToken, secondUserAccessToken + private String requestUri + public String secondAuthorisationCode, thirdAuthorisationCode = null + def clientHeader = "${Base64.encoder.encodeToString(getCDSClient().getBytes(Charset.defaultCharset()))}" + + @BeforeClass (alwaysRun = true) + void "Initial Metrics Request"() { + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Consent Amendment for Ongoing Single account consent"(){ + + //Send Authorisation Request for 1st time + doConsentAuthorisation() + + //Generate User Access Token + AccessTokenResponse userAccessTokenRes = getUserAccessTokenResponse() + String cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve the second authorization code + authorisationCode = doConsentAmendmentAuthorisation(scopes, cdrArrangementId, + AUConstants.DEFAULT_SHARING_DURATION, auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + userAccessTokenRes = getUserAccessTokenResponse() + cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active Authorisation, New Ongoing Individual and Amendment count increased by 1 + + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + amendedCurrentDayIndividual = amendedCurrentDayIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (groups = "SmokeTest", priority = 1) + void "Consent Amendment for Ongoing Business account consent"(){ + + auConfiguration.setPsuNumber(2) + //Send Authorisation Request for 1st time + doConsentAuthorisation(auConfiguration.getAppInfoClientID(), AUAccountProfile.ORGANIZATION_B) + + //Generate User Access Token + AccessTokenResponse userAccessTokenRes = getUserAccessTokenResponse() + String cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + auConfiguration.setPsuNumber(2) + //Retrieve the second authorization code + authorisationCode = doBusinessConsentAmendmentAuthorisation(scopes, cdrArrangementId, + AUConstants.ONE_YEAR_DURATION, auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + userAccessTokenRes = getUserAccessTokenResponse() + cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active Authorisation, New Ongoing Individual and Amendment count increased by 1 + + activeAuthNonIndividual = activeAuthNonIndividual + 1 + newAuthCurrentDayOngoingNonIndividual = newAuthCurrentDayOngoingNonIndividual + 1 + amendedCurrentDayNonIndividual = amendedCurrentDayNonIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (groups = "SmokeTest", priority = 2) + void "Consent Amendment for Joint account consent"(){ + + automationResponse = doJointAccountConsentAuthorisation(auConfiguration.getAppInfoClientID(), true) + authorisationCode = AUTestUtil.getCodeFromJwtResponse(automationResponse.currentUrl.get()) + + //Generate User Access Token + AccessTokenResponse userAccessTokenRes = getUserAccessTokenResponse() + String cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve the second authorization code + authorisationCode = doConsentAmendmentAuthorisation(scopes, cdrArrangementId, + AUConstants.DEFAULT_SHARING_DURATION, auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + userAccessTokenRes = getUserAccessTokenResponse() + cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active Authorisation, New Ongoing Individual and Amendment count increased by 1 + + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + amendedCurrentDayIndividual = amendedCurrentDayIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (groups = "SmokeTest", priority = 3) + void "Consent Amendment for Secondary account consent"(){ + + auConfiguration.setPsuNumber(1) + //Send Push Authorisation Request + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + + //Select Secondary Account during authorisation + doSecondaryAccountSelection(scopes, requestUri.toURI()) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + AccessTokenResponse userAccessTokenRes = getUserAccessTokenResponse() + String cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve the second authorization code + authorisationCode = doConsentAmendmentAuthorisation(scopes, cdrArrangementId, + AUConstants.DEFAULT_SHARING_DURATION, auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + userAccessTokenRes = getUserAccessTokenResponse() + cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active Authorisation, New Ongoing Individual and Amendment count increased by 1 + + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + amendedCurrentDayIndividual = amendedCurrentDayIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (priority = 4) + void "Consent Amendment with sharing duration less than 1 hr"(){ + + //Send Authorisation Request for 1st time + doConsentAuthorisation() + + //Generate User Access Token + AccessTokenResponse userAccessTokenRes = getUserAccessTokenResponse() + String cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve the second authorization code + authorisationCode = doConsentAmendmentAuthorisation(scopes, cdrArrangementId, + AUConstants.SHORT_SHARING_DURATION, auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + userAccessTokenRes = getUserAccessTokenResponse() + cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Active Authorisation, New Ongoing Individual count increased by 1 and Amendment count not changed. + + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (priority = 5) + void "Amend onceoff consent to an ongoing consent"(){ + + //Send Authorisation Request for 1st time + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.SHORT_SHARING_DURATION, + true, "", clientId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), clientId, AUAccountProfile.INDIVIDUAL) + + //Generate User Access Token + AccessTokenResponse userAccessTokenRes = getUserAccessTokenResponse() + String cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve the second authorization code + authorisationCode = doConsentAmendmentAuthorisation(scopes, cdrArrangementId, + AUConstants.DEFAULT_SHARING_DURATION, auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + userAccessTokenRes = getUserAccessTokenResponse() + cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New OnceOff Individual count increased and Amendment count increased by 1. + + newAuthCurrentDayOnceOffIndividual = newAuthCurrentDayOnceOffIndividual + 1 + amendedCurrentDayIndividual = amendedCurrentDayIndividual + 1 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (priority = 6) + void "Amendment of Consent More than once create multiple records"(){ + + //Send Authorisation Request for 1st time + doConsentAuthorisation() + + //Generate User Access Token + AccessTokenResponse userAccessTokenRes = getUserAccessTokenResponse() + String cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + //Consent Amendment - 1st time + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve the second authorization code + secondAuthorisationCode = doConsentAmendmentAuthorisation(scopes, cdrArrangementId, + AUConstants.DEFAULT_SHARING_DURATION, auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(secondAuthorisationCode) + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(secondAuthorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + String cdrArrangementId2 = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId2) + Assert.assertEquals(cdrArrangementId2, cdrArrangementId) + + //Consent Amendment - 2nd Time + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + + //Retrieve the third authorization code + thirdAuthorisationCode = doConsentAmendmentAuthorisation(scopes, cdrArrangementId2, + AUConstants.DEFAULT_SHARING_DURATION, auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(thirdAuthorisationCode) + + //Retrieve the third user access token and assert the CDR arrangement ID is the same. + userAccessToken = AURequestBuilder.getUserToken(thirdAuthorisationCode, AUConstants.CODE_VERIFIER, + auConfiguration.getAppInfoClientID()) + def cdrArrangementId3 = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId3) + Assert.assertEquals(cdrArrangementId3, cdrArrangementId) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New OnceOff Individual count increased and Amendment count increased by 1. + newAuthCurrentDayOnceOffIndividual = newAuthCurrentDayOnceOffIndividual + 1 + amendedCurrentDayIndividual = amendedCurrentDayIndividual + 2 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/RevokedAuthorisationMetrics.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/RevokedAuthorisationMetrics.groovy new file mode 100644 index 000000000..c63270f9a --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/authorisation/RevokedAuthorisationMetrics.groovy @@ -0,0 +1,280 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.authorisation + +import com.nimbusds.oauth2.sdk.AccessTokenResponse +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +/** + * Test cases to retrieve Authorisation Metrics for revokedAuthorization. + */ +class RevokedAuthorisationMetrics extends AUTest { + + private String cdrArrangementId = "" + private AccessTokenResponse userAccessToken + private String requestUri + + @BeforeClass (alwaysRun = true) + void "Initial Metrics Request"() { + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Consent revocation via CDR Arrangement Endpoint for Individual Consent"(){ + + //Send Authorisation Request for 1st time + doConsentAuthorisation() + + //Generate User Access Token + AccessTokenResponse userAccessTokenRes = getUserAccessTokenResponse() + String cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + //retrieve consumer data successfully + doAccountRetrieval(accessToken) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //revoke sharing arrangement + def revokeResponse = doRevokeCdrArrangement(auConfiguration.getAppInfoClientID(), cdrArrangementId) + Assert.assertEquals(revokeResponse.statusCode(), AUConstants.STATUS_CODE_204) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New Ongoing Individual and revoked count increased by 1. Active authorisations count should not increased. + + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + revokedCurrentDayIndividual = revokedCurrentDayIndividual + 1 + activeAuthIndividual = activeAuthIndividual + 1 + highPriorityCurrentDay = highPriorityCurrentDay + 3 + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Consent revocation via CDR Arrangement Endpoint for Business Consent"(){ + + auConfiguration.setPsuNumber(2) + + //Send Authorisation Request for 1st time + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.ORGANIZATION_A) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + AccessTokenResponse userAccessTokenRes = getUserAccessTokenResponse() + String cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + //retrieve consumer data successfully + doAccountRetrieval(accessToken) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //revoke sharing arrangement + def revokeResponse = doRevokeCdrArrangement(auConfiguration.getAppInfoClientID(), cdrArrangementId) + Assert.assertEquals(revokeResponse.statusCode(), AUConstants.STATUS_CODE_204) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New Ongoing NonIndividual and revoked count increased by 1. Active authorisations count should not increased. + + newAuthCurrentDayOngoingNonIndividual = newAuthCurrentDayOngoingNonIndividual + 1 + revokedCurrentDayNonIndividual = revokedCurrentDayNonIndividual + 1 + activeAuthNonIndividual = activeAuthNonIndividual + 1 + + highPriorityCurrentDay = highPriorityCurrentDay + 3 + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Consent revocation via CDR Arrangement Endpoint for Individual Once off Consent"(){ + + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.SINGLE_ACCESS_CONSENT, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + AccessTokenResponse userAccessTokenRes = getUserAccessTokenResponse() + String cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + //retrieve consumer data successfully + doAccountRetrieval(accessToken) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //revoke sharing arrangement + def revokeResponse = doRevokeCdrArrangement(auConfiguration.getAppInfoClientID(), cdrArrangementId) + Assert.assertEquals(revokeResponse.statusCode(), AUConstants.STATUS_CODE_204) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New Onceoff Individual count increased by 1. Active authorisations count and the revoked count should not + // increased. + newAuthCurrentDayOnceOffIndividual = newAuthCurrentDayOnceOffIndividual + 1 + + highPriorityCurrentDay = highPriorityCurrentDay + 3 + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Consent revocation via CDR Arrangement Endpoint for Business Once off Consent"(){ + + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.SINGLE_ACCESS_CONSENT, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.ORGANIZATION_A) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + AccessTokenResponse userAccessTokenRes = getUserAccessTokenResponse() + String cdrArrangementId = userAccessTokenRes.getCustomParameters().get("cdr_arrangement_id") + accessToken = userAccessTokenRes.tokens.accessToken + Assert.assertNotNull(cdrArrangementId) + + //retrieve consumer data successfully + doAccountRetrieval(accessToken) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //revoke sharing arrangement + def revokeResponse = doRevokeCdrArrangement(auConfiguration.getAppInfoClientID(), cdrArrangementId) + Assert.assertEquals(revokeResponse.statusCode(), AUConstants.STATUS_CODE_204) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New Once off Individual count increased by 1. Active authorisations count and the revoked count should not + // increased. + + newAuthCurrentDayOnceOffNonIndividual = newAuthCurrentDayOnceOffNonIndividual + 1 + + highPriorityCurrentDay = highPriorityCurrentDay + 3 + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } + + @Test + void "Consent revocation after deleting the TPP"(){ + + auConfiguration.setTppNumber(1) + + //Register Application + def registrationResponse = tppRegistration() + clientId = AUTestUtil.parseResponseBody(registrationResponse, "client_id") + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.CREATED) + + //Write Client Id to config file. + AUTestUtil.writeToConfigFile(clientId) + + //Authorise consent + doConsentAuthorisation(clientId) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + userAccessToken = AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, + clientId) + String userToken = userAccessToken.tokens.accessToken + cdrArrangementId = userAccessToken.getCustomParameters().get("cdr_arrangement_id") + Assert.assertNotNull(cdrArrangementId) + Assert.assertNotNull(userToken) + + //retrieve consumer data successfully + doAccountRetrieval(userToken) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Delete Application + deleteApplicationIfExists(clientId) + Assert.assertEquals(deletionResponse.statusCode(), AUConstants.STATUS_CODE_204) + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //New Ongoing Individual count and the revoked count increased by 1. + + revokedCurrentDayIndividual = revokedCurrentDayIndividual + 1 + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + highPriorityCurrentDay = highPriorityCurrentDay + 3 + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the response + assertMetricsAuthorisationResponse(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/customerAndRecipientCount/CustomerRecipientCountValidationTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/customerAndRecipientCount/CustomerRecipientCountValidationTests.groovy new file mode 100644 index 000000000..1a44f9c16 --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/customerAndRecipientCount/CustomerRecipientCountValidationTests.groovy @@ -0,0 +1,213 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.customerAndRecipientCount + +import com.nimbusds.oauth2.sdk.AccessTokenResponse +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import io.restassured.response.Response +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +/** + * Customer Count and Recipient Count Validation Tests. + */ +class CustomerRecipientCountValidationTests extends AUTest { + + private AccessTokenResponse accessTokenResponse + private String cdrArrangementId = "" + private String clientId, accessToken, requestUri + File xmlFile = new File(System.getProperty("user.dir").toString().concat("/../../resources/test-config.xml")) + + @BeforeClass + void "Initial Metrics Request"() { + + //Send Initial Metrics Request + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + + auConfiguration.setTppNumber(1) + jtiVal = String.valueOf(System.currentTimeMillis()) + AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() + + //Create New Application + if(auConfiguration.getAppInfoClientID().equalsIgnoreCase("") || + auConfiguration.getAppInfoClientID().equalsIgnoreCase("AppConfig2.Application.ClientID")) { + + Response registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(registrationRequestBuilder.getAURegularClaims()) + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + clientId = AUTestUtil.parseResponseBody(registrationResponse, AUConstants.CLIENT_ID) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.CREATED) + clientId = AUTestUtil.parseResponseBody(registrationResponse, "client_id") + AUTestUtil.writeXMLContent(xmlFile.toString(), "Application", "ClientID", clientId, 1) + } + } + + @Test + void "Verify the count 0 if there are no active authorisations"() { + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_CUSTOMER_COUNT), + "${customerCount}", "$AUConstants.DATA_CUSTOMER_COUNT count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_RECIPIENT_COUNT), + "${recipientCount}", "$AUConstants.DATA_RECIPIENT_COUNT count mismatch") + } + + @Test + void "Verify the count equals to the PSU count with active authorisations"() { + + auConfiguration.setPsuNumber(1) + + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Get User Access Token + accessTokenResponse = AURequestBuilder.getUserToken(authorisationCode, auAuthorisationBuilder.getCodeVerifier(), + auConfiguration.getAppInfoClientID()) + accessToken = accessTokenResponse.getTokens().accessToken + cdrArrangementId = accessTokenResponse.getCustomParameters().get("cdr_arrangement_id") + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + customerCount = customerCount + 1 + recipientCount = recipientCount + 1 + + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_CUSTOMER_COUNT), + "${customerCount}", "$AUConstants.DATA_CUSTOMER_COUNT count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_RECIPIENT_COUNT), + "${recipientCount}", "$AUConstants.DATA_RECIPIENT_COUNT count mismatch") + } + + @Test (dependsOnMethods = "Verify the count equals to the PSU count with active authorisations") + void "Verify the count after revoking consent"() { + + //revoke sharing arrangement + Response response = doRevokeCdrArrangement(auConfiguration.getAppInfoClientID(), cdrArrangementId) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_204) + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + customerCount = customerCount - 1 + recipientCount = recipientCount - 1 + + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_CUSTOMER_COUNT), + "${customerCount}", "$AUConstants.DATA_CUSTOMER_COUNT count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_RECIPIENT_COUNT), + "${recipientCount}", "$AUConstants.DATA_RECIPIENT_COUNT count mismatch") + } + + @Test + void "Verify the count unchanged when there is at least one active authorisation exist"() { + + //Create Consent + auConfiguration.setPsuNumber(1) + auConfiguration.setTppNumber(1) + + def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Send Metrics Request and Verify count + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + customerCount = customerCount + 1 + recipientCount = recipientCount + 1 + + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_CUSTOMER_COUNT), + "${customerCount}", "$AUConstants.DATA_CUSTOMER_COUNT count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_RECIPIENT_COUNT), + "${recipientCount}", "$AUConstants.DATA_RECIPIENT_COUNT count mismatch") + + //Same TPP and PSU Create another consent + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI(), auConfiguration.getAppInfoClientID(), + AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Send Metrics Request and Verify count + metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_CUSTOMER_COUNT), + "${customerCount}", "$AUConstants.DATA_CUSTOMER_COUNT count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_RECIPIENT_COUNT), + "${recipientCount}", "$AUConstants.DATA_RECIPIENT_COUNT count mismatch") + } + + @Test (dependsOnMethods = "Verify the count unchanged when there is at least one active authorisation exist") + void "Verify the count after deleting App via DCR API"() { + + //Get Application Access Token + auConfiguration.setTppNumber(1) + + accessToken = getApplicationAccessToken(auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(accessToken) + + //Delete DCR Request + def registrationResponse = AURegistrationRequestBuilder.buildBasicRequest(accessToken) + .when() + .delete(AUConstants.DCR_REGISTRATION_ENDPOINT + clientId) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_204) + + //Send Metrics Request and Verify count + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + customerCount = customerCount - 1 + recipientCount = recipientCount - 1 + + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_CUSTOMER_COUNT), + "${customerCount}", "$AUConstants.DATA_CUSTOMER_COUNT count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_RECIPIENT_COUNT), + "${recipientCount}", "$AUConstants.DATA_RECIPIENT_COUNT count mismatch") + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/error/ErrorMetrics_Authenticated.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/error/ErrorMetrics_Authenticated.groovy new file mode 100644 index 000000000..b8889aeb3 --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/error/ErrorMetrics_Authenticated.groovy @@ -0,0 +1,1048 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.error + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import io.restassured.http.ContentType +import io.restassured.response.Response +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +import java.nio.charset.Charset + +/** + * Authenticated Error Metrics Validation. + */ +class ErrorMetrics_Authenticated extends AUTest { + + String encryptedAccount1Id, encryptedAccount2Id + def clientHeader = "${Base64.encoder.encodeToString(getCDSClient().getBytes(Charset.defaultCharset()))}" + + @BeforeClass (alwaysRun = true) + void "Initial Metrics Request"() { + + if(!auConfiguration.getAppInfoClientID().equalsIgnoreCase("") || + !auConfiguration.getAppInfoClientID().equalsIgnoreCase("AppConfig.Application.ClientID") ) { + + doConsentAuthorisation() + generateUserAccessToken() + + //Account Retrieval + doAccountRetrieval(userAccessToken) + encryptedAccount1Id = AUTestUtil.parseResponseBody(response, "data.accounts.accountId[0]") + encryptedAccount2Id = AUTestUtil.parseResponseBody(response, "data.accounts.accountId[1]") + } + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Verify the 400 error count for authenticated High priority invocation is listed"() { + + //Send DCR Registration request with same Service Provider Name + if(auConfiguration.getAppInfoClientID().equalsIgnoreCase("") || + auConfiguration.getAppInfoClientID().equalsIgnoreCase("AppConfig.Application.ClientID") ) { + + AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() + + Response registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(registrationRequestBuilder.getAURegularClaims(auConfiguration.getAppDCRSoftwareId(), + new File(auConfiguration.getAppDCRSelfSignedSSAPath()).text)) + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + clientId = AUTestUtil.parseResponseBody(registrationResponse, AUConstants.CLIENT_ID) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_400) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_400) + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + } + + @Test + void "Verify the 401 error count for authenticated High priority invocation is listed"(){ + + def response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(AUConstants.INCORRECT_ACCESS_TOKEN, + AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_401) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_401) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + sleep(AUConstants.ABANDON_WAIT_TIME) + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 403 error count for authenticated High priority invocation is listed"() { + + scopes = [ + AUAccountScope.BANK_ACCOUNT_BASIC_READ + ] + + doConsentAuthorisation() + generateUserAccessToken() + + def response = AURequestBuilder.buildBasicRequest(userAccessToken, + AUConstants.X_V_HEADER_CUSTOMER_DETAIL) + .header(AUConstants.X_FAPI_CUSTOMER_IP_ADDRESS , AUConstants.IP) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_CUSTOMER)) + .get("${AUConstants.CUSTOMER_DETAILS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_403) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_403) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //High Priority Invocation count increase by 3 + highPriorityCurrentDay = highPriorityCurrentDay + 3 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 405 error count for authenticated High priority invocation is listed"() { + + def response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(userAccessToken, + AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .post("${AUConstants.BULK_ACCOUNT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_405) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_405) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 406 error count for authenticated High priority invocation is listed"() { + + def response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(userAccessToken, + AUConstants.UNSUPPORTED_X_V_VERSION, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_406) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_406) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 500 error count for authenticated High priority invocation is listed"() { + + accessToken = getApplicationAccessToken(clientId) + Assert.assertNotNull(accessToken) + + AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() + def response = AURegistrationRequestBuilder + .buildRegistrationRequest(registrationRequestBuilder.getRegularClaimsWithNewRedirectUri()) + .header(AUConstants.AUTHORIZATION_HEADER_KEY, "${AUConstants.AUTHORIZATION_BEARER_TAG}${accessToken}") + .contentType(ContentType.JSON) + .when() + .put(AUConstants.REGISTER_PATH + auConfiguration.getAppInfoClientID()) + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_500) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_500) + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + } + + @Test + void "Verify the 400 error count for authenticated Low priority invocation is listed"() { + + Response response = AURestAsRequestBuilder.buildRequest() + .header(AUConstants.AUTHORIZATION_HEADER_KEY, "Bearer ${userAccessToken}") + .header(AUConstants.X_FAPI_CUSTOMER_IP_ADDRESS , AUConstants.IP) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PAYEES)) + .get("${AUConstants.BULK_PAYEES}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_400) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_400) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Low Priority Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 401 error count for authenticated Low priority invocation is listed"(){ + + Response response = AURequestBuilder.buildBasicRequest(AUConstants.INCORRECT_ACCESS_TOKEN, AUConstants.X_V_HEADER_PAYEES) + .header(AUConstants.X_FAPI_CUSTOMER_IP_ADDRESS , AUConstants.IP) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PAYEES)) + .get("${AUConstants.BULK_PAYEES}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_401) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_401) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Low Priority Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 403 error count for authenticated Low priority invocation is listed"() { + + scopes = [ + AUAccountScope.BANK_ACCOUNT_BASIC_READ + ] + + doConsentAuthorisation() + generateUserAccessToken() + + def response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(userAccessToken, + AUConstants.X_V_HEADER_ACCOUNT, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_403) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_403) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //High Priority Invocation count increase by 2 + highPriorityCurrentDay = highPriorityCurrentDay + 2 + + //Low Priority Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 405 error count for authenticated Low priority invocation is listed"() { + + def response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(userAccessToken, + AUConstants.X_V_HEADER_PAYEES, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PAYEES)) + .put("${AUConstants.BULK_PAYEES}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_405) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_405) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Low Priority Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 404 error count for authenticated Low priority invocation is listed"() { + + doConsentAuthorisation() + generateUserAccessToken() + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_PAYEES) + .header(AUConstants.X_FAPI_CUSTOMER_IP_ADDRESS , AUConstants.IP) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PAYEES)) + .get("${AUConstants.BULK_PAYEES}/1426558421") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_404) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_404) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Low Priority Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 406 error count for authenticated Low priority invocation is listed"() { + + doConsentAuthorisation() + generateUserAccessToken() + + def response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(userAccessToken, + AUConstants.UNSUPPORTED_X_V_VERSION, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_BALANCES)) + .get("${AUConstants.BULK_BALANCES_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_406) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_406) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Low Priority Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (invocationCount = 3) + void "Verify the 415 error count for authenticated Low priority invocation is listed"() { + + String requestBody = """ + { + "data": { + "accountIds": [ + "${encryptedAccount1Id}", "${encryptedAccount2Id}" + ] + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(userAccessToken, + AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + .contentType(ContentType.XML) + .body(requestBody) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_SCHEDULED_PAYMENT)) + .post("${AUConstants.BULK_SCHEDULE_PAYMENTS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_415) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_415) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Low Priority Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 400 error count for authenticated Unattended invocation is listed"() { + + def response = AURestAsRequestBuilder.buildRequest() + .header(AUConstants.AUTHORIZATION_HEADER_KEY, "Bearer ${userAccessToken}") + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_CUSTOMER)) + .get("${AUConstants.CUSTOMER_DETAILS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_400) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_400) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Unattended count increase by 2 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 401 error count for authenticated Unattended invocation is listed"(){ + + def response = AURequestBuilder.buildBasicRequest(AUConstants.INCORRECT_ACCESS_TOKEN, AUConstants.X_V_HEADER_PAYMENT_SCHEDULED) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_SCHEDULED_PAYMENT)) + .get("${AUConstants.BULK_SCHEDULE_PAYMENTS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_401) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_401) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Unattended count increase by 2 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 403 error count for authenticated Unattended invocation is listed"() { + + scopes = [ + AUAccountScope.BANK_CUSTOMER_BASIC_READ + ] + + doConsentAuthorisationWithoutAccountSelection() + generateUserAccessToken() + + def response = AURequestBuilder.buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_CUSTOMER) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_CUSTOMER)) + .get("${AUConstants.CUSTOMER_DETAILS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_403) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_403) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //High Priority count increase by 2 + highPriorityCurrentDay = highPriorityCurrentDay + 2 + + //Unattended count increase by 2 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 405 error count for authenticated Unattended invocation is listed"() { + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_CUSTOMER_DETAIL) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_CUSTOMER)) + .put("${AUConstants.CUSTOMER_DETAILS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_405) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_405) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Unattended count increase by 2 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 404 error count for authenticated Unattended invocation is listed"() { + + doConsentAuthorisation() + generateUserAccessToken() + + String requestUrl = "${AUConstants.BULK_ACCOUNT_PATH}/12345/transactions" + + Response response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_TRANSACTIONS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_TRANSACTIONS)) + .get(requestUrl) + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_404) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_404) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Unattended count increase by 2 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 406 error count for authenticated Unattended invocation is listed"() { + + doConsentAuthorisation() + generateUserAccessToken() + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.UNSUPPORTED_X_V_VERSION) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_406) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_406) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Unattended count increase by 2 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 415 error count for authenticated Unattended invocation is listed"() { + + String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) + + String requestBody = """ + { + "data": { + "action": "REFRESH" + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METRICS) + .contentType(ContentType.TEXT) + .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) + .body(requestBody) + .post("${AUConstants.CDS_PATH}/admin/register/metadata") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_415) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_415) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Unattended count increase by 2 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 400 error count for authenticated LargePayload invocation is listed"() { + + def response = AURestAsRequestBuilder.buildRequest() + .header(AUConstants.AUTHORIZATION_HEADER_KEY, "Bearer ${userAccessToken}") + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .get("${AUConstants.BULK_DIRECT_DEBITS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_400) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_400) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Large Payload count increase by 1 + largePayloadCurrentDay = largePayloadCurrentDay + 1 + + //Unattended count increase by 1 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 401 error count for authenticated LargePayload invocation is listed"(){ + + def response = AURequestBuilder.buildBasicRequestWithCustomHeaders(AUConstants.INCORRECT_ACCESS_TOKEN, + AUConstants.X_V_HEADER_DIRECT_DEBITS, clientHeader) + .header(AUConstants.X_FAPI_CUSTOMER_IP_ADDRESS , AUConstants.IP) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .get("${AUConstants.BULK_DIRECT_DEBITS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_401) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_401) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Large Payload count increase by 1 + largePayloadCurrentDay = largePayloadCurrentDay + 1 + + //Unattended count increase by 1 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 403 error count for authenticated LargePayload invocation is listed"() { + + scopes = [ + AUAccountScope.BANK_ACCOUNT_BASIC_READ, + AUAccountScope.BANK_ACCOUNT_DETAIL_READ, + AUAccountScope.BANK_TRANSACTION_READ + ] + + doConsentAuthorisation() + generateUserAccessToken() + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_ACCOUNTS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .get("${AUConstants.BULK_DIRECT_DEBITS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_403) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_403) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //High Priority count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 2 + + //Large Payload count increase by 1 + largePayloadCurrentDay = largePayloadCurrentDay + 1 + + //Unattended count increase by 1 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 405 error count for authenticated LargePayload invocation is listed"() { + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_ACCOUNTS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .put("${AUConstants.BULK_DIRECT_DEBITS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_405) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_405) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Large Payload count increase by 1 + largePayloadCurrentDay = largePayloadCurrentDay + 1 + + //Unattended count increase by 1 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 406 error count for authenticated LargePayload invocation is listed"() { + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.UNSUPPORTED_X_V_VERSION) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .get("${AUConstants.BULK_DIRECT_DEBITS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_406) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_406) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Large Payload count increase by 1 + largePayloadCurrentDay = largePayloadCurrentDay + 1 + + //Unattended count increase by 1 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 415 error count for authenticated LargePayload invocation is listed"() { + + String requestBody = """ + { + "data": { + "accountIds": [ + "${consentedAccount}", "${secondConsentedAccount}" + ] + }, + "meta": {} + } + """.stripIndent() + + String directDebitRequestUrl = "${AUConstants.BULK_DIRECT_DEBITS_PATH}" + + def response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(userAccessToken, + AUConstants.X_V_HEADER_DIRECT_DEBITS, clientHeader) + .contentType(ContentType.XML) + .body(requestBody) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .post(directDebitRequestUrl) + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_415) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_415) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Large Payload count increase by 1 + largePayloadCurrentDay = largePayloadCurrentDay + 1 + + //Unattended count increase by 1 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 422 error count for authenticated Low priority invocation is listed"() { + + String requestBody = """ + { + "data": { + "accountIds": [ + "eryvsy35278feegyegyse", "yvwylyg89" + ] + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(userAccessToken, + AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + .contentType(ContentType.JSON) + .body(requestBody) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_BALANCES)) + .post("${AUConstants.BULK_BALANCES_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_422) + + //Get the expected errors metrics + authErrorCurrentDay = getErrorsMetrics(authErrorCurrentDay, AUConstants.STATUS_CODE_422) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Low Priority count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 including Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/error/ErrorMetrics_Unauthenticated.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/error/ErrorMetrics_Unauthenticated.groovy new file mode 100644 index 000000000..1859fa0fa --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/error/ErrorMetrics_Unauthenticated.groovy @@ -0,0 +1,206 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.error + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import io.restassured.response.Response +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +/** + * Unauthenticated Error Metrics Validation. + */ +class ErrorMetrics_Unauthenticated extends AUTest { + + @BeforeClass (alwaysRun = true) + void "Initial Metrics Request"() { + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Verify the 400 error count for unauthenticated invocation is listed"() { + + Response response = AURestAsRequestBuilder.buildRequest() + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PRODUCTS)) + .get("${AUConstants.BANKING_PRODUCT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_400) + + unauthErrorCurrentDay = getErrorsMetrics(unauthErrorCurrentDay, AUConstants.STATUS_CODE_400) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Unauthenticated Invocation count increase by 1 + unauthenticatedCurrentDay = unauthenticatedCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 406 error count for unauthenticated invocation is listed"() { + + Response response = AURestAsRequestBuilder.buildRequest() + .header(AUConstants.X_V_HEADER, AUConstants.UNSUPPORTED_X_V_VERSION) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PRODUCTS)) + .get("${AUConstants.BANKING_PRODUCT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_406) + + unauthErrorCurrentDay = getErrorsMetrics(unauthErrorCurrentDay, AUConstants.STATUS_CODE_406) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Unauthenticated Invocation count increase by 1 + unauthenticatedCurrentDay = unauthenticatedCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 405 error count for unauthenticated invocation is listed"() { + + Response response = AURestAsRequestBuilder.buildRequest() + .header(AUConstants.X_V_HEADER, AUConstants.X_V_HEADER_PRODUCT) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PRODUCTS)) + .put("${AUConstants.BANKING_PRODUCT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_405) + + unauthErrorCurrentDay = getErrorsMetrics(unauthErrorCurrentDay, AUConstants.STATUS_CODE_405) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step but unauthenticated invocation count + // should not increase as this cannot be considered as an invocation. + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 406 error from Get Status invocation"() { + + Response response = AURequestBuilder + .buildBasicRequestWithoutAuthorisationHeader(AUConstants.UNSUPPORTED_X_V_VERSION) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DISCOVERY)) + .get("${AUConstants.DISCOVERY_STATUS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_406) + + unauthErrorCurrentDay = getErrorsMetrics(unauthErrorCurrentDay, AUConstants.STATUS_CODE_406) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //HighPriorityCurrentDay Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Verify the 406 error from Get Outages invocation"() { + + Response response = AURequestBuilder + .buildBasicRequestWithoutAuthorisationHeader(AUConstants.UNSUPPORTED_X_V_VERSION) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DISCOVERY)) + .get("${AUConstants.DISCOVERY_OUTAGES}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_406) + + unauthErrorCurrentDay = getErrorsMetrics(unauthErrorCurrentDay, AUConstants.STATUS_CODE_406) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Asserting the Errors Metrics response + assertMetricsErrorResponse(metricsResponse) + + //HighPriorityCurrentDay Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/HighPriorityMetricsValidation.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/HighPriorityMetricsValidation.groovy new file mode 100644 index 000000000..a12b495d1 --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/HighPriorityMetricsValidation.groovy @@ -0,0 +1,728 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.invocation_performance_averageResponse + +import com.nimbusds.oauth2.sdk.AccessTokenResponse +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import io.restassured.response.Response +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +import java.nio.charset.Charset + +/** + * Test Cases for Invocations, Performance, Average Response and Average TPS Metrics - High Priority Tier + */ +class HighPriorityMetricsValidation extends AUTest { + + private AccessTokenResponse accessTokenResponse + private String cdrArrangementId = "" + private String clientId, accessToken, refreshToken + def clientHeader + + @BeforeClass (alwaysRun = true) + void "Get User Access Token"() { + + clientHeader = "${Base64.encoder.encodeToString(getCDSClient().getBytes(Charset.defaultCharset()))}" + + if(!auConfiguration.getAppInfoClientID().equalsIgnoreCase("") || + !auConfiguration.getAppInfoClientID().equalsIgnoreCase("AppConfig.Application.ClientID") ) { + doConsentAuthorisation() + generateUserAccessToken() + } + + //Initial Metrics Call + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test + void "Count increase with Get Status invocation"() { + + Response response = AURequestBuilder + .buildBasicRequestWithoutAuthorisationHeader(AUConstants.X_V_HEADER_STATUS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DISCOVERY)) + .get("${AUConstants.DISCOVERY_STATUS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Outages invocation"() { + + Response response = AURequestBuilder + .buildBasicRequestWithoutAuthorisationHeader(AUConstants.X_V_HEADER_OUTAGES) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DISCOVERY)) + .get("${AUConstants.DISCOVERY_OUTAGES}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Count increase with Get Accounts - customer present invocation"() { + + def response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Customer Detail - customer present invocation"() { + + Response response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(userAccessToken, + AUConstants.X_V_HEADER_CUSTOMER_DETAIL, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_CUSTOMER)) + .get("${AUConstants.CUSTOMER_DETAILS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Customer - customer present invocation"() { + + Response response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(userAccessToken, + AUConstants.X_V_HEADER_CUSTOMER, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_CUSTOMER)) + .get("${AUConstants.BULK_CUSTOMER}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test(priority = 1) + void "Count Increase with valid authorise request"() { + + auConfiguration.setTppNumber(0) + + //Authorise the consent + doConsentAuthorisation() + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Authorisation Count increase by 1 for the new Authorisation + activeAuthIndividual = activeAuthIndividual + 1 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 1, dependsOnMethods = "Count Increase with valid authorise request") + void "Count increase with User Access Token invocation"() { + + //Get User Access Token + accessTokenResponse = getUserAccessTokenResponse(auConfiguration.getAppInfoClientID()) + accessToken = accessTokenResponse.getTokens().accessToken + refreshToken = accessTokenResponse.getTokens().refreshToken + cdrArrangementId = accessTokenResponse.getCustomParameters().get("cdr_arrangement_id") + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 1, dependsOnMethods = "Count increase with User Access Token invocation") + void "Count increase with Introspect invocation"() { + + def response = AURequestBuilder + .buildIntrospectionRequest(refreshToken.toString(), auConfiguration.getAppInfoClientID()) + .post(AUConstants.INTROSPECTION_ENDPOINT) + + Assert.assertTrue(response.jsonPath().get("active").toString().contains("true")) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 1, dependsOnMethods = "Count increase with User Access Token invocation") + void "Count increase with Revoke invocation"() { + + def revokeResponse = AURequestBuilder + .buildRevokeIntrospectionRequest(accessToken.toString(), auConfiguration.getAppInfoClientID()) + .post(AUConstants.TOKEN_REVOKE_PATH) + + Assert.assertEquals(revokeResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + revokedCurrentDayIndividual = revokedCurrentDayIndividual + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 2) + void "Count increase when an High Priority request return an 406 error"() { + + def response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(userAccessToken, + AUConstants.UNSUPPORTED_X_V_VERSION, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_406) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 2) + void "Count increase when an High Priority request return an 403 error"() { + + scopes = [ + AUAccountScope.BANK_ACCOUNT_BASIC_READ + ] + + doConsentAuthorisation() + generateUserAccessToken() + + def response = AURequestBuilder.buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_CUSTOMER_DETAIL) + .header(AUConstants.X_FAPI_CUSTOMER_IP_ADDRESS , AUConstants.IP) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_CUSTOMER)) + .get("${AUConstants.CUSTOMER_DETAILS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_403) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //High Priority Invocation count increase by 3 (Authorisation + Token Request + API Request) + highPriorityCurrentDay = highPriorityCurrentDay + 3 + newAuthCurrentDayOngoingIndividual = newAuthCurrentDayOngoingIndividual + 1 + activeAuthIndividual = activeAuthIndividual + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 2) + void "Count increase when an High Priority request return an 401 error"() { + + def response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(AUConstants.INCORRECT_ACCESS_TOKEN, + AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.UNAUTHORIZED) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 2) + void "Count increase when error in Get Status invocation"() { + + Response response = AURequestBuilder + .buildBasicRequestWithoutAuthorisationHeader(AUConstants.UNSUPPORTED_X_V_VERSION) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DISCOVERY)) + .get("${AUConstants.DISCOVERY_STATUS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_406) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 2) + void "Count increase when error in Get Outages invocation"() { + + Response response = AURequestBuilder + .buildBasicRequestWithoutAuthorisationHeader(AUConstants.UNSUPPORTED_X_V_VERSION) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DISCOVERY)) + .get("${AUConstants.DISCOVERY_OUTAGES}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_406) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 3) + void "Count increase with DCR Register invocation"() { + + //Send DCR Request + auConfiguration.setTppNumber(1) + + jtiVal = String.valueOf(System.currentTimeMillis()) + AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(registrationRequestBuilder.getAURegularClaims(auConfiguration.getAppDCRSoftwareId(), + auConfiguration.getAppDCRSelfSignedSSAPath())) + .when() + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.CREATED) + clientId = AUTestUtil.parseResponseBody(registrationResponse, "client_id") + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Verify Metrics Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 3, dependsOnMethods = "Count increase with DCR Register invocation") + void "Count increase with Application Access Token invocation"() { + + auConfiguration.setTppNumber(1) + //Get Application Access Token + accessToken = getApplicationAccessToken(clientId) + Assert.assertNotNull(accessToken) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 3, dependsOnMethods = "Count increase with Application Access Token invocation") + void "Count increase with DCR Retrieval invocation"() { + + auConfiguration.setTppNumber(1) + //DCR Retrieval Request + def registrationResponse = AURegistrationRequestBuilder.buildBasicRequest(accessToken) + .when() + .get(AUConstants.DCR_REGISTRATION_ENDPOINT + clientId) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.OK) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 3, dependsOnMethods = "Count increase with Application Access Token invocation") + void "Count increase with DCR Update invocation"() { + + auConfiguration.setTppNumber(1) + + //DCR Update Request + AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(registrationRequestBuilder.getAURegularClaims(auConfiguration.getAppDCRSoftwareId(), + auConfiguration.getAppDCRSelfSignedSSAPath())) + .header(AUConstants.AUTHORIZATION_HEADER_KEY, "${AUConstants.AUTHORIZATION_BEARER_TAG}${accessToken}") + .when() + .put(AUConstants.DCR_REGISTRATION_ENDPOINT + clientId) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.OK) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 4, dependsOnMethods = "Count increase with Application Access Token invocation") + void "Count increase with DCR Delete invocation"() { + + //Delete DCR Request + def registrationResponse = AURegistrationRequestBuilder.buildBasicRequest(accessToken) + .when() + .delete(AUConstants.DCR_REGISTRATION_ENDPOINT + clientId) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_204) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 4) + void "Count increase with DCR Retrieval invocation with incorrect access token"() { + + //DCR Retrieval Request + def registrationResponse = AURegistrationRequestBuilder.buildBasicRequest( + AUConstants.INCORRECT_ACCESS_TOKEN) + .when() + .get(AUConstants.DCR_REGISTRATION_ENDPOINT + clientId) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.UNAUTHORIZED) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), + AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 4) + void "Count increase with DCR Update invocation with incorrect access token"() { + + //DCR Update Request + AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(registrationRequestBuilder.getAURegularClaims()) + .header(AUConstants.AUTHORIZATION_HEADER_KEY, + "${AUConstants.AUTHORIZATION_BEARER_TAG}${AUConstants.INCORRECT_ACCESS_TOKEN}") + .when() + .put(AUConstants.DCR_REGISTRATION_ENDPOINT + clientId) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.UNAUTHORIZED) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 4) + void "Count increase with DCR Delete invocation with incorrect access token"() { + + //Delete DCR Request + def registrationResponse = AURegistrationRequestBuilder.buildBasicRequest( + AUConstants.INCORRECT_ACCESS_TOKEN) + .when() + .delete(AUConstants.DCR_REGISTRATION_ENDPOINT + clientId) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.UNAUTHORIZED) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //High Priority Invocation count increase by 1 + highPriorityCurrentDay = highPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/LargePayloadMetricsValidation.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/LargePayloadMetricsValidation.groovy new file mode 100644 index 000000000..66ab628b2 --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/LargePayloadMetricsValidation.groovy @@ -0,0 +1,283 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.invocation_performance_averageResponse + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import io.restassured.http.ContentType +import io.restassured.response.Response +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +import java.nio.charset.Charset + +/** + * Test Cases for Invocations, Performance, Average Response and Average TPS Metrics - Large Payload Tier + */ +class LargePayloadMetricsValidation extends AUTest { + + private String encryptedAccount1Id, encryptedAccount2Id + def clientHeader + + @BeforeClass (alwaysRun = true) + void "Get User Access Token"() { + + clientHeader = "${Base64.encoder.encodeToString(getCDSClient().getBytes(Charset.defaultCharset()))}" + + if(!auConfiguration.getAppInfoClientID().equalsIgnoreCase("") || + !auConfiguration.getAppInfoClientID().equalsIgnoreCase("AppConfig.Application.ClientID") ) { + doConsentAuthorisation() + generateUserAccessToken() + + //Account Retrieval + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_ACCOUNTS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + encryptedAccount1Id = AUTestUtil.parseResponseBody(response, "data.accounts.accountId[0]") + encryptedAccount2Id = AUTestUtil.parseResponseBody(response, "data.accounts.accountId[1]") + } + + //Initial Metrics Call + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Count increase with Get Bulk Direct Debits invocation - customer present"() { + + Response response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_DIRECT_DEBITS, clientHeader ) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .get("${AUConstants.BULK_DIRECT_DEBITS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Large Payload Current Day Invocation count increase by 1 + largePayloadCurrentDay = largePayloadCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Bulk Direct Debits invocation - without customer present"() { + + Response response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_DIRECT_DEBITS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .get("${AUConstants.BULK_DIRECT_DEBITS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Large Payload Current Day Invocation count increase by 1 + largePayloadCurrentDay = largePayloadCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Direct Debits For Specific Accounts invocation - customer present"() { + + String requestBody = """ + { + "data": { + "accountIds": [ + "${encryptedAccount1Id}", "${encryptedAccount2Id}" + ] + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_DIRECT_DEBITS, clientHeader) + .contentType(ContentType.JSON) + .body(requestBody) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .post("${AUConstants.BULK_DIRECT_DEBITS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Large Payload Current Day Invocation count increase by 1 + largePayloadCurrentDay = largePayloadCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Direct Debits For Specific Accounts invocation - without customer present"() { + + String requestBody = """ + { + "data": { + "accountIds": [ + "${encryptedAccount1Id}", "${encryptedAccount2Id}" + ] + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_DIRECT_DEBITS) + .contentType(ContentType.JSON) + .body(requestBody) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .post("${AUConstants.BULK_DIRECT_DEBITS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Large Payload Current Day Invocation count increase by 1 + largePayloadCurrentDay = largePayloadCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase when an Large Payload request return an error"() { + + String requestBody = """ + { + "data": { + "accountIds": [ + "4327823409", "455325897" + ] + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_DIRECT_DEBITS) + .contentType(ContentType.JSON) + .body(requestBody) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .post("${AUConstants.BULK_DIRECT_DEBITS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_422) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Large Payload Current Day Invocation count increase by 1 + largePayloadCurrentDay = largePayloadCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase when an Large Payload request return an 401 error"() { + + Response response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(AUConstants.INCORRECT_ACCESS_TOKEN, + AUConstants.X_V_HEADER_DIRECT_DEBITS, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .get("${AUConstants.BULK_DIRECT_DEBITS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_401) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Large Payload Current Day Invocation count increase by 1 + largePayloadCurrentDay = largePayloadCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/LowPriorityMetricsValidation.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/LowPriorityMetricsValidation.groovy new file mode 100644 index 000000000..9d9d17378 --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/LowPriorityMetricsValidation.groovy @@ -0,0 +1,508 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.invocation_performance_averageResponse + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import io.restassured.http.ContentType +import io.restassured.response.Response +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +import java.nio.charset.Charset + +/** + * Test Cases for Invocations, Performance, Average Response and Average TPS Metrics - Low Priority Tier + */ +class LowPriorityMetricsValidation extends AUTest { + + private String encryptedAccount1Id, encryptedAccount2Id, encryptedTransactionId, encryptedPayeeId + def clientHeader + + @BeforeClass (alwaysRun = true) + void "Get User Access Token"() { + + clientHeader = "${Base64.encoder.encodeToString(getCDSClient().getBytes(Charset.defaultCharset()))}" + + if(!auConfiguration.getAppInfoClientID().equalsIgnoreCase("") || + !auConfiguration.getAppInfoClientID().equalsIgnoreCase("AppConfig.Application.ClientID") ) { + doConsentAuthorisation() + generateUserAccessToken() + + //Account Retrieval + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_ACCOUNTS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + encryptedAccount1Id = AUTestUtil.parseResponseBody(response, "data.accounts.accountId[0]") + encryptedAccount2Id = AUTestUtil.parseResponseBody(response, "data.accounts.accountId[1]") + } + + //Initial Metrics Call + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Count increase with Get Account Details - customer present invocation"() { + + def response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_ACCOUNT, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Current Day Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Account Balance - customer present invocation"() { + + def response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_BALANCE, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_BALANCES)) + .get("${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}/balance") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Current Day Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Bulk Balances - customer present invocation"() { + + def response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_BALANCES, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_BALANCES)) + .get("${AUConstants.BULK_BALANCES_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Current Day Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Balances For Specific Accounts - customer present invocation"() { + + def response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_BALANCE, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_BALANCES)) + .get("${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}/balance") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Current Day Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Direct Debits For Account - customer present invocation"() { + + Response response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_DIRECT_DEBITS, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}/direct-debits") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Scheduled Payments Bulk - customer present invocation"() { + + Response response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_PAYMENT_SCHEDULED, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_SCHEDULED_PAYMENT)) + .get("${AUConstants.BULK_SCHEDULE_PAYMENTS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Scheduled Payments For Account - customer present invocation"() { + + Response response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_PAYMENT_SCHEDULED, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_SCHEDULED_PAYMENT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}/payments/scheduled") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Scheduled Payments For Specific Accounts - customer present invocation"() { + + String requestBody = """ + { + "data": { + "accountIds": [ + "${encryptedAccount1Id}", "${encryptedAccount2Id}" + ] + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_PAYMENT_SCHEDULED, clientHeader) + .contentType(ContentType.JSON) + .body(requestBody) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_SCHEDULED_PAYMENT)) + .post("${AUConstants.BULK_SCHEDULE_PAYMENTS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 1) + void "Count increase with Get Transactions For Account - customer present invocation"() { + + Response response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_TRANSACTIONS, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_TRANSACTIONS)) + .get("${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}/transactions") + + encryptedTransactionId = AUTestUtil.parseResponseBody(response, "data.transactions.transactionId[0]") + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Current Day Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 1, dependsOnMethods = "Count increase with Get Transactions For Account - customer present invocation") + void "Count increase with Get Transaction Detail - customer present invocation"() { + + Response response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_TRANSACTION, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_TRANSACTIONS)) + .get("${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}/" + + "transactions/$encryptedTransactionId") + + encryptedTransactionId = AUTestUtil.parseResponseBody(response, "data.transactions.transactionId[0]") + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Current Day Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 2) + void "Count increase with Get Payees - customer present invocation"() { + + Response response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_PAYEES, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PAYEES)) + .get("${AUConstants.BULK_PAYEES}") + + encryptedPayeeId = AUTestUtil.parseResponseBody(response, "data.payees.payeeId[0]") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Current Day Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 2, dependsOnMethods = "Count increase with Get Payees - customer present invocation") + void "Count increase with Get Payee Detail - customer present invocation"() { + + Response response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_PAYEES, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PAYEES)) + .get("${AUConstants.BULK_PAYEES}/${encryptedPayeeId}") + + encryptedPayeeId = AUTestUtil.parseResponseBody(response, "data.payees.payeeId[0]") + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Current Day Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 3) + void "Count increase when an Low Priority request return an error"() { + + String requestBody = """ + { + "data": { + "accountIds": [ + "eryvsy35278feegyegyse", "yvwylyg89" + ] + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder + .buildBasicRequestWithOptionalHeaders(userAccessToken, AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + .contentType(ContentType.JSON) + .body(requestBody) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_BALANCES)) + .post("${AUConstants.BULK_BALANCES_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_422) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 3) + void "Count increase when an Low Priority request return an 401 error"() { + + def response = AURequestBuilder.buildBasicRequestWithOptionalHeaders(AUConstants.INCORRECT_ACCESS_TOKEN, + AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_401) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Low Priority Invocation count increase by 1 + lowPriorityCurrentDay = lowPriorityCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/SessionCountMetricsValidation.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/SessionCountMetricsValidation.groovy new file mode 100644 index 000000000..e4780f202 --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/SessionCountMetricsValidation.groovy @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.invocation_performance_averageResponse + +import com.nimbusds.oauth2.sdk.TokenErrorResponse +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +/** + * Session Count Metrics Validation. + */ +class SessionCountMetricsValidation extends AUTest{ + + @BeforeClass (alwaysRun = true) + void "Initial Metrics Request"() { + + //Initial Metrics Call + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Count increase upon successful user access token request"() { + + //Get User Access Token + doConsentAuthorisation() + generateUserAccessToken() + Assert.assertNotNull(userAccessToken) + + //Send Metrics Request + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + sessionCount = sessionCount + 1 + + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_SESSION_COUNT_CURRENTDAY), + "${sessionCount}", "$AUConstants.DATA_SESSION_COUNT_CURRENTDAY count mismatch") + } + + @Test + void "Count unchanged when unsuccessful token request"() { + + //Get User Access Token + doConsentAuthorisation() + + //Send User Access Token request with incorrect redirect url + TokenErrorResponse errorResponse = AURequestBuilder.getUserTokenErrorResponse(authorisationCode, + "https://abc.com", auConfiguration.getAppInfoClientID(), true, true, + auConfiguration.getCommonSigningAlgorithm(), auAuthorisationBuilder.getCodeVerifier()) + Assert.assertEquals(errorResponse.toJSONObject().get(AUConstants.ERROR_DESCRIPTION), + AUConstants.CALLBACK_MISMATCH) + + //Send Metrics Request + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_SESSION_COUNT_CURRENTDAY), + "${sessionCount}", "$AUConstants.DATA_SESSION_COUNT_CURRENTDAY count mismatch") + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/UnattendedMetricsValidation.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/UnattendedMetricsValidation.groovy new file mode 100644 index 000000000..fe9ea7ef3 --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/UnattendedMetricsValidation.groovy @@ -0,0 +1,600 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.invocation_performance_averageResponse + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import io.restassured.http.ContentType +import io.restassured.response.Response +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +import java.nio.charset.Charset + +/** + * Test Cases for Invocations, Performance, Average Response and Average TPS Metrics - Unattended Tier + */ +class UnattendedMetricsValidation extends AUTest { + + private String encryptedAccount1Id, encryptedAccount2Id, encryptedTransactionId, encryptedPayeeId + def clientHeader + + @BeforeClass (alwaysRun = true) + void "Get User Access Token"() { + + clientHeader = "${Base64.encoder.encodeToString(getCDSClient().getBytes(Charset.defaultCharset()))}" + + if(!auConfiguration.getAppInfoClientID().equalsIgnoreCase("") || + !auConfiguration.getAppInfoClientID().equalsIgnoreCase("AppConfig.Application.ClientID") ) { + doConsentAuthorisation() + generateUserAccessToken() + + //Account Retrieval + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_ACCOUNTS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + encryptedAccount1Id = AUTestUtil.parseResponseBody(response, "data.accounts.accountId[0]") + encryptedAccount2Id = AUTestUtil.parseResponseBody(response, "data.accounts.accountId[1]") + } + + //Initial Metrics Call + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Count increase with Get Customer - Unattended invocation"() { + + Response response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_CUSTOMER) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_CUSTOMER)) + .get("${AUConstants.BULK_CUSTOMER}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Customer Detail - Unattended invocation"() { + + Response response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_CUSTOMER_DETAIL) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_CUSTOMER)) + .get("${AUConstants.CUSTOMER_DETAILS}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Metadata Update invocation"() { + + String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, AUConstants.ADMIN_API_AUDIENCE) + + String requestBody = """ + { + "data": { + "action": "REFRESH" + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METRICS) + .header(AUConstants.CONTENT_TYPE, "application/json") + .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) + .body(requestBody) + .post("${AUConstants.CDS_PATH}/admin/register/metadata") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (invocationCount = 3) + void "Count increase with Get Accounts - Unattended invocation"() { + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_ACCOUNTS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + encryptedAccount1Id = AUTestUtil.parseResponseBody(response, "data.accounts.accountId[0]") + encryptedAccount2Id = AUTestUtil.parseResponseBody(response, "data.accounts.accountId[1]") + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Account Balance invocation"() { + + String requestUrl = "${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}/balance" + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_BALANCE) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_BALANCES)) + .get(requestUrl) + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Account Detail invocation"() { + + String requestUrl = "${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}" + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_ACCOUNT) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get(requestUrl) + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Balances For Specific Accounts invocation"() { + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_BALANCE) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_BALANCES)) + .get("${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}/balance") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Transactions For Account invocation"() { + + String requestUrl = "${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}/transactions" + + Response response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_TRANSACTIONS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_TRANSACTIONS)) + .get(requestUrl) + + encryptedTransactionId = AUTestUtil.parseResponseBody(response, "data.transactions.transactionId[0]") + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Direct Debits For Account invocation"() { + + String requestUrl = "${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}/direct-debits" + + Response response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_DIRECT_DEBITS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_DIRECT_DEBIT)) + .get(requestUrl) + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Scheduled Payments Bulk invocation"() { + + Response response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_PAYMENT_SCHEDULED) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_SCHEDULED_PAYMENT)) + .get("${AUConstants.BULK_SCHEDULE_PAYMENTS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Scheduled Payments For Account invocation"() { + + String requestUrl = "${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}/payments/scheduled" + + Response response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_PAYMENT_SCHEDULED) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_SCHEDULED_PAYMENT)) + .get(requestUrl) + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase with Get Scheduled Payments For Specific Accounts invocation"() { + + String requestBody = """ + { + "data": { + "accountIds": [ + "${encryptedAccount1Id}", "${encryptedAccount2Id}" + ] + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_PAYMENT_SCHEDULED) + .contentType(ContentType.JSON) + .body(requestBody) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_SCHEDULED_PAYMENT)) + .post("${AUConstants.BULK_SCHEDULE_PAYMENTS_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test + void "Count increase when an Unattended request return an error"() { + + String requestBody = """ + { + "data": { + "accountIds": [ + "eryvsy35278feegyegyse", "yvwylyg89" + ] + }, + "meta": {} + } + """.stripIndent() + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_ACCOUNTS) + .contentType(ContentType.JSON) + .body(requestBody) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_BALANCES)) + .post("${AUConstants.BULK_BALANCES_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_422) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 1) + void "TC1202001_Get Bulk Balances"() { + + def response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_BALANCES) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_BALANCES)) + .get("${AUConstants.BULK_BALANCES_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 1, dependsOnMethods = "Count increase with Get Transactions For Account invocation") + void "Count increase with Get Transaction Detail invocation"() { + + String requestUrl = "${AUConstants.BULK_ACCOUNT_PATH}/${encryptedAccount1Id}/" + + "transactions/$encryptedTransactionId" + + Response response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_TRANSACTION) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_TRANSACTIONS)) + .get(requestUrl) + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 2) + void "Count increase with Get Payees invocation"() { + + String requestUrl = "${AUConstants.BULK_PAYEES}" + + Response response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_PAYEES) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PAYEES)) + .get(requestUrl) + + encryptedPayeeId = AUTestUtil.parseResponseBody(response, "data.payees.payeeId[0]") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 2, dependsOnMethods = "Count increase with Get Payees invocation") + void "Count increase with Get Payee Detail invocation"() { + + String requestUrl = "${AUConstants.BULK_PAYEES}/${encryptedPayeeId}" + + Response response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.X_V_HEADER_PAYEES) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PAYEES)) + .get(requestUrl) + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (priority = 3) + void "Count increase when an Unattended request return an 401 error"() { + + def response = AURequestBuilder + .buildBasicRequest(AUConstants.INCORRECT_ACCESS_TOKEN, AUConstants.X_V_HEADER_ACCOUNTS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_401) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unattended Invocation count increase by 2 (API Request + Metrics Call of BeforeClass Step) + unattendedCurrentDay = unattendedCurrentDay + 2 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/UnauthenticatedMetricsValidation.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/UnauthenticatedMetricsValidation.groovy new file mode 100644 index 000000000..ee49df2f0 --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/admin_api/invocation_performance_averageResponse/UnauthenticatedMetricsValidation.groovy @@ -0,0 +1,134 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.integration.test.admin_api.invocation_performance_averageResponse + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import io.restassured.response.Response +import org.testng.Assert +import org.testng.annotations.BeforeClass +import org.testng.annotations.Test + +/** + * Test Cases for Invocations, Performance, Average Response and Average TPS Metrics - Unauthenticated Tier + */ +class UnauthenticatedMetricsValidation extends AUTest { + + @BeforeClass (alwaysRun = true) + void "Initial Metrics Request"() { + + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Assign Metrics to Variables + getInitialMetricsResponse(metricsResponse) + } + + @Test (groups = "SmokeTest") + void "Count increase with Products Invocation"(){ + + Response response = AURequestBuilder.buildBasicRequestWithoutAuthorisationHeader(AUConstants.X_V_HEADER_PRODUCTS) + .accept(AUConstants.ACCEPT) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PRODUCTS)) + .get("${AUConstants.BANKING_PRODUCT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(response.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_PRODUCTS) + productId = AUTestUtil.parseResponseBody(response, "data.products.productId[0]").toString() + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unauthenticated Invocation count increase by 1 + unauthenticatedCurrentDay = unauthenticatedCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (dependsOnMethods = "Count increase with Products Invocation") + void "Count increase with Product Details Invocation"(){ + + Response response = AURequestBuilder.buildBasicRequestWithoutAuthorisationHeader(AUConstants.X_V_HEADER_PRODUCT) + .accept(AUConstants.ACCEPT) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PRODUCTS)) + .get("${AUConstants.BANKING_PRODUCT_PATH}/$productId") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unauthenticated Invocation count increase by 1 + unauthenticatedCurrentDay = unauthenticatedCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } + + @Test (invocationCount = 15) + void "Count increase when an unauthenticated request return an error"() { + + Response response = AURequestBuilder.buildBasicRequestWithoutAuthorisationHeader(1) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_PRODUCTS)) + .get("${AUConstants.BANKING_PRODUCT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_406) + + //Calculate Performance, Average Response and Average TPS Metrics for each tier + calculateTierBasedMetrics() + + //Send Metrics Request and Verify Response + def metricsResponse = getMetrics(AUConstants.PERIOD_CURRENT) + + Assert.assertEquals(metricsResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(metricsResponse.getHeader(AUConstants.X_V_HEADER).toInteger(), AUConstants.X_V_HEADER_METRICS) + + //Unauthenticated Invocation count increase by 1 + unauthenticatedCurrentDay = unauthenticatedCurrentDay + 1 + + //Unattended count increase by 1 for the Metrics Call of BeforeClass Step + unattendedCurrentDay = unattendedCurrentDay + 1 + + //Asserting the Performance, Average Response and Average TPS + assertTierBasedMetrics(metricsResponse) + } +} diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/authflow/AuthorisationFlowCXValidationTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/authflow/AuthorisationFlowCXValidationTest.groovy similarity index 97% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/authflow/AuthorisationFlowCXValidationTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/authflow/AuthorisationFlowCXValidationTest.groovy index f7b0f43a3..bd705e3c4 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/authflow/AuthorisationFlowCXValidationTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/authflow/AuthorisationFlowCXValidationTest.groovy @@ -16,17 +16,16 @@ * under the License. */ -package com.wso2.cds.integration.test.authflow - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AUAuthorisationBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod +package org.wso2.cds.integration.test.authflow + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod import org.openqa.selenium.By import org.testng.Assert import org.testng.annotations.BeforeClass diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/authflow/AuthorisationFlowUIValidationTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/authflow/AuthorisationFlowUIValidationTest.groovy similarity index 97% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/authflow/AuthorisationFlowUIValidationTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/authflow/AuthorisationFlowUIValidationTest.groovy index fa57662ca..91e9b6fc7 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/authflow/AuthorisationFlowUIValidationTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/authflow/AuthorisationFlowUIValidationTest.groovy @@ -15,17 +15,16 @@ * specific language governing permissions and limitations * under the License. */ -package com.wso2.cds.integration.test.authflow - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AUAuthorisationBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod +package org.wso2.cds.integration.test.authflow + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod import org.openqa.selenium.By import org.testng.Assert import org.testng.annotations.Test diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/authflow/ConsentAmendmentFlowUIValidationTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/authflow/ConsentAmendmentFlowUIValidationTest.groovy similarity index 95% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/authflow/ConsentAmendmentFlowUIValidationTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/authflow/ConsentAmendmentFlowUIValidationTest.groovy index 8c99cd758..90b56c918 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/authflow/ConsentAmendmentFlowUIValidationTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/authflow/ConsentAmendmentFlowUIValidationTest.groovy @@ -16,19 +16,19 @@ * under the License. */ -package com.wso2.cds.integration.test.authflow +package org.wso2.cds.integration.test.authflow import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod -import com.wso2.openbanking.test.framework.automation.NavigationAutomationStep +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.openbanking.test.framework.automation.NavigationAutomationStep import org.openqa.selenium.By import org.openqa.selenium.support.ui.ExpectedConditions import org.openqa.selenium.support.ui.WebDriverWait diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/authflow/UserAuthenticationFlowValidationTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/authflow/UserAuthenticationFlowValidationTest.groovy similarity index 94% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/authflow/UserAuthenticationFlowValidationTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/authflow/UserAuthenticationFlowValidationTest.groovy index 09316f9f2..953e700ce 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/authflow/UserAuthenticationFlowValidationTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/authflow/UserAuthenticationFlowValidationTest.groovy @@ -16,23 +16,20 @@ * under the License. */ -package com.wso2.cds.integration.test.authflow - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.configuration.AUConfigurationService -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AUAuthorisationBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod -import com.wso2.openbanking.test.framework.automation.NavigationAutomationStep +package org.wso2.cds.integration.test.authflow + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.openbanking.test.framework.automation.NavigationAutomationStep import org.openqa.selenium.support.ui.ExpectedConditions import org.openqa.selenium.support.ui.WebDriverWait import java.util.concurrent.TimeUnit import org.openqa.selenium.By -import org.openqa.selenium.WebElement import org.testng.Assert import org.testng.annotations.Test diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/banking_products/ProductRetrievalHeaderValidationTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/banking_products/ProductRetrievalHeaderValidationTest.groovy similarity index 97% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/banking_products/ProductRetrievalHeaderValidationTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/banking_products/ProductRetrievalHeaderValidationTest.groovy index 7f6765936..5229d8eb7 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/banking_products/ProductRetrievalHeaderValidationTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/banking_products/ProductRetrievalHeaderValidationTest.groovy @@ -16,13 +16,13 @@ * under the License. */ -package com.wso2.cds.integration.test.banking_products +package org.wso2.cds.integration.test.banking_products -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AURestAsRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import io.restassured.response.Response import org.testng.Assert import org.testng.annotations.BeforeClass @@ -37,12 +37,6 @@ class ProductRetrievalHeaderValidationTest extends AUTest { def clientHeader = "${Base64.encoder.encodeToString(getCDSClient().getBytes(Charset.defaultCharset()))}" - @BeforeClass(alwaysRun = true) - void "Get User Access Token"() { - doConsentAuthorisation() - generateUserAccessToken() - } - @Test void "TC1101004_Retrieve banking products with unsupported x-v header"() { diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/banking_products/ProductRetrievalValidationTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/banking_products/ProductRetrievalValidationTest.groovy similarity index 96% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/banking_products/ProductRetrievalValidationTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/banking_products/ProductRetrievalValidationTest.groovy index 0d7943553..6f65bccee 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/banking_products/ProductRetrievalValidationTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/banking_products/ProductRetrievalValidationTest.groovy @@ -16,12 +16,12 @@ * under the License. */ -package com.wso2.cds.integration.test.banking_products +package org.wso2.cds.integration.test.banking_products -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import io.restassured.response.Response import org.testng.Assert import org.testng.annotations.BeforeClass @@ -36,13 +36,7 @@ class ProductRetrievalValidationTest extends AUTest { def clientHeader = "${Base64.encoder.encodeToString(getCDSClient().getBytes(Charset.defaultCharset()))}" - @BeforeClass(alwaysRun = true) - void "Get User Access Token"() { - doConsentAuthorisation() - generateUserAccessToken() - } - - @Test (priority = 1, groups = "SmokeTest") + @Test (groups = "SmokeTest", priority = 1) void "TC1101001_Retrieve banking products"() { Response response = AURequestBuilder.buildBasicRequestWithoutAuthorisationHeader(AUConstants.X_V_HEADER_PRODUCTS) @@ -73,7 +67,7 @@ class ProductRetrievalValidationTest extends AUTest { Assert.assertNotNull(AUTestUtil.parseResponseBody(response, AUConstants.LINKS_LAST)) } - @Test (priority = 1, dependsOnMethods = "TC1101001_Retrieve banking products") + @Test (groups = "SmokeTest", priority = 1, dependsOnMethods = "TC1101001_Retrieve banking products") void "TC1101002_Retrieve specific banking product details"() { Response response = AURequestBuilder.buildBasicRequestWithoutAuthorisationHeader(AUConstants.X_V_HEADER_PRODUCTS) @@ -160,7 +154,8 @@ class ProductRetrievalValidationTest extends AUTest { Assert.assertNotNull(AUTestUtil.parseResponseBody(response, AUConstants.LINKS_LAST)) } - @Test + //TODO: Git issue : https://github.com/wso2-enterprise/financial-open-banking/issues/5638 + @Test (enabled = false) void "TC1101021_Retrieve banking products with invalid updated-since value"() { def updatedSince = AUConstants.DATE_FORMAT @@ -200,6 +195,7 @@ class ProductRetrievalValidationTest extends AUTest { Assert.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR_TITLE), AUConstants.INVALID_FIELD) } + //Product Issue @Test void "TC1101027_Retrieve Product list with undefined query parameter"() { @@ -245,6 +241,7 @@ class ProductRetrievalValidationTest extends AUTest { Assert.assertNotNull(AUTestUtil.parseResponseBody(response, AUConstants.LINKS_LAST)) } + //Product Issue @Test void "TC1101031_Retrieve product list with invalid product-category value"() { diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/cdr_arrangement/ConcurrentConsentTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/cdr_arrangement/ConcurrentConsentTest.groovy similarity index 73% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/cdr_arrangement/ConcurrentConsentTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/cdr_arrangement/ConcurrentConsentTest.groovy index 62c277206..1da9d5a4f 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/cdr_arrangement/ConcurrentConsentTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/cdr_arrangement/ConcurrentConsentTest.groovy @@ -16,19 +16,19 @@ * under the License. */ -package com.wso2.cds.integration.test.cdr_arrangement - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AURestAsRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod +package org.wso2.cds.integration.test.cdr_arrangement + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AUJWTGenerator +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod import io.restassured.response.Response import org.testng.Assert import org.testng.annotations.Test @@ -125,7 +125,7 @@ class ConcurrentConsentTest extends AUTest { Assert.assertEquals(secondAccountsResponse.statusCode(), AUConstants.STATUS_CODE_403) } - @Test + @Test (groups = "SmokeTest") void "TC0902001_Revoke consent using cdr management endpoint"() { List sharingScope = [ AUAccountScope.BANK_ACCOUNT_BASIC_READ ] @@ -167,7 +167,6 @@ class ConcurrentConsentTest extends AUTest { .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) .get("${AUConstants.BULK_ACCOUNT_PATH}") - //TODO: Issue: https://github.com/wso2-enterprise/financial-open-banking/issues/7882 Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_403) //validate token @@ -178,6 +177,34 @@ class ConcurrentConsentTest extends AUTest { Assert.assertTrue((introspectResponse.jsonPath().get("active")).equals(false)) } + @Test (dependsOnMethods = "TC0902001_Revoke consent using cdr management endpoint") + void "CDS-147_Invoke cdr management endpoint with previously revoked cdr_arrangement_id"() { + + //revoke sharing arrangement without cdr arrangement id + generator = new AUJWTGenerator() + String assertionString = generator.getClientAssertionJwt(clientId) + + def bodyContent = [(AUConstants.CLIENT_ID_KEY): (clientId), + (AUConstants.CLIENT_ASSERTION_TYPE_KEY): (AUConstants.CLIENT_ASSERTION_TYPE), + (AUConstants.CLIENT_ASSERTION_KEY) : assertionString, + (AUConstants.CDR_ARRANGEMENT_ID) : cdrArrangementId] + + revocationResponse = AURestAsRequestBuilder.buildRequest() + .contentType(AUConstants.ACCESS_TOKEN_CONTENT_TYPE) + .formParams(bodyContent) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_CDR_ARRANGEMENT)) + .post("${AUConstants.CDR_ARRANGEMENT_ENDPOINT}") + + Assert.assertEquals(revocationResponse.statusCode(), AUConstants.STATUS_CODE_422) + + Assert.assertEquals(AUTestUtil.parseResponseBody(revocationResponse, AUConstants.ERROR_CODE), + AUConstants.ERROR_CODE_INVALID_ARRANGEMENT) + Assert.assertEquals(AUTestUtil.parseResponseBody(revocationResponse, AUConstants.ERROR_TITLE), + AUConstants.INVALID_CONSENT_ARRANGEMENT) + Assert.assertEquals(AUTestUtil.parseResponseBody(revocationResponse, AUConstants.ERROR_DETAIL), + "invalid cdr-arrangement-id sent in the request") + } + @Test void "TC0203010_Generate User access token by revoked consent"() { @@ -313,4 +340,70 @@ class ConcurrentConsentTest extends AUTest { Assert.assertEquals(revocationResponse.statusCode(), AUConstants.STATUS_CODE_400) } + + @Test + void "CDS-1050_CDR Arrangement Revocation Request without client id param in the request body"() { + + List sharingScope = [ AUAccountScope.BANK_ACCOUNT_BASIC_READ ] + + //authorise sharing arrangement + response = auAuthorisationBuilder.doPushAuthorisationRequest(sharingScope, AUConstants.DEFAULT_SHARING_DURATION, + true, "") + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + doConsentAuthorisationViaRequestUri(sharingScope, requestUri.toURI(), clientId, AUAccountProfile.INDIVIDUAL) + Assert.assertNotNull(authorisationCode) + + //Generate User Access Token + def userAccessTokenResponse = AURequestBuilder.getUserToken(authorisationCode, + sharingScope, AUConstants.CODE_VERIFIER) + String userAccessToken = userAccessTokenResponse.tokens.accessToken.toString() + + //obtain cdr_arrangement_id from token response + String cdrArrangementId = userAccessTokenResponse.getCustomParameters().get(AUConstants.CDR_ARRANGEMENT_ID) + Assert.assertNotNull(cdrArrangementId) + + //retrieve consumer data successfully + Response response = AURequestBuilder + .buildBasicRequest(userAccessToken, AUConstants.CDR_ENDPOINT_VERSION) + .header(AUConstants.X_FAPI_AUTH_DATE, AUConstants.DATE) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) + + //revoke sharing arrangement + def revokeResponse = doRevokeCdrArrangementWithoutClientIdInRequest(auConfiguration.getAppInfoClientID(), + cdrArrangementId) + + Assert.assertEquals(revokeResponse.statusCode(), AUConstants.STATUS_CODE_204) + + } + + @Test + void "CDS-146_Invoke cdr management endpoint with invalid cdr_arrangement_id"() { + + //revoke sharing arrangement without cdr arrangement id + generator = new AUJWTGenerator() + String assertionString = generator.getClientAssertionJwt(clientId) + + def bodyContent = [(AUConstants.CLIENT_ID_KEY): (clientId), + (AUConstants.CLIENT_ASSERTION_TYPE_KEY): (AUConstants.CLIENT_ASSERTION_TYPE), + (AUConstants.CLIENT_ASSERTION_KEY) : assertionString, + (AUConstants.CDR_ARRANGEMENT_ID) : "123"] + + revocationResponse = AURestAsRequestBuilder.buildRequest() + .contentType(AUConstants.ACCESS_TOKEN_CONTENT_TYPE) + .formParams(bodyContent) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_CDR_ARRANGEMENT)) + .post("${AUConstants.CDR_ARRANGEMENT_ENDPOINT}") + + Assert.assertEquals(revocationResponse.statusCode(), AUConstants.STATUS_CODE_422) + + Assert.assertEquals(AUTestUtil.parseResponseBody(revocationResponse, AUConstants.ERROR_CODE), + AUConstants.ERROR_CODE_INVALID_ARRANGEMENT) + Assert.assertEquals(AUTestUtil.parseResponseBody(revocationResponse, AUConstants.ERROR_TITLE), + AUConstants.INVALID_CONSENT_ARRANGEMENT) + Assert.assertEquals(AUTestUtil.parseResponseBody(revocationResponse, AUConstants.ERROR_DETAIL), + "invalid cdr-arrangement-id sent in the request") + } } diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationCreateTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationCreateTest.groovy similarity index 67% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationCreateTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationCreateTest.groovy index ee6749591..4beec2193 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationCreateTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationCreateTest.groovy @@ -15,23 +15,25 @@ * specific language governing permissions and limitations * under the License. */ -package com.wso2.cds.integration.test.clientRegistration - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.configuration.AUConfigurationService -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.ContextConstants -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +package org.wso2.cds.integration.test.clientRegistration + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.ContextConstants +import org.wso2.cds.test.framework.request_builder.AUJWTGenerator +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import io.restassured.http.ContentType import org.testng.Assert -import org.testng.annotations.AfterClass import org.testng.annotations.BeforeClass import org.testng.annotations.Test import org.testng.ITestContext import java.nio.file.Path import java.nio.file.Paths +import java.time.LocalDate +import java.time.ZoneOffset /** *Test cases to validate DCR create request. @@ -39,11 +41,12 @@ import java.nio.file.Paths class DynamicClientRegistrationCreateTest extends AUTest{ AUJWTGenerator generator = new AUJWTGenerator() - String clientId + String clientId, softwareId - @BeforeClass + @BeforeClass (alwaysRun = true) void "Delete Application if exists"() { deleteApplicationIfExists(auConfiguration.getAppInfoClientID()) + softwareId = "SP1" } @Test(priority = 1,dependsOnMethods = "TC0101008_Verify Dynamic client registration test") @@ -54,7 +57,7 @@ class DynamicClientRegistrationCreateTest extends AUTest{ Assert.assertNotNull(accessToken) } - @Test(priority = 1) + @Test(groups = "SmokeTest", priority = 1) void "TC0101008_Verify Dynamic client registration test"(ITestContext context){ jtiVal = String.valueOf(System.currentTimeMillis()) @@ -197,10 +200,10 @@ class DynamicClientRegistrationCreateTest extends AUTest{ AUConstants.DCR_WITHOUT_SSA) } - @Test + @Test (priority = 2) void "TC0101012_Create application without ID Token Encrypted Response Algorithm"(ITestContext context) { - deleteApplicationIfExists(clientId) + deleteApplicationIfExists(auConfiguration.getAppInfoClientID()) AUConfigurationService auConfiguration = new AUConfigurationService() AURegistrationRequestBuilder dcr = new AURegistrationRequestBuilder() @@ -218,10 +221,10 @@ class DynamicClientRegistrationCreateTest extends AUTest{ deleteApplicationIfExists(clientId) } - @Test + @Test (priority = 2) void "TC0101013_Create application without ID Token Encrypted Response Encryption Method"(ITestContext context) { - deleteApplicationIfExists(clientId) + deleteApplicationIfExists(auConfiguration.getAppInfoClientID()) AUConfigurationService auConfiguration = new AUConfigurationService() AURegistrationRequestBuilder dcr = new AURegistrationRequestBuilder() @@ -287,10 +290,10 @@ class DynamicClientRegistrationCreateTest extends AUTest{ "Invalid issuer") } - @Test + @Test (priority = 2) void "TC0101017_Create application with a replayed JTI value in JWT request"() { - deleteApplicationIfExists(clientId) + deleteApplicationIfExists(auConfiguration.getAppInfoClientID()) jtiVal = String.valueOf(System.currentTimeMillis()) AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() def registrationResponse = AURegistrationRequestBuilder @@ -396,7 +399,7 @@ class DynamicClientRegistrationCreateTest extends AUTest{ "Malformed request JWT") } - @Test(priority = 2) + @Test (priority = 2) void "OB-1165_Create application without request_object_signing_alg"(ITestContext context) { AURegistrationRequestBuilder dcr = new AURegistrationRequestBuilder() @@ -427,10 +430,10 @@ class DynamicClientRegistrationCreateTest extends AUTest{ deleteApplicationIfExists(context.getAttribute(ContextConstants.CLIENT_ID).toString()) } - @Test + @Test (priority = 2) void "OB-1166_Create application without redirect_uris"(ITestContext context) { - deleteApplicationIfExists(clientId) + deleteApplicationIfExists(auConfiguration.getAppInfoClientID()) AURegistrationRequestBuilder dcr = new AURegistrationRequestBuilder() def registrationResponse = AURegistrationRequestBuilder .buildRegistrationRequest(dcr.getRegularClaimsWithoutRedirectUris()) @@ -464,6 +467,54 @@ class DynamicClientRegistrationCreateTest extends AUTest{ "Invalid responseTypes provided") } + @Test + void "CDS-1104_Create application with invalid TokenEndpointAuthSigningAlgorithm"() { + + AURegistrationRequestBuilder dcr = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(dcr.getRegularClaimsWithInvalidTokenAuthSignAlg()) + .when() + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_400) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR), + AUConstants.INVALID_CLIENT_METADATA) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR_DESCRIPTION), + AUConstants.INVALID_SIGNING_ALG) + } + + @Test + void "CDS-1105_Create application with invalid Aud"() { + + AURegistrationRequestBuilder dcr = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(dcr.getClaimsWithInvalidAud()) + .when() + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_400) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR), + AUConstants.INVALID_CLIENT_METADATA) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR_DESCRIPTION), + AUConstants.INVALID_AUDIENCE_ERROR) + } + + @Test + void "CDS-1106_Create application without ApplicationType"() { + + deleteApplicationIfExists(auConfiguration.getAppInfoClientID()) + + AURegistrationRequestBuilder dcr = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(dcr.getRegularClaimsWithoutApplicationType()) + .when() + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_201) + clientId = AUTestUtil.parseResponseBody(registrationResponse, AUConstants.CLIENT_ID) + deleteApplicationIfExists(clientId) + } + @Test void "CDS-673_DCR registration request with localhost url in the SSA"(ITestContext context) { @@ -474,12 +525,12 @@ class DynamicClientRegistrationCreateTest extends AUTest{ AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() def registrationResponse = AURegistrationRequestBuilder .buildRegistrationRequest(registrationRequestBuilder - .getAURegularClaims(auConfiguration.getAppDCRSoftwareId(), AUTestUtil.readFileContent(filePath), - AUConstants.LOCALHOST_REDIRECT_URL)) + .getAURegularClaims(softwareId, AUTestUtil.readFileContent(filePath), + AUConstants.LOCALHOST_REDIRECT_URL)) .when() .post(AUConstants.DCR_REGISTRATION_ENDPOINT) - clientId = AUTestUtil.parseResponseBody(registrationResponse, AUConstants.CLIENT_ID) + def appClientId = AUTestUtil.parseResponseBody(registrationResponse, AUConstants.CLIENT_ID) context.setAttribute(ContextConstants.CLIENT_ID,clientId) AUTestUtil.writeToConfigFile(clientId) @@ -490,7 +541,151 @@ class DynamicClientRegistrationCreateTest extends AUTest{ Assert.assertTrue(parseResponseBody(registrationResponse, "redirect_uris") .contains(AUConstants.LOCALHOST_REDIRECT_URL)) + deleteApplicationIfExists(appClientId) + } + + @Test + void "CDS-674_DCR registration request with different hostnames for redirect url in SSA"() { + + Path dcrArtifactsPath = Paths.get(auConfiguration.getAppDCRSSAPath()) + String filePath = Paths.get(dcrArtifactsPath.getParent().toString(), "ssa_differentHostNames.txt") + + jtiVal = String.valueOf(System.currentTimeMillis()) + AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(registrationRequestBuilder + .getAURegularClaims(softwareId, AUTestUtil.readFileContent(filePath), + AUConstants.LOCALHOST_REDIRECT_URL)) + .when() + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_400) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR), + AUConstants.INVALID_CLIENT_METADATA) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR_DESCRIPTION), + AUConstants.ERROR_REDIRECT_URL_WITH_DIFF_HOSTNAMES) + } + + @Test + void "Create application without redirect uri in SSA"() { + + Path dcrArtifactsPath = Paths.get(auConfiguration.getAppDCRSSAPath()) + String filePath = Paths.get(dcrArtifactsPath.getParent().toString(), "ssa_withoutRedirectUrl.txt") + + jtiVal = String.valueOf(System.currentTimeMillis()) + AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(registrationRequestBuilder + .getAURegularClaims(softwareId, AUTestUtil.readFileContent(filePath), + AUConstants.LOCALHOST_REDIRECT_URL)) + .when() + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_400) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR), + AUConstants.INVALID_CLIENT_METADATA) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR_DESCRIPTION), + AUConstants.ERROR_EMPTY_REDIRECT_URL_IN_SSA) + } + + @Test + void "CDS-1108_Create application with invalid request_object_signing_alg"() { + + AURegistrationRequestBuilder dcr = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(dcr.getRegularClaimsWithInvalidRequestObjectSigningAlg()) + .when() + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_400) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR), + AUConstants.INVALID_CLIENT_METADATA) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR_DESCRIPTION), + AUConstants.INVALID_SIGNING_ALG) + } + + @Test + void "CDS-1109_Create application with invalid id_token_signed_response_alg"() { + + AURegistrationRequestBuilder dcr = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(dcr.getRegularClaimsWithInvalidIdTokenSigningResponseAlg()) + .when() + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_400) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR), + AUConstants.INVALID_CLIENT_METADATA) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR_DESCRIPTION), + AUConstants.INVALID_SIGNING_ALG) + } + + @Test + void "CDS-1110_Create application without id_token_signed_response_alg"() { + + AURegistrationRequestBuilder dcr = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(dcr.getRegularClaimsWithoutIdTokenSigningResponseAlg()) + .when() + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_400) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR), + AUConstants.INVALID_CLIENT_METADATA) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR_DESCRIPTION), + AUConstants.ERROR_WITHOUT_IDTOKEN_SINGED_ALG) + } + + @Test (priority = 2) + void "CDS-476_Create application without ID_Token Response Type and verify id_token encryption not Mandatory"() { + + deleteApplicationIfExists(auConfiguration.getAppInfoClientID()) + AUConfigurationService auConfiguration = new AUConfigurationService() + AURegistrationRequestBuilder dcr = new AURegistrationRequestBuilder() + + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(dcr.getClaimsWithoutIdTokenEnc()) + .when() + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_201) + clientId = parseResponseBody(registrationResponse, AUConstants.CLIENT_ID) + deleteApplicationIfExists(clientId) } + + @Test + void "CDS-1111_Create application with unsupported content-type"() { + + jtiVal = String.valueOf(System.currentTimeMillis()) + AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(registrationRequestBuilder.getAURegularClaims()) + .contentType(ContentType.JSON) + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_415) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR_DESCRIPTION), + AUConstants.INVALID_CONTENT_TYPE) + } + + @Test + void "CDS-1112_Create application with expired Request JWT"() { + + Long expiredDate = LocalDate.now().minusDays(1).atTime(currentTime, 00, 00) + .toEpochSecond(ZoneOffset.UTC) + + AURegistrationRequestBuilder dcr = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(dcr.getExpiredRequestClaims(expiredDate)) + .when() + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_400) + Assert.assertEquals(parseResponseBody(registrationResponse, AUConstants.ERROR), + AUConstants.INVALID_CLIENT_METADATA) + //TODO: Add Error Description after fixing https://github.com/wso2-enterprise/ob-compliance-toolkit-cds/issues/403 + } + } diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationDeleteTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationDeleteTest.groovy similarity index 86% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationDeleteTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationDeleteTest.groovy index 5335e4197..762f60a85 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationDeleteTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationDeleteTest.groovy @@ -16,17 +16,16 @@ * under the License. */ -package com.wso2.cds.integration.test.clientRegistration - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.configuration.AUConfigurationService -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.ContextConstants -import com.wso2.cds.test.framework.data_provider.ConsentDataProviders -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +package org.wso2.cds.integration.test.clientRegistration + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.ContextConstants +import org.wso2.cds.test.framework.data_provider.ConsentDataProviders +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert -import org.testng.annotations.AfterClass import org.testng.annotations.Test import org.testng.ITestContext @@ -89,7 +88,6 @@ class DynamicClientRegistrationDeleteTest extends AUTest { .request(httpMethod.toString(), AUConstants.DCR_REGISTRATION_ENDPOINT + clientId) Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_405) - Assert.assertNotNull(registrationResponse.getHeader(AUConstants.X_FAPI_INTERACTION_ID)) } @Test(dependsOnMethods = "TC0101009_Verify Get Application Access Token", priority = 2, dataProvider = "unsupportedHttpMethods", @@ -100,6 +98,6 @@ class DynamicClientRegistrationDeleteTest extends AUTest { .when() .request(httpMethod.toString(), AUConstants.DCR_REGISTRATION_ENDPOINT + clientId) - Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_400) + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_501) } } diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationRetrieveTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationRetrieveTest.groovy similarity index 76% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationRetrieveTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationRetrieveTest.groovy index 053b348fc..c9c4a204c 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationRetrieveTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationRetrieveTest.groovy @@ -16,19 +16,14 @@ * under the License. */ -package com.wso2.cds.integration.test.clientRegistration - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.configuration.AUConfigurationService -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.ContextConstants -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.configuration.OBConfigParser -import com.wso2.openbanking.test.framework.constant.OBConstants -import com.wso2.openbanking.test.framework.utility.RestAsRequestBuilder +package org.wso2.cds.integration.test.clientRegistration + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.ContextConstants +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert -import org.testng.annotations.AfterClass import org.testng.annotations.Test import org.testng.ITestContext @@ -38,7 +33,7 @@ import org.testng.ITestContext class DynamicClientRegistrationRetrieveTest extends AUTest{ @SuppressWarnings('GroovyAccessibility') - @Test + @Test (groups = "SmokeTest") void "TC0101018_Retrieve Application"(ITestContext context) { AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() @@ -54,7 +49,7 @@ class DynamicClientRegistrationRetrieveTest extends AUTest{ AUTestUtil.writeToConfigFile(clientId) } - @Test(priority = 1, dependsOnMethods = "TC0101018_Retrieve Application") + @Test(groups = "SmokeTest", priority = 1, dependsOnMethods = "TC0101018_Retrieve Application") void "TC0101009_Get access token"() { accessToken = getApplicationAccessToken(clientId) @@ -73,7 +68,7 @@ class DynamicClientRegistrationRetrieveTest extends AUTest{ Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_401) } - @Test(priority = 2, dependsOnMethods = "TC0101009_Get access token") + @Test(groups = "SmokeTest", priority = 2, dependsOnMethods = "TC0101009_Get access token") void "TC0102002_Get registration details"() { def registrationResponse = AURegistrationRequestBuilder.buildBasicRequest(accessToken) diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationUpdateTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationUpdateTest.groovy similarity index 68% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationUpdateTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationUpdateTest.groovy index 13fa6deb0..74fbe7039 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationUpdateTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/DynamicClientRegistrationUpdateTest.groovy @@ -15,22 +15,24 @@ * specific language governing permissions and limitations * under the License. */ -package com.wso2.cds.integration.test.clientRegistration - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.ContextConstants -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +package org.wso2.cds.integration.test.clientRegistration + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.ContextConstants +import org.wso2.cds.test.framework.request_builder.AUJWTGenerator +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert -import org.testng.annotations.AfterClass import org.testng.annotations.BeforeClass import org.testng.annotations.Test import org.testng.ITestContext +import java.nio.file.Path +import java.nio.file.Paths + /** * Testcases for DCR Update request validation. */ @@ -38,6 +40,7 @@ class DynamicClientRegistrationUpdateTest extends AUTest{ private String registrationPath = AUConstants.DCR_REGISTRATION_ENDPOINT private String invalidClientId = "invalidclientid" + private String softwareId = "SP1" @BeforeClass(alwaysRun = true) void "Initialize Test Suite"(ITestContext context) { @@ -178,4 +181,59 @@ class DynamicClientRegistrationUpdateTest extends AUTest{ Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_401) } + + @Test + void "CDS-22_Update Application with SSA containing redirect uri in localhost value"() { + + Path dcrArtifactsPath = Paths.get(auConfiguration.getAppDCRSSAPath()) + String filePath = Paths.get(dcrArtifactsPath.getParent().toString(), "ssa_localhost.txt") + + jtiVal = String.valueOf(System.currentTimeMillis()) + AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(registrationRequestBuilder + .getAURegularClaims(softwareId, AUTestUtil.readFileContent(filePath), + AUConstants.LOCALHOST_REDIRECT_URL)) + .when() + .post(AUConstants.DCR_REGISTRATION_ENDPOINT) + + def appClientId = AUTestUtil.parseResponseBody(registrationResponse, AUConstants.CLIENT_ID) + + accessToken = getApplicationAccessToken(appClientId) + Assert.assertNotNull(accessToken) + + AUJWTGenerator aujwtGenerator =new AUJWTGenerator() + registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(registrationRequestBuilder + .getAURegularClaims(softwareId, AUTestUtil.readFileContent(filePath), + AUConstants.LOCALHOST_REDIRECT_URL)) + .header(AUConstants.AUTHORIZATION_HEADER_KEY, "${AUConstants.AUTHORIZATION_BEARER_TAG}${accessToken}") + .when() + .put(registrationPath + appClientId) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_200) + Assert.assertEquals(parseResponseBody(registrationResponse, "software_statement"), + AUTestUtil.readFileContent(filePath)) + Assert.assertTrue(parseResponseBody(registrationResponse, "redirect_uris") + .contains(AUConstants.LOCALHOST_REDIRECT_URL)) + + deleteApplicationIfExists(appClientId) + } + + @Test + void "CDS-23_Update registration details with invalid http method"() { + + accessToken = getApplicationAccessToken(clientId) + Assert.assertNotNull(accessToken) + + AUJWTGenerator aujwtGenerator =new AUJWTGenerator() + AURegistrationRequestBuilder registrationRequestBuilder = new AURegistrationRequestBuilder() + def registrationResponse = AURegistrationRequestBuilder + .buildRegistrationRequest(registrationRequestBuilder.getAURegularClaims()) + .header(AUConstants.AUTHORIZATION_HEADER_KEY, "${AUConstants.AUTHORIZATION_BEARER_TAG}${accessToken}") + .when() + .request("COPY", AUConstants.DCR_REGISTRATION_ENDPOINT + clientId) + + Assert.assertEquals(registrationResponse.statusCode(), AUConstants.STATUS_CODE_501) + } } diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/MultiTppDcrEndpointTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/MultiTppDcrEndpointTests.groovy similarity index 88% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/MultiTppDcrEndpointTests.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/MultiTppDcrEndpointTests.groovy index 9f86426a9..1ce564295 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/clientRegistration/MultiTppDcrEndpointTests.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/clientRegistration/MultiTppDcrEndpointTests.groovy @@ -16,16 +16,13 @@ * under the License. */ -package com.wso2.cds.integration.test.clientRegistration - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUMockCDRIntegrationUtil -import com.wso2.cds.test.framework.utility.AUTestUtil +package org.wso2.cds.integration.test.clientRegistration + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert import org.testng.annotations.AfterClass import org.testng.annotations.BeforeClass diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/common_api/CustomerDetailsRetrievalHeaderValidationTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/common_api/CustomerDetailsRetrievalHeaderValidationTests.groovy similarity index 98% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/common_api/CustomerDetailsRetrievalHeaderValidationTests.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/common_api/CustomerDetailsRetrievalHeaderValidationTests.groovy index 97e727f07..241034f32 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/common_api/CustomerDetailsRetrievalHeaderValidationTests.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/common_api/CustomerDetailsRetrievalHeaderValidationTests.groovy @@ -16,15 +16,14 @@ * under the License. */ -package com.wso2.cds.integration.test.common_api - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AURestAsRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import io.restassured.http.ContentType +package org.wso2.cds.integration.test.common_api + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import io.restassured.response.Response import org.testng.Assert import org.testng.annotations.BeforeClass diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/common_api/CustomerDetailsRetrievalTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/common_api/CustomerDetailsRetrievalTest.groovy similarity index 96% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/common_api/CustomerDetailsRetrievalTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/common_api/CustomerDetailsRetrievalTest.groovy index 5247eba0d..078a44944 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/common_api/CustomerDetailsRetrievalTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/common_api/CustomerDetailsRetrievalTest.groovy @@ -16,13 +16,13 @@ * under the License. */ -package com.wso2.cds.integration.test.common_api +package org.wso2.cds.integration.test.common_api -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import io.restassured.response.Response import org.testng.Assert import org.testng.annotations.BeforeClass diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataAccountRetrieval.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataAccountRetrieval.groovy similarity index 97% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataAccountRetrieval.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataAccountRetrieval.groovy index 12f322cc8..7dbbbdfba 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataAccountRetrieval.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataAccountRetrieval.groovy @@ -16,11 +16,11 @@ * under the License. */ -package com.wso2.cds.integration.test.metadata_update +package org.wso2.cds.integration.test.metadata_update -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.utility.AUTestUtil import io.restassured.response.Response import org.testng.Assert import org.testng.annotations.BeforeClass diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataConsentAmendment.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataConsentAmendment.groovy similarity index 87% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataConsentAmendment.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataConsentAmendment.groovy index 0d77d5ee9..767498a41 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataConsentAmendment.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataConsentAmendment.groovy @@ -16,20 +16,17 @@ * under the License. */ -package com.wso2.cds.integration.test.metadata_update +package org.wso2.cds.integration.test.metadata_update import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod -import org.openqa.selenium.By +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod import org.testng.Assert -import org.testng.annotations.AfterClass import org.testng.annotations.BeforeClass import org.testng.annotations.Test diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataConsentAuthorization.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataConsentAuthorization.groovy similarity index 96% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataConsentAuthorization.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataConsentAuthorization.groovy index becbd948d..3eb148027 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataConsentAuthorization.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataConsentAuthorization.groovy @@ -16,13 +16,13 @@ * under the License. */ -package com.wso2.cds.integration.test.metadata_update +package org.wso2.cds.integration.test.metadata_update -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.configuration.AUConfigurationService -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.NavigationAutomationStep +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.NavigationAutomationStep import org.testng.Assert import org.testng.annotations.BeforeClass import org.testng.annotations.Test diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataConsentWithdrawal.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataConsentWithdrawal.groovy similarity index 98% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataConsentWithdrawal.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataConsentWithdrawal.groovy index 3e9fe1a28..900385972 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataConsentWithdrawal.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataConsentWithdrawal.groovy @@ -16,12 +16,12 @@ * under the License. */ -package com.wso2.cds.integration.test.metadata_update +package org.wso2.cds.integration.test.metadata_update import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.utility.AUTestUtil import io.restassured.response.Response import org.testng.Assert import org.testng.annotations.BeforeClass diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataUpdateBatchTaskTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataUpdateBatchTaskTests.groovy similarity index 96% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataUpdateBatchTaskTests.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataUpdateBatchTaskTests.groovy index 589c32912..38221c6fd 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/metadata_update/MetaDataUpdateBatchTaskTests.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/metadata_update/MetaDataUpdateBatchTaskTests.groovy @@ -16,17 +16,15 @@ * under the License. */ -package com.wso2.cds.integration.test.metadata_update +package org.wso2.cds.integration.test.metadata_update import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import io.restassured.response.Response import org.testng.Assert -import org.testng.annotations.AfterClass import org.testng.annotations.BeforeClass import org.testng.annotations.Test diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/throttling/ThrottlingPolicyTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/throttling/ThrottlingPolicyTest.groovy similarity index 87% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/throttling/ThrottlingPolicyTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/throttling/ThrottlingPolicyTest.groovy index 87445d582..9e7b5692c 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/throttling/ThrottlingPolicyTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/throttling/ThrottlingPolicyTest.groovy @@ -16,13 +16,13 @@ * under the License. */ -package com.wso2.cds.integration.test.throttling +package org.wso2.cds.integration.test.throttling -import com.nimbusds.oauth2.sdk.Scope -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert import org.testng.annotations.BeforeClass import org.testng.annotations.Test @@ -118,8 +118,8 @@ class ThrottlingPolicyTest extends AUTest{ @Test(invocationCount = 200, threadPoolSize = 20, enabled = false) void "TC0306004_Throttle requests by DataRecipients policy - Unattended"() { - def response = AURequestBuilder.buildBasicRequestWithCustomHeaders(userAccessToken, - AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + def response = AURequestBuilder.buildBasicRequest(userAccessToken, + AUConstants.X_V_HEADER_ACCOUNTS) .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) .get("${AUConstants.BULK_ACCOUNT_PATH}") @@ -157,11 +157,11 @@ class ThrottlingPolicyTest extends AUTest{ } } - @Test(invocationCount = 200, threadPoolSize = 5, enabled = false) + @Test(invocationCount = 200, threadPoolSize = 5, enabled = true)// void "TC0306006_Throttle requests by Unattended-CallsPerSession policy"() { - def response = AURequestBuilder.buildBasicRequestWithCustomHeaders(userAccessToken, - AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + def response = AURequestBuilder.buildBasicRequest(userAccessToken, + AUConstants.X_V_HEADER_ACCOUNTS) .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) .get("${AUConstants.BULK_ACCOUNT_PATH}") @@ -178,13 +178,14 @@ class ThrottlingPolicyTest extends AUTest{ } } - @Test(invocationCount = 40, threadPoolSize = 2, enabled = true) - void "TC0306008_Throttle requests by Unattended-SessionCount policy"() { + @Test(invocationCount = 100, threadPoolSize = 10, enabled = true) + void "TC0306007_Throttle requests by Unattended-SessionTPS policy"() { - String scopeString = "openid ${String.join(" ", scopes.collect({ it.scopeString }))}" - Scope scopeList = new Scope(scopeString) + def response = AURequestBuilder.buildBasicRequest(userAccessToken, + AUConstants.X_V_HEADER_ACCOUNTS) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") - def response = AURequestBuilder.getTokenResponse(scopeList.toStringList(), clientId) int currentCount = sequence.addAndGet(1) if(currentCount > 30) { @@ -193,16 +194,19 @@ class ThrottlingPolicyTest extends AUTest{ AUConstants.ERROR_CODE_GENERAL_EXPECTED_ERROR) Assert.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR_TITLE), AUConstants.ERROR_TITLE_GENERAL_EXPECTED_ERROR) - } else { + }else { Assert.assertEquals(response.statusCode(), 200) } } - @Test(invocationCount = 100, threadPoolSize = 10, enabled = false) - void "TC0306007_Throttle requests by Unattended-SessionTPS policy"() { + @Test (invocationCount = 20, enabled = true) + void "Throttle requests by Unattended-SessionTPS policy"() { - def response = AURequestBuilder.buildBasicRequestWithCustomHeaders(userAccessToken, - AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + doConsentAuthorisation() + generateUserAccessToken() + + def response = AURequestBuilder + .buildBasicRequestWithCustomHeaders(userAccessToken, AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) .get("${AUConstants.BULK_ACCOUNT_PATH}") @@ -214,8 +218,8 @@ class ThrottlingPolicyTest extends AUTest{ AUConstants.ERROR_CODE_GENERAL_EXPECTED_ERROR) Assert.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR_TITLE), AUConstants.ERROR_TITLE_GENERAL_EXPECTED_ERROR) - }else { - Assert.assertEquals(response.statusCode(), 200) + } else { + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) } } } diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/tokenEndpoint/AccessTokenTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/tokenEndpoint/AccessTokenTest.groovy similarity index 69% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/tokenEndpoint/AccessTokenTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/tokenEndpoint/AccessTokenTest.groovy index 8b2f92cb1..44647d58d 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/tokenEndpoint/AccessTokenTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/tokenEndpoint/AccessTokenTest.groovy @@ -16,14 +16,14 @@ * under the License. */ -package com.wso2.cds.integration.test.tokenEndpoint +package org.wso2.cds.integration.test.tokenEndpoint import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import java.nio.charset.Charset import org.testng.Assert import org.testng.annotations.Test @@ -71,8 +71,8 @@ class AccessTokenTest extends AUTest { def errorObject = AURequestBuilder.getUserTokenErrorResponse(authorisationCode, auConfiguration.getAppInfoRedirectURL(), auConfiguration.getAppInfoClientID(), true, false) - Assert.assertEquals(errorObject.toJSONObject().get(AUConstants.ERROR_DESCRIPTION), "Transport certificate" + - " not found in the request") + Assert.assertEquals(errorObject.toJSONObject().get(AUConstants.ERROR_DESCRIPTION), "Transport certificate " + + "not found in the request") } @Test @@ -201,7 +201,7 @@ class AccessTokenTest extends AUTest { Assert.assertEquals(userAccessToken.toJSONObject().get("scope"),ACCOUNTS_BASIC_ACCOUNT_DETAIL_OPENID_SCOPE_LIST) } - @Test + @Test (groups = "SmokeTest") void "CDS-705_Verify introspection response not returning username field"() { // Generating a new authorisation code @@ -227,7 +227,7 @@ class AccessTokenTest extends AUTest { Assert.assertNull(introspectResponse.jsonPath().get("username")) } - @Test (dependsOnMethods = "CDS-705_Verify introspection response not returning username field") + @Test (groups = "SmokeTest", dependsOnMethods = "CDS-705_Verify introspection response not returning username field") void "CDS-718_Send introspection call for user access token"() { def introspectResponse = AURequestBuilder.buildIntrospectionRequest(user_AccessToken, @@ -237,7 +237,7 @@ class AccessTokenTest extends AUTest { Assert.assertTrue(introspectResponse.jsonPath().get("active").equals(false)) } - @Test (dependsOnMethods = "CDS-705_Verify introspection response not returning username field") + @Test (groups = "SmokeTest", dependsOnMethods = "CDS-705_Verify introspection response not returning username field") void "CDS-718_Send introspection call for id_token"() { def introspectResponse = AURequestBuilder.buildIntrospectionRequest(idToken, @@ -247,8 +247,7 @@ class AccessTokenTest extends AUTest { Assert.assertTrue(introspectResponse.jsonPath().get("active").equals(false)) } - //TODO: Issue: https://github.com/wso2-enterprise/financial-open-banking/issues/8456 - @Test(dependsOnMethods = "CDS-705_Verify introspection response not returning username field") + @Test(groups = "SmokeTest", dependsOnMethods = "CDS-705_Verify introspection response not returning username field") void "CDS-1023_Verify introspection request return cdr_arrangement_id"() { def response = AURequestBuilder.buildIntrospectionRequest(refreshToken, @@ -261,4 +260,88 @@ class AccessTokenTest extends AUTest { Assert.assertNotNull(response.jsonPath().get("exp")) Assert.assertEquals(response.jsonPath().get("cdr_arrangement_id"), cdrArrangementId) } + + @Test + void "CDS-1048_Token Request without client id param in the request body"() { + + doConsentAuthorisation( auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(authorisationCode) + + def tokenResponse = getUserAccessTokenResponse() + user_AccessToken = tokenResponse.tokens.accessToken + refreshToken = tokenResponse.tokens.refreshToken + + Assert.assertNotNull(user_AccessToken) + } + + @Test (dependsOnMethods = "CDS-1048_Token Request without client id param in the request body") + void "CDS-1052_Token introspection Request without client id param in the request body"() { + + def introspectResponseSecondToken = AURequestBuilder.buildIntrospectionWithoutClientIdParam(refreshToken, + auConfiguration.getAppInfoClientID(), 0) + .post(AUConstants.INTROSPECTION_ENDPOINT) + + Assert.assertTrue(introspectResponseSecondToken.jsonPath().get("active").toString().contains("true")) + } + + @Test (dependsOnMethods = "CDS-1052_Token introspection Request without client id param in the request body") + void "CDS-1051_Token Revocation Request without client id param in the request body"() { + + // Revoke access Token + def revokeResponse = AURequestBuilder + .buildRevokeTokenWithoutClientIdParam(user_AccessToken, auConfiguration.getAppInfoClientID()) + .post(AUConstants.TOKEN_REVOKE_PATH) + + Assert.assertEquals(revokeResponse.statusCode(), AUConstants.STATUS_CODE_200) + } + + @Test (groups = "SmokeTest") + void "CDS-1053_Token Request with client id param in the request body similar to sub value"() { + + doConsentAuthorisation( auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(authorisationCode) + + def tokenResponse = getUserAccessTokenResponse(auConfiguration.getAppInfoClientID()) + user_AccessToken = tokenResponse.tokens.accessToken + refreshToken = tokenResponse.tokens.refreshToken + + Assert.assertNotNull(user_AccessToken) + } + + @Test (groups = "SmokeTest", dependsOnMethods = "CDS-1053_Token Request with client id param in the request body similar to sub value") + void "CDS-1057_Token introspection Request with client id param in the request body similar to sub value"() { + + def introspectResponseSecondToken = AURequestBuilder.buildIntrospectionRequest(refreshToken, + auConfiguration.getAppInfoClientID(), 0) + .post(AUConstants.INTROSPECTION_ENDPOINT) + + Assert.assertTrue(introspectResponseSecondToken.jsonPath().get("active").toString().contains("true")) + } + + @Test (groups = "SmokeTest", dependsOnMethods = "CDS-1057_Token introspection Request with client id param in the request body similar to sub value") + void "CDS-1056_Token Revocation Request with client id param in the request body similar to sub value"() { + + // Revoke access Token + def revokeResponse = AURequestBuilder + .buildRevokeIntrospectionRequest(user_AccessToken, auConfiguration.getAppInfoClientID()) + .post(AUConstants.TOKEN_REVOKE_PATH) + + Assert.assertEquals(revokeResponse.statusCode(), AUConstants.STATUS_CODE_200) + } + + @Test + void "CDS-1058_Token Request with client Id in the request body not similar to client id in the client_assertion"() { + + doConsentAuthorisation( auConfiguration.getAppInfoClientID()) + Assert.assertNotNull(authorisationCode) + + def tokenResponse = AURequestBuilder.getUserTokenWithClientIdInReqBody(authorisationCode, + AUConstants.CODE_VERIFIER, auConfiguration.getAppInfoClientID(), auConfiguration.getAppInfoClientID(1)) + def response = tokenResponse.toErrorResponse() + + Assert.assertEquals(response.toHTTPResponse().statusCode, AUConstants.STATUS_CODE_401) + Assert.assertEquals(response.errorObject.description, + "Request Parameter 'client_id' does not match the 'sub' claim in the client_assertion") + Assert.assertEquals(response.errorObject.code, AUConstants.INVALID_CLIENT) + } } diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/tokenEndpoint/MultiTppTokenFlowValidationTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/tokenEndpoint/MultiTppTokenFlowValidationTests.groovy similarity index 86% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/tokenEndpoint/MultiTppTokenFlowValidationTests.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/tokenEndpoint/MultiTppTokenFlowValidationTests.groovy index 529cb0e1e..a7e07e8e6 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/tokenEndpoint/MultiTppTokenFlowValidationTests.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/tokenEndpoint/MultiTppTokenFlowValidationTests.groovy @@ -16,15 +16,13 @@ * under the License. */ -package com.wso2.cds.integration.test.tokenEndpoint - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUMockCDRIntegrationUtil -import com.wso2.cds.test.framework.utility.AUTestUtil +package org.wso2.cds.integration.test.tokenEndpoint + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert import org.testng.annotations.AfterClass import org.testng.annotations.BeforeClass diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/tpponboarding/CommonTppOnboardingStep.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/tpponboarding/CommonTppOnboardingStep.groovy similarity index 81% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/tpponboarding/CommonTppOnboardingStep.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/tpponboarding/CommonTppOnboardingStep.groovy index 04eae221b..b920f3f76 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/integration/test/tpponboarding/CommonTppOnboardingStep.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/integration/test/tpponboarding/CommonTppOnboardingStep.groovy @@ -16,14 +16,14 @@ * under the License. */ -package com.wso2.cds.integration.test.tpponboarding +package org.wso2.cds.integration.test.tpponboarding -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.ContextConstants -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.ContextConstants +import org.wso2.cds.test.framework.request_builder.AUJWTGenerator +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert import org.testng.ITestContext import org.testng.annotations.BeforeClass @@ -37,12 +37,12 @@ class CommonTppOnboardingStep extends AUTest{ AUJWTGenerator generator = new AUJWTGenerator() String clientId - @BeforeClass + @BeforeClass (alwaysRun = true) void "Delete Application if exists"() { deleteApplicationIfExists() } - @Test + @Test (groups = "SmokeTest") void "Tpp Onboarding Step"(ITestContext context){ jtiVal = String.valueOf(System.currentTimeMillis()) diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/authorizationflow/AuthorisationFlowTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/authorizationflow/AuthorisationFlowTest.groovy similarity index 95% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/authorizationflow/AuthorisationFlowTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/authorizationflow/AuthorisationFlowTest.groovy index 3112239e6..435c6a473 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/authorizationflow/AuthorisationFlowTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/authorizationflow/AuthorisationFlowTest.groovy @@ -16,25 +16,22 @@ * under the License. */ -package com.wso2.cds.keymanager.test.authorizationflow +package org.wso2.cds.keymanager.test.authorizationflow import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.nimbusds.oauth2.sdk.AuthorizationRequest import com.nimbusds.oauth2.sdk.ResponseMode import com.nimbusds.oauth2.sdk.ResponseType -import com.nimbusds.oauth2.sdk.id.ClientID -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AURestAsRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod -import com.wso2.openbanking.test.framework.automation.NavigationAutomationStep -import io.restassured.http.ContentType +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.openbanking.test.framework.automation.NavigationAutomationStep import org.openqa.selenium.By import org.testng.Assert import org.testng.annotations.Test @@ -227,7 +224,7 @@ class AuthorisationFlowTest extends AUTest { // Revoke access Token def revokeResponse = AURequestBuilder .buildRevokeIntrospectionRequest(userAccessToken, auConfiguration.getAppInfoClientID()) - .post(AUConstants.REVOKE_PATH) + .post(AUConstants.TOKEN_REVOKE_PATH) Assert.assertEquals(revokeResponse.statusCode(), AUConstants.STATUS_CODE_200) @@ -288,7 +285,6 @@ class AuthorisationFlowTest extends AUTest { Assert.assertEquals(state, stateParam) } - //TODO: Issue: https://github.com/wso2-enterprise/financial-open-banking/issues/8303 @Test void "OB-1695_Cancel consent authorisation sent with state param in the login page"() { @@ -311,7 +307,7 @@ class AuthorisationFlowTest extends AUTest { .execute() def authUrl = automation.currentUrl.get() - Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.USER_SKIP_THE_CONSENT_FLOW)) + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) String stateParam = authUrl.split("state=")[1] Assert.assertEquals(auAuthorisationBuilder.state.toString(), stateParam) } @@ -355,7 +351,7 @@ class AuthorisationFlowTest extends AUTest { .execute() def authUrl = automation.currentUrl.get() - Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.USER_SKIP_THE_CONSENT_FLOW)) + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) String stateParam = authUrl.split("state=")[1] Assert.assertEquals(auAuthorisationBuilder.state.toString(), stateParam) } @@ -393,16 +389,16 @@ class AuthorisationFlowTest extends AUTest { .execute() def authUrl = automation.currentUrl.get() - Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.USER_SKIP_THE_CONSENT_FLOW)) + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) Assert.assertTrue(authUrl.contains("state")) } - //TODO: Issue: https://github.com/wso2-enterprise/financial-open-banking/issues/8303 @Test void "OB-1697_Deny consent authorisation request sent without state param in the display_consent page"() { response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, - true, "") + true, "", auConfiguration.getAppInfoClientID(), + auConfiguration.getAppInfoRedirectURL(), ResponseType.CODE.toString(), false) requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) String authUrl = doConsentAuthorisationViaRequestUriDenyFlow(scopes, requestUri.toURI(), @@ -445,7 +441,7 @@ class AuthorisationFlowTest extends AUTest { .execute() def authUrl = automation.currentUrl.get() - Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.USER_SKIP_THE_CONSENT_FLOW)) + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) Assert.assertFalse(authUrl.contains("state")) } @@ -488,7 +484,7 @@ class AuthorisationFlowTest extends AUTest { .execute() def authUrl = automation.currentUrl.get() - Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.USER_SKIP_THE_CONSENT_FLOW)) + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) Assert.assertFalse(authUrl.contains("state")) } @@ -498,20 +494,11 @@ class AuthorisationFlowTest extends AUTest { scopes = [] response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, true, "") - requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) - - authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), - auConfiguration.getAppInfoClientID(), false).toURI().toString() + requestUri = response.jsonPath().getString(AUConstants.ERROR_DESCRIPTION) String errorMessage = "No valid scopes found in the request" - def automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) - .addStep(new NavigationAutomationStep(authoriseUrl, 10)) - .execute() - - String url = automationResponse.currentUrl.get() - String errorUrl = AUTestUtil.getErrorFromUrl(url) - Assert.assertEquals(errorUrl, errorMessage) + Assert.assertEquals(requestUri, errorMessage) } @Test (priority = 2) @@ -525,16 +512,17 @@ class AuthorisationFlowTest extends AUTest { response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, true, "") - String errorMessage = "Invalid scopes in the request" + String errorMessage = "No valid scopes found in the request" Assert.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR_DESCRIPTION), errorMessage) } - //TODO: Issue: https://github.com/wso2-enterprise/financial-open-banking/issues/8420 + //Error - Not loading Profile Selection Page @Test - void "OB-1253_Initiate authorisation consent flow only with openid and profile scopes"() { + void "OB-1253_Initiate authorisation consent flow only with openid and profile scopes"() { scopes = [ + AUAccountScope.OPENID, AUAccountScope.PROFILE ] @@ -711,7 +699,7 @@ class AuthorisationFlowTest extends AUTest { def authUrl = automation.currentUrl.get() def error_description = URLDecoder.decode(authUrl.split("&")[2].split("=")[1], "UTF8") - Assert.assertTrue(error_description.contains(AUConstants.USER_SKIP_THE_CONSENT_FLOW)) + Assert.assertTrue(error_description.contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) String actualRedirectUrl = authUrl.split("#")[0] Assert.assertEquals(actualRedirectUrl.toString(), newRedirectUri) } @@ -791,7 +779,7 @@ class AuthorisationFlowTest extends AUTest { def authUrl = automation.currentUrl.get() def error_description = URLDecoder.decode(authUrl.split("&")[2].split("=")[1], "UTF8") - Assert.assertTrue(error_description.contains(AUConstants.USER_SKIP_THE_CONSENT_FLOW)) + Assert.assertTrue(error_description.contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) String actualRedirectUrl = authUrl.split("#")[0] Assert.assertEquals(actualRedirectUrl.toString(), newRedirectUri) } @@ -840,4 +828,24 @@ class AuthorisationFlowTest extends AUTest { def automation = doAuthorisationFlowNavigation(authoriseUrl, AUAccountProfile.INDIVIDUAL, true) authorisationCode = AUTestUtil.getCodeFromJwtResponse(automation.currentUrl.get()) } + + @Test + void "CDS-720_Send authorisation request without request_uri"() { + + requestUri = "" + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), + auConfiguration.getAppInfoClientID()).toURI().toString() + + String errorMessage = "invalid.redirect.uri" + + def automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new NavigationAutomationStep(authoriseUrl, 10)) + .execute() + + String url = automationResponse.currentUrl.get() + String errorUrl + + errorUrl = AUTestUtil.getErrorFromUrl(url) + Assert.assertEquals(errorUrl, errorMessage) + } } diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/authorizationflow/ConsentAmendmentFlowTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/authorizationflow/ConsentAmendmentFlowTest.groovy similarity index 81% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/authorizationflow/ConsentAmendmentFlowTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/authorizationflow/ConsentAmendmentFlowTest.groovy index 3eb2b1223..0b87e129b 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/authorizationflow/ConsentAmendmentFlowTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/authorizationflow/ConsentAmendmentFlowTest.groovy @@ -16,21 +16,20 @@ * under the License. */ -package com.wso2.cds.keymanager.test.authorizationflow +package org.wso2.cds.keymanager.test.authorizationflow import com.nimbusds.oauth2.sdk.AccessTokenResponse import com.nimbusds.oauth2.sdk.TokenErrorResponse import com.nimbusds.oauth2.sdk.token.RefreshToken -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod -import com.wso2.openbanking.test.framework.automation.NavigationAutomationStep +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod import io.restassured.response.Response import org.testng.Assert import org.testng.annotations.Test @@ -57,6 +56,68 @@ class ConsentAmendmentFlowTest extends AUTest{ private String cdrArrangementId, userAccessToken, secondUserAccessToken private RefreshToken refreshToken, secondRefreshToken + @Test(groups = "SmokeTest") + void "CDS-9771_Verify Consent Amendment flow when both sharing duration and scope has been amended"() { + + // Send Authorisation request + doConsentAuthorisation(auConfiguration.getAppInfoClientID(), AUAccountProfile.INDIVIDUAL) + + // Retrieve the user access token by auth code + accessTokenResponse = getUserAccessTokenResponse(clientId) + cdrArrangementId = accessTokenResponse.getCustomParameters().get(AUConstants.CDR_ARRANGEMENT_ID) + userAccessToken = accessTokenResponse.tokens.accessToken + refreshToken = accessTokenResponse.tokens.refreshToken + + Assert.assertNotNull(userAccessToken) + Assert.assertNotNull(refreshToken) + Assert.assertNotNull(cdrArrangementId) + + //remove an existing scope and add a new scope to amend the consent + scopes.remove(AUAccountScope.BANK_TRANSACTION_READ) + scopes.add(AUAccountScope.BANK_PAYEES_READ) + + //Retrieve and assert the request URI from Push Authorization request + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI()).toURI().toString() + + //Consent Amendment Authorisation Flow + def automation = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Click Confirm Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + + //Click Authorise Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + } + .execute() + + // Get Code From URL + authorisationCode = AUTestUtil.getCodeFromJwtResponse(automation.currentUrl.get()) + + //Generate Token + accessTokenResponse2 = getUserAccessTokenResponse(clientId) + def cdrArrangementId2 = accessTokenResponse2.getCustomParameters().get(AUConstants.CDR_ARRANGEMENT_ID) + secondUserAccessToken = accessTokenResponse2.tokens.accessToken + secondRefreshToken = accessTokenResponse2.tokens.refreshToken + + Assert.assertNotNull(secondUserAccessToken) + Assert.assertNotNull(secondRefreshToken) + Assert.assertEquals(cdrArrangementId, cdrArrangementId2, "Amended CDR id is not original CDR id") + + //Get Account Transaction Details + def responseAfterAmendment = AURequestBuilder.buildBasicRequestWithCustomHeaders(secondUserAccessToken, + AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + Assert.assertEquals(responseAfterAmendment.statusCode(), AUConstants.STATUS_CODE_200) + } + @Test(groups = "SmokeTest") void "CDS-977_Verify Consent Amendment flow when both sharing duration and scope has been amended"() { @@ -110,9 +171,17 @@ class ConsentAmendmentFlowTest extends AUTest{ secondUserAccessToken = accessTokenResponse2.tokens.accessToken secondRefreshToken = accessTokenResponse2.tokens.refreshToken - Assert.assertNotNull(userAccessToken) Assert.assertNotNull(secondUserAccessToken) + Assert.assertNotNull(secondRefreshToken) Assert.assertEquals(cdrArrangementId, cdrArrangementId2, "Amended CDR id is not original CDR id") + + //Get Account Transaction Details + def responseAfterAmendment = AURequestBuilder.buildBasicRequestWithCustomHeaders(secondUserAccessToken, + AUConstants.X_V_HEADER_ACCOUNTS, clientHeader) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ACCOUNT)) + .get("${AUConstants.BULK_ACCOUNT_PATH}") + + Assert.assertEquals(responseAfterAmendment.statusCode(), AUConstants.STATUS_CODE_200) } @Test(groups = "SmokeTest", @@ -172,7 +241,8 @@ class ConsentAmendmentFlowTest extends AUTest{ @Test(dependsOnMethods = "CDS-977_Verify Consent Amendment flow when both sharing duration and scope has been amended") void "CDS-982_Verify regenerate Access Token using Refresh Token for amended Consent"() { - AccessTokenResponse userAccessToken = getUserAccessTokenFormRefreshToken(secondRefreshToken) + RefreshToken refreshToken = new RefreshToken(secondRefreshToken.toString()) + AccessTokenResponse userAccessToken = getUserAccessTokenFormRefreshToken(refreshToken) Assert.assertNotNull(userAccessToken.tokens.accessToken) } @@ -300,7 +370,7 @@ class ConsentAmendmentFlowTest extends AUTest{ secondUserAccessToken = accessTokenResponse2.tokens.accessToken secondRefreshToken = accessTokenResponse2.tokens.refreshToken - sleep(70000) + sleep(90000) //Verify the status of the refresh token AccessTokenResponse userAccessToken3 = AURequestBuilder.getUserTokenFromRefreshTokenErrorResponse(secondRefreshToken as RefreshToken) diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/authorizationflow/SharingDurationValidationTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/authorizationflow/SharingDurationValidationTest.groovy similarity index 94% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/authorizationflow/SharingDurationValidationTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/authorizationflow/SharingDurationValidationTest.groovy index 9a7c7f5a6..466e78fe7 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/authorizationflow/SharingDurationValidationTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/authorizationflow/SharingDurationValidationTest.groovy @@ -16,14 +16,13 @@ * under the License. */ -package com.wso2.cds.keymanager.test.authorizationflow +package org.wso2.cds.keymanager.test.authorizationflow import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.NavigationAutomationStep +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert import org.testng.annotations.Test diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/bnr/BnrEndToEndTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/bnr/BnrEndToEndTest.groovy similarity index 87% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/bnr/BnrEndToEndTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/bnr/BnrEndToEndTest.groovy index b3079411b..59b0bff9b 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/bnr/BnrEndToEndTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/bnr/BnrEndToEndTest.groovy @@ -16,16 +16,16 @@ * under the License. */ -package com.wso2.cds.keymanager.test.bnr +package org.wso2.cds.keymanager.test.bnr -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.configuration.AUConfigurationService -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUBusinessUserPermission -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.data_provider.ConsentDataProviders -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUBusinessUserPermission +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.data_provider.ConsentDataProviders +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert import org.testng.annotations.BeforeClass import org.testng.annotations.Test diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/bnr/ConsentAmendmentFlowTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/bnr/ConsentAmendmentFlowTests.groovy similarity index 95% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/bnr/ConsentAmendmentFlowTests.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/bnr/ConsentAmendmentFlowTests.groovy index aa67fcc05..ce84fd10b 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/bnr/ConsentAmendmentFlowTests.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/bnr/ConsentAmendmentFlowTests.groovy @@ -16,19 +16,19 @@ * under the License. */ -package com.wso2.cds.keymanager.test.bnr +package org.wso2.cds.keymanager.test.bnr import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUBusinessUserPermission -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUBusinessUserPermission +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod import org.testng.Assert import org.testng.annotations.BeforeClass import org.testng.annotations.Test diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/bnr/ConsentAuthFlowValidationTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/bnr/ConsentAuthFlowValidationTests.groovy similarity index 97% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/bnr/ConsentAuthFlowValidationTests.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/bnr/ConsentAuthFlowValidationTests.groovy index 5a5b10b18..556df7fac 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/bnr/ConsentAuthFlowValidationTests.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/bnr/ConsentAuthFlowValidationTests.groovy @@ -16,16 +16,16 @@ * under the License. */ -package com.wso2.cds.keymanager.test.bnr - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUBusinessUserPermission -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod +package org.wso2.cds.keymanager.test.bnr + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUBusinessUserPermission +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod import org.openqa.selenium.By import org.openqa.selenium.WebElement import org.testng.Assert @@ -232,12 +232,12 @@ class ConsentAuthFlowValidationTests extends AUTest{ .execute() def authUrl = automation.currentUrl.get() - Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.USER_SKIP_THE_CONSENT_FLOW)) + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) def stateParam = authUrl.split("state=")[1] Assert.assertEquals(auAuthorisationBuilder.state.toString(), stateParam) } - @Test + @Test (groups = "SmokeTest") void "CDS-588_Verify a Consent cancellation flow after Business Account selection"() { //Get Authorisation URL @@ -276,12 +276,12 @@ class ConsentAuthFlowValidationTests extends AUTest{ .execute() def authUrl = automation.currentUrl.get() - Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.USER_SKIP_THE_CONSENT_FLOW)) + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) def stateParam = authUrl.split("state=")[1] Assert.assertEquals(auAuthorisationBuilder.state.toString(), stateParam) } - @Test (priority = 1) + @Test (groups = "SmokeTest", priority = 1) void "CDS-540_Consent Authorisation after updating nominated representatives permission from view to authorise"() { auConfiguration.setPsuNumber(3) diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/bnr/UserNominationManagementTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/bnr/UserNominationManagementTests.groovy similarity index 98% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/bnr/UserNominationManagementTests.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/bnr/UserNominationManagementTests.groovy index a5bd44460..e79a0d1cb 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/bnr/UserNominationManagementTests.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/bnr/UserNominationManagementTests.groovy @@ -16,14 +16,14 @@ * under the License. */ -package com.wso2.cds.keymanager.test.bnr - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUBusinessUserPermission -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPayloads -import com.wso2.cds.test.framework.utility.AURestAsRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +package org.wso2.cds.keymanager.test.bnr + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUBusinessUserPermission +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPayloads +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert import org.testng.annotations.Test diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/doms/DisclosureOptionManagementServiceTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/doms/DisclosureOptionManagementServiceTest.groovy similarity index 96% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/doms/DisclosureOptionManagementServiceTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/doms/DisclosureOptionManagementServiceTest.groovy index d85ec40c1..6893d37f3 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/doms/DisclosureOptionManagementServiceTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/doms/DisclosureOptionManagementServiceTest.groovy @@ -16,19 +16,19 @@ * under the License. */ -package com.wso2.cds.keymanager.test.doms +package org.wso2.cds.keymanager.test.doms import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUDOMSStatus -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUIdEncryptorDecryptor -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUDOMSStatus +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUIdEncryptorDecryptor +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod import io.restassured.response.Response import org.testng.Assert import org.testng.annotations.BeforeClass diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JarmResponseModeFormPostJwtValidationTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JarmResponseModeFormPostJwtValidationTests.groovy similarity index 93% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JarmResponseModeFormPostJwtValidationTests.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JarmResponseModeFormPostJwtValidationTests.groovy index c04c194ef..c86087594 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JarmResponseModeFormPostJwtValidationTests.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JarmResponseModeFormPostJwtValidationTests.groovy @@ -16,16 +16,14 @@ * under the License. */ -package com.wso2.cds.keymanager.test.jarm +package org.wso2.cds.keymanager.test.jarm import com.nimbusds.jwt.JWTClaimsSet import com.nimbusds.oauth2.sdk.ResponseMode import com.nimbusds.oauth2.sdk.ResponseType -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.cds.test.framework.utility.AURestAsRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert import org.testng.annotations.Test @@ -39,7 +37,7 @@ class JarmResponseModeFormPostJwtValidationTests extends AUTest { HashMap mapPayload JWTClaimsSet jwtPayload - @Test + @Test (groups = "SmokeTest") void "CDS-582_Verify response_mode form_post jwt navigates to Authorization Flow"() { def clientId = auConfiguration.getAppInfoClientID() diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JarmResponseModeFragmentJwtValidationTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JarmResponseModeFragmentJwtValidationTests.groovy similarity index 93% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JarmResponseModeFragmentJwtValidationTests.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JarmResponseModeFragmentJwtValidationTests.groovy index 9abff5212..354450dd0 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JarmResponseModeFragmentJwtValidationTests.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JarmResponseModeFragmentJwtValidationTests.groovy @@ -16,15 +16,14 @@ * under the License. */ -package com.wso2.cds.keymanager.test.jarm +package org.wso2.cds.keymanager.test.jarm import com.nimbusds.jwt.JWTClaimsSet import com.nimbusds.oauth2.sdk.ResponseMode import com.nimbusds.oauth2.sdk.ResponseType -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert import org.testng.annotations.Test @@ -38,7 +37,7 @@ class JarmResponseModeFragmentJwtValidationTests extends AUTest { HashMap mapPayload JWTClaimsSet jwtPayload - @Test (priority = 1) + @Test (groups = "SmokeTest", priority = 1) void "CDS-569_Verify response_mode fragment jwt navigates to Authorization Flow"() { response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JarmResponseModeJwtValidationTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JarmResponseModeJwtValidationTests.groovy similarity index 93% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JarmResponseModeJwtValidationTests.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JarmResponseModeJwtValidationTests.groovy index 05d4ee845..91e87cc25 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JarmResponseModeJwtValidationTests.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JarmResponseModeJwtValidationTests.groovy @@ -16,16 +16,15 @@ * under the License. */ -package com.wso2.cds.keymanager.test.jarm +package org.wso2.cds.keymanager.test.jarm import com.nimbusds.jwt.JWTClaimsSet import com.nimbusds.oauth2.sdk.ResponseMode import com.nimbusds.oauth2.sdk.ResponseType -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AUJWTGenerator +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert import org.testng.annotations.Test @@ -38,7 +37,7 @@ class JarmResponseModeJwtValidationTests extends AUTest{ String responseJwt JWTClaimsSet jwtPayload - @Test + @Test (groups = "SmokeTest") void "CDS-577_Verify authorisation flow with response method jwt and response type code"() { doConsentAuthorisation(ResponseMode.JWT, ResponseType.CODE, auConfiguration.getAppInfoClientID()) diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JarmResponseModeQueryJwtValidationTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JarmResponseModeQueryJwtValidationTests.groovy similarity index 92% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JarmResponseModeQueryJwtValidationTests.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JarmResponseModeQueryJwtValidationTests.groovy index f7a44bcb1..3fc9e27db 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JarmResponseModeQueryJwtValidationTests.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JarmResponseModeQueryJwtValidationTests.groovy @@ -16,15 +16,14 @@ * under the License. */ -package com.wso2.cds.keymanager.test.jarm +package org.wso2.cds.keymanager.test.jarm import com.nimbusds.jwt.JWTClaimsSet import com.nimbusds.oauth2.sdk.ResponseMode import com.nimbusds.oauth2.sdk.ResponseType -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert import org.testng.annotations.Test @@ -37,7 +36,7 @@ class JarmResponseModeQueryJwtValidationTests extends AUTest { String responseJwt JWTClaimsSet jwtPayload - @Test + @Test (groups = "SmokeTest") void "CDS-587_Verify in query jwt response mode if response_type = code"() { response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JwtSecuredAuthorizationResponseValidationTests.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JwtSecuredAuthorizationResponseValidationTests.groovy similarity index 92% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JwtSecuredAuthorizationResponseValidationTests.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JwtSecuredAuthorizationResponseValidationTests.groovy index 5efa96cb6..755af08d9 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/jarm/JwtSecuredAuthorizationResponseValidationTests.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/jarm/JwtSecuredAuthorizationResponseValidationTests.groovy @@ -16,16 +16,16 @@ * under the License. */ -package com.wso2.cds.keymanager.test.jarm +package org.wso2.cds.keymanager.test.jarm import com.nimbusds.jose.JWSHeader import com.nimbusds.jwt.JWTClaimsSet import com.nimbusds.oauth2.sdk.ResponseMode import com.nimbusds.oauth2.sdk.ResponseType -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AUJWTGenerator import org.testng.Assert import org.testng.annotations.Test import org.testng.annotations.BeforeClass diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/par/PushedAuthorisationFlowTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/par/PushedAuthorisationFlowTest.groovy similarity index 87% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/par/PushedAuthorisationFlowTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/par/PushedAuthorisationFlowTest.groovy index 9b96f5bd6..05f18e4d1 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/par/PushedAuthorisationFlowTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/par/PushedAuthorisationFlowTest.groovy @@ -16,23 +16,22 @@ * under the License. */ -package com.wso2.cds.keymanager.test.par +package org.wso2.cds.keymanager.test.par import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.nimbusds.oauth2.sdk.ResponseMode import com.nimbusds.oauth2.sdk.ResponseType -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.configuration.AUConfigurationService -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AURestAsRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod -import com.wso2.openbanking.test.framework.automation.NavigationAutomationStep +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AUJWTGenerator +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.openbanking.test.framework.automation.NavigationAutomationStep import io.restassured.RestAssured import io.restassured.response.Response import org.testng.Assert @@ -47,7 +46,7 @@ class PushedAuthorisationFlowTest extends AUTest { AUJWTGenerator generator = new AUJWTGenerator() def refreshToken - @Test + @Test (groups = "SmokeTest") void "TC0205001_Data Recipients Initiate authorisation request using PAR"() { def response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, AUConstants.DEFAULT_SHARING_DURATION, @@ -59,14 +58,14 @@ class PushedAuthorisationFlowTest extends AUTest { Assert.assertNotNull(AUTestUtil.parseResponseBody(response, AUConstants.RESPONSE_EXPIRES_IN)) } - @Test(dependsOnMethods = "TC0205001_Data Recipients Initiate authorisation request using PAR") + @Test(groups = "SmokeTest", dependsOnMethods = "TC0205001_Data Recipients Initiate authorisation request using PAR") void "TC0205002_Initiate consent authorisation flow with pushed authorisation request uri"() { doConsentAuthorisationViaRequestUri(scopes, requestUri.toURI()) Assert.assertNotNull(authorisationCode) } - @Test(dependsOnMethods = "TC0205002_Initiate consent authorisation flow with pushed authorisation request uri") + @Test(groups = "SmokeTest", dependsOnMethods = "TC0205002_Initiate consent authorisation flow with pushed authorisation request uri") void "TC0203013_Generate User access token by code generated from PAR model"() { AccessTokenResponse userAccessToken = AURequestBuilder.getUserToken(authorisationCode, @@ -368,7 +367,7 @@ class PushedAuthorisationFlowTest extends AUTest { Assert.assertEquals(AUTestUtil.parseResponseBody(parResponse, AUConstants.ERROR_DESCRIPTION), "Error retrieving service provider tenant domain for client_id: ${incorrectClientId}") Assert.assertEquals(AUTestUtil.parseResponseBody(parResponse, AUConstants.ERROR), - "Service provider metadata retrieval failed") + "Service provider metadata retrieval failed") } @Test @@ -517,4 +516,49 @@ class PushedAuthorisationFlowTest extends AUTest { Assert.assertNotNull(requestUri) Assert.assertNotNull(AUTestUtil.parseResponseBody(response, AUConstants.RESPONSE_EXPIRES_IN)) } + + @Test + void "CDS-1049_PAR Request without client id param in the request body"() { + + def response = auAuthorisationBuilder.doPushAuthorisationRequestWithoutClientId(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_201) + Assert.assertNotNull(requestUri) + Assert.assertNotNull(AUTestUtil.parseResponseBody(response, AUConstants.RESPONSE_EXPIRES_IN)) + } + + @Test + void "CDS-1059_PAR Request with client Id in the request body not similar to client id in the client_assertion"() { + + def response = auAuthorisationBuilder.doPushAuthorisationRequestWithDifferentClientIds(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId, + auConfiguration.getAppInfoClientID(), auConfiguration.getAppInfoClientID(1)) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + + def errorDesc = AUTestUtil.parseResponseBody(response, AUConstants.ERROR_DESCRIPTION) + def error = AUTestUtil.parseResponseBody(response, AUConstants.ERROR) + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_401) + Assert.assertEquals(errorDesc, "Request Parameter 'client_id' does not match the 'sub' claim in the client_assertion") + Assert.assertEquals(error, AUConstants.INVALID_CLIENT) + } + + @Test + void "CDS-1069_PAR Request with valid client Id in the request body and deleted client id in the client_assertion"() { + + def invalidClientId = "qwe23rvdvdfvfd" + def response = auAuthorisationBuilder.doPushAuthorisationRequestWithDifferentClientIds(scopes, + AUConstants.DEFAULT_SHARING_DURATION, true, cdrArrangementId, + invalidClientId, auConfiguration.getAppInfoClientID(1)) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + + def errorDesc = AUTestUtil.parseResponseBody(response, AUConstants.ERROR_DESCRIPTION) + def error = AUTestUtil.parseResponseBody(response, AUConstants.ERROR) + + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_400) + Assert.assertEquals(errorDesc, "Error retrieving service provider tenant domain for client_id: $invalidClientId") + Assert.assertEquals(error, "Service provider metadata retrieval failed") + } } diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/par/RequestObjectValidationTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/par/RequestObjectValidationTest.groovy similarity index 96% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/par/RequestObjectValidationTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/par/RequestObjectValidationTest.groovy index ad31d11d2..840b85007 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/par/RequestObjectValidationTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/par/RequestObjectValidationTest.groovy @@ -16,18 +16,13 @@ * under the License. */ -package com.wso2.cds.keymanager.test.par +package org.wso2.cds.keymanager.test.par import com.nimbusds.oauth2.sdk.ResponseMode -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod -import org.openqa.selenium.By +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AUJWTGenerator +import org.wso2.cds.test.framework.utility.AUTestUtil import org.testng.Assert import org.testng.annotations.Test @@ -67,7 +62,7 @@ class RequestObjectValidationTest extends AUTest { void "OB-1233_Initiate authorisation consent flow with 'RS256' signature algorithm"() { String claims = generator.getRequestObjectClaim(scopes, AUConstants.DEFAULT_SHARING_DURATION, true, "", - auConfiguration.getAppInfoRedirectURL(), auConfiguration.getAppInfoClientID(), + auConfiguration.getAppInfoRedirectURL(), auConfiguration.getAppInfoClientID(), auAuthorisationBuilder.getResponseType().toString(), true, auAuthorisationBuilder.getState().toString()) @@ -80,7 +75,6 @@ class RequestObjectValidationTest extends AUTest { Assert.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR), AUConstants.INVALID_REQUEST_OBJECT) } - //TODO: Issue: https://github.com/wso2-enterprise/financial-open-banking/issues/8457 @Test (priority = 1) void "OB-1234_Initiate authorisation consent flow with 'PS512' signature algorithm"() { @@ -158,6 +152,7 @@ class RequestObjectValidationTest extends AUTest { auAuthorisationBuilder.getState().toString()) String modifiedClaimSet = generator.removeClaimsFromRequestObject(claims, "nbf") + def response = auAuthorisationBuilder.doPushAuthorisationRequest(modifiedClaimSet) Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_400) diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/secondaryUser/CeasingSecondaryUserConsentFlowTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/secondaryUser/CeasingSecondaryUserConsentFlowTest.groovy similarity index 94% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/secondaryUser/CeasingSecondaryUserConsentFlowTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/secondaryUser/CeasingSecondaryUserConsentFlowTest.groovy index 40529068c..508ab4f6e 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/secondaryUser/CeasingSecondaryUserConsentFlowTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/secondaryUser/CeasingSecondaryUserConsentFlowTest.groovy @@ -16,18 +16,18 @@ * under the License. */ -package com.wso2.cds.keymanager.test.secondaryUser +package org.wso2.cds.keymanager.test.secondaryUser import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod import io.restassured.response.Response import org.testng.Assert import org.testng.annotations.BeforeClass @@ -45,7 +45,7 @@ class CeasingSecondaryUserConsentFlowTest extends AUTest { Response response List legalEntityList - @BeforeClass + @BeforeClass (alwaysRun = true) void "Pre Execution Step"() { auConfiguration.setPsuNumber(1) @@ -71,7 +71,7 @@ class CeasingSecondaryUserConsentFlowTest extends AUTest { legalEntityId = registrationResponse.jsonPath().get(AUConstants.DCR_CLAIM_LEGAL_ENTITY_ID) } - @Test + @Test (groups = "SmokeTest") void "CDS-643_Verify account is listed under unavailable accounts once the legal entity is restricted by account owner"() { //Block the sharing status @@ -276,6 +276,14 @@ class CeasingSecondaryUserConsentFlowTest extends AUTest { } .execute() + authorisationCode = AUTestUtil.getCodeFromJwtResponse(automation.currentUrl.get()) + + //Get Access Token + responseBody = getUserAccessTokenResponse(clientId) + userAccessToken = responseBody.tokens.accessToken + cdrArrangementId = responseBody.getCustomParameters().get(AUConstants.CDR_ARRANGEMENT_ID) + Assert.assertNotNull(cdrArrangementId) + //Block the sharing status of one account response = updateLegalEntityStatus(clientHeader, accountID, userId, legalEntityId, AUConstants.BLOCK_ENTITY) Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_200) diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/secondaryUser/CeasingSecondaryUserManagementTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/secondaryUser/CeasingSecondaryUserManagementTest.groovy similarity index 82% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/secondaryUser/CeasingSecondaryUserManagementTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/secondaryUser/CeasingSecondaryUserManagementTest.groovy index 829ef17e3..be620feea 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/secondaryUser/CeasingSecondaryUserManagementTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/secondaryUser/CeasingSecondaryUserManagementTest.groovy @@ -16,12 +16,12 @@ * under the License. */ -package com.wso2.cds.keymanager.test.secondaryUser +package org.wso2.cds.keymanager.test.secondaryUser -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import io.restassured.response.Response import org.testng.Assert import org.testng.annotations.BeforeClass @@ -39,7 +39,7 @@ class CeasingSecondaryUserManagementTest extends AUTest { Response response List legalEntityList - @BeforeClass + @BeforeClass (alwaysRun = true) void "Pre Execution Step"() { auConfiguration.setPsuNumber(4) @@ -71,7 +71,7 @@ class CeasingSecondaryUserManagementTest extends AUTest { altLegalEntityId = AUConstants.ALT_LEGAL_ENTITY } - @Test (priority = 1) + @Test (groups = "SmokeTest", priority = 1) void "CDS-631_Block the sharing status for a legal entity"() { response = updateLegalEntityStatus(clientHeader, accountID, userId, legalEntityId, AUConstants.BLOCK_ENTITY) @@ -170,4 +170,30 @@ class CeasingSecondaryUserManagementTest extends AUTest { Assert.assertNotNull(AUTestUtil.parseResponseBody(response, "${AUConstants.PAYLOAD_SECONDARY_USERS}." + "${AUConstants.PAYLOAD_PARAM_ACCOUNTS}.${AUConstants.LEGAL_ENTITIES}.${AUConstants.SHARING_STATUS}")) } + + @Test + void "CDS-636_Block sharing status with incorrect accountId"() { + + response = updateLegalEntityStatus(clientHeader, "1234", userId, legalEntityId, AUConstants.BLOCK_ENTITY) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_400) + + //TODO: Issue: https://github.com/wso2-enterprise/financial-open-banking/issues/8275 + Assert.assertEquals(AUTestUtil.parseResponseBody(response, "errorDescription"), + "Error occurred while updating the sharing status for a legal entity/entities.") + Assert.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR), AUConstants.INVALID_REQUEST) + } + + @Test + void "CDS-637_Block sharing status with incorrect user id"() { + + response = updateLegalEntityStatus(clientHeader, accountID, "abc@gold.com", legalEntityId, AUConstants.BLOCK_ENTITY) + Assert.assertEquals(response.statusCode(), AUConstants.STATUS_CODE_400) + + //TODO: Issue: https://github.com/wso2-enterprise/financial-open-banking/issues/8275 + Assert.assertEquals(AUTestUtil.parseResponseBody(response, "errorDescription"), + "Error occurred while updating the sharing status for a legal entity/entities.") + Assert.assertEquals(AUTestUtil.parseResponseBody(response, AUConstants.ERROR), AUConstants.INVALID_REQUEST) + } + + } diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/secondaryUser/SecondaryUserAmendmentFlow.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/secondaryUser/SecondaryUserAmendmentFlow.groovy similarity index 96% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/secondaryUser/SecondaryUserAmendmentFlow.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/secondaryUser/SecondaryUserAmendmentFlow.groovy index ee624eaac..32f3d0177 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/secondaryUser/SecondaryUserAmendmentFlow.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/secondaryUser/SecondaryUserAmendmentFlow.groovy @@ -16,16 +16,16 @@ * under the License. */ -package com.wso2.cds.keymanager.test.secondaryUser +package org.wso2.cds.keymanager.test.secondaryUser import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod import org.testng.Assert import org.testng.annotations.BeforeClass import org.testng.annotations.Test @@ -111,7 +111,7 @@ class SecondaryUserAmendmentFlow extends AUTest { .execute() } - @Test + @Test (groups = "SmokeTest") void "CDS-427_Verify Consent Amendment if consumer nominated as secondary user for account by providing secondary user instruction"() { //Consent Authorisation by selecting individual accounts diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/secondaryUser/SecondaryUserInstructionsAuthorisationTest.groovy b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/secondaryUser/SecondaryUserInstructionsAuthorisationTest.groovy similarity index 97% rename from integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/secondaryUser/SecondaryUserInstructionsAuthorisationTest.groovy rename to integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/secondaryUser/SecondaryUserInstructionsAuthorisationTest.groovy index 147933177..a9459c5ea 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/com/wso2/cds/keymanager/test/secondaryUser/SecondaryUserInstructionsAuthorisationTest.groovy +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/groovy/org/wso2/cds/keymanager/test/secondaryUser/SecondaryUserInstructionsAuthorisationTest.groovy @@ -16,16 +16,16 @@ * under the License. */ -package com.wso2.cds.keymanager.test.secondaryUser - -import com.wso2.cds.test.framework.AUTest -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.automation.AutomationMethod +package org.wso2.cds.keymanager.test.secondaryUser + +import org.wso2.cds.test.framework.AUTest +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.automation.AutomationMethod import io.restassured.response.Response import org.openqa.selenium.By import org.testng.Assert @@ -276,7 +276,7 @@ class SecondaryUserInstructionsAuthorisationTest extends AUTest { .execute() def authUrl = automation.currentUrl.get() - Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.USER_SKIP_THE_CONSENT_FLOW)) + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) def stateParam = authUrl.split("state=")[1] Assert.assertEquals(auAuthorisationBuilder.state.toString(), stateParam) } @@ -306,7 +306,7 @@ class SecondaryUserInstructionsAuthorisationTest extends AUTest { .execute() def authUrl = automation.currentUrl.get() - Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.USER_SKIP_THE_CONSENT_FLOW)) + Assert.assertTrue(AUTestUtil.getDecodedUrl(authUrl).contains(AUConstants.CANCEL_ERROR_IN_ACCOUNTS_PAGE)) def stateParam = authUrl.split("state=")[1] Assert.assertEquals(auAuthorisationBuilder.state.toString(), stateParam) } diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/resources/testng.xml b/integration-test-suite/cds-toolkit-integration-test/src/test/resources/testng.xml index 32af9e64d..c2d40de96 100644 --- a/integration-test-suite/cds-toolkit-integration-test/src/test/resources/testng.xml +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/resources/testng.xml @@ -21,126 +21,152 @@ - - - - - + + + + + - + - - - - - + + + + + - - + + - - + + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - + + + + + - + - - - - + + + + - - - + + + - - + + - - - - - + + + + + - - - - + + + + - + - - + + - - + + diff --git a/integration-test-suite/cds-toolkit-integration-test/src/test/resources/testngSmokeTest.xml b/integration-test-suite/cds-toolkit-integration-test/src/test/resources/testngSmokeTest.xml new file mode 100644 index 000000000..4436581da --- /dev/null +++ b/integration-test-suite/cds-toolkit-integration-test/src/test/resources/testngSmokeTest.xml @@ -0,0 +1,287 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/integration-test-suite/cds-toolkit-test-framework/pom.xml b/integration-test-suite/cds-toolkit-test-framework/pom.xml index 3488eff7b..f5cf63d2a 100644 --- a/integration-test-suite/cds-toolkit-test-framework/pom.xml +++ b/integration-test-suite/cds-toolkit-test-framework/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 cds-toolkit-test-framework - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT jar org.wso2.openbanking integration-test-suite - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml @@ -59,7 +59,7 @@ slf4j-simple - com.wso2 + org.wso2 open-banking-test-framework @@ -110,6 +110,11 @@ org.wso2.orbit.com.nimbusds nimbus-jose-jwt + + mysql + mysql-connector-java + 5.1.49 + @@ -175,5 +180,9 @@ + + 1.0.0 + + diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/AUTest.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/AUTest.groovy similarity index 56% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/AUTest.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/AUTest.groovy index c245e4fc7..6ee591734 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/AUTest.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/AUTest.groovy @@ -16,7 +16,7 @@ * under the License. */ -package com.wso2.cds.test.framework +package org.wso2.cds.test.framework import com.google.gson.JsonArray import com.google.gson.JsonElement @@ -24,35 +24,41 @@ import com.google.gson.JsonObject import com.nimbusds.oauth2.sdk.ResponseMode import com.nimbusds.oauth2.sdk.ResponseType import com.nimbusds.oauth2.sdk.token.RefreshToken -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConfigConstants -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.constant.AUPayloads -import com.wso2.cds.test.framework.constant.ContextConstants -import com.wso2.cds.test.framework.automation.consent.AUAccountSelectionStep -import com.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConfigConstants +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.cds.test.framework.constant.AUPayloads +import org.wso2.cds.test.framework.constant.ContextConstants import com.nimbusds.oauth2.sdk.AccessTokenResponse -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.openbanking.test.framework.OBTest -import com.wso2.cds.test.framework.configuration.AUConfigurationService -import com.wso2.openbanking.test.framework.automation.AutomationMethod -import com.wso2.openbanking.test.framework.automation.NavigationAutomationStep -import com.wso2.openbanking.test.framework.configuration.OBConfigParser +import org.wso2.cds.test.framework.request_builder.AUJWTGenerator +import org.wso2.cds.test.framework.utility.DbConnection +import org.wso2.cds.test.framework.utility.SqlQuery +import org.wso2.openbanking.test.framework.OBTest +import org.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.openbanking.test.framework.automation.NavigationAutomationStep +import org.wso2.openbanking.test.framework.configuration.OBConfigParser +import io.restassured.http.ContentType import io.restassured.response.Response import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger import org.testng.Assert import org.testng.ITestContext import org.testng.annotations.BeforeClass -import com.wso2.cds.test.framework.request_builder.AUAuthorisationBuilder -import com.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder -import com.wso2.cds.test.framework.request_builder.AURequestBuilder -import com.wso2.cds.test.framework.utility.AURestAsRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.request_builder.AUAuthorisationBuilder +import org.wso2.cds.test.framework.request_builder.AURegistrationRequestBuilder +import org.wso2.cds.test.framework.request_builder.AURequestBuilder +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.testng.asserts.SoftAssert +import org.wso2.cds.test.framework.automation.consent.AUAccountSelectionStep +import org.wso2.cds.test.framework.automation.consent.AUBasicAuthAutomationStep import java.nio.charset.Charset +import java.time.LocalDate +import java.time.LocalDateTime import java.time.OffsetDateTime import java.time.ZoneOffset import com.google.gson.Gson @@ -69,6 +75,26 @@ class AUTest extends OBTest { AUAuthorisationBuilder auAuthorisationBuilder private boolean adrNameCheck AUJWTGenerator generator + public static int activeAuthIndividual, activeAuthNonIndividual, newAuthCurrentDayOngoingIndividual, + newAuthCurrentDayOngoingNonIndividual, newAuthCurrentDayOnceOffIndividual, + newAuthCurrentDayOnceOffNonIndividual, revokedCurrentDayIndividual, revokedCurrentDayNonIndividual, + amendedCurrentDayIndividual, amendedCurrentDayNonIndividual, expiredCurrentDayIndividual, + expiredCurrentDayNonIndividual, abandonedPreIdentificationCurrentDay, abandonedPreAuthenticationCurrentDay, + abandonedPreAccountSelectionCurrentDay, abandonedPreAuthorisationCurrentDay, abandonedRejectedCurrentDay, + abandonedFailedTokenExchangeCurrentDay, abandonedCurrentDay, unauthenticatedCurrentDay, + highPriorityCurrentDay, lowPriorityCurrentDay, unattendedCurrentDay, largePayloadCurrentDay, + customerCount, recipientCount, sessionCount + + int totalInvocationsPerf, totalInvocationsAvg, totalInvocationsHighPerf, totalInvocationsLowPerf, + totalInvocationsUnattendedPerf, totalInvocationsUnAuthPerf, totalInvocationsLargePayPerf, + totalInvocationsHighAvg, totalInvocationsLowAvg, totalInvocationsUnattendedAvg, totalInvocationsUnAuthAvg, + totalInvocationsLargePayAvg + public LocalDate today = LocalDate.now() + int currentTime + public String unauthErrorCurrentDay, authErrorCurrentDay, aggErrorCurrentDay + public int[] performanceMetrics + public int[] avgResponseMetrics + public int[] totalResources @BeforeClass(alwaysRun = true) void "Initialize Test Suite"() { @@ -242,7 +268,7 @@ class AUTest extends OBTest { String authCode = AUTestUtil.getCodeFromJwtResponse(automation.currentUrl.get()) return authCode } - + /** * Method for get user access token response * @return @@ -404,12 +430,12 @@ class AUTest extends OBTest { AUPageObjects.VALUE) authWebDriver.clickButtonXpath(AUTestUtil.getBusinessAccount2CheckBox()) - if (isSelectMultipleAccounts) { - //Select Business Account 2 - secondConsentedAccount = authWebDriver.getElementAttribute(AUTestUtil.getBusinessAccount3CheckBox(), - AUPageObjects.VALUE) - authWebDriver.clickButtonXpath(AUTestUtil.getBusinessAccount3CheckBox()) - } +// if (isSelectMultipleAccounts) { +// //Select Business Account 2 +// secondConsentedAccount = authWebDriver.getElementAttribute(AUTestUtil.getBusinessAccount3CheckBox(), +// AUPageObjects.VALUE) +// authWebDriver.clickButtonXpath(AUTestUtil.getBusinessAccount3CheckBox()) +// } } else { //Select Individual Profile authWebDriver.selectOption(AUPageObjects.INDIVIDUAL_PROFILE_SELECTION) @@ -590,11 +616,11 @@ class AUTest extends OBTest { * @param profiles */ String doConsentAuthorisationViaRequestUriDenyFlow(List scopes, URI requestUri, - String clientId = null , AUAccountProfile profiles = null, + String clientId = null , AUAccountProfile profiles = null, boolean isStateParamPresent = true) { if (clientId != null) { - authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri, - auConfiguration.getAppInfoClientID(), isStateParamPresent).toURI().toString() + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri, + auConfiguration.getAppInfoClientID(), isStateParamPresent).toURI().toString() } else { authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri, null, isStateParamPresent).toURI().toString() @@ -645,12 +671,10 @@ class AUTest extends OBTest { if (auConfiguration.getProfileSelectionEnabled()) { if (profiles == AUAccountProfile.ORGANIZATION_A) { //Select Business Profile - authWebDriver.selectOption(AUPageObjects.ORGANIZATION_A_PROFILE_SELECTION) authWebDriver.clickButtonXpath(AUPageObjects.PROFILE_SELECTION_NEXT_BUTTON) } else { //Select Individual Profile - authWebDriver.selectOption(AUPageObjects.INDIVIDUAL_PROFILE_SELECTION) authWebDriver.clickButtonXpath(AUPageObjects.PROFILE_SELECTION_NEXT_BUTTON) } } @@ -678,6 +702,8 @@ class AUTest extends OBTest { void doSecondaryAccountSelection(List scopes, URI requestUri, String clientId = null, boolean isMultipleAccountsSelect = false) { + auConfiguration.setPsuNumber(1) + if (clientId != null) { authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri, clientId) .toURI().toString() @@ -992,7 +1018,7 @@ class AUTest extends OBTest { return automationResponse } - + /** * Update Business Use rPermission With Incorrect Payload. * @param headerString basic auth header @@ -1148,7 +1174,7 @@ class AUTest extends OBTest { return AURestAsRequestBuilder.buildRequest() .header(AUConstants.AUTHORIZATION_HEADER_KEY, AUConstants.BASIC_HEADER_KEY + " " + Base64.encoder.encodeToString("${auConfiguration.getUserBasicAuthName()}:${auConfiguration.getUserBasicAuthPWD()}" - .getBytes(Charset.forName("UTF-8")))) + .getBytes(Charset.forName("UTF-8")))) .contentType(AUConstants.CONTENT_TYPE_APPLICATION_JSON) .body(requestBody) .baseUri(auConfiguration.getServerAuthorisationServerURL()) @@ -1201,7 +1227,7 @@ class AUTest extends OBTest { */ static Response updateSecondaryUserInstructionPermission(String secondaryAccId, String userId, String secondaryAccountInstructionStatus, - boolean otherAccountsAvailability = false) { + boolean otherAccountsAvailability = true) { def requestBody = AUPayloads.getSecondaryUserInstructionPermissionPayload(secondaryAccId, userId, secondaryAccountInstructionStatus, otherAccountsAvailability) @@ -1226,10 +1252,12 @@ class AUTest extends OBTest { */ static Response getLegalEntityIds(String userID) { + userID = "amy@gold.com@carbon.super" + return AURestAsRequestBuilder.buildRequest() .header(AUConstants.AUTHORIZATION_HEADER_KEY, AUConstants.BASIC_HEADER_KEY + " " + Base64.encoder.encodeToString("${auConfiguration.getUserBasicAuthName()}:${auConfiguration.getUserBasicAuthPWD()}" - .getBytes(Charset.forName("UTF-8")))) + .getBytes(Charset.forName("UTF-8")))) .contentType(AUConstants.CONTENT_TYPE_APPLICATION_JSON) .baseUri(auConfiguration.getServerAuthorisationServerURL()) .get("${AUConstants.CONSENT_STATUS_AU_ENDPOINT}${AUConstants.LEGAL_ENTITY_LIST_ENDPOINT}/${userID}") @@ -1288,8 +1316,8 @@ class AUTest extends OBTest { } } } - - /** + + /** * Verify Scope of Token Response. * @param scopesString - scope list * @param eliminatedScope - scope to be eliminated @@ -1302,25 +1330,25 @@ class AUTest extends OBTest { Assert.assertTrue(scopesString.contains(scope.getScopeString())) } } - } - + } + /** * Method for get user access token response * @return */ AccessTokenResponse getUserAccessTokenFormRefreshToken(RefreshToken refreshToken) { - try { - return AURequestBuilder.getUserTokenFromRefreshToken(refreshToken) - } - catch (Exception e) { - log.error(e) - } + try { + return AURequestBuilder.getUserTokenFromRefreshToken(refreshToken) } + catch (Exception e) { + log.error(e) + } + } Response doRevokeCdrArrangement(String clientId, String cdrArrangementId){ generator = new AUJWTGenerator() - String assertionString = generator.getClientAssertionJwt(clientId) + String assertionString = generator.getClientAssertionJwtWithoutIAT(clientId) def bodyContent = [(AUConstants.CLIENT_ID_KEY): (clientId), (AUConstants.CLIENT_ASSERTION_TYPE_KEY): (AUConstants.CLIENT_ASSERTION_TYPE), @@ -1375,7 +1403,7 @@ class AUTest extends OBTest { .baseUri(auConfiguration.getServerAuthorisationServerURL()) .get("${AUConstants.CONSENT_STATUS_ENDPOINT}${AUConstants.STATUS_PATH}?${consentId}") } - + /** * Consent authorization method with Request URI and Response Mode * @param scopes @@ -1444,4 +1472,913 @@ class AUTest extends OBTest { // Get Code From URL authorisationCode = AUTestUtil.getCodeFromJwtResponse(automation.currentUrl.get()) } + + /** + * Get Metrics Response. + * @param period query param to filter period (CURRENT,HISTORIC,ALL) + * @return metrics response + */ + static Response getMetrics(String period = "ALL"){ + + AUJWTGenerator generator = new AUJWTGenerator() + String assertionString = generator.getClientAssertionJwt(AUConstants.ADMIN_API_ISSUER, + AUConstants.ADMIN_API_AUDIENCE) + + def metricsResponse = AURequestBuilder.buildBasicRequest(assertionString, AUConstants.X_V_HEADER_METRICS) + .contentType(ContentType.JSON) + .header(AUConstants.X_MIN_HEADER, AUConstants.X_V_MIN_HEADER_METRICS) + .queryParam(AUConstants.PERIOD, period) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_ADMIN)) + .get("${AUConstants.CDS_ADMIN_PATH}${AUConstants.ADMIN_METRICS}") + + return metricsResponse + } + + /** + * Get the Metrics Response and assign metrics to variables. + * @param metricsResponse + */ + void getInitialMetricsResponse(Response metricsResponse) { + + //Invocation + unauthenticatedCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.INVOCATION_UNAUTHENTICATED_CURRENTDAY).toInteger() + highPriorityCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.INVOCATION_HIGHPRIORITY_CURRENTDAY).toInteger() + lowPriorityCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.INVOCATION_LOWPRIORITY_CURRENTDAY).toInteger() + largePayloadCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.INVOCATION_LARGEPAYLOAD_CURRENTDAY).toInteger() + unattendedCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.INVOCATION_UNATTENDED_CURRENTDAY).toInteger() + + //Authorisations + activeAuthIndividual = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ACTIVE_AUTHORIZATION_INDIVIDUAL).toInteger() + activeAuthNonIndividual = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ACTIVE_AUTHORIZATION_NONINDIVIDUAL).toInteger() + newAuthCurrentDayOngoingIndividual = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.NEWAUTH_CURRENTDAY_ONGOING_INDIVIDUAL).toInteger() + newAuthCurrentDayOngoingNonIndividual = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.NEWAUTH_CURRENTDAY_ONGOING_NONINDIVIDUAL).toInteger() + newAuthCurrentDayOnceOffIndividual = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.NEWAUTH_CURRENTDAY_ONCEOFF_INDIVIDUAL).toInteger() + newAuthCurrentDayOnceOffNonIndividual = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.NEWAUTH_CURRENTDAY_ONCEOFF_NONINDIVIDUAL).toInteger() + revokedCurrentDayIndividual = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.REVOKED_CURRENTDAY_INDIVIDUAL).toInteger() + revokedCurrentDayNonIndividual = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.REVOKED_CURRENTDAY_NONINDIVIDUAL).toInteger() + amendedCurrentDayIndividual = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.AMENDED_CURRENTDAY_INDIVIDUAL).toInteger() + amendedCurrentDayNonIndividual = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.AMENDED_CURRENTDAY_NONINDIVIDUAL).toInteger() + expiredCurrentDayIndividual = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.EXPIRED_CURRENTDAY_INDIVIDUAL).toInteger() + expiredCurrentDayNonIndividual = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.EXPIRED_CURRENTDAY_NONINDIVIDUAL).toInteger() + abandonedCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_CURRENTDAY).toInteger() + abandonedPreIdentificationCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_PREIDENTIFICATION_CURRENTDAY).toInteger() + abandonedPreAuthenticationCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_PREAUTHENTICATE_CURRENTDAY).toInteger() + abandonedPreAccountSelectionCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_PREACCSELECT_CURRENTDAY).toInteger() + abandonedPreAuthorisationCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_PREAUTH_CURRENTDAY).toInteger() + abandonedRejectedCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_REJECTED_CURRENTDAY).toInteger() + abandonedFailedTokenExchangeCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_FAILEDTOKEN_CURRENTDAY).toInteger() + + //Error Response + unauthErrorCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.ERROR_UNAUTH_CURRENTDAY) + authErrorCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.ERROR_AUTH_CURRENTDAY) + aggErrorCurrentDay = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.ERROR_AGGREGATE_CURRENTDAY) + + //Customer and Recipient Count + customerCount = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_CUSTOMER_COUNT).toInteger() + recipientCount = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_RECIPIENT_COUNT).toInteger() + + //Session Count + sessionCount = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.DATA_SESSION_COUNT_CURRENTDAY).toInteger() + } + + /** + * Asserting Metrics Authorisation Response. + * @param metricsResponse + */ + static void assertMetricsAuthorisationResponse(Response metricsResponse) { + + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.ACTIVE_AUTHORIZATION_INDIVIDUAL), + "${activeAuthIndividual}", "$AUConstants.ACTIVE_AUTHORIZATION_INDIVIDUAL count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.ACTIVE_AUTHORIZATION_NONINDIVIDUAL), + "${activeAuthNonIndividual}", "$AUConstants.ACTIVE_AUTHORIZATION_NONINDIVIDUAL count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.NEWAUTH_CURRENTDAY_ONGOING_INDIVIDUAL), + "${newAuthCurrentDayOngoingIndividual}", + "$AUConstants.NEWAUTH_CURRENTDAY_ONGOING_INDIVIDUAL count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.NEWAUTH_CURRENTDAY_ONGOING_NONINDIVIDUAL), "${newAuthCurrentDayOngoingNonIndividual}", + "$AUConstants.NEWAUTH_CURRENTDAY_ONGOING_NONINDIVIDUAL count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.NEWAUTH_CURRENTDAY_ONCEOFF_INDIVIDUAL), + "${newAuthCurrentDayOnceOffIndividual}", + "$AUConstants.NEWAUTH_CURRENTDAY_ONCEOFF_INDIVIDUAL count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.NEWAUTH_CURRENTDAY_ONCEOFF_NONINDIVIDUAL), "${newAuthCurrentDayOnceOffNonIndividual}", + "$AUConstants.NEWAUTH_CURRENTDAY_ONCEOFF_NONINDIVIDUAL count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.REVOKED_CURRENTDAY_INDIVIDUAL), + "${revokedCurrentDayIndividual}", "$AUConstants.REVOKED_CURRENTDAY_INDIVIDUAL count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.REVOKED_CURRENTDAY_NONINDIVIDUAL), + "${revokedCurrentDayNonIndividual}", + "$AUConstants.REVOKED_CURRENTDAY_NONINDIVIDUAL count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.AMENDED_CURRENTDAY_INDIVIDUAL), + "${amendedCurrentDayIndividual}", + "$AUConstants.AMENDED_CURRENTDAY_INDIVIDUAL count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.AMENDED_CURRENTDAY_NONINDIVIDUAL), + "${amendedCurrentDayNonIndividual}", + "$AUConstants.AMENDED_CURRENTDAY_NONINDIVIDUAL count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.EXPIRED_CURRENTDAY_INDIVIDUAL), + "${expiredCurrentDayIndividual}", "$AUConstants.EXPIRED_CURRENTDAY_INDIVIDUAL count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.EXPIRED_CURRENTDAY_NONINDIVIDUAL), + "${expiredCurrentDayNonIndividual}", "$AUConstants.EXPIRED_CURRENTDAY_NONINDIVIDUAL count mismatch") + + if (AUConstants.X_V_HEADER_METRICS == 4) { + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.ABANDON_CURRENTDAY), + "${abandonedCurrentDay}", "$AUConstants.ABANDON_CURRENTDAY count mismatch") + } else { + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.ABANDON_CURRENTDAY), + "${abandonedCurrentDay}", "$AUConstants.ABANDON_CURRENTDAY count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_PREIDENTIFICATION_CURRENTDAY), "${abandonedPreIdentificationCurrentDay}", + "$AUConstants.ABANDON_PREIDENTIFICATION_CURRENTDAY count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_PREIDENTIFICATION_CURRENTDAY), "${abandonedPreIdentificationCurrentDay}", + "$AUConstants.ABANDON_PREIDENTIFICATION_CURRENTDAY count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_PREAUTHENTICATE_CURRENTDAY), "${abandonedPreAuthenticationCurrentDay}", + "$AUConstants.ABANDON_PREAUTHENTICATE_CURRENTDAY count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_PREACCSELECT_CURRENTDAY), "${abandonedPreAccountSelectionCurrentDay}", + "$AUConstants.ABANDON_PREACCSELECT_CURRENTDAY count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_PREAUTH_CURRENTDAY), "${abandonedPreAuthorisationCurrentDay}", + "$AUConstants.ABANDON_PREAUTH_CURRENTDAY count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_REJECTED_CURRENTDAY), "${abandonedRejectedCurrentDay}", + "$AUConstants.ABANDON_REJECTED_CURRENTDAY count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.ABANDON_FAILEDTOKEN_CURRENTDAY), "${abandonedFailedTokenExchangeCurrentDay}", + "$AUConstants.ABANDON_FAILEDTOKEN_CURRENTDAY count mismatch") + } + } + + + /** + * Consent Amendment Authorisation + * @param scopes + * @param cdrArrangementId + * @param sharingDuration + * @param clientId + * @return auth code + */ + String doConsentAmendmentAuthorisation(List scopes, String cdrArrangementId, long sharingDuration, + String clientId = null) { + + if (clientId == null) { + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, sharingDuration, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI()) + .toURI().toString() + } else { + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, sharingDuration, + true, cdrArrangementId, clientId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), clientId) + .toURI().toString() + } + + //Consent Amendment Authorisation Flow + def automation = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Verify Account Selection Page + assert authWebDriver.isElementDisplayed(AUTestUtil.getAltSingleAccountXPath()) + authWebDriver.clickButtonXpath(AUTestUtil.getAltSingleAccountXPath()) + + //Click Confirm Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + + //Click Authorise Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + } + .execute() + + // Get Code From URL + return AUTestUtil.getCodeFromJwtResponse(automation.currentUrl.get()) + } + + /** + * Authorise Consent Without Closing Browser. + * @param scopes + * @param requestUri + * @return authorisation code + */ + String authoriseConsentWithoutClosingBrowser(List scopes, URI requestUri, + String clientId = null, boolean isMultipleAccSelect = false, + AUAccountProfile profiles = null) { + + if (clientId != null) { + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri, clientId) + .toURI().toString() + } else { + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri) + .toURI().toString() + } + + //UI Flow Navigation + automationResponse = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Select Profile and Accounts + selectProfileAndAccount(authWebDriver, profiles, isMultipleAccSelect) + + //Click Confirm Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + + //Click Authorise Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + } + .execute(false) + + // Get Code From URL + def authorisationCode = AUTestUtil.getCodeFromJwtResponse(automationResponse.currentUrl.get()) + return authorisationCode + } + + /** + * Get Errors Count in the Metrics Response. + * @param errorsResponse + * @param resourceType + * @param modifiedErrorCode + * @param modifiedValue + * @return updatedKeyValuePairsString + */ + static String getErrorsMetrics(String metricsResponse, int modifiedErrorCode) { + + String updatedKeyValuePairsString = "" + + // Parse the metrics response and extract the key-value pairs + List errorCountKeyValuePairs = AUTestUtil.parseKeyValuePairs(metricsResponse) + + // Define the expected order based on keys + List expectedOrderKeys = Arrays.asList(400, 422, 401, 500, 403, 415, 404, 406) + + // Flag to track if the modifiedErrorCode is found in the existing error list + boolean isStatusCodePresent = false + + // Iterate through each key-value pair + for (int i = 0; i < errorCountKeyValuePairs.size(); i++) { + + String[] keyValue = errorCountKeyValuePairs.get(i).split(":") + int key = Integer.parseInt(keyValue[0]) + int value = Integer.parseInt(keyValue[1]) + + // If new error code exist in the existing error Metrics list; Increase the value of the particular + // error code by 1 and Update the KeyValue Pair + if (key == modifiedErrorCode) { + value += 1 + errorCountKeyValuePairs.set(i, modifiedErrorCode + ":" + value) + isStatusCodePresent = true + break + } + } + + // If modifiedErrorCode is not found in the existing list, add it with value 1 + if (!isStatusCodePresent) { + errorCountKeyValuePairs.add(modifiedErrorCode + ":1") + } + + // Sort the list according to your desired order + errorCountKeyValuePairs.sort(new Comparator() { + @Override + int compare(String o1, String o2) { + int key1 = Integer.parseInt(o1.split(":")[1]) + int key2 = Integer.parseInt(o2.split(":")[1]) + return Integer.compare(key1, key2) + } + }) + + // Convert the sorted list to a string array + String[] sortedArray = errorCountKeyValuePairs.toArray(new String[0]) + + // Output the sorted array + for (String element : sortedArray) { + // Convert the list to a string + updatedKeyValuePairsString = "[" + String.join(", ", errorCountKeyValuePairs) + "]" + } + return updatedKeyValuePairsString + } + + /** + * Assert Metrics Error Response. + * @param metricsResponse + */ + void assertMetricsErrorResponse(Response metricsResponse) { + + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.ERROR_UNAUTH_CURRENTDAY), + "${unauthErrorCurrentDay}", "$AUConstants.ERROR_UNAUTH_CURRENTDAY count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.ERROR_AUTH_CURRENTDAY), + "${authErrorCurrentDay}", "$AUConstants.ERROR_AUTH_CURRENTDAY count mismatch") + Assert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.ERROR_AGGREGATE_CURRENTDAY), + "${aggErrorCurrentDay}", "$AUConstants.ERROR_AGGREGATE_CURRENTDAY count mismatch") + } + + /** + * Calculate Performance, Average Response and Average TPS Metrics for each tier + */ + void calculateTierBasedMetrics() { + + //Calculate Performance Metrics + performanceMetrics = metricsPerformanceCalculation() + + //Calculate Total Response Time for each tier + avgResponseMetrics = calculateTierWiseTotalResponseTime() + + //Calculate Total Resource count for average TPS + totalResources = calculateTotalResourceCount() + } + + /** + * Calculate Performance Metrics for Defined Tier + * @param tier + * @return metrics value + */ + int[] metricsPerformanceCalculation() { + + String tier + int responseTime + int[] withinThreshold = new int[5] // Array to store counts for each tier + totalInvocationsPerf = 0 + totalInvocationsUnAuthPerf = 0 + totalInvocationsHighPerf = 0 + totalInvocationsLowPerf = 0 + totalInvocationsUnattendedPerf = 0 + totalInvocationsLargePayPerf = 0 + + // Get the current UTC time + LocalDateTime utcTime = LocalDateTime.now(ZoneOffset.UTC) + + // Convert UTC time to GMT time + LocalDateTime gmtTime = utcTime.atOffset(ZoneOffset.UTC).atZoneSameInstant(ZoneOffset.ofHours(0)).toLocalDateTime() + + //Get the current hour + currentTime = gmtTime.getHour().toInteger() + + //Get Start and End Time + long startTimeOfDay = today.atTime(currentTime, 00, 00).toEpochSecond(ZoneOffset.UTC) + long endTimeOfDay = today.atTime(currentTime, 59, 59).toEpochSecond(ZoneOffset.UTC) + + // Execute SELECT query and get results as an array + def query = SqlQuery.retrieveRecordsWithinSpecifiedPeriod(startTimeOfDay, endTimeOfDay) + Object[][] results = DbConnection.executeSelectQuery(AUConstants.REPORTING_DBNAME, query) + totalInvocationsPerf = results.length + + // Process and check the response time within threshold + if (results != null) { + for (Object[] row : results) { + responseTime = row[0] + + //Do not count the request as a invocation if the status code is 405 + if(row[2]==AUConstants.STATUS_CODE_405) { + continue + } + + tier = AUTestUtil.getPriorityTier(row[1], row[3]) + + if(!row[1].equals("/par")) { + + switch (tier) { + case AUConstants.UNAUTHENTICATED: + totalInvocationsUnAuthPerf = totalInvocationsUnAuthPerf + 1 + if (responseTime <= 1500){ + withinThreshold[0]++ + } + break + case AUConstants.HIGH_PRIORITY: + totalInvocationsHighPerf = totalInvocationsHighPerf + 1 + if (responseTime <= 1000){ + withinThreshold[1]++ + } + break + case AUConstants.LOW_PRIORITY: + totalInvocationsLowPerf = totalInvocationsLowPerf + 1 + if (responseTime <= 1500){ + withinThreshold[2]++ + } + break + case AUConstants.UNATTENDED: + totalInvocationsUnattendedPerf = totalInvocationsUnattendedPerf + 1 + if (responseTime <= 4000){ + withinThreshold[3]++ + } + break + case AUConstants.LARGE_PAYLOAD: + totalInvocationsLargePayPerf = totalInvocationsLargePayPerf + 1 + if (responseTime <= 6000){ + withinThreshold[4]++ + } + break + default: + throw new IllegalStateException("Unexpected value: " + tier + " for " + row[1]) + } + } + } + } + + return withinThreshold + } + + /** + * Assertions for Tier Based Metrics - Performance, Average Response and Average TPS. + * @param metricsResponse + */ + void assertTierBasedMetrics(Response metricsResponse) { + + //Asserting the Invocations + assertMetricsInvocationResponse(metricsResponse) + + //Asserting the Performance + assertPerformanceMetricsResponse(metricsResponse, performanceMetrics) + + //Asserting Average Response Time + assertAvgResponseMetricsResponse(metricsResponse, avgResponseMetrics) + + //Asserting Average TPS + assertAvgTpsMetricsResponse(metricsResponse, totalResources) + } + + /** + * Asserting Metrics Invocation Response. + * @param metricsResponse + */ + static void assertMetricsInvocationResponse(Response metricsResponse) { + + SoftAssert softAssert = new SoftAssert() + + softAssert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.INVOCATION_UNAUTHENTICATED_CURRENTDAY), + "${unauthenticatedCurrentDay}", "$AUConstants.INVOCATION_UNAUTHENTICATED_CURRENTDAY count mismatch") + softAssert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.INVOCATION_HIGHPRIORITY_CURRENTDAY), + "${highPriorityCurrentDay}", "$AUConstants.INVOCATION_HIGHPRIORITY_CURRENTDAY count mismatch") + softAssert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.INVOCATION_LOWPRIORITY_CURRENTDAY), + "${lowPriorityCurrentDay}", "$AUConstants.INVOCATION_LOWPRIORITY_CURRENTDAY count mismatch") + softAssert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.INVOCATION_UNATTENDED_CURRENTDAY), + "${unattendedCurrentDay}", "$AUConstants.INVOCATION_UNATTENDED_CURRENTDAY count mismatch") + softAssert.assertEquals(AUTestUtil.parseResponseBody(metricsResponse, AUConstants.INVOCATION_LARGEPAYLOAD_CURRENTDAY), + "${largePayloadCurrentDay}", "$AUConstants.INVOCATION_LARGEPAYLOAD_CURRENTDAY count mismatch") + + softAssert.assertAll() + } + + /** + * Assert Performance Metrics Response + * @param metricsResponse + * @param withinThreshold + * @param arrayIndex + */ + void assertPerformanceMetricsResponse(Response metricsResponse, int[] withinThreshold) { + + SoftAssert softAssert = new SoftAssert() + + //Unauthenticated Performance Value + String unauthPerfResponse = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.PERFORMANCE_UNAUTH_CURRENTDAY) + double unauthPerf = roundUpThreeDecimals(Double.parseDouble(unauthPerfResponse.substring(unauthPerfResponse + .lastIndexOf(",") + 1, unauthPerfResponse.length() - 1).trim())) + + softAssert.assertEquals(unauthPerf, calculatePerformance(withinThreshold[0], totalInvocationsUnAuthPerf), + "$AUConstants.PERFORMANCE_UNAUTH_CURRENTDAY count mismatch") + + //High Priority Performance Value + String highPerfResponse = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.PERFORMANCE_HIGH_CURRENTDAY) + double highPerf = roundUpThreeDecimals(Double.parseDouble(highPerfResponse.substring(highPerfResponse + .lastIndexOf(",") + 1, highPerfResponse.length() - 1).trim())) + + softAssert.assertEquals(highPerf, calculatePerformance(withinThreshold[1], totalInvocationsHighPerf), + "$AUConstants.PERFORMANCE_HIGH_CURRENTDAY count mismatch") + + //Low Priority Performance Value + String lowPerfResponse = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.PERFORMANCE_LOW_CURRENTDAY) + double lowPerf = roundUpThreeDecimals(Double.parseDouble(lowPerfResponse.substring(lowPerfResponse + .lastIndexOf(",") + 1, lowPerfResponse.length() - 1).trim())) + + softAssert.assertEquals(lowPerf, calculatePerformance(withinThreshold[2], totalInvocationsLowPerf), + "$AUConstants.PERFORMANCE_LOW_CURRENTDAY count mismatch") + + //Unattended Performance Value + String unattendedPerfResponse = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.PERFORMANCE_UNATTENDED_CURRENTDAY) + double unattendedPerf = roundUpThreeDecimals(Double.parseDouble(unattendedPerfResponse.substring(unattendedPerfResponse + .lastIndexOf(",") + 1, unattendedPerfResponse.length() - 1).trim())) + + softAssert.assertEquals(unattendedPerf, calculatePerformance(withinThreshold[3], totalInvocationsUnattendedPerf), + "$AUConstants.PERFORMANCE_UNATTENDED_CURRENTDAY count mismatch") + + //Large Payload Performance Value + String largePayPerfResponse = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.PERFORMANCE_LARGE_PAYLOAD_CURRENTDAY) + double largePayPerf = roundUpThreeDecimals(Double.parseDouble(largePayPerfResponse.substring(largePayPerfResponse + .lastIndexOf(",") + 1, largePayPerfResponse.length() - 1).trim())) + + softAssert.assertEquals(largePayPerf, calculatePerformance(withinThreshold[4], totalInvocationsLargePayPerf), + "$AUConstants.PERFORMANCE_LARGE_PAYLOAD_CURRENTDAY count mismatch") + + softAssert.assertAll() + } + + /** + * Assert Average Response Time. + * @param metricsResponse + * @param totalResponseTime + */ + void assertAvgResponseMetricsResponse(Response metricsResponse, int[] totalResponseTime) { + + SoftAssert softAssert = new SoftAssert() + + //Unauthenticated Average Response Value + double unauthAvgResponse = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.AVG_RESPONSE_UNAUTH_CURRENTDAY) + .toDouble() + + softAssert.assertEquals(unauthAvgResponse, calculateAverageResponseTime(totalResponseTime[0], + totalInvocationsUnAuthAvg), "$AUConstants.AVG_RESPONSE_UNAUTH_CURRENTDAY count mismatch") + + //High Priority Average Response Value + double highAvgResponse = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.AVG_RESPONSE_HIGH_CURRENTDAY) + .toDouble() + + softAssert.assertEquals(highAvgResponse, calculateAverageResponseTime(totalResponseTime[1], totalInvocationsHighAvg), + "$AUConstants.AVG_RESPONSE_HIGH_CURRENTDAY count mismatch") + + //Low Priority Average Response Value + double lowAvgResponse = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.AVG_RESPONSE_LOW_CURRENTDAY) + .toDouble() + + softAssert.assertEquals(lowAvgResponse, calculateAverageResponseTime(totalResponseTime[2], totalInvocationsLowAvg), + "$AUConstants.AVG_RESPONSE_LOW_CURRENTDAY count mismatch") + + //Unattended Average Response Value + double unattendedAvgResponse = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.AVG_RESPONSE_UNATTENDED_CURRENTDAY).toDouble() + + softAssert.assertEquals(unattendedAvgResponse, calculateAverageResponseTime(totalResponseTime[3], + totalInvocationsUnattendedAvg), "$AUConstants.AVG_RESPONSE_UNATTENDED_CURRENTDAY count mismatch") + + //Large Payload Average Response Value + double largePayAvgResponse = AUTestUtil.parseResponseBody(metricsResponse, + AUConstants.AVG_RESPONSE_LARGE_PAYLOAD_CURRENTDAY).toDouble() + + softAssert.assertEquals(largePayAvgResponse, calculateAverageResponseTime(totalResponseTime[4], + totalInvocationsLargePayAvg), "$AUConstants.AVG_RESPONSE_LARGE_PAYLOAD_CURRENTDAY count mismatch") + + softAssert.assertAll() + } + + /** + * Assert Average TPS Metrics. + * @param metricsResponse + * @param totalResourceCount + */ + void assertAvgTpsMetricsResponse(Response metricsResponse, int[] totalResourceCount) { + + SoftAssert softAssert = new SoftAssert() + + //Unauthenticated Average TPS Value + String unauthAvgTps = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.AVGTPS_UNAUTHENTICATED_CURRENTDAY) + + def expectedUnauthAvgTps = calculateAverageTps(totalResourceCount[0]) + softAssert.assertEquals(unauthAvgTps, expectedUnauthAvgTps.toString(), + "$AUConstants.AVGTPS_UNAUTHENTICATED_CURRENTDAY count mismatch") + + //Authenticated Average TPS Value + def authAvgTps = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.AVGTPS_AUTHENTICATED_CURRENTDAY) + + def expectedAuthAvgTps = calculateAverageTps(totalResourceCount[1]) + softAssert.assertEquals(authAvgTps, expectedAuthAvgTps.toString(), + "$AUConstants.AVGTPS_AUTHENTICATED_CURRENTDAY count mismatch") + + //Aggregate Average TPS Value + String aggAvgTps = AUTestUtil.parseResponseBody(metricsResponse, AUConstants.AVGTPS_AGGREGATE_CURRENTDAY) + int aggregateAvgTps = totalResourceCount[1].toInteger() + totalResourceCount[0].toInteger() + + def expectedAggAvgTps = calculateAverageTps(aggregateAvgTps) + softAssert.assertEquals(aggAvgTps, expectedAggAvgTps.toString(), + "$AUConstants.AVGTPS_AGGREGATE_CURRENTDAY count mismatch") + + softAssert.assertAll() + } + + /** + * Round Up the Metrics to Three Decimal Places. + * @param withinThreshold + * @return roundedPerfValue + */ + static double roundUpThreeDecimals(def metrics) { + + // Using DecimalFormat to round to 3 decimal places + String roundedValue = String.format("%.3f", metrics.toDouble()) + return Double.parseDouble(roundedValue) + } + + /** + * Calculate Performance Metrics + * @param withinThreshold + * @param totalInvocations + * @return performanceMetrics + */ + static double calculatePerformance(int withinThreshold, int totalInvocations){ + + double performanceMetrics + + if(!withinThreshold.equals(0)) { + performanceMetrics = withinThreshold.toDouble() / totalInvocations.toDouble() + } else { + performanceMetrics = 1.000 + } + + return roundUpThreeDecimals(performanceMetrics) + } + + + /** + * Calculate Average Response Time + * @param responseTime + * @param totalInvocations + * @return + */ + static double calculateAverageResponseTime(int responseTime, int totalInvocations){ + + double avgResponseTimeMetrics + + if(!responseTime.equals(0)) { + avgResponseTimeMetrics = responseTime.toDouble() / totalInvocations.toDouble() + } else { + avgResponseTimeMetrics = 0 + } + + return roundUpThreeDecimals(avgResponseTimeMetrics/1000) + } + + /** + * Calculate Average TPS + * @param resourceCount + * @return averageTps + */ + static double calculateAverageTps(int resourceCount){ + + def averageTpsMetrics + + if(!resourceCount.equals(0)) { + averageTpsMetrics = (resourceCount / 86400) + } else { + averageTpsMetrics = 0 + } + + return roundUpThreeDecimals(averageTpsMetrics) + } + + /** + * CDR Arrangement Revocation without Client Id in the request body + * @param clientId + * @param cdrArrangementId + * @return + */ + Response doRevokeCdrArrangementWithoutClientIdInRequest(String clientId, String cdrArrangementId){ + + generator = new AUJWTGenerator() + String assertionString = generator.getClientAssertionJwt(clientId) + + def bodyContent = [ + (AUConstants.CLIENT_ASSERTION_TYPE_KEY): (AUConstants.CLIENT_ASSERTION_TYPE), + (AUConstants.CLIENT_ASSERTION_KEY) : assertionString, + (AUConstants.CDR_ARRANGEMENT_ID) : cdrArrangementId] + + revocationResponse = AURestAsRequestBuilder.buildRequest() + .contentType(AUConstants.ACCESS_TOKEN_CONTENT_TYPE) + .formParams(bodyContent) + .baseUri(AUTestUtil.getBaseUrl(AUConstants.BASE_PATH_TYPE_CDR_ARRANGEMENT)) + .post("${AUConstants.CDR_ARRANGEMENT_ENDPOINT}") + + return revocationResponse + } + + /** + * Calculate Total Response Metrics for Defined Tier + * @param tier + * @return metrics value + */ + int[] calculateTierWiseTotalResponseTime() { + + String tier + int responseTime + int[] sumResponseTime = new int[5] + totalInvocationsPerf = 0 + totalInvocationsUnAuthAvg = 0 + totalInvocationsHighAvg = 0 + totalInvocationsLowAvg = 0 + totalInvocationsUnattendedAvg = 0 + totalInvocationsLargePayAvg = 0 + + //Get Start and End Time of the day + long startTimeOfDay = today.atTime(00, 00, 00).toEpochSecond(ZoneOffset.UTC) + long endTimeOfDay = today.atTime(23, 59, 59).toEpochSecond(ZoneOffset.UTC) + + // Execute SELECT query and get results as an array + def query = SqlQuery.retrieveRecordsWithinSpecifiedPeriod(startTimeOfDay, endTimeOfDay) + Object[][] results = DbConnection.executeSelectQuery(AUConstants.REPORTING_DBNAME, query) + totalInvocationsAvg = results.length + + // Process and check the response time within threshold + if (results != null) { + for (Object[] row : results) { + responseTime = row[0] + + tier = AUTestUtil.getPriorityTier(row[1], row[3]) + + if(!row[1].equals("/par")) { + + switch (tier) { + case AUConstants.UNAUTHENTICATED: + totalInvocationsUnAuthAvg = totalInvocationsUnAuthAvg + 1 + sumResponseTime[0] += responseTime + break + case AUConstants.HIGH_PRIORITY: + totalInvocationsHighAvg = totalInvocationsHighAvg + 1 + sumResponseTime[1] += responseTime + break + case AUConstants.LOW_PRIORITY: + totalInvocationsLowAvg = totalInvocationsLowAvg + 1 + sumResponseTime[2] += responseTime + break + case AUConstants.UNATTENDED: + totalInvocationsUnattendedAvg = totalInvocationsUnattendedAvg + 1 + sumResponseTime[3] += responseTime + break + case AUConstants.LARGE_PAYLOAD: + totalInvocationsLargePayAvg = totalInvocationsLargePayAvg + 1 + sumResponseTime[4] += responseTime + break + default: + throw new IllegalStateException("Unexpected value: " + tier + " for " + row[1]) + } + } + } + } + return sumResponseTime + } + + /** + * Calculate Total Resource Count based on the resource type + * @param tier + * @return metrics value + */ + int[] calculateTotalResourceCount() { + + String resourceType + int responseTime + int[] totalResourceCount = new int[2] + totalInvocationsPerf = 0 + + //Get Start and End Time of the Day + long startTimeOfDay = today.atTime(00, 00, 00).toEpochSecond(ZoneOffset.UTC) + long endTimeOfDay = today.atTime(23, 59, 59).toEpochSecond(ZoneOffset.UTC) + + // Execute SELECT query and get results as an array + def query = SqlQuery.retrieveRecordsWithinSpecifiedPeriod(startTimeOfDay, endTimeOfDay) + Object[][] results = DbConnection.executeSelectQuery(AUConstants.REPORTING_DBNAME, query) + + // Process and check the response time within threshold + if (results != null) { + for (Object[] row : results) { + responseTime = row[0] + + resourceType = AUTestUtil.getAuthenticatedResources(row[1]) + + if (!row[1].equals("/par")) { + + switch (resourceType) { + case AUConstants.UNAUTHENTICATED: + totalResourceCount[0]++ + break + case AUConstants.AUTHENTICATED: + totalResourceCount[1]++ + break + default: + throw new IllegalStateException("Unexpected value: " + resourceType + " for " + row[1]) + } + } + } + } + + return totalResourceCount + } + + AccessTokenResponse getUserAccessTokenResponseWithDifferentClientId(String assertionClientId = null, String bodyClientID ) { + try { + return AURequestBuilder.getUserToken(authorisationCode, AUConstants.CODE_VERIFIER, clientId) + } + catch (Exception e) { + log.error(e) + } + } + + /** + * Consent Amendment Deny + * @param scopes + * @param cdrArrangementId + * @param sharingDuration + * @param clientId + * @return auth code + */ + String doConsentAmendmentDenyFlow(List scopes, String cdrArrangementId, long sharingDuration, + String clientId = null) { + + if (clientId == null) { + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, sharingDuration, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI()) + .toURI().toString() + } else { + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, sharingDuration, + true, cdrArrangementId, clientId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), clientId) + .toURI().toString() + } + + //Consent Amendment Authorisation Flow + def automation = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Verify Account Selection Page + assert authWebDriver.isElementDisplayed(AUTestUtil.getAltSingleAccountXPath()) + authWebDriver.clickButtonXpath(AUTestUtil.getAltSingleAccountXPath()) + + //Click Confirm Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + + //Click Authorise Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_DENY_XPATH) + } + .execute() + + return automation.currentUrl.get() + } + + /** + * Consent Amendment Authorisation + * @param scopes + * @param cdrArrangementId + * @param sharingDuration + * @param clientId + * @return auth code + */ + String doBusinessConsentAmendmentAuthorisation(List scopes, String cdrArrangementId, long sharingDuration, + String clientId = null) { + + if (clientId == null) { + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, sharingDuration, + true, cdrArrangementId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI()) + .toURI().toString() + } else { + response = auAuthorisationBuilder.doPushAuthorisationRequest(scopes, sharingDuration, + true, cdrArrangementId, clientId) + requestUri = AUTestUtil.parseResponseBody(response, AUConstants.REQUEST_URI) + authoriseUrl = auAuthorisationBuilder.getAuthorizationRequest(requestUri.toURI(), clientId) + .toURI().toString() + } + + //Consent Amendment Authorisation Flow + def automation = getBrowserAutomation(AUConstants.DEFAULT_DELAY) + .addStep(new AUBasicAuthAutomationStep(authoriseUrl)) + .addStep { driver, context -> + AutomationMethod authWebDriver = new AutomationMethod(driver) + + //Click Confirm Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + + //Click Authorise Button + authWebDriver.clickButtonXpath(AUPageObjects.CONSENT_CONFIRM_XPATH) + } + .execute() + + // Get Code From URL + return AUTestUtil.getCodeFromJwtResponse(automation.currentUrl.get()) + } } diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/automation/consent/AUAccountSelectionStep.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/automation/consent/AUAccountSelectionStep.groovy similarity index 77% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/automation/consent/AUAccountSelectionStep.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/automation/consent/AUAccountSelectionStep.groovy index bfe743212..9d63f2089 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/automation/consent/AUAccountSelectionStep.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/automation/consent/AUAccountSelectionStep.groovy @@ -16,15 +16,15 @@ * under the License. */ -package com.wso2.cds.test.framework.automation.consent +package org.wso2.cds.test.framework.automation.consent -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.openbanking.test.framework.automation.AutomationMethod -import com.wso2.openbanking.test.framework.automation.BrowserAutomationStep -import com.wso2.openbanking.test.framework.automation.OBBrowserAutomation -import com.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.openbanking.test.framework.automation.BrowserAutomationStep +import org.wso2.openbanking.test.framework.automation.OBBrowserAutomation +import org.wso2.cds.test.framework.configuration.AUConfigurationService import org.openqa.selenium.remote.RemoteWebDriver -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.utility.AUTestUtil /** * AU Account section automation step diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/automation/consent/AUBasicAuthAutomationStep.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/automation/consent/AUBasicAuthAutomationStep.groovy similarity index 77% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/automation/consent/AUBasicAuthAutomationStep.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/automation/consent/AUBasicAuthAutomationStep.groovy index 147da1c63..70909bc3a 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/automation/consent/AUBasicAuthAutomationStep.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/automation/consent/AUBasicAuthAutomationStep.groovy @@ -16,19 +16,17 @@ * under the License. */ -package com.wso2.cds.test.framework.automation.consent +package org.wso2.cds.test.framework.automation.consent -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.openbanking.test.framework.automation.AutomationMethod -import com.wso2.openbanking.test.framework.automation.BrowserAutomationStep -import com.wso2.openbanking.test.framework.automation.OBBrowserAutomation -import com.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.openbanking.test.framework.automation.BrowserAutomationStep +import org.wso2.openbanking.test.framework.automation.OBBrowserAutomation +import org.wso2.cds.test.framework.configuration.AUConfigurationService import org.apache.commons.logging.Log import org.apache.commons.logging.LogFactory -import org.openqa.selenium.By import org.openqa.selenium.remote.RemoteWebDriver -import org.openqa.selenium.support.ui.ExpectedConditions import org.openqa.selenium.support.ui.WebDriverWait /** @@ -38,7 +36,7 @@ class AUBasicAuthAutomationStep implements BrowserAutomationStep { private String authorizeUrl private AUConfigurationService auConfiguration -// private static final Log log = LogFactory.getLog(AUBasicAuthAutomationStep.class); + private static final Log log = LogFactory.getLog(AUBasicAuthAutomationStep.class); /** * Initialize Basic Auth Flow. @@ -70,7 +68,7 @@ class AUBasicAuthAutomationStep implements BrowserAutomationStep { driver.waitTimeRange(30) } } catch (NoSuchElementException e) { -// log.info("Second Factor Authentication Step is not required") + log.info("Second Factor Authentication Step is not required") } } } diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/automation/consent/AUBasicWithdrawalAutomationStep.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/automation/consent/AUBasicWithdrawalAutomationStep.groovy similarity index 84% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/automation/consent/AUBasicWithdrawalAutomationStep.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/automation/consent/AUBasicWithdrawalAutomationStep.groovy index d6db46c4a..6be86821b 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/automation/consent/AUBasicWithdrawalAutomationStep.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/automation/consent/AUBasicWithdrawalAutomationStep.groovy @@ -16,13 +16,13 @@ * under the License. */ -package com.wso2.cds.test.framework.automation.consent +package org.wso2.cds.test.framework.automation.consent -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.openbanking.test.framework.automation.AutomationMethod -import com.wso2.openbanking.test.framework.automation.BrowserAutomationStep -import com.wso2.openbanking.test.framework.automation.OBBrowserAutomation -import com.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.openbanking.test.framework.automation.BrowserAutomationStep +import org.wso2.openbanking.test.framework.automation.OBBrowserAutomation +import org.wso2.cds.test.framework.configuration.AUConfigurationService import org.openqa.selenium.remote.RemoteWebDriver import java.util.concurrent.TimeUnit diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/automation/dashboard/AUCCPortalWithdrawalAutomationStep.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/automation/dashboard/AUCCPortalWithdrawalAutomationStep.groovy similarity index 83% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/automation/dashboard/AUCCPortalWithdrawalAutomationStep.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/automation/dashboard/AUCCPortalWithdrawalAutomationStep.groovy index 5506e3ce5..db1d0ae39 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/automation/dashboard/AUCCPortalWithdrawalAutomationStep.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/automation/dashboard/AUCCPortalWithdrawalAutomationStep.groovy @@ -16,13 +16,13 @@ * under the License. */ -package com.wso2.cds.test.framework.automation.dashboard +package org.wso2.cds.test.framework.automation.dashboard -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.openbanking.test.framework.automation.AutomationMethod -import com.wso2.openbanking.test.framework.automation.BrowserAutomationStep -import com.wso2.openbanking.test.framework.automation.OBBrowserAutomation -import com.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.cds.test.framework.constant.AUPageObjects +import org.wso2.openbanking.test.framework.automation.AutomationMethod +import org.wso2.openbanking.test.framework.automation.BrowserAutomationStep +import org.wso2.openbanking.test.framework.automation.OBBrowserAutomation +import org.wso2.cds.test.framework.configuration.AUConfigurationService import org.openqa.selenium.remote.RemoteWebDriver import java.util.concurrent.TimeUnit @@ -55,6 +55,4 @@ class AUCCPortalWithdrawalAutomationStep implements BrowserAutomationStep{ driver.submitButtonXpath(AUPageObjects.AU_CCPORTAL_SIGNIN_XPATH) webDriver.manage().timeouts().implicitlyWait(100,TimeUnit.SECONDS); } - } - diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/configuration/AUConfigurationService.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/configuration/AUConfigurationService.groovy similarity index 86% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/configuration/AUConfigurationService.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/configuration/AUConfigurationService.groovy index 4644c1c69..c5a1399ca 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/configuration/AUConfigurationService.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/configuration/AUConfigurationService.groovy @@ -16,11 +16,12 @@ * under the License. */ -package com.wso2.cds.test.framework.configuration +package org.wso2.cds.test.framework.configuration -import com.wso2.cds.test.framework.constant.AUConfigConstants -import com.wso2.openbanking.test.framework.configuration.OBConfigurationService -import com.wso2.openbanking.test.framework.constant.OBConfigConstants + +import org.wso2.openbanking.test.framework.configuration.OBConfigurationService +import org.wso2.openbanking.test.framework.constant.OBConfigConstants +import org.wso2.cds.test.framework.constant.AUConfigConstants /** * Class for provide configuration data to the AU layers and AU tests @@ -253,5 +254,47 @@ class AUConfigurationService extends OBConfigurationService { String getSharableAccountUrl() { return configuration.get(OBConfigConstants.SERVER + "." + AUConfigConstants.SHARABLE_ACCOUNT_URL) } + + /** + * Get DB Type + */ + String getDbType() { + return configuration.get(AUConfigConstants.DATA_BASE_CONFIGURATION + "." + AUConfigConstants.DB_TYPE) + } + + /** + * Get DB Server Host + */ + String getDbServerHost() { + return configuration.get(AUConfigConstants.DATA_BASE_CONFIGURATION + "." + AUConfigConstants.DB_SERVER_HOST) + } + + /** + * Get DB Username + */ + String getDbUsername() { + return configuration.get(AUConfigConstants.DATA_BASE_CONFIGURATION + "." + AUConfigConstants.DB_USERNAME) + } + + /** + * Get DB Password + */ + String getDbPassword() { + return configuration.get(AUConfigConstants.DATA_BASE_CONFIGURATION + "." + AUConfigConstants.DB_PASSWORD) + } + + /** + * Get DB Driver Class + */ + String getDbDriverClass() { + return configuration.get(AUConfigConstants.DATA_BASE_CONFIGURATION + "." + AUConfigConstants.DB_DRIVER_CLASS) + } + + /** + * Get Oracle DB SID + */ + String getOracleSid() { + return configuration.get(AUConfigConstants.DATA_BASE_CONFIGURATION + "." + AUConfigConstants.ORACLE_DB_SID) + } } diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUAccountProfile.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUAccountProfile.groovy similarity index 95% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUAccountProfile.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUAccountProfile.groovy index eecc9763a..2b203a5b9 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUAccountProfile.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUAccountProfile.groovy @@ -16,7 +16,7 @@ * under the License. */ -package com.wso2.cds.test.framework.constant +package org.wso2.cds.test.framework.constant /** * Enum class for keeping account Profiles Eg: Business and Individual. diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUAccountScope.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUAccountScope.groovy similarity index 94% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUAccountScope.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUAccountScope.groovy index e64ecf3bd..d45543116 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUAccountScope.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUAccountScope.groovy @@ -16,7 +16,7 @@ * under the License. */ -package com.wso2.cds.test.framework.constant +package org.wso2.cds.test.framework.constant /** * Enum class for keeping account scopes @@ -33,7 +33,8 @@ enum AUAccountScope { CDR_REGISTRATION("cdr:registration"), ADMIN_METRICS_BASIC_READ("admin:metrics.basic:read"), ADMIN_METADATA_UPDATE("admin:metadata:update"), - PROFILE("profile") + PROFILE("profile"), + OPENID("openid") private String value diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUBusinessUserPermission.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUBusinessUserPermission.groovy similarity index 95% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUBusinessUserPermission.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUBusinessUserPermission.groovy index 60beee9d9..b1170cd8f 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUBusinessUserPermission.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUBusinessUserPermission.groovy @@ -16,7 +16,7 @@ * under the License. */ -package com.wso2.cds.test.framework.constant +package org.wso2.cds.test.framework.constant /** * Enum class for keeping Permissions of Business Users. diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUConfigConstants.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUConfigConstants.groovy similarity index 88% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUConfigConstants.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUConfigConstants.groovy index 2b13ce496..0372921e6 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUConfigConstants.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUConfigConstants.groovy @@ -16,7 +16,7 @@ * under the License. */ -package com.wso2.cds.test.framework.constant +package org.wso2.cds.test.framework.constant /** * Class for provide AU configuration constants with OB configuration constants @@ -77,5 +77,14 @@ class AUConfigConstants { //Sharable Account URL public static final String SHARABLE_ACCOUNT_URL = "SharableAccountsURL" + + //Database Configuration Details + public static final String DATA_BASE_CONFIGURATION = "DataBaseConfiguration" + public static final String DB_TYPE = "DBType" + public static final String DB_SERVER_HOST = "DBServerHost" + public static final String DB_USERNAME = "DBUsername" + public static final String DB_PASSWORD = "DBPassword" + public static final String DB_DRIVER_CLASS = "DBDriverClass" + public static final String ORACLE_DB_SID = "OracleDBSID" } diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUConstants.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUConstants.groovy similarity index 80% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUConstants.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUConstants.groovy index ac292f4e3..364f01eb8 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUConstants.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUConstants.groovy @@ -16,12 +16,12 @@ * under the License. */ -package com.wso2.cds.test.framework.constant +package org.wso2.cds.test.framework.constant import com.nimbusds.oauth2.sdk.pkce.CodeVerifier -import com.wso2.openbanking.test.framework.constant.OBConstants -import com.wso2.cds.test.framework.configuration.AUConfigurationService -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.openbanking.test.framework.constant.OBConstants +import org.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.cds.test.framework.utility.AUTestUtil /** * Class for provide AU and OB constants to the @@ -71,13 +71,14 @@ class AUConstants extends OBConstants { public static final String CODE = "code" public static final String ERROR_INVALID_SOFTWARE_PRODUCT = "Invalid Software Product" - public static final long DEFAULT_SHARING_DURATION = 60000 + public static final long DEFAULT_SHARING_DURATION = 172800 public static final long SINGLE_ACCESS_CONSENT = 0 public static final long ONE_YEAR_DURATION = 31536200 public static final long NEGATIVE_DURATION = -3000 public static final long AMENDED_SHARING_DURATION = 3000 - public static final long SHORT_SHARING_DURATION = 60 + public static final long SHORT_SHARING_DURATION = 84600 static final long NEGATIVE_SHARING_DURATION = -3000 + public static final long SHARING_DURATION_24H = 86400 public static final String BULK_ACCOUNT_PATH = CDS_PATH + "/banking/accounts" public static final String SINGLE_ACCOUNT_PATH = CDS_PATH + "/banking/accounts/" + accountID @@ -87,18 +88,17 @@ class AUConstants extends OBConstants { public static final String BULK_DIRECT_DEBITS_PATH = CDS_PATH + "/banking/accounts/direct-debits" public static final String BULK_SCHEDULE_PAYMENTS_PATH = CDS_PATH + "/banking/payments/scheduled" public static final String BULK_PAYEES = CDS_PATH + "/banking/payees" - public static final String BULK_CUSTOMER = CDS_COMMON_PATH + "/common/customer" - public static final String CUSTOMER_DETAILS = CDS_COMMON_PATH + "/common/customer/detail" - public static final String DISCOVERY_STATUS = CDS_COMMON_PATH + "/discovery/status" - public static final String DISCOVERY_OUTAGES = CDS_COMMON_PATH + "/discovery/outages" + public static final String BULK_CUSTOMER = CDS_PATH + "/common/customer" + public static final String CUSTOMER_DETAILS = CDS_PATH + "/common/customer/detail" + public static final String DISCOVERY_STATUS = CDS_PATH + "/discovery/status" + public static final String DISCOVERY_OUTAGES = CDS_PATH + "/discovery/outages" public static final String ACCOUNTS_CONSENT_PATH = "/au100/accounts-validation" public static final String CDR_ARRANGEMENT_ENDPOINT = "/arrangements/1.0.0/revoke" public static final String INTROSPECTION_ENDPOINT = "/oauth2/introspect" public static final String CONSENT_STATUS_ENDPOINT = "/api/openbanking/consent-mgt/uk300" - public static final String PUSHED_AUTHORISATION_BASE_PATH = auConfiguration.getServerAuthorisationServerURL() + - "/api/openbanking/push-authorization" - public static final String PAR_ENDPOINT = "/par" - public static final String REVOKE_PATH = "/oauth2/revoke" + public static final String PUSHED_AUTHORISATION_BASE_PATH = auConfiguration.getServerAuthorisationServerURL() + public static final String PAR_ENDPOINT = "/api/openbanking/push-authorization/par" + public static final String TOKEN_REVOKE_PATH = "/oauth2/revoke" public static final String STATUS_PATH = "/account-confirmation" public static final String CONSENT_STATUS_AU_ENDPOINT = "api/openbanking/account-type-mgt" public static final String UPDATE_BUSINESS_USER = "/account-type-management/business-stakeholders" @@ -180,10 +180,6 @@ class AUConstants extends OBConstants { public static final String LBL_NAME = "Name" public static final String LBL_OCCUPATION = "Occupation" - public static final String CONSENT_MANAGER_URL = auConfiguration.getServerAuthorisationServerURL() + "/consentmgt" - public static final String OAUTH2_INTROSPECT_URL = auConfiguration.getServerAuthorisationServerURL() + "/oauth2/introspect" - public static final String CCPORTAL_URL = auConfiguration.getServerAuthorisationServerURL() + "/ccportal" - public static final String ERROR = "error"; public static final String ERROR_DESCRIPTION = "error_description"; public static final String ERROR_DETAIL = "errors[0].detail" @@ -317,6 +313,11 @@ class AUConstants extends OBConstants { public static final String UNSUPPORTED_RESPONSE_MODE = "Unsupported response_mode value. Only jwt response mode is allowed." public static final String ERROR_CODE_INVALID_PAGE = "urn:au-cds:error:cds-all:Field/InvalidPage" public static final String INVALID_PAGE = "Invalid Page" + public static final String INVALID_SIGNING_ALG = "Invalid signing algorithm sent" + public static final String INVALID_AUDIENCE_ERROR = "Invalid audience provided" + public static final String ERROR_REDIRECT_URL_WITH_DIFF_HOSTNAMES = "Redirect URIs do not contain the same hostname" + public static final String ERROR_EMPTY_REDIRECT_URL_IN_SSA = "Redirect URIs can not be null or empty in SSA" + public static final String ERROR_WITHOUT_IDTOKEN_SINGED_ALG = "Required parameter idTokenSignedResponseAlg cannot be null" /** * Mock Register Constants @@ -394,7 +395,7 @@ class AUConstants extends OBConstants { public static final String ALL = "ALL" public static final String PAGE_SIZE = "page-size" public static final String UPDATED_SINCE = "updated-since" - public static final String BRAND = "BRAND" + public static final String BRAND = "brand" public static final String EFFECTIVE = "EFFECTIVE" public static final String PERIOD = "period" public static final String HISTORIC = "HISTORIC" @@ -408,7 +409,8 @@ class AUConstants extends OBConstants { public static final String ERROR_NOT_ALLOWED_TO_ACCESS = "The access token does not allow you to access the requested resource" public static final String PARAM_PROFILE_NAME = "profileName" public static final String USER_DENIED_THE_CONSENT = "User denied the consent" - public static final String USER_SKIP_THE_CONSENT_FLOW = "User skip the consent flow" + public static final String USER_SKIP_THE_CONSENT_FLOW = "User skipped the consent flow" + public static final String CANCEL_ERROR_IN_ACCOUNTS_PAGE = "User skip the consent flow" public static final String ACTIVE = "active" public static final String INACTIVE = "inactive" @@ -468,11 +470,11 @@ class AUConstants extends OBConstants { public static final int X_V_HEADER_TRANSACTIONS = 1 public static final int X_V_HEADER_TRANSACTION = 1 public static final int X_V_HEADER_DIRECT_DEBITS = 1 - public static final int X_V_HEADER_PAYMENT_SCHEDULED = 1 + public static final int X_V_HEADER_PAYMENT_SCHEDULED = 2 public static final int X_V_HEADER_PAYEES = 2 public static final int X_V_HEADER_PRODUCTS = 3 public static final int X_V_HEADER_PRODUCT = 4 - public static final int X_V_HEADER_METRICS = 3 + public static final int X_V_HEADER_METRICS = 5 public static final int X_V_HEADER_METADATA = 1 public static final int X_V_HEADER_CUSTOMER = 1 public static final int X_V_HEADER_CUSTOMER_DETAIL = 2 @@ -485,7 +487,7 @@ class AUConstants extends OBConstants { public static final String ERROR_UNSUPPORTED_RESPONSE = "Unsupported response_type value. Only code response type is allowed." public static final String DCR_CLAIM_LEGAL_ENTITY_ID = "legal_entity_id" public static final String DCR_CLAIM_LEGAL_ENTITY_NAME = "legal_entity_name" - public static final String SAMPLE_LEGAL_ENTITY_ID = "344F0E809-BDBE-4F8E-BD30-5E6C3CB78D7B" + public static final String SAMPLE_LEGAL_ENTITY_ID = "TPP7" public static final String SAMPLE_LEGAL_ENTITY_NAME = "Mock Company Pty Ltd." public static final String AlternateAccountId = "30080098763501" public static final CodeVerifier CODE_VERIFIER = new CodeVerifier() @@ -512,5 +514,100 @@ class AUConstants extends OBConstants { public static final String ADR_STATUS_NOT_ACTIVE = "ADR Status Is Not Active" public static final String ERROR_CODE_ADR_STATUS_NOT_ACTIVE = "urn:au-cds:error:cds-banking:Authorisation/AdrStatusNotActive" public static final String CONFIG_FILE_NAME = "TestConfiguration.xml" + + static final String PERIOD_CURRENT = "CURRENT" + static final String PERIOD_ALL = "ALL" + static final String PERIOD_HISTORIC = "HISTORIC" + static final String ACTIVE_AUTHORIZATION_INDIVIDUAL = "data.authorisations.activeAuthorisationCount.individual" + static final String ACTIVE_AUTHORIZATION_NONINDIVIDUAL = "data.authorisations.activeAuthorisationCount.nonIndividual" + static final String NEWAUTH_CURRENTDAY_ONGOING_INDIVIDUAL = + "data.authorisations.newAuthorisationCount.currentDay.ongoing.individual" + static final String NEWAUTH_CURRENTDAY_ONGOING_NONINDIVIDUAL = + "data.authorisations.newAuthorisationCount.currentDay.ongoing.nonIndividual" + static final String NEWAUTH_CURRENTDAY_ONCEOFF_INDIVIDUAL = + "data.authorisations.newAuthorisationCount.currentDay.onceOff.individual" + static final String NEWAUTH_CURRENTDAY_ONCEOFF_NONINDIVIDUAL = + "data.authorisations.newAuthorisationCount.currentDay.onceOff.nonIndividual" + static final String REVOKED_CURRENTDAY_INDIVIDUAL = + "data.authorisations.revokedAuthorisationCount.currentDay.individual" + static final String REVOKED_CURRENTDAY_NONINDIVIDUAL = + "data.authorisations.revokedAuthorisationCount.currentDay.nonIndividual" + static final String AMENDED_CURRENTDAY_INDIVIDUAL = + "data.authorisations.amendedAuthorisationCount.currentDay.individual" + static final String AMENDED_CURRENTDAY_NONINDIVIDUAL = + "data.authorisations.amendedAuthorisationCount.currentDay.nonIndividual" + static final String EXPIRED_CURRENTDAY_INDIVIDUAL = + "data.authorisations.expiredAuthorisationCount.currentDay.individual" + static final String EXPIRED_CURRENTDAY_NONINDIVIDUAL = + "data.authorisations.expiredAuthorisationCount.currentDay.nonIndividual" + static final String ABANDON_PREIDENTIFICATION_CURRENTDAY = + "data.authorisations.abandonmentsByStage.preIdentification.currentDay" + static final String ABANDON_PREAUTHENTICATE_CURRENTDAY = + "data.authorisations.abandonmentsByStage.preAuthentication.currentDay" + static final String ABANDON_PREACCSELECT_CURRENTDAY = + "data.authorisations.abandonmentsByStage.preAccountSelection.currentDay" + static final String ABANDON_PREAUTH_CURRENTDAY = + "data.authorisations.abandonmentsByStage.preAuthorisation.currentDay" + static final String ABANDON_REJECTED_CURRENTDAY = + "data.authorisations.abandonmentsByStage.rejected.currentDay" + static final String ABANDON_FAILEDTOKEN_CURRENTDAY = + "data.authorisations.abandonmentsByStage.failedTokenExchange.currentDay" + static final String ABANDON_CURRENTDAY = + "data.authorisations.abandonedConsentFlowCount.currentDay" + static final String PERFORMANCE_CURRENTDAY ="data.performance.currentDay" + static final String PERFORMANCE_HIGH_CURRENTDAY ="data.performance.highPriority.currentDay" + static final String PERFORMANCE_LOW_CURRENTDAY ="data.performance.lowPriority.currentDay" + static final String PERFORMANCE_UNATTENDED_CURRENTDAY ="data.performance.unattended.currentDay" + static final String PERFORMANCE_UNAUTH_CURRENTDAY ="data.performance.unauthenticated.currentDay" + static final String PERFORMANCE_LARGE_PAYLOAD_CURRENTDAY ="data.performance.largePayload.currentDay" + static final String PERFORMANCE_AGGREGATE_CURRENTDAY ="data.performance.aggregate.currentDay" + static final String AVG_RESPONSE_HIGH_CURRENTDAY ="data.averageResponse.highPriority.currentDay" + static final String AVG_RESPONSE_LOW_CURRENTDAY ="data.averageResponse.lowPriority.currentDay" + static final String AVG_RESPONSE_UNATTENDED_CURRENTDAY ="data.averageResponse.unattended.currentDay" + static final String AVG_RESPONSE_UNAUTH_CURRENTDAY ="data.averageResponse.unauthenticated.currentDay" + static final String AVG_RESPONSE_LARGE_PAYLOAD_CURRENTDAY ="data.averageResponse.largePayload.currentDay" + static final String AVGTPS_AUTHENTICATED_CURRENTDAY ="data.averageTps.authenticated.currentDay" + static final String AVGTPS_UNAUTHENTICATED_CURRENTDAY ="data.averageTps.unauthenticated.currentDay" + static final String AVGTPS_AGGREGATE_CURRENTDAY ="data.averageTps.aggregate.currentDay" + static final String INVOCATION_UNAUTHENTICATED_CURRENTDAY = "data.invocations.unauthenticated.currentDay" + static final String INVOCATION_HIGHPRIORITY_CURRENTDAY = "data.invocations.highPriority.currentDay" + static final String INVOCATION_LOWPRIORITY_CURRENTDAY = "data.invocations.lowPriority.currentDay" + static final String INVOCATION_UNATTENDED_CURRENTDAY = "data.invocations.unattended.currentDay" + static final String INVOCATION_LARGEPAYLOAD_CURRENTDAY = "data.invocations.largePayload.currentDay" + static final String INCORRECT_ACCESS_TOKEN = "95d4d70e-0319-3fea-9532-e199fe72d489" + + static final String ERROR_UNAUTH_CURRENTDAY = "data.errors.unauthenticated.currentDay" + static final String ERROR_AUTH_CURRENTDAY = "data.errors.authenticated.currentDay" + static final String ERROR_AGGREGATE_CURRENTDAY = "data.errors.aggregate.currentDay" + static final String DATA_CUSTOMER_COUNT = "data.customerCount" + static final String DATA_RECIPIENT_COUNT = "data.recipientCount" + static final String DATA_SESSION_COUNT_CURRENTDAY = "data.sessionCount.currentDay" + + static final String CUSTOMER_PRESENT = "customer-present" + static final ABANDON_WAIT_TIME = 78000 + static final AUTH_CODE_EXPIRATION_TIME = 110001 + public static final String CODE_EXPIRE_ERROR_MSG = "Expired or Revoked authorization code received from token request" + public static final String CALLBACK_MISMATCH = "Callback url mismatch" + public static final String LOCALHOST = "localhost" + + public static String REPORTING_DBNAME = "openbank_ob_reporting_statsdb" + public static String UNAUTHENTICATED = "Unauthenticated" + public static String HIGH_PRIORITY = "High Priority" + public static String LOW_PRIORITY = "Low Priority" + public static String UNATTENDED = "Unattended" + public static String LARGE_PAYLOAD = "Large Payload" + public static String REGISTER_PATH = "/register/" + public static String AUTHENTICATED = "authenticated" + public static String AGGREGATE = "aggregate" + static final String AVAILABILITY_UNAUTH_CURRENTMONTH = "data.availability.unauthenticated.currentMonth" + static final String AVAILABILITY_AUTH_CURRENTMONTH = "data.availability.authenticated.currentMonth" + static final String AVAILABILITY_AGG_CURRENTMONTH = "data.availability.aggregate.currentMonth" + + public static final String ERROR_CODE_INVALID_ARRANGEMENT = "urn:au-cds:error:cds-all:Authorisation/InvalidArrangement" + public static final String INVALID_CONSENT_ARRANGEMENT = "Invalid Arrangement ID" + public static TOKEN_ENDPOINT = "/oauth2/token" + + public static MESSAGE = "message" + public static DESCRIPTION = "description" } diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUDOMSStatus.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUDOMSStatus.groovy similarity index 95% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUDOMSStatus.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUDOMSStatus.groovy index 8d5e20c01..21112f76f 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUDOMSStatus.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUDOMSStatus.groovy @@ -16,7 +16,7 @@ * under the License. */ -package com.wso2.cds.test.framework.constant +package org.wso2.cds.test.framework.constant /** * Enum class for keeping AU Disclosure Option Management Service Statuses diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUPageObjects.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUPageObjects.groovy similarity index 99% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUPageObjects.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUPageObjects.groovy index f1cfd1672..bebb38efa 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUPageObjects.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUPageObjects.groovy @@ -16,7 +16,7 @@ * under the License. */ -package com.wso2.cds.test.framework.constant +package org.wso2.cds.test.framework.constant /** * Class for keep automation Page objects diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUPayloads.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUPayloads.groovy similarity index 96% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUPayloads.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUPayloads.groovy index 3622fb7c3..15bc64b53 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/AUPayloads.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/AUPayloads.groovy @@ -1,4 +1,4 @@ -package com.wso2.cds.test.framework.constant +package org.wso2.cds.test.framework.constant class AUPayloads { @@ -245,7 +245,7 @@ class AUPayloads { */ static String getSecondaryUserInstructionPermissionPayload(String secondaryAccountId, String secondaryUserId, String secondaryAccountInstructionStatus = "active", - boolean otherAccountsAvailability = false) { + boolean otherAccountsAvailability = true) { return """ { "data": [ @@ -290,12 +290,6 @@ class AUPayloads { "secondaryUserID": "${secondaryUserId}", "legalEntitySharingStatus": "${sharingStatus}", "legalEntityID": "${legalEntityId}" - }, - { - "accountID": "${accountId2}", - "secondaryUserID": "${secondaryUserId2}", - "legalEntitySharingStatus": "${sharingStatus2}", - "legalEntityID": "${legalEntityId2}" } ] } diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/ContextConstants.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/ContextConstants.groovy similarity index 95% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/ContextConstants.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/ContextConstants.groovy index 34cce1629..84c9b3cba 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/constant/ContextConstants.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/constant/ContextConstants.groovy @@ -16,7 +16,7 @@ * under the License. */ -package com.wso2.cds.test.framework.constant +package org.wso2.cds.test.framework.constant /** * Class for keep constants of tests context diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/data_provider/ConsentDataProviders.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/data_provider/ConsentDataProviders.groovy similarity index 95% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/data_provider/ConsentDataProviders.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/data_provider/ConsentDataProviders.groovy index 81c665d10..68d9c57c1 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/data_provider/ConsentDataProviders.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/data_provider/ConsentDataProviders.groovy @@ -16,11 +16,11 @@ * under the License. */ -package com.wso2.cds.test.framework.data_provider +package org.wso2.cds.test.framework.data_provider + -import com.wso2.cds.test.framework.constant.AUConstants -import org.openqa.selenium.remote.http.HttpMethod import org.testng.annotations.DataProvider +import org.wso2.cds.test.framework.constant.AUConstants /** * Data provide class for Accounts tests diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/keystore/AUKeyStore.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/keystore/AUKeyStore.groovy similarity index 90% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/keystore/AUKeyStore.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/keystore/AUKeyStore.groovy index d5ad75d16..86619489b 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/keystore/AUKeyStore.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/keystore/AUKeyStore.groovy @@ -16,11 +16,11 @@ * under the License. */ -package com.wso2.cds.test.framework.keystore +package org.wso2.cds.test.framework.keystore -import com.wso2.bfsi.test.framework.exception.TestFrameworkException -import com.wso2.openbanking.test.framework.keystore.OBKeyStore -import com.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.bfsi.test.framework.exception.TestFrameworkException +import org.wso2.openbanking.test.framework.keystore.OBKeyStore +import org.wso2.cds.test.framework.configuration.AUConfigurationService import java.security.Key import java.security.KeyStore import java.security.cert.Certificate diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/request_builder/AUAuthorisationBuilder.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/request_builder/AUAuthorisationBuilder.groovy similarity index 78% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/request_builder/AUAuthorisationBuilder.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/request_builder/AUAuthorisationBuilder.groovy index 5c1f9f69b..b30bbae8c 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/request_builder/AUAuthorisationBuilder.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/request_builder/AUAuthorisationBuilder.groovy @@ -16,24 +16,23 @@ * under the License. */ -package com.wso2.cds.test.framework.request_builder +package org.wso2.cds.test.framework.request_builder import com.nimbusds.oauth2.sdk.ResponseMode import com.nimbusds.oauth2.sdk.pkce.CodeChallengeMethod import com.nimbusds.oauth2.sdk.pkce.CodeVerifier -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants import com.nimbusds.oauth2.sdk.AuthorizationRequest import com.nimbusds.oauth2.sdk.ResponseType import com.nimbusds.oauth2.sdk.Scope import com.nimbusds.oauth2.sdk.id.ClientID import com.nimbusds.oauth2.sdk.id.State -import com.wso2.openbanking.test.framework.request_builder.SignedObject -import com.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.openbanking.test.framework.request_builder.SignedObject +import org.wso2.cds.test.framework.configuration.AUConfigurationService import io.restassured.response.Response -import com.wso2.cds.test.framework.utility.AURestAsRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil -import java.nio.charset.Charset +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil /** * Class for AU Authorization handling @@ -160,7 +159,6 @@ class AUAuthorisationBuilder { String assertionString = generator.getClientAssertionJwt(clientId) def bodyContent = [ - (AUConstants.CLIENT_ID_KEY) : (clientId), (AUConstants.CLIENT_ASSERTION_TYPE_KEY): (AUConstants.CLIENT_ASSERTION_TYPE), (AUConstants.CLIENT_ASSERTION_KEY) : assertionString, ] @@ -304,7 +302,7 @@ class AUAuthorisationBuilder { private URI getEndpoint() { if (endpoint == null) { - endpoint = new URI("${auConfiguration.getServerAuthorisationServerURL()}/oauth2/authorize/") + endpoint = new URI("${auConfiguration.getServerAuthorisationServerURL()}/oauth2/authorize") } return endpoint } @@ -546,8 +544,63 @@ class AUAuthorisationBuilder { generator.setSigningAlgorithm(algorithm) } + String signedRequest = generator.getSignedAuthRequestObject(requestObjectClaims).serialize() + if (isStateParamRequired) { + parResponse = AURestAsRequestBuilder.buildRequest() + .contentType(AUConstants.ACCESS_TOKEN_CONTENT_TYPE) + .formParams(bodyContent) + .formParams(AUConstants.REQUEST_KEY, signedRequest) + .baseUri(AUConstants.PUSHED_AUTHORISATION_BASE_PATH) + .post(AUConstants.PAR_ENDPOINT) + } else { + + parResponse = AURestAsRequestBuilder.buildRequest() + .contentType(AUConstants.ACCESS_TOKEN_CONTENT_TYPE) + .formParams(bodyContent) + .formParams(AUConstants.REQUEST_KEY, signedRequest) + .baseUri(AUConstants.PUSHED_AUTHORISATION_BASE_PATH) + .post(AUConstants.PAR_ENDPOINT) + } + + return parResponse + } + + /** + * AU Authorisation Builder for Pushed Authorisation Flow without Client Id in the Request Body. + * @param headerString + * @param scopes + * @param sharingDuration + * @param sendSharingDuration + * @param cdrArrangementId + * @param clientId + * @return + */ + Response doPushAuthorisationRequestWithoutClientId(List scopes, long sharingDuration, + boolean sendSharingDuration, String cdrArrangementId, + String clientId = getClientID().getValue(), + String redirectUrl = getRedirectURI().toString(), + String responseType = getResponseType().toString(), + boolean isStateParamRequired = true, + String responseMode = ResponseMode.JWT, + String state = getState().toString()) { + + Response parResponse + + String assertionString = generator.getClientAssertionJwt(clientId) + + def bodyContent = [ + (AUConstants.CLIENT_ASSERTION_TYPE_KEY): (AUConstants.CLIENT_ASSERTION_TYPE), + (AUConstants.CLIENT_ASSERTION_KEY) : assertionString, + ] + + String requestObjectClaims + + if(isStateParamRequired) { + requestObjectClaims = generator.getRequestObjectClaim(scopes, sharingDuration, sendSharingDuration, + cdrArrangementId, redirectUrl, clientId, responseType, true, state, responseMode) + parResponse = AURestAsRequestBuilder.buildRequest() .contentType(AUConstants.ACCESS_TOKEN_CONTENT_TYPE) .formParams(bodyContent) @@ -556,6 +609,70 @@ class AUAuthorisationBuilder { .post(AUConstants.PAR_ENDPOINT) } else { + requestObjectClaims = generator.getRequestObjectClaim(scopes, sharingDuration, sendSharingDuration, + cdrArrangementId, redirectUrl, clientId, responseType, false, state, responseMode) + + parResponse = AURestAsRequestBuilder.buildRequest() + .contentType(AUConstants.ACCESS_TOKEN_CONTENT_TYPE) + .formParams(bodyContent) + .formParams(AUConstants.REQUEST_KEY, generator.getSignedAuthRequestObject(requestObjectClaims).serialize()) + .baseUri(AUConstants.PUSHED_AUTHORISATION_BASE_PATH) + .post(AUConstants.PAR_ENDPOINT) + } + + return parResponse + } + + /** + * AU Authorisation Builder for Pushed Authorisation Flow with different clientIds in client assertion and request body + * @param headerString + * @param scopes + * @param sharingDuration + * @param sendSharingDuration + * @param cdrArrangementId + * @param clientIdInAssertion + * @param clientIdInRequest + * @return + */ + Response doPushAuthorisationRequestWithDifferentClientIds(List scopes, long sharingDuration, + boolean sendSharingDuration, String cdrArrangementId, + String clientIdInAssertion = getClientID().getValue(), + String clientIdInRequest = getClientID().getValue(), + String redirectUrl = getRedirectURI().toString(), + String responseType = getResponseType().toString(), + boolean isStateParamRequired = true, + String responseMode = ResponseMode.JWT, + String state = getState().toString()) { + + Response parResponse + + String assertionString = generator.getClientAssertionJwt(clientIdInAssertion) + + def bodyContent = [ + (AUConstants.CLIENT_ID_KEY) : (clientIdInRequest), + (AUConstants.CLIENT_ASSERTION_TYPE_KEY): (AUConstants.CLIENT_ASSERTION_TYPE), + (AUConstants.CLIENT_ASSERTION_KEY) : assertionString, + ] + + String requestObjectClaims + + if(isStateParamRequired) { + requestObjectClaims = generator.getRequestObjectClaim(scopes, sharingDuration, sendSharingDuration, + cdrArrangementId, redirectUrl, getClientID().getValue(), responseType, true, + state, responseMode) + + parResponse = AURestAsRequestBuilder.buildRequest() + .contentType(AUConstants.ACCESS_TOKEN_CONTENT_TYPE) + .formParams(bodyContent) + .formParams(AUConstants.REQUEST_KEY, generator.getSignedAuthRequestObject(requestObjectClaims).serialize()) + .baseUri(AUConstants.PUSHED_AUTHORISATION_BASE_PATH) + .post(AUConstants.PAR_ENDPOINT) + } else { + + requestObjectClaims = generator.getRequestObjectClaim(scopes, sharingDuration, sendSharingDuration, + cdrArrangementId, redirectUrl, getClientID().getValue(), responseType, false, + state, responseMode) + parResponse = AURestAsRequestBuilder.buildRequest() .contentType(AUConstants.ACCESS_TOKEN_CONTENT_TYPE) .formParams(bodyContent) diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/request_builder/AUJWTGenerator.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/request_builder/AUJWTGenerator.groovy similarity index 91% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/request_builder/AUJWTGenerator.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/request_builder/AUJWTGenerator.groovy index d5b02dd24..dcde0af64 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/request_builder/AUJWTGenerator.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/request_builder/AUJWTGenerator.groovy @@ -16,7 +16,7 @@ * under the License. */ -package com.wso2.cds.test.framework.request_builder +package org.wso2.cds.test.framework.request_builder import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.ObjectMapper @@ -24,11 +24,10 @@ import com.fasterxml.jackson.databind.node.ObjectNode import com.nimbusds.jwt.JWTClaimsSet import com.nimbusds.oauth2.sdk.AuthorizationRequest import com.nimbusds.oauth2.sdk.ResponseMode -import com.nimbusds.oauth2.sdk.id.ClientID import com.nimbusds.oauth2.sdk.pkce.CodeChallenge import com.nimbusds.oauth2.sdk.pkce.CodeChallengeMethod import com.nimbusds.oauth2.sdk.pkce.CodeVerifier -import com.wso2.bfsi.test.framework.exception.TestFrameworkException +import org.wso2.bfsi.test.framework.exception.TestFrameworkException import com.nimbusds.jose.JOSEObjectType import com.nimbusds.jose.JWSAlgorithm import com.nimbusds.jose.JWSHeader @@ -38,24 +37,20 @@ import com.nimbusds.jose.Payload import com.nimbusds.jose.crypto.RSASSASigner import com.nimbusds.jwt.JWT import com.nimbusds.jwt.SignedJWT -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.utility.AUTestUtil -import com.wso2.openbanking.test.framework.request_builder.JSONRequestGenerator -import com.wso2.openbanking.test.framework.request_builder.PayloadGenerator -import com.wso2.cds.test.framework.configuration.AUConfigurationService -import com.wso2.cds.test.framework.keystore.AUKeyStore -import com.wso2.openbanking.test.framework.keystore.OBKeyStore -import io.restassured.response.Response +import org.wso2.openbanking.test.framework.request_builder.JSONRequestGenerator +import org.wso2.openbanking.test.framework.request_builder.PayloadGenerator +import org.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.openbanking.test.framework.keystore.OBKeyStore import org.apache.commons.lang3.StringUtils import org.bouncycastle.jce.provider.BouncyCastleProvider import org.json.JSONException import org.json.JSONObject import org.testng.Reporter +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.keystore.AUKeyStore -import java.nio.charset.StandardCharsets import java.security.Key -import java.security.MessageDigest import java.security.PrivateKey import java.security.Security import java.security.cert.Certificate @@ -161,6 +156,14 @@ class AUJWTGenerator { return payload } + String getClientAssertionJwtWithoutIAT(String clientId=null) { + JSONObject clientAssertion = new JSONRequestGenerator().addIssuer(clientId) + .addSubject(clientId).addAudience().addExpireDate().addJti().getJsonObject() + + String payload = getSignedRequestObject(clientAssertion.toString()) + return payload + } + /** * Get Client Assertion with customized Issuer and Audience * @param issuer Issuer @@ -249,7 +252,7 @@ class AUJWTGenerator { * @return */ JWT getSignedAuthRequestObjectForStringSharingDuration(String scopeString, String sharingDuration, - String cdrArrangementId, String redirect_uri, String clientId, String responseType, + String cdrArrangementId, String redirect_uri, String clientId, String responseType, String responseMode, CodeChallengeMethod codeChallengeMethod) { //Generate Code Challenge @@ -331,6 +334,7 @@ class AUJWTGenerator { } }) JSONObject authTimeString = new JSONObject().put("essential", true) + JSONObject maxAgeString = new JSONObject().put("essential", true).put("max_age", 86400) JSONObject userInfoString = new JSONObject().put("name", null).put("given_name", null).put("family_name", null).put("updated_at", Instant.now()) JSONObject claimsString = new JSONObject().put("id_token", new JSONObject().put("acr", acr).put("auth_time", authTimeString)) if (sendSharingDuration) { @@ -352,7 +356,7 @@ class AUJWTGenerator { .addScope(scopeString) .addState(state) .addNonce() - .addCustomValue("max_age", 86400) + .addCustomValue("max_age", maxAgeString) .addCustomValue("nbf", notBefore.getEpochSecond().toLong()) .addCustomJson("claims", claimsString) .addCustomValue("response_mode", responseMode) @@ -370,7 +374,7 @@ class AUJWTGenerator { .addRedirectURI(redirect_uri) .addScope(scopeString) .addNonce() - .addCustomValue("max_age", 86400) + .addCustomValue("max_age", maxAgeString) .addCustomValue("nbf", notBefore.getEpochSecond().toLong()) .addCustomJson("claims", claimsString) .addCustomValue("response_mode", responseMode) @@ -457,11 +461,11 @@ class AUJWTGenerator { * @return claimSet */ String getRequestObjectClaimWithMaxAge(List scopes, long sharingDuration, Boolean sendSharingDuration, - String cdrArrangementId, String redirect_uri, String clientId, String responseType, - boolean isStateRequired = true, String state, String responseMode = ResponseMode.JWT, - Instant expiryDate = Instant.now().plus(1, ChronoUnit.HOURS), - Instant notBefore = Instant.now(), - CodeChallengeMethod codeChallengeMethod = CodeChallengeMethod.S256) { + String cdrArrangementId, String redirect_uri, String clientId, String responseType, + boolean isStateRequired = true, String state, String responseMode = ResponseMode.JWT, + Instant expiryDate = Instant.now().plus(1, ChronoUnit.HOURS), + Instant notBefore = Instant.now(), + CodeChallengeMethod codeChallengeMethod = CodeChallengeMethod.S256) { String claims String scopeString = "openid ${String.join(" ", scopes.collect({ it.scopeString }))}" diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/request_builder/AURegistrationRequestBuilder.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/request_builder/AURegistrationRequestBuilder.groovy similarity index 81% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/request_builder/AURegistrationRequestBuilder.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/request_builder/AURegistrationRequestBuilder.groovy index 7d076330a..8b42cb6b6 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/request_builder/AURegistrationRequestBuilder.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/request_builder/AURegistrationRequestBuilder.groovy @@ -16,20 +16,20 @@ * under the License. */ -package com.wso2.cds.test.framework.request_builder +package org.wso2.cds.test.framework.request_builder import com.nimbusds.oauth2.sdk.ResponseType -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.openbanking.test.framework.request_builder.OBRegistrationRequestBuilder -import com.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.openbanking.test.framework.request_builder.OBRegistrationRequestBuilder +import org.wso2.cds.test.framework.configuration.AUConfigurationService import io.restassured.RestAssured import io.restassured.config.EncoderConfig import io.restassured.http.ContentType import io.restassured.specification.RequestSpecification import org.json.JSONArray -import com.wso2.cds.test.framework.utility.AUMockCDRIntegrationUtil -import com.wso2.cds.test.framework.utility.AURestAsRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.utility.AUMockCDRIntegrationUtil +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.constant.AUConstants /** * Class that provides DCR functions for tests @@ -285,6 +285,56 @@ class AURegistrationRequestBuilder extends OBRegistrationRequestBuilder { .addCustomValue("adr_name", "ADR").getClaimsJsonAsString() } + String getRegularClaimsWithInvalidTokenAuthSignAlg() { + return regularClaims.addIssuer(getSoftwareID()).addSoftwareStatement(getSSA()) + .removeKeyValue(AUConstants.RESPONSE_TYPES_KEY).addResponseType(ResponseType.CODE.toString()) + .addTokenEndpointAuthSignAlg("ES512") + .addIDTokenEncResponseAlg().addIDTokenEncResponseEnc() + .getClaimsJsonAsString() + } + + String getClaimsWithInvalidAud() { + return regularClaims.addIssuer(getSoftwareID()).addSoftwareStatement(getSSA()).addIDTokenEncResponseAlg() + .addIDTokenEncResponseEnc().removeKeyValue(AUConstants.RESPONSE_TYPES_KEY).addResponseType(ResponseType.CODE.toString()) + .addAudience("https://obiam:9446/client-registration").getClaimsJsonAsString() + } + + String getRegularClaimsWithoutApplicationType() { + return regularClaims.addIssuer(getSoftwareID()).addSoftwareStatement(getSSA()) + .removeKeyValue(AUConstants.RESPONSE_TYPES_KEY).addResponseType(ResponseType.CODE.toString()) + .addIDTokenEncResponseAlg().addIDTokenEncResponseEnc() + .removeKeyValue(AUConstants.APPLICATION_TYPE_KEY).getClaimsJsonAsString() + } + + String getRegularClaimsWithInvalidRequestObjectSigningAlg() { + return regularClaims.addIssuer(getSoftwareID()).addSoftwareStatement(getSSA()) + .removeKeyValue(AUConstants.RESPONSE_TYPES_KEY).addResponseType(ResponseType.CODE.toString()) + .addIDTokenEncResponseAlg().addIDTokenEncResponseEnc() + .addRequestObjectSigningAlgo("ES512").getClaimsJsonAsString() + } + + String getRegularClaimsWithInvalidIdTokenSigningResponseAlg() { + return regularClaims.addIssuer(getSoftwareID()).addSoftwareStatement(getSSA()) + .removeKeyValue(AUConstants.RESPONSE_TYPES_KEY).addResponseType(ResponseType.CODE.toString()) + .addIDTokenEncResponseAlg().addIDTokenEncResponseEnc() + .addIDTokenSignedResponseAlg("ES512").getClaimsJsonAsString() + } + + String getRegularClaimsWithoutIdTokenSigningResponseAlg() { + return regularClaims.addIssuer(getSoftwareID()).addSoftwareStatement(getSSA()) + .removeKeyValue(AUConstants.RESPONSE_TYPES_KEY).addResponseType(ResponseType.CODE.toString()) + .addIDTokenEncResponseAlg().addIDTokenEncResponseEnc() + .removeKeyValue(AUConstants.ID_TOKEN_SIGNED_RESPONSE_ALG_KEY).getClaimsJsonAsString() + } + + String getExpiredRequestClaims(long date) { + return regularClaims.addIssuer(getSoftwareID()).addSoftwareStatement(getSSA()) + .removeKeyValue(AUConstants.RESPONSE_TYPES_KEY).addResponseType(ResponseType.CODE.toString()) + .addIDTokenEncResponseAlg().addIDTokenEncResponseEnc() + .addExpireDate(date) + .getClaimsJsonAsString() + } + /** * Provide regular payload with Hybrid Response Type for DCR * @return diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/request_builder/AURequestBuilder.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/request_builder/AURequestBuilder.groovy similarity index 79% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/request_builder/AURequestBuilder.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/request_builder/AURequestBuilder.groovy index 93428f65e..790dbe6d4 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/request_builder/AURequestBuilder.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/request_builder/AURequestBuilder.groovy @@ -16,11 +16,9 @@ * under the License. */ -package com.wso2.cds.test.framework.request_builder +package org.wso2.cds.test.framework.request_builder import com.nimbusds.oauth2.sdk.pkce.CodeVerifier -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants import com.nimbusds.jwt.SignedJWT import com.nimbusds.oauth2.sdk.AccessTokenResponse import com.nimbusds.oauth2.sdk.AuthorizationCode @@ -37,16 +35,18 @@ import com.nimbusds.oauth2.sdk.http.HTTPRequest import com.nimbusds.oauth2.sdk.http.HTTPResponse import com.nimbusds.oauth2.sdk.id.ClientID import com.nimbusds.oauth2.sdk.token.RefreshToken -import com.wso2.openbanking.test.framework.request_builder.SignedObject -import com.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.openbanking.test.framework.request_builder.SignedObject +import org.wso2.cds.test.framework.configuration.AUConfigurationService import io.restassured.RestAssured import io.restassured.http.ContentType import io.restassured.response.Response import io.restassured.specification.RequestSpecification import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger -import com.wso2.cds.test.framework.utility.AURestAsRequestBuilder -import com.wso2.cds.test.framework.utility.AUTestUtil +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.utility.AURestAsRequestBuilder +import org.wso2.cds.test.framework.utility.AUTestUtil import java.nio.charset.Charset @@ -59,6 +59,7 @@ class AURequestBuilder { private static Logger log = LogManager.getLogger(AURequestBuilder.class.getName()) private static AUConfigurationService auConfiguration = new AUConfigurationService() + static AUAuthorisationBuilder auAuthorisationBuilder = new AUAuthorisationBuilder() /** * Method for get application access token @@ -93,7 +94,7 @@ class AURequestBuilder { auJwtGenerator.setScopes(scopes) String jwt = auJwtGenerator.getUserAccessTokenJwt(code) - RestAssured.baseURI = auConfiguration.getServerBaseURL() + RestAssured.baseURI = auConfiguration.getServerAuthorisationServerURL() Response response = AURestAsRequestBuilder.buildRequest().contentType(AUConstants.ACCESS_TOKEN_CONTENT_TYPE) .body(jwt) .post(AUConstants.TOKEN_ENDPOINT) @@ -109,6 +110,7 @@ class AURequestBuilder { return AURestAsRequestBuilder.buildRequest() .header(AUConstants.X_V_HEADER, xv_header) + .header(AUConstants.X_FAPI_AUTH_DATE, AUConstants.DATE) .header(AUConstants.AUTHORIZATION_HEADER_KEY, "${AUConstants.AUTHORIZATION_BEARER_TAG}${userAccessToken}") } @@ -133,6 +135,7 @@ class AURequestBuilder { return AURestAsRequestBuilder.buildRequest() .header(AUConstants.X_V_HEADER, xv_header) .header(AUConstants.AUTHORIZATION_HEADER_KEY, "${AUConstants.AUTHORIZATION_BEARER_TAG}${userAccessToken}") + .header(AUConstants.X_FAPI_CUSTOMER_IP_ADDRESS , AUConstants.IP) .header(AUConstants.X_FAPI_AUTH_DATE, authDate) .header(AUConstants.X_CDS_CLIENT_HEADERS , clientHeader) } @@ -198,7 +201,6 @@ class AURequestBuilder { } - /** * Get User Access Token From Authorization Code and optional scopes list. * @@ -252,10 +254,11 @@ class AURequestBuilder { String client_id = auConfiguration.getAppInfoClientID(), Boolean clientAuthRequired = true, Boolean mtlsRequired = true, - String signingAlg = auConfiguration.getCommonSigningAlgorithm()) { + String signingAlg = auConfiguration.getCommonSigningAlgorithm(), + CodeVerifier verifier = auAuthorisationBuilder.getCodeVerifier()) { AuthorizationCode grant = new AuthorizationCode(code) URI callbackUri = new URI(redirectUrl) - AuthorizationGrant codeGrant = new AuthorizationCodeGrant(grant, callbackUri) + AuthorizationGrant codeGrant = new AuthorizationCodeGrant(grant, callbackUri, verifier) URI tokenEndpoint = new URI("${auConfiguration.getServerAuthorisationServerURL()}${AUConstants.TOKEN_ENDPOINT}") @@ -471,8 +474,101 @@ class AURequestBuilder { def response = AURestAsRequestBuilder.buildRequest() .contentType(AUConstants.ACCESS_TOKEN_CONTENT_TYPE) .formParams(bodyContent) - .baseUri(auConfiguration.getServerBaseURL()) + .baseUri(auConfiguration.getServerAuthorisationServerURL()) .post("${AUConstants.CDR_ARRANGEMENT_ENDPOINT}") return response } + + /** + * Build Introspection Request for Revoke Access Token without Client Id param in request body + * + * @param token access token + * @return Introspection Request Specification + */ + static RequestSpecification buildRevokeTokenWithoutClientIdParam(String token, String clientId) { + + String assertionString = new SignedObject().getJwt(clientId) + + def bodyContent = [ + (AUConstants.CLIENT_ASSERTION_TYPE_KEY): (AUConstants.CLIENT_ASSERTION_TYPE), + (AUConstants.CLIENT_ASSERTION_KEY) : assertionString] + + + return AURestAsRequestBuilder.buildRequest() + .contentType(ContentType.URLENC) + .formParams(bodyContent) + .formParams("token", token) + .formParams("token_type_hint", "access_token") + .baseUri(auConfiguration.getServerAuthorisationServerURL()) + } + + /** + * Build Introspection Request without ClientId Param in request body + * + * @param token access token + * @return Introspection Request Specification + */ + static RequestSpecification buildIntrospectionWithoutClientIdParam(String token, String clientId, Integer tpp = null) { + + String assertionString = new SignedObject().getJwt(clientId) + + def bodyContent = [ + (AUConstants.CLIENT_ASSERTION_TYPE_KEY): (AUConstants.CLIENT_ASSERTION_TYPE), + (AUConstants.CLIENT_ASSERTION_KEY) : assertionString] + + return AURestAsRequestBuilder.buildRequest() + .contentType(ContentType.URLENC) + .header(AUConstants.AUTHORIZATION_HEADER_KEY, "Basic ${AUTestUtil.getBasicAuthorizationHeader(tpp)}") + .formParams(bodyContent) + .formParams("token", token) + .baseUri(auConfiguration.getServerAuthorisationServerURL()) + } + + /** + * Get User Access Token From Authorization Code. + * @param code authorisation code + * @param codeVerifier code verifier + * @param clientId client id + * @param redirectUrl application redirect url + * @return user access token + */ + static TokenResponse getUserTokenWithClientIdInReqBody(String code, CodeVerifier codeVerifier, + String clientIdInAssertion = auConfiguration.getAppInfoClientID(), + String clientIdInReqBody = auConfiguration.getAppInfoClientID(), + String redirectUrl = auConfiguration.getAppInfoRedirectURL() + ) { + + AuthorizationCode grant = new AuthorizationCode(code) + URI callbackUri = new URI(redirectUrl) + AuthorizationGrant codeGrant = new AuthorizationCodeGrant(grant, callbackUri, codeVerifier) + + String assertionString = new SignedObject().getJwt(clientIdInAssertion) + + ClientAuthentication clientAuth = new PrivateKeyJWT(SignedJWT.parse(assertionString)) + + URI tokenEndpoint = new URI("${auConfiguration.getServerAuthorisationServerURL()}${AUConstants.TOKEN_ENDPOINT}") + + TokenRequest request = new TokenRequest(tokenEndpoint, clientAuth, codeGrant) + + HTTPRequest httpRequest = request.toHTTPRequest() + + ClientID clientIdReqBody = new ClientID(clientIdInReqBody) + + // Manually add the client_id to the HTTPRequest query parameters + String originalQuery = httpRequest.getQuery() + String newQuery = originalQuery + "&client_id=" + clientIdReqBody.getValue() + httpRequest.setQuery(newQuery) + + def response = AURestAsRequestBuilder.buildRequest() + .contentType(AUConstants.ACCESS_TOKEN_CONTENT_TYPE) + .body(httpRequest.query) + .post(tokenEndpoint) + + HTTPResponse httpResponse = new HTTPResponse(response.statusCode()) + httpResponse.setContentType(response.contentType()) + httpResponse.setContent(response.getBody().print()) + + return TokenResponse.parse(httpResponse) + + } } diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AUIdEncryptorDecryptor.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AUIdEncryptorDecryptor.groovy similarity index 98% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AUIdEncryptorDecryptor.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AUIdEncryptorDecryptor.groovy index 46488da73..79aba7ba5 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AUIdEncryptorDecryptor.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AUIdEncryptorDecryptor.groovy @@ -16,7 +16,7 @@ * under the License. */ -package com.wso2.cds.test.framework.utility +package org.wso2.cds.test.framework.utility import javax.crypto.Cipher import javax.crypto.spec.SecretKeySpec diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AUMockCDRIntegrationUtil.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AUMockCDRIntegrationUtil.groovy similarity index 97% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AUMockCDRIntegrationUtil.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AUMockCDRIntegrationUtil.groovy index cc7566695..bb525a7de 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AUMockCDRIntegrationUtil.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AUMockCDRIntegrationUtil.groovy @@ -16,16 +16,17 @@ * under the License. */ -package com.wso2.cds.test.framework.utility +package org.wso2.cds.test.framework.utility + -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.cds.test.framework.configuration.AUConfigurationService import groovy.json.JsonOutput import groovy.json.JsonSlurper import io.restassured.RestAssured import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.Logger import org.testng.Assert +import org.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.cds.test.framework.constant.AUConstants /** * The util class to invoke the Mock CDR Registration endpoints diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AURestAsRequestBuilder.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AURestAsRequestBuilder.groovy similarity index 89% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AURestAsRequestBuilder.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AURestAsRequestBuilder.groovy index 38f90ba60..0753acf69 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AURestAsRequestBuilder.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AURestAsRequestBuilder.groovy @@ -16,18 +16,19 @@ * under the License. */ -package com.wso2.cds.test.framework.utility +package org.wso2.cds.test.framework.utility -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.bfsi.test.framework.exception.TestFrameworkException -import com.wso2.openbanking.test.framework.configuration.OBConfigurationService -import com.wso2.openbanking.test.framework.utility.RestAsRequestBuilder + +import org.wso2.bfsi.test.framework.exception.TestFrameworkException +import org.wso2.openbanking.test.framework.configuration.OBConfigurationService +import org.wso2.openbanking.test.framework.utility.RestAsRequestBuilder import io.restassured.RestAssured import io.restassured.config.EncoderConfig import io.restassured.config.RestAssuredConfig import io.restassured.http.ContentType import io.restassured.specification.RequestSpecification import org.apache.http.conn.ssl.SSLSocketFactory +import org.wso2.cds.test.framework.constant.AUConstants /** * AU Class for provide Basic Rest-assured Request Objects diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AUSSLSocketFactoryCreator.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AUSSLSocketFactoryCreator.groovy similarity index 93% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AUSSLSocketFactoryCreator.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AUSSLSocketFactoryCreator.groovy index 0246ac481..e863508dd 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AUSSLSocketFactoryCreator.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AUSSLSocketFactoryCreator.groovy @@ -16,10 +16,10 @@ * under the License. */ -package com.wso2.cds.test.framework.utility +package org.wso2.cds.test.framework.utility -import com.wso2.bfsi.test.framework.exception.TestFrameworkException -import com.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.bfsi.test.framework.exception.TestFrameworkException +import org.wso2.cds.test.framework.configuration.AUConfigurationService import org.apache.http.conn.ssl.SSLSocketFactory import java.security.KeyManagementException diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AUTestUtil.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AUTestUtil.groovy similarity index 76% rename from integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AUTestUtil.groovy rename to integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AUTestUtil.groovy index a1a6d3689..4ebae24c5 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/com/wso2/cds/test/framework/utility/AUTestUtil.groovy +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/AUTestUtil.groovy @@ -16,33 +16,30 @@ * under the License. */ -package com.wso2.cds.test.framework.utility +package org.wso2.cds.test.framework.utility import com.google.gson.Gson import com.google.gson.JsonArray import com.google.gson.JsonElement import com.google.gson.JsonObject -import com.nimbusds.oauth2.sdk.pkce.CodeVerifier -import com.wso2.cds.test.framework.constant.AUAccountProfile -import com.wso2.cds.test.framework.constant.AUAccountScope -import com.wso2.cds.test.framework.constant.AUConstants -import com.wso2.bfsi.test.framework.exception.TestFrameworkException -import com.wso2.cds.test.framework.constant.AUPageObjects -import com.wso2.cds.test.framework.request_builder.AUAuthorisationBuilder -import com.wso2.cds.test.framework.request_builder.AUJWTGenerator -import com.wso2.openbanking.test.framework.utility.OBTestUtil -import com.wso2.cds.test.framework.configuration.AUConfigurationService +import org.wso2.bfsi.test.framework.exception.TestFrameworkException +import org.wso2.cds.test.framework.request_builder.AUAuthorisationBuilder +import org.wso2.cds.test.framework.request_builder.AUJWTGenerator +import org.wso2.openbanking.test.framework.utility.OBTestUtil +import org.wso2.cds.test.framework.configuration.AUConfigurationService import org.apache.http.conn.ssl.SSLSocketFactory import org.jsoup.nodes.Document import org.jsoup.nodes.Element import org.testng.Assert import io.restassured.response.Response import org.jsoup.Jsoup +import org.wso2.cds.test.framework.constant.AUAccountProfile +import org.wso2.cds.test.framework.constant.AUAccountScope +import org.wso2.cds.test.framework.constant.AUConstants +import org.wso2.cds.test.framework.constant.AUPageObjects -import java.nio.charset.StandardCharsets import java.nio.file.Path import java.nio.file.Paths -import java.security.MessageDigest /** * Domain specific AU layer Class to contain utility classes used for Test Framework. @@ -386,7 +383,7 @@ class AUTestUtil extends OBTestUtil { } return legalEntityIds } - + /** * Read Attributes from HTML Document * @param htmlDocumentBody @@ -450,7 +447,8 @@ class AUTestUtil extends OBTestUtil { * @return AccountXPath */ static String getUnavailableAccountsXPath(String accountNumber) { - return AUPageObjects.LBL_UNAVAILABLE_ACCOUNT + "div[@id='${accountNumber}']" + String lastFourDigits = accountNumber.substring(accountNumber.length() - 4) + return AUPageObjects.LBL_UNAVAILABLE_ACCOUNT + "div[contains(@id,'${lastFourDigits}')]" } /** @@ -521,5 +519,113 @@ class AUTestUtil extends OBTestUtil { writeXMLContent(configFilePath, "Application", "ClientID", clientId, auConfiguration.getTppNumber()) } + /** + * Get the Hostname from Configuration + * @return hostname + */ + static String getHostname() { + + try { + URL url = new URL(auConfiguration.getServerBaseURL()) + return url.getHost() + + } catch (MalformedURLException e) { + System.err.println("Invalid URL: " + e.getMessage()) + } + } + + /** + * Parse Key Value Pair from string array. + * @param keyValuePairsString + * @return keyValuePairs + */ + static List parseKeyValuePairs(String keyValuePairsString) { + + List keyValuePairs = new ArrayList<>() + + // Remove leading and trailing brackets, then split by comma + String[] pairs = keyValuePairsString.substring(1, keyValuePairsString.length() - 1).split(", ") + + for (String pair : pairs) { + keyValuePairs.add(pair.trim()) + } + return keyValuePairs + } + + /** + * Get the tier of a particular request. + * @param resourcePath + * @param customerStatus + * @return tier + */ + static String getPriorityTier(String resourcePath, String customerStatus){ + + def highPriorityResources = ["/discovery/status", "/discovery/outages", + "/register", + "/register/{ClientId}", "/", "/token", "/authorize", "/revoke", "/userinfo", + "/introspect", "/jwks", "/.well-known/openid-configuration"] + def commonResources = ["/common/customer", "/common/customer/detail"] + def accountsResources = ["/banking/accounts"] + + def lowPriorityResources = ["/banking/accounts/{accountId}", "/banking/accounts/{accountId}/balance", + "/banking/accounts/balances", "/banking/accounts/{accountId}/transactions", + "/banking/accounts/{accountId}/transactions/{transactionId}", "/banking/payees", + "/banking/payees/{payeeId}", "/banking/accounts/{accountId}/direct-debits", + "/banking/accounts/{accountId}/payments/scheduled", "/banking/payments/scheduled"] + + def unattendedList = [ "/register/metadata", "/metrics"] + def largePayloadList = ["/banking/accounts/direct-debits"] + def unauthenticatedList = ["/banking/products", "/banking/products/{productId}"] + + if (highPriorityResources.contains(resourcePath) || + (customerStatus.equalsIgnoreCase(AUConstants.CUSTOMER_PRESENT) && commonResources.contains(resourcePath)) || + (customerStatus.equalsIgnoreCase(AUConstants.CUSTOMER_PRESENT) && accountsResources.contains(resourcePath))) { + return AUConstants.HIGH_PRIORITY + + } else if(lowPriorityResources.contains(resourcePath) && + customerStatus.equalsIgnoreCase(AUConstants.CUSTOMER_PRESENT)) { + return AUConstants.LOW_PRIORITY + + } else if((unattendedList.contains(resourcePath)) || + (customerStatus.equalsIgnoreCase(AUConstants.UNATTENDED) && accountsResources.contains(resourcePath)) || + (customerStatus.equalsIgnoreCase(AUConstants.UNATTENDED) && commonResources.contains(resourcePath)) || + (customerStatus.equalsIgnoreCase(AUConstants.UNATTENDED) && lowPriorityResources.contains(resourcePath))) { + return AUConstants.UNATTENDED + + } else if (largePayloadList.contains(resourcePath)) { + return AUConstants.LARGE_PAYLOAD + + } else if (unauthenticatedList.contains(resourcePath)) { + return AUConstants.UNAUTHENTICATED + } + } + + /** + * Get Authenticated and Unauthenticated Resources + * @param resourcePath + * @return relevant tier for resource + */ + static String getAuthenticatedResources(String resourcePath){ + + def authenticatedList = ["/register", "/register/{ClientId}", "/", "/token", "/authorize", "/revoke", + "/userinfo", "/introspect", "/jwks", "/common/customer", "/common/customer/detail", + "/banking/accounts", "/banking/accounts/{accountId}", "/banking/accounts/{accountId}/balance", + "/banking/accounts/balances", "/banking/accounts/{accountId}/transactions", + "/banking/accounts/{accountId}/transactions/{transactionId}", "/banking/payees", + "/banking/payees/{payeeId}", "/banking/accounts/{accountId}/direct-debits", + "/banking/accounts/{accountId}/payments/scheduled", "/banking/payments/scheduled", + "/register/metadata", "/metrics", "/banking/accounts/direct-debits"] + + def unauthenticatedList = ["/banking/products", "/banking/products/{productId}", + "/discovery/status", "/discovery/outages"] + + if (authenticatedList.contains(resourcePath)) { + return AUConstants.AUTHENTICATED + + } else if(unauthenticatedList.contains(resourcePath)) { + return AUConstants.UNAUTHENTICATED + + } + } } diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/DbConnection.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/DbConnection.groovy new file mode 100644 index 000000000..0995101a3 --- /dev/null +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/DbConnection.groovy @@ -0,0 +1,162 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.test.framework.utility + +import org.wso2.cds.test.framework.configuration.AUConfigurationService + +import java.lang.reflect.InvocationTargetException +import java.sql.Connection +import java.sql.DriverManager +import java.sql.ResultSet +import java.sql.SQLException +import java.sql.Statement + +import static java.lang.System.err +import static java.lang.System.exit + +/** + * Class contains methods for DB Connections. + */ +class DbConnection { + + static Statement stmt; + static Connection con; + static String dbUrl; + static int metricsValue; + static AUConfigurationService auConfiguration = new AUConfigurationService(); + + /** + * Method to connect with DataBase. + * @param databaseName - Name of the Database + * @return Statement object to send the SQL statement to the Database + */ + public static Statement dbConnection (String databaseName) { + try { + String dbUrl = generateDbUrl(databaseName); + String username = auConfiguration.getDbUsername(); + String password = auConfiguration.getDbPassword(); + String driverClass = auConfiguration.getDbDriverClass(); + + // Database connection + String dbClass = driverClass; + Class.forName(dbClass).getDeclaredConstructor().newInstance(); + + // Get connection to DB + con = DriverManager.getConnection(dbUrl, username, password); + + // Statement object to send the SQL statement to the Database + stmt = con.createStatement(); + + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (SQLException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + + return stmt; + } + + /** + * Method to retrieve records from a particular database. + * @param databaseName + * @param query + * @return query response + */ + public static Object[][] executeSelectQuery(String databaseName, String query) { + + List resultList = new ArrayList<>(); + + //Create DB Connection + dbConnection(databaseName); + + try { + // Execute a query + ResultSet resultSet = stmt.executeQuery(query); + + // Get the number of columns in the result set + int columnCount = resultSet.getMetaData().getColumnCount(); + + // Iterate through the result set and generate the list + while (resultSet.next()) { + Object[] row = new Object[columnCount]; + for (int i = 1; i <= columnCount; i++) { + row[i - 1] = resultSet.getObject(i); + } + resultList.add(row); + } + + // Convert the list to a 2D array + Object[][] resultArray = new Object[resultList.size()][columnCount]; + for (int i = 0; i < resultList.size(); i++) { + resultArray[i] = resultList.get(i); + } + + // Close the result set and connection + stmt.close(); + con.close(); + return resultArray; + + } catch (SQLException ex) { + err.println("Transaction rollback with error: " + ex); + exit(0); + return null; + } + } + + /** + * Generate DB URL based on the provided DB Type. + * @param databaseName Database + * @return dbUrl + */ + public static String generateDbUrl(String databaseName) { + + String dbType = auConfiguration.getDbType(); + String dbServerHost = auConfiguration.getDbServerHost(); + + switch (dbType) { + case "MySQL": + case "mysql": + dbUrl = "jdbc:mysql://" + dbServerHost + ":3306/" + databaseName + "?autoReconnect=true&&useSSL=false"; + break; + case "MSSQL": + case "mssql": + dbUrl = "jdbc:sqlserver://" + dbServerHost + ":1433;databaseName=" + databaseName + ";encrypt=false"; + break; + case "Oracle": + case "oracle": +// dbUrl = "jdbc:oracle:thin:@" + dbServerHost + ":1521/" + auConfiguration.getOracleDbSid() + ""; + break; + case "PostgreSQL": + case "postgresql": + dbUrl = "jdbc:postgresql://" + dbServerHost + ":5432/" + databaseName + ""; + break; + default: + throw new IllegalStateException("Unexpected value: " + dbType); + } + return dbUrl; + } +} diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/SqlQuery.groovy b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/SqlQuery.groovy new file mode 100644 index 000000000..e24ad53bf --- /dev/null +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/groovy/org/wso2/cds/test/framework/utility/SqlQuery.groovy @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.cds.test.framework.utility + +import org.wso2.cds.test.framework.configuration.AUConfigurationService + +/** + * Class contains the SQL queries related to testing. + */ +class SqlQuery { + + /** + * Retrieve Records from API_INVOCATION_RAW_DATA Within Specified Period. + * @param executionStartTime + * @param executionEndTime + * @return results set + */ + static String retrieveRecordsWithinSpecifiedPeriod(long executionStartTime, long executionEndTime) { + + AUConfigurationService auConfiguration = new AUConfigurationService() + String dbType = auConfiguration.getDbType() + def query + + switch (dbType) { + case "MySQL": + case "mysql": + query = "SELECT alr.RESPONSE_LATENCY as RESPONSE_TIME, api.ELECTED_RESOURCE, api.STATUS_CODE, api.CUSTOMER_STATUS \n" + + "FROM openbank_ob_reporting_statsdb.API_INVOCATION_RAW_DATA api, " + + "openbank_ob_reporting_statsdb.API_LATENCY_RAW_DATA alr\n" + + "WHERE api.MESSAGE_ID = alr.MESSAGE_ID AND api.`TIMESTAMP` BETWEEN \"$executionStartTime\" " + + "AND \"$executionEndTime\" \n" + + "ORDER BY api.`TIMESTAMP` DESC;" + break + default: + throw new IllegalStateException("Unexpected value: " + dbType) + break + } + return query + } + + /** + * Outage Details from SERVER_OUTAGES_RAW_DATA. + * @param outageStartTime + * @param outageEndTime + * @return results set + */ + static String retrieveOutageDetails(long outageStartTime, long outageEndTime) { + + AUConfigurationService auConfiguration = new AUConfigurationService() + String dbType = auConfiguration.getDbType() + def query + + switch (dbType) { + case "MySQL": + case "mysql": + query = "SELECT x.TYPE, x.ASPECT, x.TIME_TO - x.TIME_FROM as OUTAGE_TIME \n" + + "FROM openbank_ob_reporting_statsdb.SERVER_OUTAGES_RAW_DATA x \n" + + "WHERE x.TIME_TO BETWEEN \"$outageStartTime\" AND \"$outageEndTime\" " + + "ORDER BY x.TIME_FROM DESC;" + break + default: + throw new IllegalStateException("Unexpected value: " + dbType) + break + } + return query + } +} diff --git a/integration-test-suite/cds-toolkit-test-framework/src/main/resources/TestConfigurationExample.xml b/integration-test-suite/cds-toolkit-test-framework/src/main/resources/TestConfigurationExample.xml index 7d9f84a78..b0c78a217 100644 --- a/integration-test-suite/cds-toolkit-test-framework/src/main/resources/TestConfigurationExample.xml +++ b/integration-test-suite/cds-toolkit-test-framework/src/main/resources/TestConfigurationExample.xml @@ -71,11 +71,11 @@ - AppConfig1.KeyStore.Location - + AppConfig1.KeyStore.Alias @@ -84,7 +84,7 @@ AppConfig1.KeyStore.DomainName - + AppConfig1.KeyStore.SigningKid @@ -98,7 +98,7 @@ - AppConfig1.Transport.KeyStore.Location @@ -112,12 +112,12 @@ - AppConfig1.DCR.SSAPath - + DCR.SoftwareId @@ -144,11 +144,11 @@ - AppConfig2.KeyStore.Location - + AppConfig2.KeyStore.Alias @@ -157,7 +157,7 @@ AppConfig2.KeyStore.DomainName - + AppConfig2.KeyStore.SigningKid @@ -170,7 +170,7 @@ true--> - @@ -183,12 +183,12 @@ - AppConfig2.DCR.SSAPath - + DCR.SoftwareId @@ -321,15 +321,15 @@ BrowserAutomation.BrowserPreference BrowserAutomation.HeadlessEnabled - + BrowserAutomation.WebDriverLocation - + ConsentApi.AudienceValue - + ConsentApi.RevocationAudienceValue @@ -429,4 +429,23 @@ ProfileSelection.Enabled + + + DataBaseConfiguration.DBType + + DataBaseConfiguration.DBServerHost + + DataBaseConfiguration.DBUsername + + DataBaseConfiguration.DBPassword + + + + + DataBaseConfiguration.DBDriverClass + + + DataBaseConfiguration.OracleDBSID + + diff --git a/integration-test-suite/pom.xml b/integration-test-suite/pom.xml index 8d7f03541..63dcba416 100644 --- a/integration-test-suite/pom.xml +++ b/integration-test-suite/pom.xml @@ -22,7 +22,7 @@ 4.0.0 org.wso2.openbanking integration-test-suite - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT pom @@ -79,9 +79,9 @@ ${org.testng.version} - com.wso2 + org.wso2 open-banking-test-framework - ${com.wso2.openbanking.test} + ${org.wso2.openbanking.test} compile @@ -212,6 +212,11 @@ java-jwt ${com.auth0.version} + + mysql + mysql-connector-java + 5.1.49 + @@ -349,7 +354,7 @@ 31.0.1-jre 4.2.3 9.35 - 1.0.0 + 4.0.0-SNAPSHOT 2.8.9 1.15.4 3.18.0 diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/README.md b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/README.md new file mode 100644 index 000000000..686067101 --- /dev/null +++ b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/README.md @@ -0,0 +1,30 @@ +#Using Sample Resources + +Following configs can be used in test-config.xml to use sample SSA and keystores for DCR tests. + + + Path.To.Directory/ssa.txt + + jFQuQ4eQbNCMSqdCog21nF + + https://www.google.com/redirects/redirect1 + + +SoftwareId of App Config 2 - SP1 + +Use signing.jks in 'signing-keystore' directory as the Application Keystore, and transport.jks in 'transport-keystore' +directory as the Transport Keystore. + +Sample Keystore information: + +- Signing Kid = 7eJ8S_ZgvlYxFAFSghV9xMJROvk + +- Signing keystore alias = tpp7-signing + +- Signing keystore password = wso2carbon + +- Transport Kid - 7x6UrhU-Yj1Aa9Ird03JJCcDurs + +- Transport keystore alias = tpp7-transport + +- Transport keystore password = wso2carbon \ No newline at end of file diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/signing-keystore/signing.jks b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/signing-keystore/signing.jks new file mode 100644 index 000000000..87b936726 Binary files /dev/null and b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/signing-keystore/signing.jks differ diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/signing-keystore/signing.key b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/signing-keystore/signing.key new file mode 100644 index 000000000..1c497f458 --- /dev/null +++ b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/signing-keystore/signing.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCot+hw9Ka8dTd6 +X2nyXOqUjINItIzokK7flmehqYSlIQNia2wcVk72m19UO4Yn5eVG5ATpJ590gsqg +aZT0qpLGC3T0nJG9ie1FS4++ju0ZBC6BQ/r0q0PBVhJ/JV7+FIkvMpb5ayD2vPqV +bQMDriN/2BZqgdZXB4ASPBBCw1Fh10qdzoZHCo65u+rdbEM9LbJouWh2UdxV29HQ +AkDvnRmpCHq6s1JgHXHC7VrkiTE/m+3OyAw5vyEfzFe4qJdOMngZDpVq3iCjqh1N +ejyNzfz0jBLfeiQFCmf59FQtMeGB2gWA19u7H+Bsqbm4JpHHeCGxv/FxLh6tyJPO +KBKT+UBFAgMBAAECggEAAw2g9TpYMhzk7h//6NTpodqRHaW2zxafM4ijQ3ev4NUi +HIvZHwIo16mkJgAVw28ToR7LP/Tpm9AqHpEKkwrrMQ5QBYU31fhDBPgDF+26OLOs +q8YxKnBW/46xMv/YIjz45pPBy622oQB2gHHCljR2i/+7GB5VZKnMFYhkuvCR7nVR +bHaOdISM9fyzJBkUY5pVkCqvAdSQGoLKubAAuHN/wzVevowmCwOluED3+kliOhma +9UccRWlprTsWbMenIZKY8lJmiA0bOGrkyCVz23780bVB/gFpeCNsYjUrLwazAfbI +wKpsdgxOrVsaluaFWZ7TQtgSXvZWCtHfpvbz5yQOAQKBgQDMceH3gLpV5/uZdulI +84aVrXREkWN0AVCM1PHhtAocom/+Dvu+L1qNDtT2iPzH95gKhRwk4NA+ag4Ycns9 +HZkTQbwMOuybC7BvrLI0vnQfTkyiAjUownRJSgZfo7vYt7Ap88jgBhsGd4XmvEbO +SYwyCuXCeZvYLPhDT3MkrKgbhQKBgQDTQ6wJJYCva/FJ46huRL93tnfT6xFjyAwU +9UttYYRDrCANTyPPFTL6T1welRpUq8ZbitgI6FOrUCC/80X6hNcD8O8PWXcTS4oK +OEIzo5EOSB6yNeWwPaUd50i+iDD0W0K94dmj+DLjGJY8wA8yaLr2oWJW5GyAGhYm +AdBe/VfNwQKBgQC1jCeiVrChWpjFBaBRhNetkNMflI/hUs2J0gtdZzhXhzO2Qu3w +TDK38kTRDIKUvFxKczuzz+N8mUcdFIQ1mFP3krb/kU/MuwuZj5zMU5fguPI6J4W3 +RT5oWpDgWxCTeUK5bl+h+CoFixvf8q9Zvlv9kEnJcZ4f0IdBlorkNWIu1QKBgQCh +PZ344SGlQWpILbQobNoBYUd1e4yrLkxiVpD565qKF73iyosXCyP8PUOep8gP5Yaf +6YlWyxLIxoAoYGEBgg+lF2ctvOeP13CEukl0phsY3lxnQZGLgJEcEKDJoqJSbbCz +wcNdTRpxjxtjRGaU37AKekPW88IHx2EuIuZJCWzRQQKBgFE8vbLbSYxFIE1uhast +2/9WFblB2Mrxsr2HFMW7xwOPmeh7H2+zZ2ZS7rVls1jC6e25SgnPyF/FItPrNCmW +7EFzv73oRhMxGS6LImFQtTLqNAUl0Msmpheaxgcb6bM6Gns1co8bEykoaFRdhmHR +kcoyjehtpocckAWTrtW7gPcl +-----END PRIVATE KEY----- diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/signing-keystore/signing.pem b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/signing-keystore/signing.pem new file mode 100644 index 000000000..0ebf69a67 --- /dev/null +++ b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/signing-keystore/signing.pem @@ -0,0 +1,30 @@ +-----BEGIN CERTIFICATE----- +MIIFLTCCBBWgAwIBAgIEWcbiiDANBgkqhkiG9w0BAQsFADBTMQswCQYDVQQGEwJH +QjEUMBIGA1UEChMLT3BlbkJhbmtpbmcxLjAsBgNVBAMTJU9wZW5CYW5raW5nIFBy +ZS1Qcm9kdWN0aW9uIElzc3VpbmcgQ0EwHhcNMjMxMTE1MDUxMDA4WhcNMjQxMjE1 +MDU0MDA4WjBhMQswCQYDVQQGEwJHQjEUMBIGA1UEChMLT3BlbkJhbmtpbmcxGzAZ +BgNVBAsTEjAwMTU4MDAwMDFIUVFyWkFBWDEfMB0GA1UEAxMWakZRdVE0ZVFiTkNN +U3FkQ29nMjFuRjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKi36HD0 +prx1N3pfafJc6pSMg0i0jOiQrt+WZ6GphKUhA2JrbBxWTvabX1Q7hifl5UbkBOkn +n3SCyqBplPSqksYLdPSckb2J7UVLj76O7RkELoFD+vSrQ8FWEn8lXv4UiS8ylvlr +IPa8+pVtAwOuI3/YFmqB1lcHgBI8EELDUWHXSp3OhkcKjrm76t1sQz0tsmi5aHZR +3FXb0dACQO+dGakIerqzUmAdccLtWuSJMT+b7c7IDDm/IR/MV7iol04yeBkOlWre +IKOqHU16PI3N/PSMEt96JAUKZ/n0VC0x4YHaBYDX27sf4Gypubgmkcd4IbG/8XEu +Hq3Ik84oEpP5QEUCAwEAAaOCAfkwggH1MA4GA1UdDwEB/wQEAwIGwDAVBgNVHSUE +DjAMBgorBgEEAYI3CgMMMIHgBgNVHSAEgdgwgdUwgdIGCysGAQQBqHWBBgFkMIHC +MCoGCCsGAQUFBwIBFh5odHRwOi8vb2IudHJ1c3Rpcy5jb20vcG9saWNpZXMwgZMG +CCsGAQUFBwICMIGGDIGDVXNlIG9mIHRoaXMgQ2VydGlmaWNhdGUgY29uc3RpdHV0 +ZXMgYWNjZXB0YW5jZSBvZiB0aGUgT3BlbkJhbmtpbmcgUm9vdCBDQSBDZXJ0aWZp +Y2F0aW9uIFBvbGljaWVzIGFuZCBDZXJ0aWZpY2F0ZSBQcmFjdGljZSBTdGF0ZW1l +bnQwbQYIKwYBBQUHAQEEYTBfMCYGCCsGAQUFBzABhhpodHRwOi8vb2IudHJ1c3Rp +cy5jb20vb2NzcDA1BggrBgEFBQcwAoYpaHR0cDovL29iLnRydXN0aXMuY29tL29i +X3BwX2lzc3VpbmdjYS5jcnQwOgYDVR0fBDMwMTAvoC2gK4YpaHR0cDovL29iLnRy +dXN0aXMuY29tL29iX3BwX2lzc3VpbmdjYS5jcmwwHwYDVR0jBBgwFoAUUHORxiFy +03f0/gASBoFceXluP1AwHQYDVR0OBBYEFKjCef/JxD+ND9eSb7hQlmEhSxUqMA0G +CSqGSIb3DQEBCwUAA4IBAQCnKH9FdLmJMruX2qfbrpT0qaV8bP7xa9UDRYSMsAWC +2kqCxs8CJmARt5+xsxBW6P65+mkLS2vXgQl7J8RTMiQVnHJvvNaldYnV6odsYOqv +v+vGib8Qe0gKWSjih+Gd1Ct4UQFtn6P3ph+6OBB0OieZb7DYXqPJrX5UlG7K2fQ4 +0MdFgBdeQZ3iNkXi43UIrQ5cF4cjYavmEFRmYeHya8AKfNCiWly15mNazW/X6SWf +7pz+yk/l+gBv0wm3QT7ANXGf8izgoh6T5fmixPXSbdn8RUIV0kXp2TRRZ+CYUWBP +Jc3PvRXiiEEo2eHLXfEHG2jzrt1iKnjk6hzuC1hUzK0t +-----END CERTIFICATE----- \ No newline at end of file diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/ssa.txt b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/ssa.txt new file mode 100644 index 000000000..2e3fa60f4 --- /dev/null +++ b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/ssa.txt @@ -0,0 +1 @@ +eyJhbGciOiJQUzI1NiIsImtpZCI6IjdlSjhTX1pndmxZeEZBRlNnaFY5eE1KUk92ayJ9.eyJpc3MiOiJjZHItcmVnaXN0ZXIiLCJpYXQiOjE2NjU5Nzg5NjMsImV4cCI6MjE0NzQ4MzY0NiwianRpIjoiM2JjMjA1YTFlYmM5NDNmYmI2MjRiMTRmY2IyNDExOTYiLCJvcmdfaWQiOiJUUFAyIiwib3JnX25hbWUiOiJNb2NrIENvbXBhbnkgSW5jLiIsImxlZ2FsX2VudGl0eV9pZCI6IlRQUDIiLCJsZWdhbF9lbnRpdHlfbmFtZSI6Ik1vY2sgQ29tcGFueSBQdHkgTHRkLiIsImNsaWVudF9kZXNjcmlwdGlvbiI6IkEgbW9jayBzb2Z0d2FyZSBwcm9kdWN0IGZvciB0ZXN0aW5nIFNTQSIsImNsaWVudF91cmkiOiJodHRwczovL3d3dy5tb2NrY29tcGFueS5jb20uYXUiLCJyZWRpcmVjdF91cmlzIjpbImh0dHBzOi8vd3d3Lmdvb2dsZS5jb20vcmVkaXJlY3RzL3JlZGlyZWN0MSIsImh0dHBzOi8vd3d3Lmdvb2dsZS5jb20vcmVkaXJlY3RzL3JlZGlyZWN0MiIsImh0dHBzOi8vd3d3Lmdvb2dsZS5jb20vcmVkaXJlY3RzL3JlZGlyZWN0MyJdLCJsb2dvX3VyaSI6Imh0dHBzOi8vd3d3Lm1vY2tjb21wYW55LmNvbS5hdS9sb2dvcy9sb2dvMS5wbmciLCJ0b3NfdXJpIjoiaHR0cHM6Ly93d3cubW9ja2NvbXBhbnkuY29tLmF1L3Rvcy5odG1sIiwicG9saWN5X3VyaSI6Imh0dHBzOi8vd3d3Lm1vY2tjb21wYW55LmNvbS5hdS9wb2xpY3kuaHRtbCIsImp3a3NfdXJpIjoiaHR0cHM6Ly9rZXlzdG9yZS5vcGVuYmFua2luZ3Rlc3Qub3JnLnVrLzAwMTU4MDAwMDFIUVFyWkFBWC9qRlF1UTRlUWJOQ01TcWRDb2cyMW5GLmp3a3MiLCJyZXZvY2F0aW9uX3VyaSI6Imh0dHBzOi8vZ2lzdC5naXRodWJ1c2VyY29udGVudC5jb20vaW1lc2g5NC8zMTcyZTJlNDU3NTdjZGEwOGVjMjcyN2Y5MGI3MmNlZC9yYXcvZmYwZDNlYWJlNGNkZGNlNDdlZWMwMjI4ZjU5MjE3NTIyM2RkOTJiMi93c28yLWF1LWRjci1kZW1vLmp3a3MiLCJyZWNpcGllbnRfYmFzZV91cmkiOiJodHRwczovL3d3dy5tb2NrY29tcGFueS5jb20uYXUiLCJzb2Z0d2FyZV9pZCI6IlNQMiIsInNvZnR3YXJlX3JvbGVzIjoiZGF0YS1yZWNpcGllbnQtc29mdHdhcmUtcHJvZHVjdCIsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgYmFuazphY2NvdW50cy5iYXNpYzpyZWFkIGJhbms6YWNjb3VudHMuZGV0YWlsOnJlYWQgYmFuazp0cmFuc2FjdGlvbnM6cmVhZCBiYW5rOnBheWVlczpyZWFkIGJhbms6cmVndWxhcl9wYXltZW50czpyZWFkIGNvbW1vbjpjdXN0b21lci5iYXNpYzpyZWFkIGNvbW1vbjpjdXN0b21lci5kZXRhaWw6cmVhZCBjZHI6cmVnaXN0cmF0aW9uIn0.Log1HrX7lozIqQS_SWlAbVgGuloBwsF2YsTs67nWP1EZSZEFLgPF7TMW_WMBb4Ne3zo9Va6d_6HYdMkPQEcvbVW9FjBW_NB367Y-K9eoVASMkuZd1XVtgnaqDVCVJL_jGiprkNQ_Bc8eZLQvJ34uJOm9gTjrMZB9eF1v61_Zb6rmZeLXDOSp948WTDABtwghJNFHdor24t_xYT1V9KZDeASqByxNzb_mcNV8JRF07XEdbgKnTkofA7wHHoJxcxi6qG0x8310JPjJkiCQcmh7N2RXw4awOAPMZMFX_CCRY_bqCq2asgkbiGyUyyXQuuXkGNuCYEE5g31tvL_dfJSYLQ \ No newline at end of file diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/transport-keystore/transport.jks b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/transport-keystore/transport.jks new file mode 100644 index 000000000..9c70d7fb9 Binary files /dev/null and b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/transport-keystore/transport.jks differ diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/transport-keystore/transport.key b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/transport-keystore/transport.key new file mode 100644 index 000000000..1a6efe673 --- /dev/null +++ b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/transport-keystore/transport.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCbJRo05tLVsJ5y +oAu1jalEmDcW5VEZCcqA+VLkps6bDOZ5VAQMWMQYM7U6NOtiyRC81E8wP/ZICyDD +II/sBtTkuO+UAoHsqA5sH9Ej7hUQZdBtAI8QLyc87Nmoo88YmEWylGuIJjtSj1N1 +5c/PZovJcI02ZcbRpNwAcARuH+Z2uU2O7mTJYFj1w504OwnNR+JqzGxBZFGl5m+m +YYRradCS9OPuC6dekFq4Ih65aKfj/G3fqcJpjpi7oJUyBIfr/fd4/u7/AV2KnZmE +N56IjoSvcpxTw9QO7q65u9T4JLqvlpORwrzIgSu82eEp/RQ6L8pAymUxWDJaFQ1y +4Znw0K5nAgMBAAECggEAIlg4UPW4Pq32pZFghjRyAEliCKODLHPKbHrFKvDyU8ir +TLiYnNMZtfHccKI+aYPxPJwTW68NKi2sdwXCVpG8l1WJU86qTGV3q9/vQHD4IMUp +Orgg84g8u3QDSx3YPq2W4E2S8HTmNQSdiT/ynQsqbtGHsT8eoFJKkZ46nNZbAnTy +dW0ZEDNvNJ/F7KMxrnf4ibrQKx22rQtF5Go3G/Nm2WQZbcJ+0fkccXtunL3c4uuG +xH/xdlOUlay4WOcmKw93HJOs7D2YEdZ2uTATgas74dK+RyXzyvVQoEpOSIJ2jQYb +wEfcR85p5hvU9xR085Cp8+LAo2bKiQWGw0VUkIaTAQKBgQC3J/z2m6Wq5nvnIKE4 +vWg12jwvHhyP2zIZjKPncA0lKmUC7vBJ60KIm4O0fDVfSksgsLhxgZxchDfRjZN2 +olVqrqYTYi/OL4gSroSMK1VNyGj/n+4LTPIQxwiepGkbdj0vv+eKXG0CNZEOACyq +jhA97GaeY3aUTsE/EzSVaa6mYQKBgQDY2Sb1P8oTxFcfrNyLyr663N+uLPzEfu+S +vFvvvG3ppcZjijmQVOJsW5R2F/7QCG2VdWft6Q6g2Ae/zWNSCvP2qYxJFhqtXPHx +j33pU0sveQZdEy/dfiNfqqepd4EyZWFsLUQ2c4NMYvmT8PiArn6YUZ/nKcnwNGek +t2hGItn5xwKBgC4j9sgxgdTB56jcQYFHxf77EXpVPaDH+aESGyBszAL24SeSBhq5 +F7POaamIOPHeh3qeynhdzIRKEr3JysJyNs5/XPs5Gw34T3FVYbLmH8FOoZT0N0XF +hp3PZk6A4LG4YcWrtKrYieWqlPZP+PCmhVT0Pw3bxL2r8WbwcajKTONBAoGAWia9 +SYyBiIJB7ktBTWS2sp0M6S6Oz2ouU4S3fA2MbGyc89kNYXHIyF+ycv4602YNmOs8 +j+4qRLhLUHQk7IDdOBj415G2+YgAlfqf0Bbu1Qetm5hUd/Lu5eDe31dtgPQg8oZH +K5QOa/1h4R13Upg4zT5yCfqXl6NRy2rskOwATxUCgYBbnpKY0sPyY1BxaxPChXuN +hlIeRMwhurk+VylkvNOF3GvwJ9Z7Uzuf62PzXRu0anWtlGY9KFP494SX1YL7CQO9 +Mws8Zo881MJr+oYzgwhv9CQhmNTtK7awjDizOlyuz7r4PJYIaKuqFxwiRBqNxJdA +loFhm8Tc2RjLkAHcKjGgBQ== +-----END PRIVATE KEY----- diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/transport-keystore/transport.pem b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/transport-keystore/transport.pem new file mode 100644 index 000000000..294bf61d0 --- /dev/null +++ b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources-2/transport-keystore/transport.pem @@ -0,0 +1,30 @@ +-----BEGIN CERTIFICATE----- +MIIFODCCBCCgAwIBAgIEWcbiiTANBgkqhkiG9w0BAQsFADBTMQswCQYDVQQGEwJH +QjEUMBIGA1UEChMLT3BlbkJhbmtpbmcxLjAsBgNVBAMTJU9wZW5CYW5raW5nIFBy +ZS1Qcm9kdWN0aW9uIElzc3VpbmcgQ0EwHhcNMjMxMTE1MDUxMDMxWhcNMjQxMjE1 +MDU0MDMxWjBhMQswCQYDVQQGEwJHQjEUMBIGA1UEChMLT3BlbkJhbmtpbmcxGzAZ +BgNVBAsTEjAwMTU4MDAwMDFIUVFyWkFBWDEfMB0GA1UEAxMWakZRdVE0ZVFiTkNN +U3FkQ29nMjFuRjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJslGjTm +0tWwnnKgC7WNqUSYNxblURkJyoD5UuSmzpsM5nlUBAxYxBgztTo062LJELzUTzA/ +9kgLIMMgj+wG1OS475QCgeyoDmwf0SPuFRBl0G0AjxAvJzzs2aijzxiYRbKUa4gm +O1KPU3Xlz89mi8lwjTZlxtGk3ABwBG4f5na5TY7uZMlgWPXDnTg7Cc1H4mrMbEFk +UaXmb6ZhhGtp0JL04+4Lp16QWrgiHrlop+P8bd+pwmmOmLuglTIEh+v993j+7v8B +XYqdmYQ3noiOhK9ynFPD1A7urrm71Pgkuq+Wk5HCvMiBK7zZ4Sn9FDovykDKZTFY +MloVDXLhmfDQrmcCAwEAAaOCAgQwggIAMA4GA1UdDwEB/wQEAwIHgDAgBgNVHSUB +Af8EFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwgeAGA1UdIASB2DCB1TCB0gYLKwYB +BAGodYEGAWQwgcIwKgYIKwYBBQUHAgEWHmh0dHA6Ly9vYi50cnVzdGlzLmNvbS9w +b2xpY2llczCBkwYIKwYBBQUHAgIwgYYMgYNVc2Ugb2YgdGhpcyBDZXJ0aWZpY2F0 +ZSBjb25zdGl0dXRlcyBhY2NlcHRhbmNlIG9mIHRoZSBPcGVuQmFua2luZyBSb290 +IENBIENlcnRpZmljYXRpb24gUG9saWNpZXMgYW5kIENlcnRpZmljYXRlIFByYWN0 +aWNlIFN0YXRlbWVudDBtBggrBgEFBQcBAQRhMF8wJgYIKwYBBQUHMAGGGmh0dHA6 +Ly9vYi50cnVzdGlzLmNvbS9vY3NwMDUGCCsGAQUFBzAChilodHRwOi8vb2IudHJ1 +c3Rpcy5jb20vb2JfcHBfaXNzdWluZ2NhLmNydDA6BgNVHR8EMzAxMC+gLaArhilo +dHRwOi8vb2IudHJ1c3Rpcy5jb20vb2JfcHBfaXNzdWluZ2NhLmNybDAfBgNVHSME +GDAWgBRQc5HGIXLTd/T+ABIGgVx5eW4/UDAdBgNVHQ4EFgQU7T6cMtCSQTT5JWW3 +O6vifRUSdpkwDQYJKoZIhvcNAQELBQADggEBAE9jrd/AE65vy3SEWdmFKPS4su7u +EHy+KH18PETV6jMF2UFIJAOx7jl+5a3O66NkcpxFPeyvSuH+6tAAr2ZjpoQwtW9t +Z9k2KSOdNOiJeQgjavwQC6t/BHI3yXWOIQm445BUN1cV9pagcRJjRyL3SPdHVoRf +IbF7VI/+ULHwWdZYPXxtwUoda1mQFf6a+2lO4ziUHb3U8iD90FBURzID7WJ1ODSe +B5zE/hG9Sxd9wlSXvl1oNmc/ha5oG/7rJpRqrx5Dcq3LEoX9iZZ3knHLkCm/abIQ +7Nff8GQytuGhnGZxmGFYKDXdKElcl9dAlZ3bIK2I+I6jD2z2XvSfrhFyRjU= +-----END CERTIFICATE----- \ No newline at end of file diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/obsigning-oQ4KoaavpOuoE7rvQsZEOV_NO_UPLOAD.key b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/obsigning-oQ4KoaavpOuoE7rvQsZEOV_NO_UPLOAD.key deleted file mode 100644 index ccec6f046..000000000 --- a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/obsigning-oQ4KoaavpOuoE7rvQsZEOV_NO_UPLOAD.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCsAsw5mDMKXp45 -C1lDGHXE/Njh/H8kB0nPQee1zgjST/FSGnUEQ2KWXgaCfybbkBh1Eb3F+a5FFZ4W -1SnAhK9muKVdCfLUIRQO+HFUDzFHwEuRcN4qxI5TuAp9C1oJ0gUof6HZjzRe+LEg -72sTDxEr8XOEjVrTjQ0L7HDUDQItH9TQNoFjENPcRiWiPLuGaZvTgxVWbo7C70Rq -4afg+YNQmY10XblgEq1e7fhV4E3rRNbXrClUclb7DnZ8PXDP2j3PQBmnY1tMDnjD -jpr9JqRJlKyFmZwijMcGhEdl7CI5IprfvE7Oawx/zRJDTFmLDbCPUJIHIfsZLymu -ydR8lUJ/AgMBAAECggEAAxE8XxKNu8jwKAhBxpEwbcYsf+smwUJireV496RS7UfW -VSZ6S7cqkjqJrINj8qphJUVJuGFkGtXwhGu3W42CKzduYM2v8i8c0nTaYICyL5td -kvG2TyuYy3lkBn17VOLVNgxV8IaTN9ZWIkY4B0D6MhRo1kZHBlq6OX+Ki4gn2nId -UrSubo1mNg8U5HKl/yJREF3vk+Jxx6xthHIlEZIxX+4ahmOMCSC+POtaelnzKtpL -ttyf3kvfK/dA58yLkq1boirXE7ZwN9Oqj6j+DgW11zDe3qqUYEzsqbLGqR1ITeVm -G+dg3gsaLGDzsVhcbmGNwD/FhbpyZkbvM+dzqAc1kQKBgQDuOdGNxbpOA2UPxZb4 -HNQMAzplwg2WBnXhsxlL2am0AsZSR/I2jFMB7FiXGsZKMQR9YpfHkd+cTdDkdzjo -5S4L6SVGmHiEfGxmX77HHekJPEpLk3iYNKfFwlftB5YWmVrj9PqHXj/Yf3oRHBHS -iTHWE0zfEdhnapL6nd5LGUVUSwKBgQC42EFcosc9raliMghiyOBvPne4rFLhMt0D -T7vCwPA902psklY+ME+B5sVpU9V7vSTFRRsV6Xm6RjFCMyOgxFp+O7lK1QwmfQCe -JbLUO+DnOyLKMVY8ZfFaW4QKqD4TsKOkhfVz4vWPiHmKzKzGqYK+Ml8FboDlcwcM -tcvxeqJiHQKBgQCdPQqE0iLDRVhaTaf1Akov152e9rOy93atT2J9/yAVEdPHEXfc -60gKt+5NZj3FUI9PF1lpP25ho7ciZVLp3gNDl1KkQxUhFWMTO1UX5jUfhGzhb2gk -xnSKglk4uU4mgnhMiDEoUlw/0PxH+MgGt8luLHULs6Krt9tlkffch8SL+wKBgC72 -quypYuvV0qJjSeQnW3aILYzbI5eZ/7NWr8LUmHVs4K5DI+xbA+hiRKf1J9lvfgcs -/qu7jTT5noxOR/AR01gdPn+3z4V73wtPUrc/m23EhZtPm7RuxjqJ4+t9QYBpMbqc -WneeI3vbVd4hEIjNCq3eSGwt3kvtxM3C5tUsrlM1AoGAW85yN3VUj9A+5+z/ne7z -Ct17Vakt2f51fWm/r438H5gQfElCtxvH91/fu1SvxvvqZszN5K7YC/TsNsM9R0aV -EXPbM7wtcMudlTfTyuX+CdkKqEM4wnKWYCzNiQEOsXB0dn7DnNDoPz7jVsv4LElg -BygVYMKJ1dfFZwbpBorBstU= ------END PRIVATE KEY----- diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.jks b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.jks index 609fd0e48..87b936726 100644 Binary files a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.jks and b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.jks differ diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.key b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.key new file mode 100644 index 000000000..1c497f458 --- /dev/null +++ b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCot+hw9Ka8dTd6 +X2nyXOqUjINItIzokK7flmehqYSlIQNia2wcVk72m19UO4Yn5eVG5ATpJ590gsqg +aZT0qpLGC3T0nJG9ie1FS4++ju0ZBC6BQ/r0q0PBVhJ/JV7+FIkvMpb5ayD2vPqV +bQMDriN/2BZqgdZXB4ASPBBCw1Fh10qdzoZHCo65u+rdbEM9LbJouWh2UdxV29HQ +AkDvnRmpCHq6s1JgHXHC7VrkiTE/m+3OyAw5vyEfzFe4qJdOMngZDpVq3iCjqh1N +ejyNzfz0jBLfeiQFCmf59FQtMeGB2gWA19u7H+Bsqbm4JpHHeCGxv/FxLh6tyJPO +KBKT+UBFAgMBAAECggEAAw2g9TpYMhzk7h//6NTpodqRHaW2zxafM4ijQ3ev4NUi +HIvZHwIo16mkJgAVw28ToR7LP/Tpm9AqHpEKkwrrMQ5QBYU31fhDBPgDF+26OLOs +q8YxKnBW/46xMv/YIjz45pPBy622oQB2gHHCljR2i/+7GB5VZKnMFYhkuvCR7nVR +bHaOdISM9fyzJBkUY5pVkCqvAdSQGoLKubAAuHN/wzVevowmCwOluED3+kliOhma +9UccRWlprTsWbMenIZKY8lJmiA0bOGrkyCVz23780bVB/gFpeCNsYjUrLwazAfbI +wKpsdgxOrVsaluaFWZ7TQtgSXvZWCtHfpvbz5yQOAQKBgQDMceH3gLpV5/uZdulI +84aVrXREkWN0AVCM1PHhtAocom/+Dvu+L1qNDtT2iPzH95gKhRwk4NA+ag4Ycns9 +HZkTQbwMOuybC7BvrLI0vnQfTkyiAjUownRJSgZfo7vYt7Ap88jgBhsGd4XmvEbO +SYwyCuXCeZvYLPhDT3MkrKgbhQKBgQDTQ6wJJYCva/FJ46huRL93tnfT6xFjyAwU +9UttYYRDrCANTyPPFTL6T1welRpUq8ZbitgI6FOrUCC/80X6hNcD8O8PWXcTS4oK +OEIzo5EOSB6yNeWwPaUd50i+iDD0W0K94dmj+DLjGJY8wA8yaLr2oWJW5GyAGhYm +AdBe/VfNwQKBgQC1jCeiVrChWpjFBaBRhNetkNMflI/hUs2J0gtdZzhXhzO2Qu3w +TDK38kTRDIKUvFxKczuzz+N8mUcdFIQ1mFP3krb/kU/MuwuZj5zMU5fguPI6J4W3 +RT5oWpDgWxCTeUK5bl+h+CoFixvf8q9Zvlv9kEnJcZ4f0IdBlorkNWIu1QKBgQCh +PZ344SGlQWpILbQobNoBYUd1e4yrLkxiVpD565qKF73iyosXCyP8PUOep8gP5Yaf +6YlWyxLIxoAoYGEBgg+lF2ctvOeP13CEukl0phsY3lxnQZGLgJEcEKDJoqJSbbCz +wcNdTRpxjxtjRGaU37AKekPW88IHx2EuIuZJCWzRQQKBgFE8vbLbSYxFIE1uhast +2/9WFblB2Mrxsr2HFMW7xwOPmeh7H2+zZ2ZS7rVls1jC6e25SgnPyF/FItPrNCmW +7EFzv73oRhMxGS6LImFQtTLqNAUl0Msmpheaxgcb6bM6Gns1co8bEykoaFRdhmHR +kcoyjehtpocckAWTrtW7gPcl +-----END PRIVATE KEY----- diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.p12 b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.p12 deleted file mode 100644 index 0b2710dbd..000000000 Binary files a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.p12 and /dev/null differ diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.pem b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.pem index bad383611..0ebf69a67 100644 --- a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.pem +++ b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/signing-keystore/signing.pem @@ -1,16 +1,16 @@ -----BEGIN CERTIFICATE----- -MIIFLTCCBBWgAwIBAgIEWca5LjANBgkqhkiG9w0BAQsFADBTMQswCQYDVQQGEwJH +MIIFLTCCBBWgAwIBAgIEWcbiiDANBgkqhkiG9w0BAQsFADBTMQswCQYDVQQGEwJH QjEUMBIGA1UEChMLT3BlbkJhbmtpbmcxLjAsBgNVBAMTJU9wZW5CYW5raW5nIFBy -ZS1Qcm9kdWN0aW9uIElzc3VpbmcgQ0EwHhcNMjMwNDE3MDQ1NjM0WhcNMjQwNTE3 -MDUyNjM0WjBhMQswCQYDVQQGEwJHQjEUMBIGA1UEChMLT3BlbkJhbmtpbmcxGzAZ -BgNVBAsTEjAwMTU4MDAwMDFIUVFyWkFBWDEfMB0GA1UEAxMWb1E0S29hYXZwT3Vv -RTdydlFzWkVPVjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKwCzDmY -MwpenjkLWUMYdcT82OH8fyQHSc9B57XOCNJP8VIadQRDYpZeBoJ/JtuQGHURvcX5 -rkUVnhbVKcCEr2a4pV0J8tQhFA74cVQPMUfAS5Fw3irEjlO4Cn0LWgnSBSh/odmP -NF74sSDvaxMPESvxc4SNWtONDQvscNQNAi0f1NA2gWMQ09xGJaI8u4Zpm9ODFVZu -jsLvRGrhp+D5g1CZjXRduWASrV7t+FXgTetE1tesKVRyVvsOdnw9cM/aPc9AGadj -W0wOeMOOmv0mpEmUrIWZnCKMxwaER2XsIjkimt+8Ts5rDH/NEkNMWYsNsI9Qkgch -+xkvKa7J1HyVQn8CAwEAAaOCAfkwggH1MA4GA1UdDwEB/wQEAwIGwDAVBgNVHSUE +ZS1Qcm9kdWN0aW9uIElzc3VpbmcgQ0EwHhcNMjMxMTE1MDUxMDA4WhcNMjQxMjE1 +MDU0MDA4WjBhMQswCQYDVQQGEwJHQjEUMBIGA1UEChMLT3BlbkJhbmtpbmcxGzAZ +BgNVBAsTEjAwMTU4MDAwMDFIUVFyWkFBWDEfMB0GA1UEAxMWakZRdVE0ZVFiTkNN +U3FkQ29nMjFuRjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKi36HD0 +prx1N3pfafJc6pSMg0i0jOiQrt+WZ6GphKUhA2JrbBxWTvabX1Q7hifl5UbkBOkn +n3SCyqBplPSqksYLdPSckb2J7UVLj76O7RkELoFD+vSrQ8FWEn8lXv4UiS8ylvlr +IPa8+pVtAwOuI3/YFmqB1lcHgBI8EELDUWHXSp3OhkcKjrm76t1sQz0tsmi5aHZR +3FXb0dACQO+dGakIerqzUmAdccLtWuSJMT+b7c7IDDm/IR/MV7iol04yeBkOlWre +IKOqHU16PI3N/PSMEt96JAUKZ/n0VC0x4YHaBYDX27sf4Gypubgmkcd4IbG/8XEu +Hq3Ik84oEpP5QEUCAwEAAaOCAfkwggH1MA4GA1UdDwEB/wQEAwIGwDAVBgNVHSUE DjAMBgorBgEEAYI3CgMMMIHgBgNVHSAEgdgwgdUwgdIGCysGAQQBqHWBBgFkMIHC MCoGCCsGAQUFBwIBFh5odHRwOi8vb2IudHJ1c3Rpcy5jb20vcG9saWNpZXMwgZMG CCsGAQUFBwICMIGGDIGDVXNlIG9mIHRoaXMgQ2VydGlmaWNhdGUgY29uc3RpdHV0 @@ -20,11 +20,11 @@ bnQwbQYIKwYBBQUHAQEEYTBfMCYGCCsGAQUFBzABhhpodHRwOi8vb2IudHJ1c3Rp cy5jb20vb2NzcDA1BggrBgEFBQcwAoYpaHR0cDovL29iLnRydXN0aXMuY29tL29i X3BwX2lzc3VpbmdjYS5jcnQwOgYDVR0fBDMwMTAvoC2gK4YpaHR0cDovL29iLnRy dXN0aXMuY29tL29iX3BwX2lzc3VpbmdjYS5jcmwwHwYDVR0jBBgwFoAUUHORxiFy -03f0/gASBoFceXluP1AwHQYDVR0OBBYEFFbNRf2on1lD/kZMxwUqtGQB0O7jMA0G -CSqGSIb3DQEBCwUAA4IBAQBFNMFwWVRKcv7TSoHlDsG6bKN/TP0JEzy5cZkhqqpc -upV+4w+Yhw3IqJvV08SFRKSwPshEMbTIoAtcxVGz9FAtV3TixTl9BXRdXImLRBsX -FWfFSzeNYL3gyhdwfItoyRWVMEfHC4KsOGQ7DNl90mUaOkB4vGZTTLV8PQKhkRVP -h33pPRdxi+d3PNFzOhed8hAB4anb/ckio2np7JunCOrU2kYEW2yc7DTJc+grCD/T -+eJzf3AXeWb+fIVyc+luabxJFKsfblcoSXdIRj3fKjGMOuvPvd5SzS4tU1uzl2OO -zPcowKfDtBAeJZ4Gmdj+RnbmH8QsHTdOJ8gxMXL9rKfF +03f0/gASBoFceXluP1AwHQYDVR0OBBYEFKjCef/JxD+ND9eSb7hQlmEhSxUqMA0G +CSqGSIb3DQEBCwUAA4IBAQCnKH9FdLmJMruX2qfbrpT0qaV8bP7xa9UDRYSMsAWC +2kqCxs8CJmARt5+xsxBW6P65+mkLS2vXgQl7J8RTMiQVnHJvvNaldYnV6odsYOqv +v+vGib8Qe0gKWSjih+Gd1Ct4UQFtn6P3ph+6OBB0OieZb7DYXqPJrX5UlG7K2fQ4 +0MdFgBdeQZ3iNkXi43UIrQ5cF4cjYavmEFRmYeHya8AKfNCiWly15mNazW/X6SWf +7pz+yk/l+gBv0wm3QT7ANXGf8izgoh6T5fmixPXSbdn8RUIV0kXp2TRRZ+CYUWBP +Jc3PvRXiiEEo2eHLXfEHG2jzrt1iKnjk6hzuC1hUzK0t -----END CERTIFICATE----- \ No newline at end of file diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/ssa_differentHostNames.txt b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/ssa_differentHostNames.txt new file mode 100644 index 000000000..22fe215c1 --- /dev/null +++ b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/ssa_differentHostNames.txt @@ -0,0 +1 @@ +eyJhbGciOiJQUzI1NiIsImtpZCI6IjdlSjhTX1pndmxZeEZBRlNnaFY5eE1KUk92ayJ9.eyJpc3MiOiJjZHItcmVnaXN0ZXIiLCJpYXQiOjE2NjU5Nzg5NjMsImV4cCI6MjE0NzQ4MzY0NiwianRpIjoiM2JjMjA1YTFlYmM5NDNmYmI2MjRiMTRmY2IyNDExOTYiLCJvcmdfaWQiOiJUUFAxIiwib3JnX25hbWUiOiJNb2NrIENvbXBhbnkgSW5jLiIsImxlZ2FsX2VudGl0eV9pZCI6IlRQUDEiLCJsZWdhbF9lbnRpdHlfbmFtZSI6Ik1vY2sgQ29tcGFueSBQdHkgTHRkLiIsImNsaWVudF9kZXNjcmlwdGlvbiI6IkEgbW9jayBzb2Z0d2FyZSBwcm9kdWN0IGZvciB0ZXN0aW5nIFNTQSIsImNsaWVudF91cmkiOiJodHRwczovL3d3dy5tb2NrY29tcGFueS5jb20uYXUiLCJyZWRpcmVjdF91cmlzIjpbImh0dHBzOi8vbG9jYWxob3N0Ojk0NDMvZGV2cG9ydGFsIiwiaHR0cHM6Ly9vYmFtOjk0NDMiXSwibG9nb191cmkiOiJodHRwczovL3d3dy5tb2NrY29tcGFueS5jb20uYXUvbG9nb3MvbG9nbzEucG5nIiwidG9zX3VyaSI6Imh0dHBzOi8vd3d3Lm1vY2tjb21wYW55LmNvbS5hdS90b3MuaHRtbCIsInBvbGljeV91cmkiOiJodHRwczovL3d3dy5tb2NrY29tcGFueS5jb20uYXUvcG9saWN5Lmh0bWwiLCJqd2tzX3VyaSI6Imh0dHBzOi8va2V5c3RvcmUub3BlbmJhbmtpbmd0ZXN0Lm9yZy51ay8wMDE1ODAwMDAxSFFRclpBQVgvakZRdVE0ZVFiTkNNU3FkQ29nMjFuRi5qd2tzIiwicmV2b2NhdGlvbl91cmkiOiJodHRwczovL2dpc3QuZ2l0aHVidXNlcmNvbnRlbnQuY29tL2ltZXNoOTQvMzE3MmUyZTQ1NzU3Y2RhMDhlYzI3MjdmOTBiNzJjZWQvcmF3L2ZmMGQzZWFiZTRjZGRjZTQ3ZWVjMDIyOGY1OTIxNzUyMjNkZDkyYjIvd3NvMi1hdS1kY3ItZGVtby5qd2tzIiwicmVjaXBpZW50X2Jhc2VfdXJpIjoiaHR0cHM6Ly93d3cubW9ja2NvbXBhbnkuY29tLmF1Iiwic29mdHdhcmVfaWQiOiJTUDEiLCJzb2Z0d2FyZV9yb2xlcyI6ImRhdGEtcmVjaXBpZW50LXNvZnR3YXJlLXByb2R1Y3QiLCJzY29wZSI6Im9wZW5pZCBwcm9maWxlIGJhbms6YWNjb3VudHMuYmFzaWM6cmVhZCBiYW5rOmFjY291bnRzLmRldGFpbDpyZWFkIGJhbms6dHJhbnNhY3Rpb25zOnJlYWQgYmFuazpwYXllZXM6cmVhZCBiYW5rOnJlZ3VsYXJfcGF5bWVudHM6cmVhZCBjb21tb246Y3VzdG9tZXIuYmFzaWM6cmVhZCBjb21tb246Y3VzdG9tZXIuZGV0YWlsOnJlYWQgY2RyOnJlZ2lzdHJhdGlvbiJ9.R3VzlpqZ4cAYE9Q99to8BoPc9-JgJAjvUWEX1KdX8FDDqsMFPDv1nHMaS4Vn_lWURRnNoVD3R5tuuj38stpAFcCce35yYWHHWXL7-L5hda9yoMLD-Mc_rZl4_AMEFs3ACduoM8m4p0PUSh8NvcDiWJPNxwFTCxmp-D1pw75sX4SP6-lIQ3gKOFm4laxjcNGBubEG1ypIa73OpJpNuuGa5a-wUfqNO5Yf0sS3k_d69mGq-ROUz_A5hb-RethxNBn3dolV-Iz8xyOmdCEdrGZPn0w9Ii53g7vX61AGW_JS-o0MmrHAb5PFF1CTtc66wN83e_NkCC8tMRFC7-uEKrROSg \ No newline at end of file diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/ssa_localhost.txt b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/ssa_localhost.txt index 23ed9bd52..88fa1ee1a 100644 --- a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/ssa_localhost.txt +++ b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/ssa_localhost.txt @@ -1 +1 @@ -eyJhbGciOiJQUzI1NiIsImtpZCI6ImgzWkNGMFZyemdYZ25IQ3FiSGJLWHp6ZmpUZyIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjZHItcmVnaXN0ZXIiLCJpYXQiOjE2MzAyOTY2MzksImV4cCI6MjE0NzQ4MzY0NiwianRpIjoiM2JjMjA1YTFlYmM5NDNmYmI2MjRiMTRmY2IyNDExOTgiLCJvcmdfaWQiOiIzQjBCMEE3Qi0zRTdCLTRBMkMtOTQ5Ny1FMzU3QTcxRDA3QzgiLCJvcmdfbmFtZSI6Ik1vY2sgQ29tcGFueSBJbmMuIiwiY2xpZW50X25hbWUiOiJNb2NrIFNvZnR3YXJlIiwiY2xpZW50X2Rlc2NyaXB0aW9uIjoiQSBtb2NrIHNvZnR3YXJlIHByb2R1Y3QgZm9yIHRlc3RpbmcgU1NBIiwiY2xpZW50X3VyaSI6Imh0dHBzOi8vd3d3Lm1vY2tjb21wYW55LmNvbS5hdSIsInJlZGlyZWN0X3VyaXMiOlsiaHR0cHM6Ly9sb2NhbGhvc3Q6OTQ0My9jYXJib24iLCJodHRwczovL2xvY2FsaG9zdDo5NDQzL2FkbWluIl0sImxvZ29fdXJpIjoiaHR0cHM6Ly93d3cubW9ja2NvbXBhbnkuY29tLmF1L2xvZ29zL2xvZ28xLnBuZyIsInRvc191cmkiOiJodHRwczovL3d3dy5tb2NrY29tcGFueS5jb20uYXUvdG9zLmh0bWwiLCJwb2xpY3lfdXJpIjoiaHR0cHM6Ly93d3cubW9ja2NvbXBhbnkuY29tLmF1L3BvbGljeS5odG1sIiwiandrc191cmkiOiJodHRwczovL2tleXN0b3JlLm9wZW5iYW5raW5ndGVzdC5vcmcudWsvMDAxNTgwMDAwMUhRUXJaQUFYL29RNEtvYWF2cE91b0U3cnZRc1pFT1YuandrcyIsInJldm9jYXRpb25fdXJpIjoiaHR0cHM6Ly9naXN0LmdpdGh1YnVzZXJjb250ZW50LmNvbS9pbWVzaDk0LzMxNzJlMmU0NTc1N2NkYTA4ZWMyNzI3ZjkwYjcyY2VkL3Jhdy9mZjBkM2VhYmU0Y2RkY2U0N2VlYzAyMjhmNTkyMTc1MjIzZGQ5MmIyL3dzbzItYXUtZGNyLWRlbW8uandrcyIsInJlY2lwaWVudF9iYXNlX3VyaSI6Imh0dHBzOi8vd3d3Lm1vY2tjb21wYW55LmNvbS5hdSIsInNvZnR3YXJlX2lkIjoib1E0S29hYXZwT3VvRTdydlFzWkVPViIsInNvZnR3YXJlX3JvbGVzIjoiZGF0YS1yZWNpcGllbnQtc29mdHdhcmUtcHJvZHVjdCIsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgYmFuazphY2NvdW50cy5iYXNpYzpyZWFkIGJhbms6YWNjb3VudHMuZGV0YWlsOnJlYWQgYmFuazp0cmFuc2FjdGlvbnM6cmVhZCBiYW5rOnBheWVlczpyZWFkIGJhbms6cmVndWxhcl9wYXltZW50czpyZWFkIGNvbW1vbjpjdXN0b21lci5iYXNpYzpyZWFkIGNvbW1vbjpjdXN0b21lci5kZXRhaWw6cmVhZCBjZHI6cmVnaXN0cmF0aW9uIn0.kUc7UyHziz7eElQ5bLSwr7p6oPZDpZas8pQeVOyul7racakp3F5djJ__P17OcrwFebbwTYt7LVY_0FGkHQa7DA9-U1CbCaz6XwmHprKr8sqWQwNw7MmuOG3h1xeNN0SL5TIhWckZcuZE3engRYCk_2Ss-USZqSf4ZEHFX6aF-1pcAb1Ua3e9uU1YEYUZTJEN5GIR6H8opg6KPXuBcv6pffdYNq6r3mS7ze-xRSH0RFFW0uq_VBBcCX82HvTwLSqrWzoyXiEI--n3ZN8TVJ0AuOgwOXXpUBTtIb6tnFv3_yGqT7cmn3bd9ytmAUsLgCnjEhs3KpXowEM2PaceADjuKA \ No newline at end of file +eyJhbGciOiJQUzI1NiIsImtpZCI6IjdlSjhTX1pndmxZeEZBRlNnaFY5eE1KUk92ayJ9.eyJpc3MiOiJjZHItcmVnaXN0ZXIiLCJpYXQiOjE2NjU5Nzg5NjMsImV4cCI6MjE0NzQ4MzY0NiwianRpIjoiM2JjMjA1YTFlYmM5NDNmYmI2MjRiMTRmY2IyNDExOTYiLCJvcmdfaWQiOiJUUFAxIiwib3JnX25hbWUiOiJNb2NrIENvbXBhbnkgSW5jLiIsImxlZ2FsX2VudGl0eV9pZCI6IlRQUDEiLCJsZWdhbF9lbnRpdHlfbmFtZSI6Ik1vY2sgQ29tcGFueSBQdHkgTHRkLiIsImNsaWVudF9kZXNjcmlwdGlvbiI6IkEgbW9jayBzb2Z0d2FyZSBwcm9kdWN0IGZvciB0ZXN0aW5nIFNTQSIsImNsaWVudF91cmkiOiJodHRwczovL3d3dy5tb2NrY29tcGFueS5jb20uYXUiLCJyZWRpcmVjdF91cmlzIjpbImh0dHBzOi8vbG9jYWxob3N0Ojk0NDMvY2FyYm9uIiwiaHR0cHM6Ly9sb2NhbGhvc3Q6OTQ0My9hZG1pbiJdLCJsb2dvX3VyaSI6Imh0dHBzOi8vd3d3Lm1vY2tjb21wYW55LmNvbS5hdS9sb2dvcy9sb2dvMS5wbmciLCJ0b3NfdXJpIjoiaHR0cHM6Ly93d3cubW9ja2NvbXBhbnkuY29tLmF1L3Rvcy5odG1sIiwicG9saWN5X3VyaSI6Imh0dHBzOi8vd3d3Lm1vY2tjb21wYW55LmNvbS5hdS9wb2xpY3kuaHRtbCIsImp3a3NfdXJpIjoiaHR0cHM6Ly9rZXlzdG9yZS5vcGVuYmFua2luZ3Rlc3Qub3JnLnVrLzAwMTU4MDAwMDFIUVFyWkFBWC9qRlF1UTRlUWJOQ01TcWRDb2cyMW5GLmp3a3MiLCJyZXZvY2F0aW9uX3VyaSI6Imh0dHBzOi8vZ2lzdC5naXRodWJ1c2VyY29udGVudC5jb20vaW1lc2g5NC8zMTcyZTJlNDU3NTdjZGEwOGVjMjcyN2Y5MGI3MmNlZC9yYXcvZmYwZDNlYWJlNGNkZGNlNDdlZWMwMjI4ZjU5MjE3NTIyM2RkOTJiMi93c28yLWF1LWRjci1kZW1vLmp3a3MiLCJyZWNpcGllbnRfYmFzZV91cmkiOiJodHRwczovL3d3dy5tb2NrY29tcGFueS5jb20uYXUiLCJzb2Z0d2FyZV9pZCI6IlNQMSIsInNvZnR3YXJlX3JvbGVzIjoiZGF0YS1yZWNpcGllbnQtc29mdHdhcmUtcHJvZHVjdCIsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgYmFuazphY2NvdW50cy5iYXNpYzpyZWFkIGJhbms6YWNjb3VudHMuZGV0YWlsOnJlYWQgYmFuazp0cmFuc2FjdGlvbnM6cmVhZCBiYW5rOnBheWVlczpyZWFkIGJhbms6cmVndWxhcl9wYXltZW50czpyZWFkIGNvbW1vbjpjdXN0b21lci5iYXNpYzpyZWFkIGNvbW1vbjpjdXN0b21lci5kZXRhaWw6cmVhZCBjZHI6cmVnaXN0cmF0aW9uIn0.AXkzX0L8eDdJpwH-R3ZC6nGmY7KiC0pSTI7HCkwPVRLBw5g8cqULIjK37vQbMkyRTYSkFNU7XVsgZDRlQHIl_W66mo0G3anoTpzsjqWHRTOtQs0a36LYKdQZ-w1guNrNQ_rVHw8wNkQfSmcKM8CknEPOEIQg4o-wQz4LGGddE6ZJhKxcxFGgPZHY-RA8NK1zlMOmdQUFH-_3weZfbQbQU1JCjs8y9sQ05BWTzdozun7jFPOqhVTZ-xXRO77AVQIJxhuubidgofwITaIIetk-eEaLbYziNn8vGio_iafV2UwBJdBhk0wmPcANSJETt63WdRcgded1BZ92-JVoJG75zw \ No newline at end of file diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/ssa_withoutRedirectUrl.txt b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/ssa_withoutRedirectUrl.txt new file mode 100644 index 000000000..7cf81f7f2 --- /dev/null +++ b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/ssa_withoutRedirectUrl.txt @@ -0,0 +1 @@ +eyJhbGciOiJQUzI1NiIsImtpZCI6IjdlSjhTX1pndmxZeEZBRlNnaFY5eE1KUk92ayJ9.eyJpc3MiOiJjZHItcmVnaXN0ZXIiLCJpYXQiOjE2NjU5Nzg5NjMsImV4cCI6MjE0NzQ4MzY0NiwianRpIjoiM2JjMjA1YTFlYmM5NDNmYmI2MjRiMTRmY2IyNDExOTYiLCJvcmdfaWQiOiJUUFAxIiwib3JnX25hbWUiOiJNb2NrIENvbXBhbnkgSW5jLiIsImxlZ2FsX2VudGl0eV9pZCI6IlRQUDEiLCJsZWdhbF9lbnRpdHlfbmFtZSI6Ik1vY2sgQ29tcGFueSBQdHkgTHRkLiIsImNsaWVudF9kZXNjcmlwdGlvbiI6IkEgbW9jayBzb2Z0d2FyZSBwcm9kdWN0IGZvciB0ZXN0aW5nIFNTQSIsImNsaWVudF91cmkiOiJodHRwczovL3d3dy5tb2NrY29tcGFueS5jb20uYXUiLCJsb2dvX3VyaSI6Imh0dHBzOi8vd3d3Lm1vY2tjb21wYW55LmNvbS5hdS9sb2dvcy9sb2dvMS5wbmciLCJ0b3NfdXJpIjoiaHR0cHM6Ly93d3cubW9ja2NvbXBhbnkuY29tLmF1L3Rvcy5odG1sIiwicG9saWN5X3VyaSI6Imh0dHBzOi8vd3d3Lm1vY2tjb21wYW55LmNvbS5hdS9wb2xpY3kuaHRtbCIsImp3a3NfdXJpIjoiaHR0cHM6Ly9rZXlzdG9yZS5vcGVuYmFua2luZ3Rlc3Qub3JnLnVrLzAwMTU4MDAwMDFIUVFyWkFBWC9qRlF1UTRlUWJOQ01TcWRDb2cyMW5GLmp3a3MiLCJyZXZvY2F0aW9uX3VyaSI6Imh0dHBzOi8vZ2lzdC5naXRodWJ1c2VyY29udGVudC5jb20vaW1lc2g5NC8zMTcyZTJlNDU3NTdjZGEwOGVjMjcyN2Y5MGI3MmNlZC9yYXcvZmYwZDNlYWJlNGNkZGNlNDdlZWMwMjI4ZjU5MjE3NTIyM2RkOTJiMi93c28yLWF1LWRjci1kZW1vLmp3a3MiLCJyZWNpcGllbnRfYmFzZV91cmkiOiJodHRwczovL3d3dy5tb2NrY29tcGFueS5jb20uYXUiLCJzb2Z0d2FyZV9pZCI6IlNQMSIsInNvZnR3YXJlX3JvbGVzIjoiZGF0YS1yZWNpcGllbnQtc29mdHdhcmUtcHJvZHVjdCIsInNjb3BlIjoib3BlbmlkIHByb2ZpbGUgYmFuazphY2NvdW50cy5iYXNpYzpyZWFkIGJhbms6YWNjb3VudHMuZGV0YWlsOnJlYWQgYmFuazp0cmFuc2FjdGlvbnM6cmVhZCBiYW5rOnBheWVlczpyZWFkIGJhbms6cmVndWxhcl9wYXltZW50czpyZWFkIGNvbW1vbjpjdXN0b21lci5iYXNpYzpyZWFkIGNvbW1vbjpjdXN0b21lci5kZXRhaWw6cmVhZCBjZHI6cmVnaXN0cmF0aW9uIn0.ZdsXPQjxvnACo0_iTGck6lxPp2HatRs2is19jtgDedwTBLRwV1QWPaFm8P24_aNjFYcMKAhleCjJR1VOtkuouRxrpmUBrKXnCTRrSDEwbjTkyi4vDyKTbHqL1ldmDA3L64o9k-6HXIRbOkcZHNyAYU8C85iLddfvDJmPnJs1Uh54I_PTz2MsgEpWUk9-c3OEjJ6M9KuUtSgWVgM81AKpsV4oswc6rRQAaGoSsS_Ft9O7Mh8PJCbF9lzfKhFWQmt-cps8b6i3Oz4lxyWa8__kisb74wro6iWwPXmrK3KkvujG8jlzJW_-vgl4ywGMyRpmWXeyTKLig5Gv-MNC1_6Wwg \ No newline at end of file diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/obtransport-oQ4KoaavpOuoE7rvQsZEOV_NO_UPLOAD.key b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/obtransport-oQ4KoaavpOuoE7rvQsZEOV_NO_UPLOAD.key deleted file mode 100644 index b83e50f41..000000000 --- a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/obtransport-oQ4KoaavpOuoE7rvQsZEOV_NO_UPLOAD.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCXjGlqc5sGGduX -Axy0hFoXMGmvySV4MLqWSYnwcoWmqPJvx4cfD2aVzl8+xnH4jVZs98NXABV736zY -eAO63Nr46fbITUOm0J2zilY6DfqzcbJGI8abyzpZQlGoouZI3URea9GBPe7d4R+x -nQE0+eibPWqJspG3mKHRtbzeHg3IAK59Xzu6vuvtBMNjJWuV/k/37H7vteLVzC8e -wAEEgsxn7GJyaenwiUOLpNXeZpWFnfnDNoFn9XkObB3i9SvQfnM6LOezRYbFVAbz -wjy5q2rWp4+/LTfDuszsQLNVBHJH/s9ayytw9jQqr/RZ3we7GiyoaefL0KqEZzol -vpa9WeG7AgMBAAECggEAF6Phw9HMd8tWe6boIOlZIQSTz/CO2uywW9uVMWq5RNyr -k4U/+OKO9u/DisgrpNaYtJSCURLPHHeGqm6E7Rl2Ql2Yz05s2bDxkL1pIv2QQygJ -Y7NBUDHdDxRvJuELuYe5RQiznIy73g+368hulO7Q+qUTdpm3l7ivBsa/SLTOeIlp -NHGZtilclW0jKF8s8yZRdCjIHTJeddKdNVD1uE0qiNhMLVk9mQBb5+sdEh+3+nTP -YaWZJtc30/h8s1dKsV/NERmU34vb38jNydz3+WUQZQATsw3Qg0gCgNnKPiUroPLU -dqb1uORaEEAM48RfWt5j6blqcREn6rwPLsE+emXx7QKBgQDKz2w2goXV6CfWs02B -/Myl7KmZDIO/vlZS+f+UJWmmRnTmTsHk35eZ6V1VUtBUvRcQ8BDDDVuNP9cooA1h -nvCbulD5wEZ5OqwuJKMmiBlJ7hLr67YjD2eWI3GvTJgwVMOGBgfsfDXUg3Q+iTUN -0dg/cjRwly2fPh9HBUeISNtcjwKBgQC/S0zik7Nhg9uezN/dBQTKw9eaLzVvNTL3 -Qr4amKssGT2hhJWadbtJvozf8SWKS61Sj+u3OQ7FgHQyHIv2iHwQZTyTl+L1bXUW -LkeesTiriwtTbZfamjGsLk5AckL0Jf7H5d+80RDh0aAFiLbRvCPFHjPs9k2FQLbT -YimSwakWFQKBgD34HS+WuEBBHJMs3F0AmqOEadn7CfK3vPbDrsVcnSiSVLveir5d -V5xOwxcEI+YQlRC22dhPp47EWADwzsXqY8ihqIZ3qtD2DZBX34YxhdCiLyPpNREH -bvZgRCd1Nvdlnwy/oQIwfd4+gHFvSUe8u9+/DKjueKE0wSfZRB8va9+fAoGAR3ry -wuOgLvsfkMpLiII8lSvzH5kuZVzCq6RT9wo/RB42amlpoasGjfrXF0M73N6EaIqA -8RkwDNsAEE2ce0Xq3hGGPjyOQVliXCR0/LaKT4eIdudHzBa8IvO2p9xKaoLcHoQm -Q573qPo0ynyYm+yqjRjJHG247+cLqhdPI5ib/zUCgYB2LF4I/46XDyQw2sEJjEP/ -xTEKeo+TqNQTIGrkdiLqAvIKDYfyBxp7qtmwFkM1OOiqjWF0JpZD4haMH9HJFzA6 -mUZVVUB2UlEoknvXSKhbefPpNpCWYJcvQ24aEsE7IcxNasDgtY2dRHdg+/LdOtPY -7bjFcMY3B6PzLER1Q9hyBw== ------END PRIVATE KEY----- diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.jks b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.jks index 0d1dc3446..9c70d7fb9 100644 Binary files a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.jks and b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.jks differ diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.key b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.key new file mode 100644 index 000000000..1a6efe673 --- /dev/null +++ b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCbJRo05tLVsJ5y +oAu1jalEmDcW5VEZCcqA+VLkps6bDOZ5VAQMWMQYM7U6NOtiyRC81E8wP/ZICyDD +II/sBtTkuO+UAoHsqA5sH9Ej7hUQZdBtAI8QLyc87Nmoo88YmEWylGuIJjtSj1N1 +5c/PZovJcI02ZcbRpNwAcARuH+Z2uU2O7mTJYFj1w504OwnNR+JqzGxBZFGl5m+m +YYRradCS9OPuC6dekFq4Ih65aKfj/G3fqcJpjpi7oJUyBIfr/fd4/u7/AV2KnZmE +N56IjoSvcpxTw9QO7q65u9T4JLqvlpORwrzIgSu82eEp/RQ6L8pAymUxWDJaFQ1y +4Znw0K5nAgMBAAECggEAIlg4UPW4Pq32pZFghjRyAEliCKODLHPKbHrFKvDyU8ir +TLiYnNMZtfHccKI+aYPxPJwTW68NKi2sdwXCVpG8l1WJU86qTGV3q9/vQHD4IMUp +Orgg84g8u3QDSx3YPq2W4E2S8HTmNQSdiT/ynQsqbtGHsT8eoFJKkZ46nNZbAnTy +dW0ZEDNvNJ/F7KMxrnf4ibrQKx22rQtF5Go3G/Nm2WQZbcJ+0fkccXtunL3c4uuG +xH/xdlOUlay4WOcmKw93HJOs7D2YEdZ2uTATgas74dK+RyXzyvVQoEpOSIJ2jQYb +wEfcR85p5hvU9xR085Cp8+LAo2bKiQWGw0VUkIaTAQKBgQC3J/z2m6Wq5nvnIKE4 +vWg12jwvHhyP2zIZjKPncA0lKmUC7vBJ60KIm4O0fDVfSksgsLhxgZxchDfRjZN2 +olVqrqYTYi/OL4gSroSMK1VNyGj/n+4LTPIQxwiepGkbdj0vv+eKXG0CNZEOACyq +jhA97GaeY3aUTsE/EzSVaa6mYQKBgQDY2Sb1P8oTxFcfrNyLyr663N+uLPzEfu+S +vFvvvG3ppcZjijmQVOJsW5R2F/7QCG2VdWft6Q6g2Ae/zWNSCvP2qYxJFhqtXPHx +j33pU0sveQZdEy/dfiNfqqepd4EyZWFsLUQ2c4NMYvmT8PiArn6YUZ/nKcnwNGek +t2hGItn5xwKBgC4j9sgxgdTB56jcQYFHxf77EXpVPaDH+aESGyBszAL24SeSBhq5 +F7POaamIOPHeh3qeynhdzIRKEr3JysJyNs5/XPs5Gw34T3FVYbLmH8FOoZT0N0XF +hp3PZk6A4LG4YcWrtKrYieWqlPZP+PCmhVT0Pw3bxL2r8WbwcajKTONBAoGAWia9 +SYyBiIJB7ktBTWS2sp0M6S6Oz2ouU4S3fA2MbGyc89kNYXHIyF+ycv4602YNmOs8 +j+4qRLhLUHQk7IDdOBj415G2+YgAlfqf0Bbu1Qetm5hUd/Lu5eDe31dtgPQg8oZH +K5QOa/1h4R13Upg4zT5yCfqXl6NRy2rskOwATxUCgYBbnpKY0sPyY1BxaxPChXuN +hlIeRMwhurk+VylkvNOF3GvwJ9Z7Uzuf62PzXRu0anWtlGY9KFP494SX1YL7CQO9 +Mws8Zo881MJr+oYzgwhv9CQhmNTtK7awjDizOlyuz7r4PJYIaKuqFxwiRBqNxJdA +loFhm8Tc2RjLkAHcKjGgBQ== +-----END PRIVATE KEY----- diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.p12 b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.p12 deleted file mode 100644 index 1d10c4f38..000000000 Binary files a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.p12 and /dev/null differ diff --git a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.pem b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.pem index 9486712a3..294bf61d0 100644 --- a/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.pem +++ b/integration-test-suite/test-artifacts/DynamicClientRegistration/AU/sample-client-resources/transport-keystore/transport.pem @@ -1,16 +1,16 @@ -----BEGIN CERTIFICATE----- -MIIFODCCBCCgAwIBAgIEWca5LzANBgkqhkiG9w0BAQsFADBTMQswCQYDVQQGEwJH +MIIFODCCBCCgAwIBAgIEWcbiiTANBgkqhkiG9w0BAQsFADBTMQswCQYDVQQGEwJH QjEUMBIGA1UEChMLT3BlbkJhbmtpbmcxLjAsBgNVBAMTJU9wZW5CYW5raW5nIFBy -ZS1Qcm9kdWN0aW9uIElzc3VpbmcgQ0EwHhcNMjMwNDE3MDQ1ODE2WhcNMjQwNTE3 -MDUyODE2WjBhMQswCQYDVQQGEwJHQjEUMBIGA1UEChMLT3BlbkJhbmtpbmcxGzAZ -BgNVBAsTEjAwMTU4MDAwMDFIUVFyWkFBWDEfMB0GA1UEAxMWb1E0S29hYXZwT3Vv -RTdydlFzWkVPVjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJeMaWpz -mwYZ25cDHLSEWhcwaa/JJXgwupZJifByhaao8m/Hhx8PZpXOXz7GcfiNVmz3w1cA -FXvfrNh4A7rc2vjp9shNQ6bQnbOKVjoN+rNxskYjxpvLOllCUaii5kjdRF5r0YE9 -7t3hH7GdATT56Js9aomykbeYodG1vN4eDcgArn1fO7q+6+0Ew2Mla5X+T/fsfu+1 -4tXMLx7AAQSCzGfsYnJp6fCJQ4uk1d5mlYWd+cM2gWf1eQ5sHeL1K9B+czos57NF -hsVUBvPCPLmratanj78tN8O6zOxAs1UEckf+z1rLK3D2NCqv9FnfB7saLKhp58vQ -qoRnOiW+lr1Z4bsCAwEAAaOCAgQwggIAMA4GA1UdDwEB/wQEAwIHgDAgBgNVHSUB +ZS1Qcm9kdWN0aW9uIElzc3VpbmcgQ0EwHhcNMjMxMTE1MDUxMDMxWhcNMjQxMjE1 +MDU0MDMxWjBhMQswCQYDVQQGEwJHQjEUMBIGA1UEChMLT3BlbkJhbmtpbmcxGzAZ +BgNVBAsTEjAwMTU4MDAwMDFIUVFyWkFBWDEfMB0GA1UEAxMWakZRdVE0ZVFiTkNN +U3FkQ29nMjFuRjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJslGjTm +0tWwnnKgC7WNqUSYNxblURkJyoD5UuSmzpsM5nlUBAxYxBgztTo062LJELzUTzA/ +9kgLIMMgj+wG1OS475QCgeyoDmwf0SPuFRBl0G0AjxAvJzzs2aijzxiYRbKUa4gm +O1KPU3Xlz89mi8lwjTZlxtGk3ABwBG4f5na5TY7uZMlgWPXDnTg7Cc1H4mrMbEFk +UaXmb6ZhhGtp0JL04+4Lp16QWrgiHrlop+P8bd+pwmmOmLuglTIEh+v993j+7v8B +XYqdmYQ3noiOhK9ynFPD1A7urrm71Pgkuq+Wk5HCvMiBK7zZ4Sn9FDovykDKZTFY +MloVDXLhmfDQrmcCAwEAAaOCAgQwggIAMA4GA1UdDwEB/wQEAwIHgDAgBgNVHSUB Af8EFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwgeAGA1UdIASB2DCB1TCB0gYLKwYB BAGodYEGAWQwgcIwKgYIKwYBBQUHAgEWHmh0dHA6Ly9vYi50cnVzdGlzLmNvbS9w b2xpY2llczCBkwYIKwYBBQUHAgIwgYYMgYNVc2Ugb2YgdGhpcyBDZXJ0aWZpY2F0 @@ -20,11 +20,11 @@ aWNlIFN0YXRlbWVudDBtBggrBgEFBQcBAQRhMF8wJgYIKwYBBQUHMAGGGmh0dHA6 Ly9vYi50cnVzdGlzLmNvbS9vY3NwMDUGCCsGAQUFBzAChilodHRwOi8vb2IudHJ1 c3Rpcy5jb20vb2JfcHBfaXNzdWluZ2NhLmNydDA6BgNVHR8EMzAxMC+gLaArhilo dHRwOi8vb2IudHJ1c3Rpcy5jb20vb2JfcHBfaXNzdWluZ2NhLmNybDAfBgNVHSME -GDAWgBRQc5HGIXLTd/T+ABIGgVx5eW4/UDAdBgNVHQ4EFgQUSoZfmnXGAPddPqfH -WVOvkxD89MgwDQYJKoZIhvcNAQELBQADggEBABHzHOJzn4DPHay8xGzlWJIxxe+X -sNtupR5V/ouEGCzJMUPmegYeK2Kiv+Z9nJKnbspgqLil52yauKWRmiXif4FWoOPR -wspR9ijnynCgIp6z3EAOawbe28HkaGEfAi8PMqdNAYLKpXg35TUnbP+p2Q55Grq9 -EpSR2APQfJ4TjgLgKjqLRf/RjJAY9hJbQJIUl07esYf8hH7mX6uHDCywzic+UEQ3 -tUfo7PgWmnmtyUdFcW1qAl4P80a5fb8Wq0gNu6gN5tK2bg5TfSo3Gp2It8NVu/dY -7q3ur7CAYTXrThjg4GXUQgVqYgV3pHbr1LTAiRtac7RBhMNPCklZA78RpTM= +GDAWgBRQc5HGIXLTd/T+ABIGgVx5eW4/UDAdBgNVHQ4EFgQU7T6cMtCSQTT5JWW3 +O6vifRUSdpkwDQYJKoZIhvcNAQELBQADggEBAE9jrd/AE65vy3SEWdmFKPS4su7u +EHy+KH18PETV6jMF2UFIJAOx7jl+5a3O66NkcpxFPeyvSuH+6tAAr2ZjpoQwtW9t +Z9k2KSOdNOiJeQgjavwQC6t/BHI3yXWOIQm445BUN1cV9pagcRJjRyL3SPdHVoRf +IbF7VI/+ULHwWdZYPXxtwUoda1mQFf6a+2lO4ziUHb3U8iD90FBURzID7WJ1ODSe +B5zE/hG9Sxd9wlSXvl1oNmc/ha5oG/7rJpRqrx5Dcq3LEoX9iZZ3knHLkCm/abIQ +7Nff8GQytuGhnGZxmGFYKDXdKElcl9dAlZ3bIK2I+I6jD2z2XvSfrhFyRjU= -----END CERTIFICATE----- \ No newline at end of file diff --git a/integration-test-suite/test-artifacts/custom-authenticator-sms-otp/identity-outbound-auth-sms-otp/pom.xml b/integration-test-suite/test-artifacts/custom-authenticator-sms-otp/identity-outbound-auth-sms-otp/pom.xml index c8d8db264..cc038798f 100644 --- a/integration-test-suite/test-artifacts/custom-authenticator-sms-otp/identity-outbound-auth-sms-otp/pom.xml +++ b/integration-test-suite/test-artifacts/custom-authenticator-sms-otp/identity-outbound-auth-sms-otp/pom.xml @@ -143,7 +143,7 @@ org.apache.oltu.oauth2 org.apache.oltu.oauth2.common - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT org.json.wso2 diff --git a/internal-apis/internal-webapps/org.wso2.openbanking.cds.account.type.management.endpoint/pom.xml b/internal-apis/internal-webapps/org.wso2.openbanking.cds.account.type.management.endpoint/pom.xml index 53ec93492..9e60588aa 100644 --- a/internal-apis/internal-webapps/org.wso2.openbanking.cds.account.type.management.endpoint/pom.xml +++ b/internal-apis/internal-webapps/org.wso2.openbanking.cds.account.type.management.endpoint/pom.xml @@ -23,7 +23,7 @@ org.wso2.openbanking internal-apis - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../../pom.xml diff --git a/internal-apis/internal-webapps/org.wso2.openbanking.cds.arrangement.revocation.endpoint/pom.xml b/internal-apis/internal-webapps/org.wso2.openbanking.cds.arrangement.revocation.endpoint/pom.xml index 59b7a2b3a..2285dc3f0 100644 --- a/internal-apis/internal-webapps/org.wso2.openbanking.cds.arrangement.revocation.endpoint/pom.xml +++ b/internal-apis/internal-webapps/org.wso2.openbanking.cds.arrangement.revocation.endpoint/pom.xml @@ -23,7 +23,7 @@ internal-apis org.wso2.openbanking - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/internal-apis/internal-webapps/org.wso2.openbanking.cds.metadata.mgt.endpoint/pom.xml b/internal-apis/internal-webapps/org.wso2.openbanking.cds.metadata.mgt.endpoint/pom.xml index ba67bc935..b0bac56a5 100644 --- a/internal-apis/internal-webapps/org.wso2.openbanking.cds.metadata.mgt.endpoint/pom.xml +++ b/internal-apis/internal-webapps/org.wso2.openbanking.cds.metadata.mgt.endpoint/pom.xml @@ -23,7 +23,7 @@ reference-implementation-consumerdatastandards-au org.wso2.openbanking - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../../../pom.xml 4.0.0 diff --git a/internal-apis/internal-webapps/org.wso2.openbanking.cds.metrics.endpoint/pom.xml b/internal-apis/internal-webapps/org.wso2.openbanking.cds.metrics.endpoint/pom.xml index 0248893ae..32d281bd5 100644 --- a/internal-apis/internal-webapps/org.wso2.openbanking.cds.metrics.endpoint/pom.xml +++ b/internal-apis/internal-webapps/org.wso2.openbanking.cds.metrics.endpoint/pom.xml @@ -23,7 +23,7 @@ reference-implementation-consumerdatastandards-au org.wso2.openbanking - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../../../pom.xml 4.0.0 diff --git a/internal-apis/pom.xml b/internal-apis/pom.xml index 74dd9b2eb..44e4859b7 100644 --- a/internal-apis/pom.xml +++ b/internal-apis/pom.xml @@ -23,7 +23,7 @@ reference-implementation-consumerdatastandards-au org.wso2.openbanking - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index 4529e9f41..8fa8f45d6 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.wso2.openbanking reference-implementation-consumerdatastandards-au pom - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT org.wso2 wso2 diff --git a/react-apps/pom.xml b/react-apps/pom.xml index 5d6bd85ac..7e151b2c0 100644 --- a/react-apps/pom.xml +++ b/react-apps/pom.xml @@ -23,7 +23,7 @@ reference-implementation-consumerdatastandards-au org.wso2.openbanking - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml diff --git a/toolkits/ob-apim/pom.xml b/toolkits/ob-apim/pom.xml index b757ad5a7..e6bee06b8 100644 --- a/toolkits/ob-apim/pom.xml +++ b/toolkits/ob-apim/pom.xml @@ -25,7 +25,7 @@ org.wso2.openbanking open-banking-toolkit-cds-modules - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml @@ -90,7 +90,7 @@ regex="org.wso2.openbanking.cds.gateway-(\d.*?)\.jar$"/> - + diff --git a/toolkits/ob-bi/carbon-home/deployment/siddhi-files/CDSCustomerRecipientMetricsApp.siddhi b/toolkits/ob-bi/carbon-home/deployment/siddhi-files/CDSCustomerRecipientMetricsApp.siddhi index 2e8209ac7..9ef3fa21b 100644 --- a/toolkits/ob-bi/carbon-home/deployment/siddhi-files/CDSCustomerRecipientMetricsApp.siddhi +++ b/toolkits/ob-bi/carbon-home/deployment/siddhi-files/CDSCustomerRecipientMetricsApp.siddhi @@ -93,7 +93,7 @@ select CDR_ARRANGEMENT_ID as CONSENT_ID, CLIENT_ID, USER_ID insert into CountableConsentAuthStream; -- Filter revoked authorizations that should be counted -from ConsentInputStream[STATUS == "Revoked"]#window.unique:first(CDR_ARRANGEMENT_ID) as I join CONSENT_RAW_DATA as T +from ConsentInputStream[str:equalsIgnoreCase(STATUS, "Revoked")]#window.unique:first(CDR_ARRANGEMENT_ID) as I join CONSENT_RAW_DATA as T on I.CDR_ARRANGEMENT_ID == T.CONSENT_ID select I.CDR_ARRANGEMENT_ID as CONSENT_ID, T.CLIENT_ID as CLIENT_ID, T.USER_ID as USER_ID, T.STATUS as CURRENT_STATUS having CURRENT_STATUS == "authorized" diff --git a/toolkits/ob-bi/pom.xml b/toolkits/ob-bi/pom.xml index f000a10b0..739cfa863 100644 --- a/toolkits/ob-bi/pom.xml +++ b/toolkits/ob-bi/pom.xml @@ -25,7 +25,7 @@ org.wso2.openbanking open-banking-toolkit-cds-modules - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml diff --git a/toolkits/ob-is/pom.xml b/toolkits/ob-is/pom.xml index cf2126b79..10de0e11e 100644 --- a/toolkits/ob-is/pom.xml +++ b/toolkits/ob-is/pom.xml @@ -24,7 +24,7 @@ org.wso2.openbanking open-banking-toolkit-cds-modules - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml @@ -67,7 +67,7 @@ package - + diff --git a/toolkits/ob-is/repository/resources/wso2is-6.0.0-deployment-cds.toml b/toolkits/ob-is/repository/resources/wso2is-6.0.0-deployment-cds.toml index e6dbb096c..7aa31a959 100644 --- a/toolkits/ob-is/repository/resources/wso2is-6.0.0-deployment-cds.toml +++ b/toolkits/ob-is/repository/resources/wso2is-6.0.0-deployment-cds.toml @@ -168,6 +168,7 @@ skip_db_schema_creation = true [oauth] allowed_scopes = ["OB.*", "profile"] +keep_oidc_scopes_in_consent_url = true [oauth.token_renewal] renew_refresh_token = false diff --git a/toolkits/pom.xml b/toolkits/pom.xml index 8aefb059f..b491b86b7 100644 --- a/toolkits/pom.xml +++ b/toolkits/pom.xml @@ -23,7 +23,7 @@ org.wso2.openbanking reference-implementation-consumerdatastandards-au - 1.0.6-SNAPSHOT + 1.1.1-SNAPSHOT ../pom.xml