Skip to content

Commit

Permalink
Merge branch 'main' into bnr-revoke
Browse files Browse the repository at this point in the history
  • Loading branch information
anjuchamantha committed Dec 9, 2024
2 parents 8b3a849 + 05db9f6 commit d604016
Show file tree
Hide file tree
Showing 147 changed files with 11,561 additions and 1,279 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/create-release-tag.yaml
Original file line number Diff line number Diff line change
@@ -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<release-version>"
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
2 changes: 1 addition & 1 deletion components/org.wso2.openbanking.cds.common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<artifactId>reference-implementation-consumerdatastandards-au-components</artifactId>
<groupId>org.wso2.openbanking</groupId>
<version>1.0.6-SNAPSHOT</version>
<version>1.1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>reference-implementation-consumerdatastandards-au-components</artifactId>
<groupId>org.wso2.openbanking</groupId>
<version>1.0.6-SNAPSHOT</version>
<version>1.1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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<String, Object> 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);
}
Expand Down Expand Up @@ -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<AuthorizationResource> 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.openbanking.cds.demo.backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>reference-implementation-consumerdatastandards-au-components</artifactId>
<groupId>org.wso2.openbanking</groupId>
<version>1.0.6-SNAPSHOT</version>
<version>1.1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.openbanking.cds.gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>reference-implementation-consumerdatastandards-au</artifactId>
<groupId>org.wso2.openbanking</groupId>
<version>1.0.6-SNAPSHOT</version>
<version>1.1.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.openbanking.cds.identity/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>reference-implementation-consumerdatastandards-au-components</artifactId>
<groupId>org.wso2.openbanking</groupId>
<version>1.0.6-SNAPSHOT</version>
<version>1.1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/org.wso2.openbanking.cds.metrics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>reference-implementation-consumerdatastandards-au-components</artifactId>
<groupId>org.wso2.openbanking</groupId>
<version>1.0.6-SNAPSHOT</version>
<version>1.1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion components/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>reference-implementation-consumerdatastandards-au</artifactId>
<groupId>org.wso2.openbanking</groupId>
<version>1.0.6-SNAPSHOT</version>
<version>1.1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
5 changes: 2 additions & 3 deletions integration-test-suite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
23 changes: 19 additions & 4 deletions integration-test-suite/cds-toolkit-integration-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>cds-toolkit-integration-test</artifactId>
<version>1.0.6-SNAPSHOT</version>
<version>1.1.1-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
<groupId>org.wso2.openbanking</groupId>
<artifactId>integration-test-suite</artifactId>
<version>1.0.6-SNAPSHOT</version>
<version>1.1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -42,7 +42,7 @@
<dependency>
<groupId>org.wso2.openbanking</groupId>
<artifactId>cds-toolkit-test-framework</artifactId>
<version>${com.wso2.openbanking.test.cds.version}</version>
<version>${org.wso2.openbanking.test.cds.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand Down Expand Up @@ -79,6 +79,21 @@
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.49</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -163,7 +178,7 @@
</build>

<properties>
<com.wso2.openbanking.test.cds.version>1.0.0</com.wso2.openbanking.test.cds.version>
<org.wso2.openbanking.test.cds.version>1.0.0</org.wso2.openbanking.test.cds.version>
</properties>

</project>
Expand Down
Loading

0 comments on commit d604016

Please sign in to comment.