diff --git a/.github/scripts/pr-builder-7.sh b/.github/scripts/pr-builder-7.sh
deleted file mode 100644
index e86d98d96be..00000000000
--- a/.github/scripts/pr-builder-7.sh
+++ /dev/null
@@ -1,371 +0,0 @@
-#!/bin/bash +x
-OUTBOUND_AUTH_OIDC_REPO=identity-outbound-auth-oidc
-OUTBOUND_AUTH_OIDC_REPO_CLONE_LINK=https://github.com/wso2-extensions/identity-outbound-auth-oidc.git
-SCIM2_REPO=identity-inbound-provisioning-scim2
-SCIM2_REPO_CLONE_LINK=https://github.com/wso2-extensions/identity-inbound-provisioning-scim2.git
-
-echo ""
-echo "=========================================================="
-PR_LINK=${PR_LINK%/}
-JDK_VERSION=${JDK_VERSION%/}
-JAVA_8_HOME=${JAVA_8_HOME%/}
-JAVA_11_HOME=${JAVA_11_HOME%/}
-echo " PR_LINK: $PR_LINK"
-echo " JAVA 8 Home: $JAVA_8_HOME"
-echo " JAVA 11 Home: $JAVA_11_HOME"
-echo " User Input: $JDK_VERSION"
-echo "::warning::Build ran for PR $PR_LINK"
-
-USER=$(echo $PR_LINK | awk -F'/' '{print $4}')
-REPO=$(echo $PR_LINK | awk -F'/' '{print $5}')
-PULL_NUMBER=$(echo $PR_LINK | awk -F'/' '{print $7}')
-
-echo " USER: $USER"
-echo " REPO: $REPO"
-echo " PULL_NUMBER: $PULL_NUMBER"
-echo "::set-output name=REPO_NAME::$REPO"
-echo "=========================================================="
-echo "Cloning product-is"
-echo "=========================================================="
-
-git clone https://github.com/wso2/product-is
-
-if [ "$REPO" = "product-is" ]; then
-
- echo ""
- echo "PR is for the product-is itself. Start building with test..."
- echo "=========================================================="
- cd product-is
- git checkout 7.x.x
-
- echo ""
- echo "Applying PR $PULL_NUMBER as a diff..."
- echo "=========================================================="
- wget -q --output-document=diff.diff $PR_LINK.diff
- cat diff.diff
- echo "=========================================================="
- git apply diff.diff || {
- echo 'Applying diff failed. Exiting...'
- echo "::error::Applying diff failed."
- exit 1
- }
-
- echo "Last 3 changes:"
- COMMIT1=$(git log --oneline -1)
- COMMIT2=$(git log --oneline -2 | tail -1)
- COMMIT3=$(git log --oneline -3 | tail -1)
- echo "$COMMIT1"
- echo "$COMMIT2"
- echo "$COMMIT3"
-
- cat pom.xml
- export JAVA_HOME=$JAVA_11_HOME
- mvn clean install --batch-mode | tee mvn-build.log
-
- PR_BUILD_STATUS=$(cat mvn-build.log | grep "\[INFO\] BUILD" | grep -oE '[^ ]+$')
- PR_TEST_RESULT=$(sed -n -e '/\[INFO\] Results:/,/\[INFO\] Tests run:/ p' mvn-build.log)
-
- PR_BUILD_FINAL_RESULT=$(
- echo "==========================================================="
- echo "product-is BUILD $PR_BUILD_STATUS"
- echo "=========================================================="
- echo ""
- echo "$PR_TEST_RESULT"
- )
-
- PR_BUILD_RESULT_LOG_TEMP=$(echo "$PR_BUILD_FINAL_RESULT" | sed 's/$/%0A/')
- PR_BUILD_RESULT_LOG=$(echo $PR_BUILD_RESULT_LOG_TEMP)
- echo "::warning::$PR_BUILD_RESULT_LOG"
-
- PR_BUILD_SUCCESS_COUNT=$(grep -o -i "\[INFO\] BUILD SUCCESS" mvn-build.log | wc -l)
- if [ "$PR_BUILD_SUCCESS_COUNT" != "1" ]; then
- echo "PR BUILD not successfull. Aborting."
- echo "::error::PR BUILD not successfull. Check artifacts for logs."
- exit 1
- fi
-else
- echo ""
- echo "PR is for the dependency repository $REPO."
- echo ""
- echo "Cloning $USER/$REPO"
- echo "=========================================================="
- git clone https://github.com/$USER/$REPO
- echo ""
- echo "Determining dependency version property key..."
- echo "=========================================================="
- wget https://raw.githubusercontent.com/wso2/product-is/master/.github/scripts/version_property_finder.py
- VERSION_PROPERTY=$(python version_property_finder.py $REPO product-is 2>&1)
- VERSION_PROPERTY_KEY=""
- if [ "$VERSION_PROPERTY" != "invalid" ]; then
- echo "Version property key for the $REPO is $VERSION_PROPERTY"
- VERSION_PROPERTY_KEY=$VERSION_PROPERTY
- else
- echo ""
- echo "=========================================================="
- echo "$REPO is not yet supported! Exiting..."
- echo "=========================================================="
- echo ""
- echo "::error::PR builder not supprted"
- exit 1
- fi
-
- echo ""
- echo "Property key found: $VERSION_PROPERTY_KEY"
- cd $REPO
- if [ "$REPO" = "carbon-kernel" ]; then
- echo ""
- echo "Checking out for 4.10.x branch..."
- echo "=========================================================="
- git checkout 4.10.x
- elif [ "$REPO" = "carbon-deployment" ]; then
- echo ""
- echo "Checking out for 4.x.x branch in carbon-deployment..."
- echo "=========================================================="
- git checkout 4.x.x
- elif [ "$REPO" = "carbon-analytics-common" ]; then
- echo ""
- echo "Checking out for 5.2.x branch in carbon-analytics-common..."
- echo "=========================================================="
- git checkout 5.2.x
- elif [ "$REPO" = "carbon-identity-framework" ]; then
- echo ""
- echo "Checking out for 6.0.x branch in carbon-identity-framework..."
- echo "=========================================================="
- git checkout 6.0.x
- elif [ "$REPO" = "identity-governance" ]; then
- echo ""
- echo "Checking out for 2.0.x branch in identity-governance..."
- echo "=========================================================="
- git checkout 2.0.x
- fi
- DEPENDENCY_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
- echo "Dependency Version: $DEPENDENCY_VERSION"
- echo ""
- echo "Applying PR $PULL_NUMBER as a diff..."
- echo "=========================================================="
- wget -q --output-document=diff.diff $PR_LINK.diff
- cat diff.diff
- echo "=========================================================="
- git apply diff.diff || {
- echo 'Applying diff failed. Exiting...'
- echo "::error::Applying diff failed."
- exit 1
- }
-
- echo ""
- echo "Building dependency repo $REPO..."
- echo "=========================================================="
-
- if [ "$JDK_VERSION" = "11" ]; then
- export JAVA_HOME=$JAVA_11_HOME
- else
- export JAVA_HOME=$JAVA_8_HOME
- fi
-
- if [ "$REPO" = "carbon-kernel" ]; then
- mvn clean install -Dmaven.test.skip=true --batch-mode | tee mvn-build.log
- else
- mvn clean install --batch-mode | tee mvn-build.log
- fi
-
- echo ""
- echo "Dependency repo $REPO build complete."
- echo "Built version: $DEPENDENCY_VERSION"
- echo "=========================================================="
- echo ""
-
- REPO_BUILD_STATUS=$(cat mvn-build.log | grep "\[INFO\] BUILD" | grep -oE '[^ ]+$')
- REPO_TEST_RESULT_1=$(sed -n -e '/Results :/,/Tests run:/ p' mvn-build.log)
- REPO_TEST_RESULT_2=$(sed -n -e '/\[INFO\] Results:/,/\[INFO\] Tests run:/ p' mvn-build.log)
-
- REPO_FINAL_RESULT=$(
- echo "==========================================================="
- echo "$REPO BUILD $REPO_BUILD_STATUS"
- echo "=========================================================="
- echo ""
- echo "Built version: $DEPENDENCY_VERSION"
- echo ""
- echo "$REPO_TEST_RESULT_1"
- echo ""
- echo "$REPO_TEST_RESULT_2"
- )
-
- REPO_BUILD_RESULT_LOG_TEMP=$(echo "$REPO_FINAL_RESULT" | sed 's/$/%0A/')
- REPO_BUILD_RESULT_LOG=$(echo $REPO_BUILD_RESULT_LOG_TEMP)
- echo "::warning::$REPO_BUILD_RESULT_LOG"
-
- if [ "$REPO_BUILD_STATUS" != "SUCCESS" ]; then
- echo "$REPO BUILD not successfull. Aborting."
- echo "::error::$REPO BUILD not successfull. Check artifacts for logs."
- exit 1
- fi
- cd ..
-
- OUTBOUND_AUTH_OIDC_VERSION_PROPERTY_KEY=""
- OUTBOUND_AUTH_OIDC_DEPENDENCY_VERSION=""
- if [ "$REPO" = "carbon-kernel" ]; then
- echo ""
- echo "Building Outbound Auth OIDC repo..."
- echo "=========================================================="
- git clone $OUTBOUND_AUTH_OIDC_REPO_CLONE_LINK
- OUTBOUND_AUTH_OIDC_VERSION_PROPERTY=$(python version_property_finder.py $OUTBOUND_AUTH_OIDC_REPO product-is 2>&1)
- if [ "$OUTBOUND_AUTH_OIDC_VERSION_PROPERTY" != "invalid" ]; then
- echo "Version property key for the $OUTBOUND_AUTH_OIDC_REPO is $OUTBOUND_AUTH_OIDC_VERSION_PROPERTY"
- OUTBOUND_AUTH_OIDC_VERSION_PROPERTY_KEY=$OUTBOUND_AUTH_OIDC_VERSION_PROPERTY
- else
- echo ""
- echo "=========================================================="
- echo "Unable to find the version property for $OUTBOUND_AUTH_OIDC_REPO..."
- echo "=========================================================="
- echo ""
- echo "::error::Unable to find the version property for $OUTBOUND_AUTH_OIDC_REPO..."
- exit 1
- fi
- cd $OUTBOUND_AUTH_OIDC_REPO
- OUTBOUND_AUTH_OIDC_DEPENDENCY_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
- echo "Outbound Auth OIDC Dependency Version: $OUTBOUND_AUTH_OIDC_DEPENDENCY_VERSION"
- echo ""
-
- KERNEL_VERSION_PROPERTY_KEY=carbon.kernel.version
- echo "Updating carbon-kernel dependency version in identity-outbound-auth-oidc repo..."
- echo "=========================================================="
- echo ""
- sed -i "s/<$KERNEL_VERSION_PROPERTY_KEY>.*<\/$KERNEL_VERSION_PROPERTY_KEY>/<$KERNEL_VERSION_PROPERTY_KEY>$DEPENDENCY_VERSION<\/$KERNEL_VERSION_PROPERTY_KEY>/" pom.xml
-
- echo ""
- echo "Building repo $OUTBOUND_AUTH_OIDC_REPO..."
- echo "=========================================================="
-
-
- export JAVA_HOME=$JAVA_11_HOME
- mvn clean install -Dmaven.test.skip=true --batch-mode | tee mvn-build.log
-
- echo "Repo $OUTBOUND_AUTH_OIDC_REPO build complete."
- SUB_REPO_BUILD_STATUS=$(cat mvn-build.log | grep "\[INFO\] BUILD" | grep -oE '[^ ]+$')
-
- if [ "$SUB_REPO_BUILD_STATUS" != "SUCCESS" ]; then
- echo "$OUTBOUND_AUTH_OIDC_REPO repo build not successfull. Aborting."
- echo "::error::$OUTBOUND_AUTH_OIDC_REPO repo build not successfull. Aborting."
- exit 1
- fi
-
- echo ""
- echo "Built version: $OUTBOUND_AUTH_OIDC_DEPENDENCY_VERSION"
- echo "=========================================================="
- echo ""
- cd ..
- fi
-
- SCIM2_VERSION_PROPERTY_KEY=""
- SCIM2_DEPENDENCY_VERSION=""
- if [ "$REPO" = "charon" ]; then
- echo ""
- echo "Building SCIM2 repo..."
- echo "=========================================================="
- git clone $SCIM2_REPO_CLONE_LINK
- SCIM2_VERSION_PROPERTY=$(python version_property_finder.py $SCIM2_REPO product-is 2>&1)
- if [ "$SCIM2_VERSION_PROPERTY" != "invalid" ]; then
- echo "Version property key for the $SCIM2_REPO is $SCIM2_VERSION_PROPERTY"
- SCIM2_VERSION_PROPERTY_KEY=$SCIM2_VERSION_PROPERTY
- else
- echo ""
- echo "=========================================================="
- echo "Unable to find the version property for $SCIM2_REPO..."
- echo "=========================================================="
- echo ""
- echo "::error::Unable to find the version property for $SCIM2_REPO..."
- exit 1
- fi
- cd $SCIM2_REPO
- SCIM2_DEPENDENCY_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
- echo "SCIM2 Dependency Version: $SCIM2_DEPENDENCY_VERSION"
- echo ""
-
- CHARON_VERSION_PROPERTY_KEY=charon.version
- echo "Updating charon dependency version in $SCIM2_REPO repo..."
- echo "=========================================================="
- echo ""
- sed -i "s/<$CHARON_VERSION_PROPERTY_KEY>.*<\/$CHARON_VERSION_PROPERTY_KEY>/<$CHARON_VERSION_PROPERTY_KEY>$DEPENDENCY_VERSION<\/$CHARON_VERSION_PROPERTY_KEY>/" pom.xml
-
- echo ""
- echo "Building $SCIM2_REPO repo..."
- echo "=========================================================="
-
- export JAVA_HOME=$JAVA_8_HOME
- mvn clean install -Dmaven.test.skip=true --batch-mode | tee mvn-build.log
-
- echo "Repo $SCIM2_REPO build complete."
- SUB_REPO_BUILD_STATUS=$(cat mvn-build.log | grep "\[INFO\] BUILD" | grep -oE '[^ ]+$')
-
- if [ "$SUB_REPO_BUILD_STATUS" != "SUCCESS" ]; then
- echo "$SCIM2_REPO repo build not successfull. Aborting."
- echo "::error::$SCIM2_REPO repo build not successfull. Aborting."
- exit 1
- fi
-
- echo ""
- echo "Built version: $SCIM2_DEPENDENCY_VERSION"
- echo "=========================================================="
- echo ""
- cd ..
- fi
-
- cd product-is
- git checkout 7.x.x
-
- echo "Updating dependency version in product-is..."
- echo "=========================================================="
- echo ""
- if [ "$REPO" = "charon" ]; then
- echo "Updating SCIM2 version in product-is..."
- echo "=========================================================="
- echo ""
- sed -i "s/<$SCIM2_VERSION_PROPERTY_KEY>.*<\/$SCIM2_VERSION_PROPERTY_KEY>/<$SCIM2_VERSION_PROPERTY_KEY>$SCIM2_DEPENDENCY_VERSION<\/$SCIM2_VERSION_PROPERTY_KEY>/" pom.xml
- else
- sed -i "s/<$VERSION_PROPERTY_KEY>.*<\/$VERSION_PROPERTY_KEY>/<$VERSION_PROPERTY_KEY>$DEPENDENCY_VERSION<\/$VERSION_PROPERTY_KEY>/" pom.xml
- if [ "$REPO" = "carbon-kernel" ]; then
- echo "Updating Outbound Auth OIDC version in product-is..."
- echo "=========================================================="
- echo ""
- sed -i "s/<$OUTBOUND_AUTH_OIDC_VERSION_PROPERTY_KEY>.*<\/$OUTBOUND_AUTH_OIDC_VERSION_PROPERTY_KEY>/<$OUTBOUND_AUTH_OIDC_VERSION_PROPERTY_KEY>$OUTBOUND_AUTH_OIDC_DEPENDENCY_VERSION<\/$OUTBOUND_AUTH_OIDC_VERSION_PROPERTY_KEY>/" pom.xml
- echo "Updating caron-kernel version in carbon.product..."
- echo "=========================================================="
- echo ""
- KERNEL_DEPENDENCY_VERSION=$(echo $DEPENDENCY_VERSION | sed -e "s/-/./g")
- echo "Dependency version for carbon.product : $KERNEL_DEPENDENCY_VERSION"
- sed -i "s/version=\"4.10.*\"/version=\"$KERNEL_DEPENDENCY_VERSION\"/g" modules/p2-profile-gen/carbon.product
- fi
- fi
-
- export JAVA_HOME=$JAVA_11_HOME
- cat pom.xml
- mvn clean install --batch-mode | tee mvn-build.log
-
- PR_BUILD_STATUS=$(cat mvn-build.log | grep "\[INFO\] BUILD" | grep -oE '[^ ]+$')
- PR_TEST_RESULT=$(sed -n -e '/\[INFO\] Results:/,/\[INFO\] Tests run:/ p' mvn-build.log)
-
- PR_BUILD_FINAL_RESULT=$(
- echo "==========================================================="
- echo "product-is BUILD $PR_BUILD_STATUS"
- echo "=========================================================="
- echo ""
- echo "$PR_TEST_RESULT"
- )
-
- PR_BUILD_RESULT_LOG_TEMP=$(echo "$PR_BUILD_FINAL_RESULT" | sed 's/$/%0A/')
- PR_BUILD_RESULT_LOG=$(echo $PR_BUILD_RESULT_LOG_TEMP)
- echo "::warning::$PR_BUILD_RESULT_LOG"
-
- PR_BUILD_SUCCESS_COUNT=$(grep -o -i "\[INFO\] BUILD SUCCESS" mvn-build.log | wc -l)
- if [ "$PR_BUILD_SUCCESS_COUNT" != "1" ]; then
- echo "PR BUILD not successfull. Aborting."
- echo "::error::PR BUILD not successfull. Check artifacts for logs."
- exit 1
- fi
-fi
-
-echo ""
-echo "=========================================================="
-echo "Build completed"
-echo "=========================================================="
-echo ""
diff --git a/.github/scripts/pr-builder.sh b/.github/scripts/pr-builder.sh
index 83c681ef493..c191e75a666 100644
--- a/.github/scripts/pr-builder.sh
+++ b/.github/scripts/pr-builder.sh
@@ -23,7 +23,7 @@ PULL_NUMBER=$(echo $PR_LINK | awk -F'/' '{print $7}')
echo " USER: $USER"
echo " REPO: $REPO"
echo " PULL_NUMBER: $PULL_NUMBER"
-echo "::set-output name=REPO_NAME::$REPO"
+echo "REPO_NAME=$REPO" >> "$GITHUB_OUTPUT"
echo "=========================================================="
echo "Cloning product-is"
echo "=========================================================="
diff --git a/.github/workflows/dependency-updater-7.yml b/.github/workflows/dependency-updater-7.yml
deleted file mode 100644
index 6989aeeef74..00000000000
--- a/.github/workflows/dependency-updater-7.yml
+++ /dev/null
@@ -1,161 +0,0 @@
-# This workflow will update dependencies for product-is 7.x.x.
-name: "[Deprecated] Dependency Updater 7.x.x"
-on:
- workflow_dispatch:
- # schedule:
- # Everyday at 15:30 UTC (9.00 PM SL time)
- # - cron: '30 15 * * *'
-
-env:
- MAVEN_OPTS: -Xmx4g -Xms1g
- REPOSITORY: product-is
- GIT_USERNAME: jenkins-is-staging
- GIT_EMAIL: jenkins-is-staging@wso2.com
- PRODUCT_REPOSITORY_FORKED: $GIT_USERNAME'/'${REPOSITORY}
- REMOTE_PRODUCT_REPOSITORY_PUBLIC: wso2/$REPOSITORY
- PRODUCT_REPOSITORY_PUBLIC: wso2/$REPOSITORY
- BUILD_NUMBER: ${{github.run_id}}
- DEPENDENCY_UPGRADE_BRANCH_NAME: IS_dependency_updater_7.x.x_github_action/$BUILD_NUMBER
- PR: "https://github.com/wso2/product-is/pulls"
- TARGET_BRANCH_NAME: 7.x.x
-
-jobs:
- build:
- runs-on: ubuntu-latest
-
- steps:
- - uses: actions/checkout@v2
- - name: Set up Adopt JDK 11
- uses: actions/setup-java@v2
- with:
- java-version: "11"
- distribution: "adopt"
- - name: Check $JAVA_HOME
- run: |
- echo $JAVA_HOME
- - name: Cache local Maven repository
- id: cache-maven-m2
- uses: actions/cache@v2
- env:
- cache-name: cache-m2
- with:
- path: ~/.m2/repository
- key: ${{ runner.os }}-maven-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
- restore-keys: |
- ${{ runner.os }}-maven-${{ env.cache-name }}-
- ${{ runner.os }}-maven-
- ${{ runner.os }}-
- - name: Update Dependencies
- id: builder_step
- run: |
- echo "::set-output name=REPO_NAME::${{ env.REPOSITORY }}"
- echo ""
- echo "Starting dependency upgrade"
- echo "=========================================================="
- echo ""
- echo "Clean up any existing files"
- echo "=========================================================="
- rm -rf ${{ env.REPOSITORY }}
- echo ""
- echo "Cloning: https://github.com/'${{ env.PRODUCT_REPOSITORY_FORKED }}"
- echo "=========================================================="
- git clone 'https://github.com/'${{ env.PRODUCT_REPOSITORY_FORKED }}'.git'
- cd ${{ env.REPOSITORY }}
- echo ""
- echo 'Add remote: '${{ env.REMOTE_PRODUCT_REPOSITORY_PUBLIC }} 'as https://github.com/'${{ env.PRODUCT_REPOSITORY_PUBLIC }}
- echo "=========================================================="
- git remote add ${{ env.REMOTE_PRODUCT_REPOSITORY_PUBLIC }} 'https://@github.com/'${{ env.PRODUCT_REPOSITORY_PUBLIC }}
- echo ""
- echo 'Fetching:' ${{ env.REMOTE_PRODUCT_REPOSITORY_PUBLIC }}
- echo "=========================================================="
- git fetch ${{ env.REMOTE_PRODUCT_REPOSITORY_PUBLIC }}
- echo ""
- echo 'Checking out:' ${{ env.REMOTE_PRODUCT_REPOSITORY_PUBLIC }} ${{ env.TARGET_BRANCH_NAME }} 'branch'
- echo "=========================================================="
- git checkout -b ${{ env.DEPENDENCY_UPGRADE_BRANCH_NAME }} ${{ env.REMOTE_PRODUCT_REPOSITORY_PUBLIC }}'/'${{ env.TARGET_BRANCH_NAME }}
-
- echo ""
- echo 'Updating dependencies'
- echo "=========================================================="
- mvn versions:update-properties -U -DgenerateBackupPoms=false -DallowMajorUpdates=false -Dincludes=org.wso2.carbon.identity.*,org.wso2.carbon.extension.identity.*,org.wso2.identity.*,org.wso2.carbon.consent.*,org.wso2.carbon.healthcheck.*,org.wso2.carbon.utils,org.wso2.charon,org.apache.rampart.wso2,org.apache.ws.security.wso2
- echo ""
- echo 'Available updates'
- echo "=========================================================="
- git diff --color > dependency_updates.diff
- cat dependency_updates.diff
-
- echo ""
- echo 'Build'
- echo "=========================================================="
- mvn clean install -Dmaven.test.failure.ignore=false | tee mvn-build.log
- PR_BUILD_STATUS=$(cat mvn-build.log | grep "\[INFO\] BUILD" | grep -oE '[^ ]+$')
- PR_TEST_RESULT=$(sed -n -e '/\[INFO\] Results:/,/\[INFO\] Tests run:/ p' mvn-build.log)
- PR_BUILD_FINAL_RESULT=$(
- echo "==========================================================="
- echo "product-is BUILD $PR_BUILD_STATUS"
- echo "=========================================================="
- echo ""
- echo "$PR_TEST_RESULT"
- )
- PR_BUILD_RESULT_LOG_TEMP=$(echo "$PR_BUILD_FINAL_RESULT" | sed 's/$/%0A/')
- PR_BUILD_RESULT_LOG=$(echo $PR_BUILD_RESULT_LOG_TEMP)
- echo "::warning::$PR_BUILD_RESULT_LOG"
- PR_BUILD_SUCCESS_COUNT=$(grep -o -i "\[INFO\] BUILD SUCCESS" mvn-build.log | wc -l)
- if [ "$PR_BUILD_SUCCESS_COUNT" != "1" ]; then
- echo "PR BUILD not successfull. Aborting."
- echo "::error::PR BUILD not successfull. Check artifacts for logs."
- exit 1
- fi
-
- if [ -s dependency_updates.diff ]
- then
- echo ""
- echo 'Commit Changes'
- echo "=========================================================="
- git config --global user.email ${{ env.GIT_EMAIL }}
- git config --global user.name ${{ env.GIT_USERNAME }}
- git commit -a -m 'Bump dependencies from '${{ env.DEPENDENCY_UPGRADE_BRANCH_NAME }}
- git remote rm origin
- git remote add origin 'https://'${{ secrets.PAT }}'@github.com/'${{ env.PRODUCT_REPOSITORY_FORKED }}
-
- echo ""
- echo 'Push Changes'
- echo "=========================================================="
- git push -u origin ${{ env.DEPENDENCY_UPGRADE_BRANCH_NAME }}
-
- echo ""
- echo 'Send Pull Request'
- echo "=========================================================="
-
- TITLE="[7.x.x] Bump Dependencies #"${{ env.BUILD_NUMBER }}
- RESPONSE=$(curl -s -w "%{http_code}" -k -X \
- POST https://api.github.com/repos/${{ env.PRODUCT_REPOSITORY_PUBLIC }}/pulls \
- -H "Authorization: Bearer "${{ secrets.PAT }}"" \
- -H "Content-Type: application/json" \
- -d '{ "title": "'"${TITLE}"'","body": "Bumps dependencies for product-is. Link : https://github.com/wso2/product-is/actions/runs/${{github.run_id}}","head": "'"${{ env.GIT_USERNAME }}:${{ env.DEPENDENCY_UPGRADE_BRANCH_NAME }}"'","base":"'"${{ env.TARGET_BRANCH_NAME }}"'"}')
- RESPONSE_BODY=${RESPONSE::-3}
- STATUS=$(printf "%s" "$RESPONSE" | tail -c 3)
- if [[ $STATUS == "201" ]]; then
- echo "PR=$(echo $RESPONSE_BODY | jq -r '.html_url')" >> $GITHUB_ENV
- fi
- else
- echo ""
- echo "There are no dependency updates available"
- echo "=========================================================="
- exit 0
- fi
- - name: Archive dependency diff file
- if: always()
- uses: actions/upload-artifact@v4
- with:
- name: dependency-updates-diff
- path: |
- ${{steps.builder_step.outputs.REPO_NAME}}/dependency_updates.diff
- - name: Archive maven-build-log file
- if: always()
- uses: actions/upload-artifact@v4
- with:
- name: mvn-build.log
- path: |
- ${{steps.builder_step.outputs.REPO_NAME}}/mvn-build.log
- if-no-files-found: warn
diff --git a/.github/workflows/dependency-updater.yml b/.github/workflows/dependency-updater.yml
index 284ac65fe0a..c12d9c1e4cc 100644
--- a/.github/workflows/dependency-updater.yml
+++ b/.github/workflows/dependency-updater.yml
@@ -7,7 +7,7 @@ on:
- cron: '0 15 * * *'
env:
- MAVEN_OPTS: -Xmx4g -Xms1g
+ MAVEN_OPTS: -Xmx4g -Xms1g -XX:+HeapDumpOnOutOfMemoryError
REPOSITORY: product-is
GIT_USERNAME: jenkins-is-staging
GIT_EMAIL: jenkins-is-staging@wso2.com
@@ -26,9 +26,9 @@ jobs:
JAVA_TOOL_OPTIONS: "-Djdk.util.zip.disableZip64ExtraFieldValidation=true -Djdk.nio.zipfs.allowDotZipEntry=true"
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
- name: Set up Adopt JDK 11
- uses: actions/setup-java@v2
+ uses: actions/setup-java@v4
with:
java-version: "11"
distribution: "adopt"
@@ -37,7 +37,7 @@ jobs:
echo $JAVA_HOME
- name: Cache local Maven repository
id: cache-maven-m2
- uses: actions/cache@v2
+ uses: actions/cache@v4
env:
cache-name: cache-m2
with:
@@ -50,7 +50,7 @@ jobs:
- name: Update Dependencies
id: builder_step
run: |
- echo "::set-output name=REPO_NAME::${{ env.REPOSITORY }}"
+ echo "REPO_NAME=${{ env.REPOSITORY }}" >> "$GITHUB_OUTPUT"
echo ""
echo "Starting dependency upgrade"
echo "=========================================================="
@@ -161,6 +161,14 @@ jobs:
path: |
${{steps.builder_step.outputs.REPO_NAME}}/mvn-build.log
if-no-files-found: warn
+ - name: Archive heap dump
+ if: always()
+ uses: actions/upload-artifact@v4
+ with:
+ name: heap-dump
+ path: |
+ **/**.hprof
+ if-no-files-found: ignore
- name: Google Chat Notification
run: |
STATUS_COLOR=$(if [[ ${{ job.status }} == "success" ]];then echo "#009944";
diff --git a/.github/workflows/fapi-oidc-conformance-test.yml b/.github/workflows/fapi-oidc-conformance-test.yml
index db67cf415cd..36829d3aec2 100644
--- a/.github/workflows/fapi-oidc-conformance-test.yml
+++ b/.github/workflows/fapi-oidc-conformance-test.yml
@@ -32,14 +32,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
path: './product-is'
- name: Set up JDK 11
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v4
with:
java-version: 11.0.18+10
+ distribution: temurin
- name: Setup Python
run: |
@@ -189,7 +190,7 @@ jobs:
python3 ./configure_is_fapi.py ../../$PRODUCT_IS_ZIP
- name: Set up JDK 17
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
diff --git a/.github/workflows/fork-branch-deleter.yml b/.github/workflows/fork-branch-deleter.yml
index a6b1e897c69..d6dbcb6c902 100644
--- a/.github/workflows/fork-branch-deleter.yml
+++ b/.github/workflows/fork-branch-deleter.yml
@@ -13,7 +13,7 @@ jobs:
steps:
# Check out the product-is fork of 'jenkins-is-staging' user
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: ${{ secrets.PAT }}
diff --git a/.github/workflows/fossa-scanner.yaml b/.github/workflows/fossa-scanner.yaml
index f735365f733..b735f753f62 100644
--- a/.github/workflows/fossa-scanner.yaml
+++ b/.github/workflows/fossa-scanner.yaml
@@ -8,7 +8,7 @@ jobs:
fossa-scan:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: fossas/fossa-action@main
with:
api-key: ${{secrets.FOSSAAPIKEY}}
diff --git a/.github/workflows/migration-automation.yml b/.github/workflows/migration-automation.yml
index eead65a5089..b4d9167c57d 100644
--- a/.github/workflows/migration-automation.yml
+++ b/.github/workflows/migration-automation.yml
@@ -53,7 +53,7 @@ jobs:
runs-on: ${{ github.event.inputs.os }}
steps:
- name: Checkout code
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Setup Docker environment
run: |
# Get the ID of the workflow from the GitHub API using curl and jq
@@ -136,7 +136,7 @@ jobs:
runs-on: ${{ github.event.inputs.os }}
steps:
- name: Checkout code
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Execute Migration Automation Script Ubuntu
run: |
chmod +x ${{ github.workspace }}/.github/migration-tester/migration-automation/ubuntu-os/migration-script-ubuntu.sh
@@ -172,7 +172,7 @@ jobs:
steps:
- name: Checkout code
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Create MS SQL Database
run: |
@@ -215,7 +215,7 @@ jobs:
runs-on: ${{ github.event.inputs.os }}
steps:
- name: Checkout code
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Execute Migration Automation Script Mac
run: |
@@ -240,7 +240,7 @@ jobs:
if: ${{ github.event.inputs.database == 'postgres' && github.event.inputs.os == 'macos-latest' }}
steps:
- name: Checkout code
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Set up PostgreSQL
env:
PGDATA: /usr/local/var/postgres
@@ -287,7 +287,7 @@ jobs:
runs-on: ${{ github.event.inputs.os }}
steps:
- name: Checkout code
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- uses: potatoqualitee/mssqlsuite@v1.7
with:
@@ -344,7 +344,7 @@ jobs:
runs-on: ${{ github.event.inputs.os }}
steps:
- name: Checkout code
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v2
if: always()
diff --git a/.github/workflows/oidc-conformance-test.yml b/.github/workflows/oidc-conformance-test.yml
index e6391ced686..bd4d328dbfa 100644
--- a/.github/workflows/oidc-conformance-test.yml
+++ b/.github/workflows/oidc-conformance-test.yml
@@ -36,14 +36,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
path: './product-is'
- name: Set up JDK 11
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v4
with:
java-version: 11.0.18+10
+ distribution: temurin
- name: Setup Python
run: |
@@ -142,7 +143,7 @@ jobs:
python3 ./configure_is.py ../../$PRODUCT_IS_ZIP $ROOT_DIR $ROOT_DIR/jacoco.exec
- name: Set up JDK 17
- uses: actions/setup-java@v3
+ uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
diff --git a/.github/workflows/pr-builder-test-JDK11-7.yml b/.github/workflows/pr-builder-test-JDK11-7.yml
deleted file mode 100644
index 75aab52ac5c..00000000000
--- a/.github/workflows/pr-builder-test-JDK11-7.yml
+++ /dev/null
@@ -1,130 +0,0 @@
-name: "[Deprecated] pr-builder-test 7.x.x"
-
-on:
- workflow_dispatch:
- inputs:
- pr:
- description: "Enter PR link (ex: https://github.com/wso2-extensions/identity-inbound-auth-oauth/pull/1481)"
- default:
- required: true
- jdk:
- description: "Enter Java version (ex: 8,11)"
- default:
- required: true
-
-env:
- MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3
-
-
-jobs:
- build:
- runs-on: ubuntu-latest
-
- steps:
- - name: Print Input
- run: echo Running the PR builder for PR - ${{ github.event.inputs.pr }}
- - name: Comment build info
- run: |
- owner=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 4)
- repo=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 5)
- pr_number=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 7)
- curl -X POST https://api.github.com/repos/$owner/$repo/issues/$pr_number/comments -H 'Authorization: token ${{secrets.PR_BUILDER_COMMENT}}' -d '{"body":"PR builder [7.x.x] started \nLink: https://github.com/wso2/product-is/actions/runs/${{github.run_id}}"}'
- - uses: actions/checkout@v2
- - name: Set up Adopt JDK 8
- uses: actions/setup-java@v2
- with:
- java-version: "8"
- distribution: "adopt"
- - name: Echo java 8 home
- run: |
- echo "J8HOME=$JAVA_HOME" >> ${GITHUB_ENV}
- id: java-8-setup
- - name: Set up Adopt JDK 11
- uses: actions/setup-java@v2
- with:
- java-version: "11"
- distribution: "adopt"
- - name: Echo java 11 home
- run: |
- echo "J11HOME=$JAVA_HOME" >> ${GITHUB_ENV}
- - name: Build init
- run: |
- echo "CURRENT_MONTH=$(date +%Y-%m)" >> ${GITHUB_ENV}
- - name: Cache maven packages
- id: cache-maven-m2
- uses: actions/cache@v2
- with:
- path: |
- ~/.m2
- !~/.m2/repository/org/wso2/is/wso2is
- key: ${{ runner.os }}-pr-builder-${{ env.CURRENT_MONTH }}
- - name: Setup pnpm
- id: setup-pnpm
- uses: pnpm/action-setup@v2.1.0
- with:
- version: latest
- run_install: false
- - name: Run PR builder
- id: builder_step
- env:
- PR_LINK: ${{github.event.inputs.pr}}
- JDK_VERSION: ${{github.event.inputs.jdk}}
- JAVA_8_HOME: ${{env.J8HOME}}
- JAVA_11_HOME: ${{env.J11HOME}}
- run: |
- wget https://raw.githubusercontent.com/wso2/product-is/master/.github/scripts/pr-builder-7.sh
- bash pr-builder-7.sh
- - name: Archive PR diff file
- if: always()
- uses: actions/upload-artifact@v4
- with:
- name: repo-pr-diff
- path: |
- ${{steps.builder_step.outputs.REPO_NAME}}/diff.diff
- if-no-files-found: warn
- - name: Archive repo mvn build log
- if: always() && steps.builder_step.outputs.REPO_NAME != 'product-is'
- uses: actions/upload-artifact@v4
- with:
- name: repo-mvn-build-log
- path: |
- ${{steps.builder_step.outputs.REPO_NAME}}/mvn-build.log
- if-no-files-found: warn
- - name: Archive repo surefire reports
- if: always() && steps.builder_step.outputs.REPO_NAME != 'product-is'
- uses: actions/upload-artifact@v4
- with:
- name: repo-surefire-report
- path: |
- ${{steps.builder_step.outputs.REPO_NAME}}/**/surefire-reports
- if-no-files-found: warn
- - name: Archive product-is mvn build log
- if: always()
- uses: actions/upload-artifact@v4
- with:
- name: product-is-mvn-build-log
- path: |
- product-is/mvn-build.log
- if-no-files-found: warn
- - name: Archive product-is surefire reports
- if: always()
- uses: actions/upload-artifact@v4
- with:
- name: product-is-surefire-report
- path: |
- product-is/**/surefire-reports
- if-no-files-found: warn
- - name: Comment build status
- if: always()
- run: |
- owner=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 4)
- repo=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 5)
- pr_number=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 7)
- curl -X POST https://api.github.com/repos/$owner/$repo/issues/$pr_number/comments -H 'Authorization: token ${{secrets.PR_BUILDER_COMMENT}}' -d '{"body":"PR builder [7.x.x] completed \nLink: https://github.com/wso2/product-is/actions/runs/${{github.run_id}} \nStatus: **${{job.status}}**"}'
- - name: Approve PR
- if: success()
- run: |
- owner=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 4)
- repo=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 5)
- pr_number=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 7)
- curl -X POST https://api.github.com/repos/$owner/$repo/pulls/$pr_number/reviews -H 'Authorization:token ${{secrets.PR_BUILDER_COMMENT}}' -d '{"body":"Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/${{github.run_id}}","event":"APPROVE"}'
diff --git a/.github/workflows/pr-builder-test-JDK11.yml b/.github/workflows/pr-builder-test-JDK11.yml
index 8dba76647fc..1a15290ef75 100644
--- a/.github/workflows/pr-builder-test-JDK11.yml
+++ b/.github/workflows/pr-builder-test-JDK11.yml
@@ -13,7 +13,7 @@ on:
required: true
env:
- MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Djdk.util.zip.disableZip64ExtraFieldValidation=true
+ MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.class=standard -Dmaven.wagon.http.retryHandler.count=3 -Djdk.util.zip.disableZip64ExtraFieldValidation=true -XX:+HeapDumpOnOutOfMemoryError
jobs:
@@ -32,9 +32,9 @@ jobs:
repo=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 5)
pr_number=$(echo '${{github.event.inputs.pr}}' | cut -d "/" -f 7)
curl -X POST https://api.github.com/repos/$owner/$repo/issues/$pr_number/comments -H 'Authorization: token ${{secrets.PR_BUILDER_COMMENT}}' -d '{"body":"PR builder started \nLink: https://github.com/wso2/product-is/actions/runs/${{github.run_id}}"}'
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v4
- name: Set up Adopt JDK 8
- uses: actions/setup-java@v2
+ uses: actions/setup-java@v4
with:
java-version: "8"
distribution: "adopt"
@@ -43,7 +43,7 @@ jobs:
echo "J8HOME=$JAVA_HOME" >> ${GITHUB_ENV}
id: java-8-setup
- name: Set up Adopt JDK 11
- uses: actions/setup-java@v2
+ uses: actions/setup-java@v4
with:
java-version: "11"
distribution: "adopt"
@@ -55,7 +55,7 @@ jobs:
echo "CURRENT_MONTH=$(date +%Y-%m)" >> ${GITHUB_ENV}
- name: Cache maven packages
id: cache-maven-m2
- uses: actions/cache@v2
+ uses: actions/cache@v4
with:
path: |
~/.m2
@@ -63,7 +63,7 @@ jobs:
key: ${{ runner.os }}-pr-builder-${{ env.CURRENT_MONTH }}
- name: Setup pnpm
id: setup-pnpm
- uses: pnpm/action-setup@v2.1.0
+ uses: pnpm/action-setup@v4
with:
version: latest
run_install: false
@@ -117,6 +117,14 @@ jobs:
path: |
product-is/**/surefire-reports
if-no-files-found: warn
+ - name: Archive heap dump
+ if: always()
+ uses: actions/upload-artifact@v4
+ with:
+ name: heap-dump
+ path: |
+ **/**.hprof
+ if-no-files-found: ignore
- name: Comment build status
if: always()
run: |
diff --git a/.github/workflows/product-is-builder-jdk17.yml b/.github/workflows/product-is-builder-jdk17.yml
index c94a139c99d..5ab1355da9d 100644
--- a/.github/workflows/product-is-builder-jdk17.yml
+++ b/.github/workflows/product-is-builder-jdk17.yml
@@ -20,9 +20,9 @@ jobs:
steps:
- name: Checkout repository code
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Set up Adopt JDK 11
- uses: actions/setup-java@v2
+ uses: actions/setup-java@v4
with:
java-version: "11"
distribution: "adopt"
@@ -30,7 +30,7 @@ jobs:
run: |
mvn clean install --batch-mode -Dmaven.test.skip=true | tee mvn-build.log
- name: Set up Adopt JDK 17
- uses: actions/setup-java@v2
+ uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "adopt"
diff --git a/.github/workflows/product-is-builder-jdk21.yml b/.github/workflows/product-is-builder-jdk21.yml
index 632f0b71100..772a3331918 100644
--- a/.github/workflows/product-is-builder-jdk21.yml
+++ b/.github/workflows/product-is-builder-jdk21.yml
@@ -20,9 +20,9 @@ jobs:
steps:
- name: Checkout repository code
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Set up Adopt JDK 11
- uses: actions/setup-java@v2
+ uses: actions/setup-java@v4
with:
java-version: "11"
distribution: "adopt"
@@ -30,7 +30,7 @@ jobs:
run: |
mvn clean install --batch-mode -Dmaven.test.skip=true | tee mvn-build.log
- name: Set up Adopt JDK 21
- uses: actions/setup-java@v2
+ uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "adopt"
diff --git a/modules/api-resources/api-resources-full/pom.xml b/modules/api-resources/api-resources-full/pom.xml
index e9b975035a7..4b274403394 100644
--- a/modules/api-resources/api-resources-full/pom.xml
+++ b/modules/api-resources/api-resources-full/pom.xml
@@ -23,12 +23,12 @@
org.wso2.is
api-resources
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
../pom.xml
api-resources-full
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
war
WSO2 Identity Server - All Rest API
@@ -440,10 +440,6 @@
org.wso2.carbon.identity.governance
org.wso2.carbon.identity.api.user.governance
-
- org.wso2.carbon.identity.framework
- org.wso2.carbon.identity.api.server.entitlement
-
org.wso2.carbon.identity.framework
org.wso2.carbon.identity.api.server.configuration.mgt
@@ -504,5 +500,13 @@
org.wso2.carbon.identity.server.api
org.wso2.carbon.identity.api.server.action.management.common
+
+ org.wso2.carbon.identity.server.api
+ org.wso2.carbon.identity.api.server.rule.metadata.v1
+
+
+ org.wso2.carbon.identity.server.api
+ org.wso2.carbon.identity.api.server.rule.metadata.common
+
diff --git a/modules/api-resources/api-resources-full/src/main/webapp/WEB-INF/beans.xml b/modules/api-resources/api-resources-full/src/main/webapp/WEB-INF/beans.xml
index 9801310b857..3fa00cc159e 100644
--- a/modules/api-resources/api-resources-full/src/main/webapp/WEB-INF/beans.xml
+++ b/modules/api-resources/api-resources-full/src/main/webapp/WEB-INF/beans.xml
@@ -80,6 +80,7 @@
+
@@ -147,6 +148,7 @@
+
@@ -210,6 +212,8 @@
+
+
@@ -423,15 +427,6 @@
-
-
-
-
-
-
-
-
-
diff --git a/modules/api-resources/pom.xml b/modules/api-resources/pom.xml
index 63c91008f21..6a2fac4e2e9 100644
--- a/modules/api-resources/pom.xml
+++ b/modules/api-resources/pom.xml
@@ -23,12 +23,12 @@
org.wso2.is
identity-server-parent
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
../../pom.xml
api-resources
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
pom
WSO2 Identity Server - Rest API
@@ -515,6 +515,16 @@
org.wso2.carbon.identity.api.server.action.management.common
${identity.server.api.version}
+
+ org.wso2.carbon.identity.server.api
+ org.wso2.carbon.identity.api.server.rule.metadata.v1
+ ${identity.server.api.version}
+
+
+ org.wso2.carbon.identity.server.api
+ org.wso2.carbon.identity.api.server.rule.metadata.common
+ ${identity.server.api.version}
+
@@ -532,11 +542,6 @@
org.wso2.carbon.identity.api.user.governance
${identity.governance.version}
-
- org.wso2.carbon.identity.framework
- org.wso2.carbon.identity.api.server.entitlement
- ${carbon.identity.framework.version}
-
org.wso2.carbon.identity.framework
org.wso2.carbon.identity.api.server.configuration.mgt
@@ -557,11 +562,6 @@
org.wso2.carbon.api.server.consent.mgt
${carbon.consent.mgt.version}
-
- org.wso2.carbon.consent.mgt
- org.wso2.carbon.api.server.consent.mgt
- ${carbon.consent.mgt.version}
-
org.wso2.carbon.identity.local.auth.api
org.wso2.carbon.api.server.local.auth.api
diff --git a/modules/authenticators/pom.xml b/modules/authenticators/pom.xml
index 8efe358f734..1c65ce9c06f 100644
--- a/modules/authenticators/pom.xml
+++ b/modules/authenticators/pom.xml
@@ -19,7 +19,7 @@
org.wso2.is
identity-server-parent
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
../../pom.xml
4.0.0
diff --git a/modules/connectors/pom.xml b/modules/connectors/pom.xml
index c92af98df42..8b5a2404b43 100644
--- a/modules/connectors/pom.xml
+++ b/modules/connectors/pom.xml
@@ -19,7 +19,7 @@
org.wso2.is
identity-server-parent
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
../../pom.xml
4.0.0
diff --git a/modules/distribution/pom.xml b/modules/distribution/pom.xml
index d850c76813e..aa8a32075f3 100755
--- a/modules/distribution/pom.xml
+++ b/modules/distribution/pom.xml
@@ -19,7 +19,7 @@
org.wso2.is
identity-server-parent
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
../../pom.xml
@@ -139,7 +139,6 @@
${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/conf/org.wso2.carbon.event.processor.manager.core.default.json
${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/conf/org.wso2.carbon.identity.application.authentication.framework.server.feature.default.json
${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/conf/org.wso2.carbon.identity.event.server.feature.default.json
- ${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/conf/org.wso2.carbon.identity.xacml.server.feature.default.json
${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/conf/org.wso2.carbon.identity.captcha.server.feature.default.json
${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/conf/org.wso2.carbon.identity.scim2.common.feature.default.json
${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/conf/org.wso2.carbon.identity.scim.common.feature.default.json
@@ -187,7 +186,6 @@
${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/conf/org.wso2.carbon.identity.core.server.feature.unit-resolve.json
${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/conf/org.wso2.carbon.event.output.adapter.unit-resolve.json
${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/conf/org.wso2.carbon.identity.event.server.feature.unit-resolve.json
- ${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/conf/org.wso2.carbon.identity.xacml.server.feature.unit-resolve.json
${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/conf/unit-resolve.json
true
@@ -210,7 +208,6 @@
-
@@ -582,23 +579,7 @@
org.apache.maven.plugins
maven-site-plugin
- 3.3
-
-
-
- org.apache.maven.plugins
- maven-project-info-reports-plugin
- 2.4
-
-
-
- index
-
-
-
-
-
-
+ 3.21.0
package
@@ -638,13 +619,6 @@
-
-
-
- com.google.code.maven-config-processor-plugin
- config-processor-maven-plugin
- 2.6
-
add-missing-axis2-configs
prepare-package
@@ -783,11 +757,12 @@
-
+
diff --git a/modules/distribution/registry_config_change.xml.j2 b/modules/distribution/registry_config_change.xml.j2
index 726adf857cd..52fc7fa923a 100644
--- a/modules/distribution/registry_config_change.xml.j2
+++ b/modules/distribution/registry_config_change.xml.j2
@@ -51,17 +51,4 @@
]]>
-
-
- //wso2registry/staticConfiguration
-
-
-
- application/xacml-policy+xml
-
-
- ]]>
-
-
diff --git a/modules/distribution/src/assembly/bin.xml b/modules/distribution/src/assembly/bin.xml
index 65218c78949..3edd2fc81f7 100644
--- a/modules/distribution/src/assembly/bin.xml
+++ b/modules/distribution/src/assembly/bin.xml
@@ -181,6 +181,17 @@
**/
+
+
+
+ ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/identity/rulemeta
+
+ wso2is-${pom.version}/repository/resources/identity/rulemeta
+
+ **/*.json
+
+
+
src/repository/resources/conf/templates
wso2is-${pom.version}/repository/resources/conf/templates
@@ -392,11 +403,6 @@
-
- conf/policies
- wso2is-${pom.version}/repository/resources/identity/policies/xacml/default
-
-
@@ -759,13 +765,6 @@
wso2is-${pom.version}/repository/conf/identity
644
-
-
- wso2is-${pom.version}/repository/conf/identity
- 644
-
-
-
- wso2is-${pom.version}/repository/conf/security
- 644
-
-
-
- wso2is-${pom.version}/repository/resources/identity/policies/xacml/default
-
- 644
-
-
-
- wso2is-${pom.version}/repository/resources/identity/policies/xacml/default
-
- 644
-
+
+ org.wso2.carbon.identity.integration.ui.templates
+ org.wso2.carbon.identity.integration.ui.templates.applications.zoom
+ zip
+
+
+ org.wso2.carbon.identity.integration.ui.templates
+ org.wso2.carbon.identity.integration.ui.templates.applications.slack
+ zip
+
diff --git a/modules/integration/pom.xml b/modules/integration/pom.xml
index b63df326048..1fd4f003557 100644
--- a/modules/integration/pom.xml
+++ b/modules/integration/pom.xml
@@ -19,7 +19,7 @@
org.wso2.is
identity-server-parent
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
../../pom.xml
diff --git a/modules/integration/tests-common/admin-clients/pom.xml b/modules/integration/tests-common/admin-clients/pom.xml
index d1bd5192d9b..0b1bfc0d3cf 100644
--- a/modules/integration/tests-common/admin-clients/pom.xml
+++ b/modules/integration/tests-common/admin-clients/pom.xml
@@ -19,7 +19,7 @@
org.wso2.is
identity-integration-tests
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
../../pom.xml
@@ -67,10 +67,6 @@
org.wso2.carbon.identity.inbound.auth.oauth2
org.wso2.carbon.identity.oauth.stub
-
- org.wso2.carbon.identity.framework
- org.wso2.carbon.identity.entitlement.stub
-
org.wso2.carbon.automationutils
org.wso2.carbon.integration.common.admin.client
diff --git a/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/KeyStoreAdminClient.java b/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/KeyStoreAdminClient.java
index f726273a85f..02fcf401142 100644
--- a/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/KeyStoreAdminClient.java
+++ b/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/KeyStoreAdminClient.java
@@ -38,6 +38,7 @@
import org.wso2.carbon.security.mgt.stub.keystore.RemoveCertFromStore;
import org.wso2.carbon.security.mgt.stub.keystore.xsd.KeyStoreData;
import org.wso2.carbon.security.mgt.stub.keystore.xsd.PaginatedKeyStoreData;
+import org.wso2.carbon.utils.security.KeystoreUtils;
import java.io.ByteArrayInputStream;
import java.rmi.RemoteException;
@@ -143,7 +144,7 @@ public boolean isPrivateKeyStore(byte[] content, String password, String type)
try {
boolean isPrivateStore = false;
ByteArrayInputStream stream = new ByteArrayInputStream(content);
- KeyStore store = KeyStore.getInstance(type);
+ KeyStore store = KeystoreUtils.getKeystoreInstance(type);
store.load(stream, password.toCharArray());
Enumeration aliases = store.aliases();
while (aliases.hasMoreElements()) {
diff --git a/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/entitlement/EntitlementAdminServiceClient.java b/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/entitlement/EntitlementAdminServiceClient.java
deleted file mode 100644
index e576e705daa..00000000000
--- a/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/entitlement/EntitlementAdminServiceClient.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
-* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* WSO2 Inc. 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.identity.integration.common.clients.entitlement;
-
-import java.rmi.RemoteException;
-
-import org.apache.axis2.AxisFault;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.identity.entitlement.stub.dto.PolicyFinderDataHolder;
-import org.wso2.carbon.identity.entitlement.stub.dto.PIPFinderDataHolder;
-import org.wso2.carbon.identity.entitlement.stub.dto.PDPDataHolder;
-import org.wso2.carbon.identity.entitlement.stub.EntitlementAdminServiceIdentityException;
-import org.wso2.carbon.identity.entitlement.stub.EntitlementAdminServiceStub;
-import org.wso2.identity.integration.common.clients.AuthenticateStub;
-
-public class EntitlementAdminServiceClient {
-
- private static final Log log = LogFactory.getLog(EntitlementAdminServiceClient.class);
-
- private final String serviceName = "EntitlementAdminService";
- private EntitlementAdminServiceStub entitlementAdminServiceStub;
- private String endPoint;
-
- public EntitlementAdminServiceClient(String backEndUrl, String sessionCookie)
- throws AxisFault {
- this.endPoint = backEndUrl + serviceName;
- entitlementAdminServiceStub = new EntitlementAdminServiceStub(endPoint);
- AuthenticateStub.authenticateStub(sessionCookie, entitlementAdminServiceStub);
- }
-
- public EntitlementAdminServiceClient(String backEndUrl, String userName, String password)
- throws AxisFault {
- this.endPoint = backEndUrl + serviceName;
- entitlementAdminServiceStub = new EntitlementAdminServiceStub(endPoint);
- AuthenticateStub.authenticateStub(userName, password, entitlementAdminServiceStub);
- }
-
- public String getGlobalPolicyAlgorithm() throws RemoteException{
- String algo = null;
- try {
- algo = entitlementAdminServiceStub.getGlobalPolicyAlgorithm();
- } catch (EntitlementAdminServiceIdentityException e) {
- e.printStackTrace();
- }
- return algo;
- }
-
- public String doTestRequest(String xacmlRequest) throws RemoteException{
- String requestStatus = null;
- try {
- requestStatus = entitlementAdminServiceStub.doTestRequest(xacmlRequest);
- } catch (EntitlementAdminServiceIdentityException e) {
- e.printStackTrace();
- }
- return requestStatus;
- }
-
- public PDPDataHolder getPDPData() throws RemoteException{
- PDPDataHolder holder = null;
- holder = entitlementAdminServiceStub.getPDPData();
- return holder;
- }
-
- public PIPFinderDataHolder getPIPAttributeFinderData(String finder) throws RemoteException{
- PIPFinderDataHolder holder = null;
- holder = entitlementAdminServiceStub.getPIPAttributeFinderData(finder);
- return holder;
- }
-
- public PIPFinderDataHolder getPIPResourceFinderData(String finder) throws RemoteException{
- PIPFinderDataHolder holder = null;
- holder = entitlementAdminServiceStub.getPIPResourceFinderData(finder);
- return holder;
- }
-
- public PolicyFinderDataHolder getPolicyFinderData(String finder) throws RemoteException{
- PolicyFinderDataHolder holder = null;
- holder = entitlementAdminServiceStub.getPolicyFinderData(finder);
- return holder;
- }
-
- public void refreshAttributeFinder(String attributeFinder) throws RemoteException{
- try {
- entitlementAdminServiceStub.refreshAttributeFinder(attributeFinder);
- } catch (EntitlementAdminServiceIdentityException e) {
- e.printStackTrace();
- }
- }
-
- public void refreshPolicyFinders(String policyFinder) throws RemoteException{
- try {
- entitlementAdminServiceStub.refreshPolicyFinders(policyFinder);
- } catch (EntitlementAdminServiceIdentityException e) {
- e.printStackTrace();
- }
- }
-
- public void refreshResourceFinder(String resourceFinder) throws RemoteException{
- try {
- entitlementAdminServiceStub.refreshResourceFinder(resourceFinder);
- } catch (EntitlementAdminServiceIdentityException e) {
- e.printStackTrace();
- }
- }
-
- public void setGlobalPolicyAlgorithm(String policyCombiningAlgorithm) throws RemoteException{
- try {
- entitlementAdminServiceStub.setGlobalPolicyAlgorithm(policyCombiningAlgorithm);
- } catch (EntitlementAdminServiceIdentityException e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/entitlement/EntitlementPolicyServiceClient.java b/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/entitlement/EntitlementPolicyServiceClient.java
deleted file mode 100644
index c58386aa2f0..00000000000
--- a/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/entitlement/EntitlementPolicyServiceClient.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
-*Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*WSO2 Inc. 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.identity.integration.common.clients.entitlement;
-
-import org.apache.axis2.AxisFault;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.identity.entitlement.stub.dto.PaginatedPolicySetDTO;
-import org.wso2.carbon.identity.entitlement.stub.EntitlementPolicyAdminServiceEntitlementException;
-import org.wso2.carbon.identity.entitlement.stub.EntitlementPolicyAdminServiceStub;
-import org.wso2.carbon.identity.entitlement.stub.dto.PaginatedStatusHolder;
-import org.wso2.carbon.identity.entitlement.stub.dto.PolicyDTO;
-import org.wso2.carbon.identity.entitlement.stub.dto.PublisherDataHolder;
-import org.wso2.identity.integration.common.clients.AuthenticateStub;
-import org.xml.sax.SAXException;
-
-import javax.activation.DataHandler;
-import javax.activation.FileDataSource;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import java.io.*;
-import java.rmi.RemoteException;
-
-public class EntitlementPolicyServiceClient {
- private static final Log log = LogFactory.getLog(EntitlementPolicyServiceClient.class);
-
- private final String serviceName = "EntitlementPolicyAdminService";
- private EntitlementPolicyAdminServiceStub entitlementPolicyAdminServiceStub;
- private String endPoint;
-
- public EntitlementPolicyServiceClient(String backEndUrl, String sessionCookie)
- throws AxisFault {
- this.endPoint = backEndUrl + serviceName;
- entitlementPolicyAdminServiceStub = new EntitlementPolicyAdminServiceStub(endPoint);
- AuthenticateStub.authenticateStub(sessionCookie, entitlementPolicyAdminServiceStub);
- }
-
- public EntitlementPolicyServiceClient(String backEndUrl, String userName, String password)
- throws AxisFault {
- this.endPoint = backEndUrl + serviceName;
- entitlementPolicyAdminServiceStub = new EntitlementPolicyAdminServiceStub(endPoint);
- AuthenticateStub.authenticateStub(userName, password, entitlementPolicyAdminServiceStub);
- }
-
- public void addPolicies(File policyFile)
- throws IOException,
- ParserConfigurationException, TransformerException, SAXException,
- EntitlementPolicyAdminServiceEntitlementException {
-
- DataHandler policydh =
- new DataHandler(new FileDataSource(policyFile));
- String policy = convertXMLFileToString(policyFile);
-
- PolicyDTO policySetDTO = new PolicyDTO();
- policySetDTO.setPolicy(policy);
- policySetDTO.setActive(true);
- entitlementPolicyAdminServiceStub.addPolicy(policySetDTO);
- }
-
- public void removePolicy(String policyId)
- throws IOException, EntitlementPolicyAdminServiceEntitlementException {
- entitlementPolicyAdminServiceStub.removePolicy(policyId, false);
- }
-
- public void removePolicy(String policyId, boolean dePromote)
- throws IOException, EntitlementPolicyAdminServiceEntitlementException {
- entitlementPolicyAdminServiceStub.removePolicy(policyId, dePromote);
- }
-
- public void updatePolicy(PolicyDTO policyDTO) throws RemoteException, EntitlementPolicyAdminServiceEntitlementException {
- entitlementPolicyAdminServiceStub.updatePolicy(policyDTO);
- }
-
- public void removePolicies(String[] policies, boolean dePromote) throws RemoteException {
- try {
- entitlementPolicyAdminServiceStub.removePolicies(policies, dePromote);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- }
-
- public String[] getAllPolicyIds(String searchString) throws RemoteException, EntitlementPolicyAdminServiceEntitlementException {
- return entitlementPolicyAdminServiceStub.getAllPolicyIds(searchString);
- }
-
- public void addPolicy(PolicyDTO policyDTO) throws RemoteException, EntitlementPolicyAdminServiceEntitlementException {
- entitlementPolicyAdminServiceStub.addPolicy(policyDTO);
- }
-
- public void addPolicies(PolicyDTO[] policies) throws RemoteException {
- try {
- entitlementPolicyAdminServiceStub.addPolicies(policies);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- }
-
- public PolicyDTO getPolicy(String policyId, boolean isPDPPolicy) throws RemoteException, EntitlementPolicyAdminServiceEntitlementException {
- return entitlementPolicyAdminServiceStub.getPolicy(policyId, isPDPPolicy);
- }
-
- public String[] getPolicyVersions(String policyId) throws RemoteException, EntitlementPolicyAdminServiceEntitlementException {
- return entitlementPolicyAdminServiceStub.getPolicyVersions(policyId);
- }
-
- public PaginatedPolicySetDTO getAllPolicies(String policyTypeFilter, String policySearchString,
- int pageNumber, boolean isPDPPolicy) throws RemoteException, EntitlementPolicyAdminServiceEntitlementException {
- return entitlementPolicyAdminServiceStub.getAllPolicies(policyTypeFilter, policySearchString, pageNumber, isPDPPolicy);
- }
-
- public PolicyDTO getPolicyByVersion(String policyId, String version) throws RemoteException, EntitlementPolicyAdminServiceEntitlementException {
- return entitlementPolicyAdminServiceStub.getPolicyByVersion(policyId, version);
- }
-
- public void importPolicyFromRegistry(String policyRegistryPath) throws RemoteException, EntitlementPolicyAdminServiceEntitlementException {
- entitlementPolicyAdminServiceStub.importPolicyFromRegistry(policyRegistryPath);
- }
-
- public PaginatedStatusHolder getStatusData(String about, String key, String type,
- String searchString, int pageNumber) throws RemoteException {
-
- PaginatedStatusHolder holder = null;
- try {
- holder = entitlementPolicyAdminServiceStub.getStatusData(about, key, type, searchString, pageNumber);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- return holder;
- }
-
- public void addSubscriber(PublisherDataHolder holder) throws RemoteException {
- try {
- entitlementPolicyAdminServiceStub.addSubscriber(holder);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- }
-
- public void updateSubscriber(PublisherDataHolder holder) throws RemoteException {
- try {
- entitlementPolicyAdminServiceStub.updateSubscriber(holder);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- }
-
- public PublisherDataHolder getSubscriber(String subscribeId) throws RemoteException {
- PublisherDataHolder holder = null;
- try {
- holder = entitlementPolicyAdminServiceStub.getSubscriber(subscribeId);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- return holder;
- }
-
- public String[] getSubscriberIds(String searchString) throws RemoteException {
- String[] ids = null;
- try {
- ids = entitlementPolicyAdminServiceStub.getSubscriberIds(searchString);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- return ids;
- }
-
- public void deleteSubscriber(String subscriberId) throws RemoteException {
- try {
- entitlementPolicyAdminServiceStub.deleteSubscriber(subscriberId);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- }
-
- public void enableDisablePolicy(String policyId, boolean enable) throws RemoteException {
- try {
- entitlementPolicyAdminServiceStub.enableDisablePolicy(policyId, enable);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- }
-
- public void publish(String verificationCode) throws RemoteException {
- try {
- entitlementPolicyAdminServiceStub.publish(verificationCode);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- }
-
- public void publishToPDP(String[] policies, String action, boolean enabled, String version, int order) throws RemoteException {
- try {
- entitlementPolicyAdminServiceStub.publishToPDP(policies, action, version, enabled, order);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- }
-
- public void publishPolicies(String[] policies, String[] subscriberIds, String action, boolean enabled, String version, int order) throws RemoteException {
- try {
- entitlementPolicyAdminServiceStub.publishPolicies(policies, subscriberIds, action, version, enabled, order);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- }
-
- public void orderPolicy(String policyId, int newOrder) throws RemoteException {
- try {
- entitlementPolicyAdminServiceStub.orderPolicy(policyId, newOrder);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- }
-
- public void dePromotePolicy(String policyId) throws RemoteException {
- try {
- entitlementPolicyAdminServiceStub.dePromotePolicy(policyId);
- } catch (EntitlementPolicyAdminServiceEntitlementException e) {
- log.error(e);
- }
- }
-
- private String convertXMLFileToString(File fileName)
- throws IOException, ParserConfigurationException, SAXException, TransformerException {
-
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
- InputStream inputStream = new FileInputStream(fileName);
- org.w3c.dom.Document doc = documentBuilderFactory.newDocumentBuilder().parse(inputStream);
- StringWriter stw = new StringWriter();
- Transformer serializer = TransformerFactory.newInstance().newTransformer();
- serializer.transform(new DOMSource(doc), new StreamResult(stw));
- return stw.toString();
- }
-}
diff --git a/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/entitlement/EntitlementServiceClient.java b/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/entitlement/EntitlementServiceClient.java
deleted file mode 100644
index ddc5992e59e..00000000000
--- a/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/entitlement/EntitlementServiceClient.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.identity.integration.common.clients.entitlement;
-
-import org.apache.axis2.AxisFault;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.identity.entitlement.stub.EntitlementServiceCallbackHandler;
-import org.wso2.carbon.identity.entitlement.stub.EntitlementServiceException;
-import org.wso2.carbon.identity.entitlement.stub.EntitlementServiceIdentityException;
-import org.wso2.carbon.identity.entitlement.stub.EntitlementServiceStub;
-import org.wso2.carbon.identity.entitlement.stub.dto.AttributeDTO;
-import org.wso2.carbon.identity.entitlement.stub.dto.EntitledResultSetDTO;
-import org.wso2.identity.integration.common.clients.AuthenticateStub;
-
-import java.rmi.RemoteException;
-
-public class EntitlementServiceClient {
- private static final Log log = LogFactory.getLog(EntitlementServiceClient.class);
-
- private final String serviceName = "EntitlementService";
- private EntitlementServiceStub entitlementServiceStub;
- private String endPoint;
-
- public EntitlementServiceClient(String backEndUrl, String sessionCookie) throws AxisFault {
- this.endPoint = backEndUrl + serviceName;
- entitlementServiceStub = new EntitlementServiceStub(endPoint);
- AuthenticateStub.authenticateStub(sessionCookie, entitlementServiceStub);
- }
-
- public EntitlementServiceClient(String backEndUrl, String userName, String password) throws AxisFault {
- this.endPoint = backEndUrl + serviceName;
- entitlementServiceStub = new EntitlementServiceStub(endPoint);
- AuthenticateStub.authenticateStub(userName, password, entitlementServiceStub);
- }
-
- public EntitledResultSetDTO getEntitledAttributes(String subjectName, String resourceName, String subjectId,
- String action, boolean enableChildSearch)
- throws RemoteException, EntitlementServiceIdentityException {
- return entitlementServiceStub.getEntitledAttributes(subjectName, resourceName, subjectId, action, enableChildSearch);
- }
-
- public void startgetEntitledAttributes(String subjectName, String resourceName, String subjectId,
- String action, boolean enableChildSearch, EntitlementServiceCallbackHandler callback)
- throws RemoteException {
- entitlementServiceStub.startgetEntitledAttributes(subjectName, resourceName, subjectId, action, enableChildSearch, callback);
- }
-
- public String xACMLAuthzDecisionQuery(String request) throws EntitlementServiceException, RemoteException {
- return entitlementServiceStub.xACMLAuthzDecisionQuery(request);
- }
-
- public void startxACMLAuthzDecisionQuery(String request, EntitlementServiceCallbackHandler callback)
- throws RemoteException {
- entitlementServiceStub.startxACMLAuthzDecisionQuery(request, callback);
- }
-
- public EntitledResultSetDTO getAllEntitlements(String identifier, AttributeDTO[] givenAttributes)
- throws RemoteException, EntitlementServiceIdentityException {
- return entitlementServiceStub.getAllEntitlements(identifier, givenAttributes);
- }
-
- public void startgetAllEntitlements(String identifier, AttributeDTO[] givenAttributes,
- EntitlementServiceCallbackHandler callback) throws RemoteException {
- entitlementServiceStub.startgetAllEntitlements(identifier, givenAttributes, callback);
- }
-
- public String getDecision(String request) throws EntitlementServiceException, RemoteException {
- return entitlementServiceStub.getDecision(request);
- }
-
- public void startgetDecision(String request, EntitlementServiceCallbackHandler callback) throws RemoteException {
- entitlementServiceStub.startgetDecision(request, callback);
- }
-
- public String getDecisionByAttributes(String subject, String resource, String action, String[] environment)
- throws EntitlementServiceException, RemoteException {
- return entitlementServiceStub.getDecisionByAttributes(subject, resource, action, environment);
- }
-
- public void startgetDecisionByAttributes(String subject, String resource, String action, String[] environment,
- EntitlementServiceCallbackHandler callback) throws RemoteException {
- entitlementServiceStub.startgetDecisionByAttributes(subject, resource, action, environment, callback);
- }
-
- public boolean getBooleanDecision(String subject, String resource, String action)
- throws EntitlementServiceException, RemoteException {
- return entitlementServiceStub.getBooleanDecision(subject, resource, action);
- }
-
- public void startgetBooleanDecision(String subject, String resource, String action,
- EntitlementServiceCallbackHandler callback) throws RemoteException {
- entitlementServiceStub.startgetBooleanDecision(subject, resource, action, callback);
- }
-}
diff --git a/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/sso/saml/query/ClientSignKeyDataHolder.java b/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/sso/saml/query/ClientSignKeyDataHolder.java
index ddeb0a68609..ae33b0db335 100644
--- a/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/sso/saml/query/ClientSignKeyDataHolder.java
+++ b/modules/integration/tests-common/admin-clients/src/main/java/org/wso2/identity/integration/common/clients/sso/saml/query/ClientSignKeyDataHolder.java
@@ -24,6 +24,7 @@
import org.opensaml.security.credential.CredentialContextSet;
import org.opensaml.security.credential.UsageType;
import org.opensaml.security.x509.X509Credential;
+import org.wso2.carbon.utils.security.KeystoreUtils;
import java.io.File;
import java.io.FileInputStream;
@@ -59,6 +60,8 @@ public class ClientSignKeyDataHolder implements X509Credential {
private PublicKey publicKey = null;
+ private static final String KEYSTORE_TYPE = "PKCS12";
+
/**
* Constructor method
* @param keyStorePath path to the key store
@@ -74,7 +77,7 @@ public ClientSignKeyDataHolder(String keyStorePath, String password, String key
try {
File file = new File(keyStorePath);
is = new FileInputStream(file);
- KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
+ KeyStore keystore = KeystoreUtils.getKeystoreInstance(KEYSTORE_TYPE);
keystore.load(is, password.toCharArray());
privateKey = (PrivateKey) keystore.getKey(keyAlias, password.toCharArray());
diff --git a/modules/integration/tests-common/extensions/pom.xml b/modules/integration/tests-common/extensions/pom.xml
index 5a78447b776..e69de29bb2d 100644
--- a/modules/integration/tests-common/extensions/pom.xml
+++ b/modules/integration/tests-common/extensions/pom.xml
@@ -1,41 +0,0 @@
-
-
-
-
-
-
- org.wso2.is
- identity-integration-tests
- 7.1.0-m5-SNAPSHOT
- ../../pom.xml
-
-
- 4.0.0
- Custom Attribute Finder
- org.wso2.carbon.identity.custom.pip
- jar
-
-
-
- org.wso2.carbon.identity.framework
- org.wso2.carbon.identity.entitlement
-
-
-
-
diff --git a/modules/integration/tests-common/extensions/src/main/java/org/wso2/carbon/identity/custom/pip/CustomAttributeFinder.java b/modules/integration/tests-common/extensions/src/main/java/org/wso2/carbon/identity/custom/pip/CustomAttributeFinder.java
deleted file mode 100644
index b5731b30f1b..00000000000
--- a/modules/integration/tests-common/extensions/src/main/java/org/wso2/carbon/identity/custom/pip/CustomAttributeFinder.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* WSO2 Inc. 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.carbon.identity.custom.pip;
-
-
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-
-import org.wso2.carbon.identity.entitlement.pip.AbstractPIPAttributeFinder;
-
-/**
- * This class is used by EntitlementPIPAttributeCacheTestCase to simulate the PIP attribute caching scenario.
- */
-public class CustomAttributeFinder extends AbstractPIPAttributeFinder {
-
-
- private static final String EMAIL_ID = "http://wso2.org/claims/emailaddress";
-
-
- /**
- * List of attribute finders supported by the this PIP attribute finder
- */
- private Set supportedAttributes = new HashSet();
-
- @Override
- public void init(Properties properties) throws Exception {
- supportedAttributes.add(EMAIL_ID);
- }
-
- @Override
- public String getModuleName() {
- return "Custom Attribute Finder";
- }
-
- @Override
- public boolean overrideDefaultCache() {
- return false;
- }
-
- @Override
- public Set getAttributeValues(String subjectId, String resourceId, String actionId,
- String environmentId, String attributeId, String issuer) throws Exception {
-
-
- Set values = new HashSet();
- if ("admin@wso2.com".equals(subjectId)) {
- values.add(subjectId);
- } else {
- values.add("notexist");
- }
- return values;
- }
-
- @Override
- public Set getSupportedAttributes() {
- return supportedAttributes;
- }
-}
diff --git a/modules/integration/tests-common/integration-test-utils/pom.xml b/modules/integration/tests-common/integration-test-utils/pom.xml
index 6bea82aa5f7..68e72fd171c 100644
--- a/modules/integration/tests-common/integration-test-utils/pom.xml
+++ b/modules/integration/tests-common/integration-test-utils/pom.xml
@@ -19,7 +19,7 @@
org.wso2.is
identity-integration-tests
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
../../pom.xml
diff --git a/modules/integration/tests-common/jacoco-report-generator/pom.xml b/modules/integration/tests-common/jacoco-report-generator/pom.xml
index 83de5aaf985..ba260627b59 100644
--- a/modules/integration/tests-common/jacoco-report-generator/pom.xml
+++ b/modules/integration/tests-common/jacoco-report-generator/pom.xml
@@ -22,7 +22,7 @@
org.wso2.is
identity-integration-tests
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
../../pom.xml
diff --git a/modules/integration/tests-common/pom.xml b/modules/integration/tests-common/pom.xml
index e0b64ccd5cd..303f1c22ee2 100644
--- a/modules/integration/tests-common/pom.xml
+++ b/modules/integration/tests-common/pom.xml
@@ -19,7 +19,7 @@
org.wso2.is
identity-integration-tests
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
../pom.xml
@@ -32,7 +32,6 @@
admin-clients
ui-pages
integration-test-utils
- extensions
jacoco-report-generator
diff --git a/modules/integration/tests-common/ui-pages/pom.xml b/modules/integration/tests-common/ui-pages/pom.xml
index 1a27cbee757..0a01bd787ac 100644
--- a/modules/integration/tests-common/ui-pages/pom.xml
+++ b/modules/integration/tests-common/ui-pages/pom.xml
@@ -19,7 +19,7 @@
org.wso2.is
identity-integration-tests
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
../../pom.xml
diff --git a/modules/integration/tests-cypress-integration/tests-identity-apps/src/test/resources/instrumentation.txt b/modules/integration/tests-cypress-integration/tests-identity-apps/src/test/resources/instrumentation.txt
index 4bd93d2dfbb..fddfc506bee 100644
--- a/modules/integration/tests-cypress-integration/tests-identity-apps/src/test/resources/instrumentation.txt
+++ b/modules/integration/tests-cypress-integration/tests-identity-apps/src/test/resources/instrumentation.txt
@@ -25,8 +25,6 @@ org.wso2.carbon.identity.authenticator.saml2.sso.common*
org.wso2.carbon.identity.authorization.core*
org.wso2.carbon.identity.base*
org.wso2.carbon.identity.core*
-org.wso2.carbon.identity.entitlement*
-org.wso2.carbon.identity.entitlement.common*
org.wso2.carbon.identity.mgt*
org.wso2.carbon.identity.oauth*
org.wso2.carbon.identity.oauth.common*
diff --git a/modules/integration/tests-integration/pom.xml b/modules/integration/tests-integration/pom.xml
index fd48eb1af64..e749240db12 100644
--- a/modules/integration/tests-integration/pom.xml
+++ b/modules/integration/tests-integration/pom.xml
@@ -19,7 +19,7 @@
org.wso2.is
identity-integration-tests
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
../pom.xml
diff --git a/modules/integration/tests-integration/tests-backend/pom.xml b/modules/integration/tests-integration/tests-backend/pom.xml
index 2b984b1a3c2..ebf130c74ac 100644
--- a/modules/integration/tests-integration/tests-backend/pom.xml
+++ b/modules/integration/tests-integration/tests-backend/pom.xml
@@ -18,7 +18,7 @@
org.wso2.is
identity-integration-tests
- 7.1.0-m5-SNAPSHOT
+ 7.1.0-m6-SNAPSHOT
../../pom.xml
@@ -47,7 +47,7 @@
2.22.1
- -Xmx1024m
+ -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError
-Dorg.apache.jasper.compiler.disablejsr199=true
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
@@ -446,21 +446,6 @@
run
-
- packaging-war-artifacts-openid
- process-test-resources
-
-
-
-
-
-
-
-
-
- run
-
-
packaging-war-artifacts-oauth
process-test-resources
@@ -473,19 +458,6 @@
run
-
- packaging-war-artifacts-oidc
- process-test-resources
-
-
-
-
-
-
-
- run
-
-
packaging-war-artifacts-passivests
process-test-resources
@@ -855,10 +827,6 @@
org.wso2.carbon.identity.inbound.auth.oauth2
org.wso2.carbon.identity.oauth.stub
-
- org.wso2.carbon.identity.framework
- org.wso2.carbon.identity.entitlement.stub
-
org.wso2.carbon.identity.framework
org.wso2.carbon.identity.user.profile.stub
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/IdentityServerTestSuitInitializerTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/IdentityServerTestSuitInitializerTestCase.java
index fb9eda85607..bca5435c501 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/IdentityServerTestSuitInitializerTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/IdentityServerTestSuitInitializerTestCase.java
@@ -18,6 +18,7 @@
package org.wso2.identity.integration.test;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.testng.annotations.Test;
import org.wso2.identity.integration.test.util.Utils;
@@ -27,5 +28,10 @@ public class IdentityServerTestSuitInitializerTestCase {
public void testInitialize() throws Exception {
//save the carbon.home system property
Utils.getResidentCarbonHome();
+ //add BC provider
+ BouncyCastleProvider bouncyCastleProvider = new BouncyCastleProvider();
+ if (java.security.Security.getProvider(bouncyCastleProvider.getName()) == null) {
+ java.security.Security.addProvider(bouncyCastleProvider);
+ }
}
}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionFailureClientCredentialsGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionFailureClientCredentialsGrantTestCase.java
new file mode 100644
index 00000000000..4bacd83e704
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionFailureClientCredentialsGrantTestCase.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (http://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.identity.integration.test.actions;
+
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONObject;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Factory;
+import org.testng.annotations.Test;
+import org.wso2.carbon.automation.engine.context.TestUserMode;
+import org.wso2.identity.integration.test.actions.dataprovider.model.ActionResponse;
+import org.wso2.identity.integration.test.actions.dataprovider.model.ExpectedTokenResponse;
+import org.wso2.identity.integration.test.actions.mockserver.ActionsMockServer;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.ActionModel;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.AuthenticationType;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.Endpoint;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration;
+import org.wso2.identity.integration.test.utils.FileUtils;
+import org.wso2.identity.integration.test.utils.OAuth2Constant;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.ACCESS_TOKEN_ENDPOINT;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.AUTHORIZATION_HEADER;
+
+/**
+ * Tests the pre-issue access token action failure scenarios with password grant type.
+ */
+public class PreIssueAccessTokenActionFailureClientCredentialsGrantTestCase extends ActionsBaseTestCase {
+
+ private static final String USERNAME_PROPERTY = "username";
+ private static final String PASSWORD_PROPERTY = "password";
+ private static final String EXTERNAL_SERVICE_URI = "http://localhost:8587/test/action";
+ private static final String PRE_ISSUE_ACCESS_TOKEN_API_PATH = "preIssueAccessToken";
+ private static final String MOCK_SERVER_ENDPOINT_RESOURCE_PATH = "/test/action";
+ private static final String MOCK_SERVER_AUTH_BASIC_USERNAME = "test";
+ private static final String MOCK_SERVER_AUTH_BASIC_PASSWORD = "test";
+ private static final String CLIENT_CREDENTIALS_GRANT_TYPE = "client_credentials";
+ private CloseableHttpClient client;
+ private List requestedScopes;
+ private String clientId;
+ private String clientSecret;
+ private String actionId;
+ private String applicationId;
+ private final TestUserMode userMode;
+ private ActionsMockServer actionsMockServer;
+ private final ActionResponse actionResponse;
+ private final ExpectedTokenResponse expectedTokenResponse;
+
+ @Factory(dataProvider = "testExecutionContextProvider")
+ public PreIssueAccessTokenActionFailureClientCredentialsGrantTestCase(TestUserMode testUserMode,
+ ActionResponse actionResponse,
+ ExpectedTokenResponse expectedTokenResponse) {
+
+ this.userMode = testUserMode;
+ this.actionResponse = actionResponse;
+ this.expectedTokenResponse = expectedTokenResponse;
+ }
+
+ @DataProvider(name = "testExecutionContextProvider")
+ public static Object[][] getTestExecutionContext() throws Exception {
+
+ return new Object[][]{
+ {TestUserMode.SUPER_TENANT_USER, new ActionResponse(200,
+ FileUtils.readFileInClassPathAsString("actions/response/failure-response.json")),
+ new ExpectedTokenResponse(400, "Some failure reason", "Some description")},
+ {TestUserMode.TENANT_USER, new ActionResponse(200,
+ FileUtils.readFileInClassPathAsString("actions/response/failure-response.json")),
+ new ExpectedTokenResponse(400, "Some failure reason", "Some description")},
+ {TestUserMode.TENANT_USER, new ActionResponse(500,
+ FileUtils.readFileInClassPathAsString("actions/response/error-response.json")),
+ new ExpectedTokenResponse(500, "server_error", "Internal Server Error.")},
+ {TestUserMode.TENANT_USER, new ActionResponse(401, "Unauthorized"),
+ new ExpectedTokenResponse(500, "server_error", "Internal Server Error.")},
+ };
+ }
+
+ @BeforeClass(alwaysRun = true)
+ public void testInit() throws Exception {
+
+ super.init(userMode);
+ client = HttpClientBuilder.create().build();
+
+ ApplicationResponseModel application = addApplicationWithGrantType(CLIENT_CREDENTIALS_GRANT_TYPE);
+ applicationId = application.getId();
+ OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(applicationId);
+ clientId = oidcConfig.getClientId();
+ clientSecret = oidcConfig.getClientSecret();
+ actionId = createPreIssueAccessTokenAction();
+
+ requestedScopes = new ArrayList<>(Arrays.asList("scope_1", "scope_2"));
+
+ actionsMockServer = new ActionsMockServer();
+ actionsMockServer.startServer();
+ actionsMockServer.setupStub(MOCK_SERVER_ENDPOINT_RESOURCE_PATH,
+ "Basic " + getBase64EncodedString(MOCK_SERVER_AUTH_BASIC_USERNAME, MOCK_SERVER_AUTH_BASIC_PASSWORD),
+ actionResponse.getResponseBody(), actionResponse.getStatusCode());
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void atEnd() throws Exception {
+
+ actionsMockServer.stopServer();
+
+ deleteAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionId);
+ deleteApp(applicationId);
+
+ restClient.closeHttpClient();
+ actionsRestClient.closeHttpClient();
+ client.close();
+
+ actionsMockServer = null;
+ }
+
+ @Test(groups = "wso2.is", description = "Verify token response when pre-issue access token action fails with " +
+ "client credentials grant type.")
+ public void testPreIssueAccessTokenActionFailure() throws Exception {
+
+ HttpResponse response = sendTokenRequestForClientCredentialsGrant();
+
+ assertNotNull(response);
+ assertEquals(response.getStatusLine().getStatusCode(), expectedTokenResponse.getStatusCode());
+
+ String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+ JSONObject jsonResponse = new JSONObject(responseString);
+ assertEquals(jsonResponse.getString("error"), expectedTokenResponse.getErrorMessage());
+ assertEquals(jsonResponse.getString("error_description"), expectedTokenResponse.getErrorDescription());
+ }
+
+ public HttpResponse sendTokenRequestForClientCredentialsGrant() throws Exception {
+
+ List parameters = new ArrayList<>();
+ parameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_CLIENT_CREDENTIALS));
+
+ String scopes = String.join(" ", requestedScopes);
+ parameters.add(new BasicNameValuePair("scope", scopes));
+
+ List headers = new ArrayList<>();
+ headers.add(new BasicHeader(AUTHORIZATION_HEADER, OAuth2Constant.BASIC_HEADER + " " +
+ getBase64EncodedString(clientId, clientSecret)));
+ headers.add(new BasicHeader("Content-Type", "application/x-www-form-urlencoded"));
+ headers.add(new BasicHeader("User-Agent", OAuth2Constant.USER_AGENT));
+
+ return sendPostRequest(client, headers, parameters,
+ getTenantQualifiedURL(ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
+ }
+
+ private String createPreIssueAccessTokenAction() throws IOException {
+
+ AuthenticationType authenticationType = new AuthenticationType();
+ authenticationType.setType(AuthenticationType.TypeEnum.BASIC);
+ Map authProperties = new HashMap<>();
+ authProperties.put(USERNAME_PROPERTY, MOCK_SERVER_AUTH_BASIC_USERNAME);
+ authProperties.put(PASSWORD_PROPERTY, MOCK_SERVER_AUTH_BASIC_PASSWORD);
+ authenticationType.setProperties(authProperties);
+
+ Endpoint endpoint = new Endpoint();
+ endpoint.setUri(EXTERNAL_SERVICE_URI);
+ endpoint.setAuthentication(authenticationType);
+
+ ActionModel actionModel = new ActionModel();
+ actionModel.setName("Access Token Pre Issue");
+ actionModel.setDescription("This is a test pre issue access token type");
+ actionModel.setEndpoint(endpoint);
+
+ return createAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionModel);
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionFailureCodeGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionFailureCodeGrantTestCase.java
new file mode 100644
index 00000000000..80defdc50bc
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionFailureCodeGrantTestCase.java
@@ -0,0 +1,326 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (http://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.identity.integration.test.actions;
+
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.DefaultRedirectStrategy;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONObject;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Factory;
+import org.testng.annotations.Test;
+import org.wso2.carbon.automation.engine.context.TestUserMode;
+import org.wso2.identity.integration.test.actions.dataprovider.model.ActionResponse;
+import org.wso2.identity.integration.test.actions.dataprovider.model.ExpectedTokenResponse;
+import org.wso2.identity.integration.test.actions.mockserver.ActionsMockServer;
+import org.wso2.identity.integration.test.oauth2.dataprovider.model.ApplicationConfig;
+import org.wso2.identity.integration.test.oauth2.dataprovider.model.UserClaimConfig;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.ActionModel;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.AuthenticationType;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.Endpoint;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration;
+import org.wso2.identity.integration.test.rest.api.user.common.model.Email;
+import org.wso2.identity.integration.test.rest.api.user.common.model.Name;
+import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject;
+import org.wso2.identity.integration.test.restclients.SCIM2RestClient;
+import org.wso2.identity.integration.test.utils.DataExtractUtil;
+import org.wso2.identity.integration.test.utils.FileUtils;
+import org.wso2.identity.integration.test.utils.OAuth2Constant;
+
+import java.io.IOException;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.ACCESS_TOKEN_ENDPOINT;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.AUTHORIZATION_HEADER;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.AUTHORIZE_ENDPOINT_URL;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE;
+
+/**
+ * This class tests the pre issue access token action failure scenarios with code grant type.
+ */
+public class PreIssueAccessTokenActionFailureCodeGrantTestCase extends ActionsBaseTestCase {
+
+ private static final String USERNAME_PROPERTY = "username";
+ private static final String PASSWORD_PROPERTY = "password";
+ private static final String TEST_USER = "test_user";
+ private static final String TEST_WSO2 = "Test@wso2";
+ private static final String EXTERNAL_SERVICE_URI = "http://localhost:8587/test/action";
+ private static final String PRE_ISSUE_ACCESS_TOKEN_API_PATH = "preIssueAccessToken";
+ private static final String MOCK_SERVER_ENDPOINT_RESOURCE_PATH = "/test/action";
+ private static final String MOCK_SERVER_AUTH_BASIC_USERNAME = "test";
+ private static final String MOCK_SERVER_AUTH_BASIC_PASSWORD = "test";
+ private CloseableHttpClient client;
+ private SCIM2RestClient scim2RestClient;
+ private List requestedScopes;
+ private String sessionDataKey;
+ private String authorizationCode;
+ private String clientId;
+ private String clientSecret;
+ private String actionId;
+ private String applicationId;
+ private String userId;
+ private final TestUserMode userMode;
+ private ActionsMockServer actionsMockServer;
+ private final ActionResponse actionResponse;
+ private final ExpectedTokenResponse expectedResponse;
+
+ @Factory(dataProvider = "testExecutionContextProvider")
+ public PreIssueAccessTokenActionFailureCodeGrantTestCase(TestUserMode testUserMode, ActionResponse actionResponse,
+ ExpectedTokenResponse expectedResponse) {
+
+ this.userMode = testUserMode;
+ this.actionResponse = actionResponse;
+ this.expectedResponse = expectedResponse;
+ }
+
+ @DataProvider(name = "testExecutionContextProvider")
+ public static Object[][] getTestExecutionContext() throws Exception {
+
+ return new Object[][]{
+ {TestUserMode.SUPER_TENANT_USER, new ActionResponse(200,
+ FileUtils.readFileInClassPathAsString("actions/response/failure-response.json")),
+ new ExpectedTokenResponse(400, "Some failure reason", "Some description")},
+ {TestUserMode.TENANT_USER, new ActionResponse(200,
+ FileUtils.readFileInClassPathAsString("actions/response/failure-response.json")),
+ new ExpectedTokenResponse(400, "Some failure reason", "Some description")},
+ {TestUserMode.TENANT_USER, new ActionResponse(500,
+ FileUtils.readFileInClassPathAsString("actions/response/error-response.json")),
+ new ExpectedTokenResponse(500, "server_error", "Internal Server Error.")},
+ {TestUserMode.TENANT_USER, new ActionResponse(401, "Unauthorized"),
+ new ExpectedTokenResponse(500, "server_error", "Internal Server Error.")},
+ };
+ }
+
+ @BeforeClass(alwaysRun = true)
+ public void testInit() throws Exception {
+
+ super.init(userMode);
+ client = HttpClientBuilder.create()
+ .setRedirectStrategy(new DefaultRedirectStrategy() {
+ @Override
+ protected boolean isRedirectable(String method) {
+
+ return false;
+ }
+ }).build();
+
+ scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo);
+ applicationId = createOIDCAppWithClaims();
+ actionId = createPreIssueAccessTokenAction();
+ addUser();
+
+ requestedScopes = new ArrayList<>(Arrays.asList("openid", "profile"));
+
+ actionsMockServer = new ActionsMockServer();
+ actionsMockServer.startServer();
+ actionsMockServer.setupStub(MOCK_SERVER_ENDPOINT_RESOURCE_PATH,
+ "Basic " + getBase64EncodedString(MOCK_SERVER_AUTH_BASIC_USERNAME, MOCK_SERVER_AUTH_BASIC_PASSWORD),
+ actionResponse.getResponseBody(), actionResponse.getStatusCode());
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void atEnd() throws Exception {
+
+ actionsMockServer.stopServer();
+
+ deleteAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionId);
+ deleteApp(applicationId);
+ scim2RestClient.deleteUser(userId);
+
+ restClient.closeHttpClient();
+ scim2RestClient.closeHttpClient();
+ actionsRestClient.closeHttpClient();
+ client.close();
+
+ actionsMockServer = null;
+ authorizationCode = null;
+ }
+
+ @Test(groups = "wso2.is", description = "Verify token response when pre-issue access token action fails with " +
+ "authorization code grant type.")
+ public void testPreIssueAccessActionFailure() throws Exception {
+
+ sendAuthorizeRequest();
+ performUserLogin();
+ HttpResponse response = sendTokenRequestForCodeGrant();
+
+ assertNotNull(response);
+ assertEquals(response.getStatusLine().getStatusCode(), expectedResponse.getStatusCode());
+
+ String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+ JSONObject jsonResponse = new JSONObject(responseString);
+ assertEquals(jsonResponse.getString("error"), expectedResponse.getErrorMessage());
+ assertEquals(jsonResponse.getString("error_description"), expectedResponse.getErrorDescription());
+ }
+
+ private void sendAuthorizeRequest() throws Exception {
+
+ List urlParameters = new ArrayList<>();
+ urlParameters.add(new BasicNameValuePair("response_type", OAuth2Constant.OAUTH2_GRANT_TYPE_CODE));
+ urlParameters.add(new BasicNameValuePair("client_id", clientId));
+ urlParameters.add(new BasicNameValuePair("redirect_uri", OAuth2Constant.CALLBACK_URL));
+
+ String scopes = String.join(" ", requestedScopes);
+ urlParameters.add(new BasicNameValuePair("scope", scopes));
+
+ HttpResponse response = sendPostRequestWithParameters(client, urlParameters,
+ getTenantQualifiedURL(AUTHORIZE_ENDPOINT_URL, tenantInfo.getDomain()));
+
+ Header locationHeader = response.getFirstHeader(OAuth2Constant.HTTP_RESPONSE_HEADER_LOCATION);
+ assertNotNull(locationHeader, "Location header expected for authorize request is not available");
+ EntityUtils.consume(response.getEntity());
+
+ response = sendGetRequest(client, locationHeader.getValue());
+
+ Map keyPositionMap = new HashMap<>(1);
+ keyPositionMap.put("name=\"sessionDataKey\"", 1);
+ List keyValues = DataExtractUtil.extractDataFromResponse(response, keyPositionMap);
+ assertNotNull(keyValues, "SessionDataKey key value is null");
+
+ sessionDataKey = keyValues.get(0).getValue();
+ assertNotNull(sessionDataKey, "Session data key is null");
+ EntityUtils.consume(response.getEntity());
+ }
+
+ public void performUserLogin() throws Exception {
+
+ HttpResponse response = sendLoginPostForCustomUsers(client, sessionDataKey, TEST_USER, TEST_WSO2);
+
+ Header locationHeader = response.getFirstHeader(OAuth2Constant.HTTP_RESPONSE_HEADER_LOCATION);
+ assertNotNull(locationHeader, "Location header expected post login is not available.");
+ EntityUtils.consume(response.getEntity());
+
+ response = sendGetRequest(client, locationHeader.getValue());
+ locationHeader = response.getFirstHeader(OAuth2Constant.HTTP_RESPONSE_HEADER_LOCATION);
+ assertNotNull(locationHeader, "Redirection URL to the application with authorization code is null.");
+ EntityUtils.consume(response.getEntity());
+
+ authorizationCode = getAuthorizationCodeFromURL(locationHeader.getValue());
+ assertNotNull(authorizationCode);
+ }
+
+ private HttpResponse sendTokenRequestForCodeGrant() throws Exception {
+
+ List urlParameters = new ArrayList<>();
+ urlParameters.add(new BasicNameValuePair("code", authorizationCode));
+ urlParameters.add(new BasicNameValuePair("grant_type", OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE));
+ urlParameters.add(new BasicNameValuePair("redirect_uri", OAuth2Constant.CALLBACK_URL));
+ urlParameters.add(new BasicNameValuePair("client_id", clientId));
+
+ String scopes = String.join(" ", requestedScopes);
+ urlParameters.add(new BasicNameValuePair("scope", scopes));
+
+ List headers = new ArrayList<>();
+ headers.add(new BasicHeader(AUTHORIZATION_HEADER,
+ OAuth2Constant.BASIC_HEADER + " " + getBase64EncodedString(clientId, clientSecret)));
+ headers.add(new BasicHeader("Content-Type", "application/x-www-form-urlencoded"));
+ headers.add(new BasicHeader("User-Agent", OAuth2Constant.USER_AGENT));
+
+ return sendPostRequest(client, headers, urlParameters,
+ getTenantQualifiedURL(ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
+ }
+
+ private String getAuthorizationCodeFromURL(String location) {
+
+ URI uri = URI.create(location);
+ return URLEncodedUtils.parse(uri, StandardCharsets.UTF_8).stream()
+ .filter(param -> "code".equals(param.getName()))
+ .map(NameValuePair::getValue)
+ .findFirst()
+ .orElse(null);
+ }
+
+ private String createPreIssueAccessTokenAction() throws IOException {
+
+ AuthenticationType authenticationType = new AuthenticationType();
+ authenticationType.setType(AuthenticationType.TypeEnum.BASIC);
+ Map authProperties = new HashMap<>();
+ authProperties.put(USERNAME_PROPERTY, MOCK_SERVER_AUTH_BASIC_USERNAME);
+ authProperties.put(PASSWORD_PROPERTY, MOCK_SERVER_AUTH_BASIC_PASSWORD);
+ authenticationType.setProperties(authProperties);
+
+ Endpoint endpoint = new Endpoint();
+ endpoint.setUri(EXTERNAL_SERVICE_URI);
+ endpoint.setAuthentication(authenticationType);
+
+ ActionModel actionModel = new ActionModel();
+ actionModel.setName("Access Token Pre Issue");
+ actionModel.setDescription("This is a test pre issue access token type");
+ actionModel.setEndpoint(endpoint);
+
+ return createAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionModel);
+ }
+
+ private void addUser() throws Exception {
+
+ UserObject userInfo = new UserObject();
+ userInfo.setUserName(TEST_USER);
+ userInfo.setPassword(TEST_WSO2);
+ userInfo.setName(new Name().givenName("test_user_given_name"));
+ userInfo.getName().setFamilyName("test_user_last_name");
+ userInfo.addEmail(new Email().value("test.user@gmail.com"));
+ userId = scim2RestClient.createUser(userInfo);
+ }
+
+ private String createOIDCAppWithClaims() throws Exception {
+
+ List userClaimConfigs = Arrays.asList(
+ new UserClaimConfig.Builder().localClaimUri("http://wso2.org/claims/givenname").
+ oidcClaimUri("given_name").build(),
+ new UserClaimConfig.Builder().localClaimUri("http://wso2.org/claims/lastname").
+ oidcClaimUri("family_name").build()
+ );
+
+ ApplicationConfig applicationConfig = new ApplicationConfig.Builder()
+ .claimsList(userClaimConfigs)
+ .grantTypes(new ArrayList<>(Collections.singleton(OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE)))
+ .tokenType(ApplicationConfig.TokenType.JWT)
+ .expiryTime(3600)
+ .skipConsent(true)
+ .build();
+
+ ApplicationResponseModel application = addApplication(applicationConfig);
+ String applicationId = application.getId();
+
+ OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(applicationId);
+ clientId = oidcConfig.getClientId();
+ clientSecret = oidcConfig.getClientSecret();
+
+ return applicationId;
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionFailurePasswordGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionFailurePasswordGrantTestCase.java
new file mode 100644
index 00000000000..e2ca94f144f
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionFailurePasswordGrantTestCase.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (http://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.identity.integration.test.actions;
+
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONObject;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Factory;
+import org.testng.annotations.Test;
+import org.wso2.carbon.automation.engine.context.TestUserMode;
+import org.wso2.identity.integration.test.actions.dataprovider.model.ActionResponse;
+import org.wso2.identity.integration.test.actions.dataprovider.model.ExpectedTokenResponse;
+import org.wso2.identity.integration.test.actions.mockserver.ActionsMockServer;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.ActionModel;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.AuthenticationType;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.Endpoint;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration;
+import org.wso2.identity.integration.test.rest.api.user.common.model.Email;
+import org.wso2.identity.integration.test.rest.api.user.common.model.Name;
+import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject;
+import org.wso2.identity.integration.test.restclients.SCIM2RestClient;
+import org.wso2.identity.integration.test.utils.FileUtils;
+import org.wso2.identity.integration.test.utils.OAuth2Constant;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.ACCESS_TOKEN_ENDPOINT;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.AUTHORIZATION_HEADER;
+
+/**
+ * Tests the pre-issue access token action failure scenarios with password grant type.
+ */
+public class PreIssueAccessTokenActionFailurePasswordGrantTestCase extends ActionsBaseTestCase {
+
+ private static final String USERNAME_PROPERTY = "username";
+ private static final String PASSWORD_PROPERTY = "password";
+ private static final String TEST_USER = "test_user";
+ private static final String TEST_WSO2 = "Test@wso2";
+ private static final String EXTERNAL_SERVICE_URI = "http://localhost:8587/test/action";
+ private static final String PRE_ISSUE_ACCESS_TOKEN_API_PATH = "preIssueAccessToken";
+ private static final String MOCK_SERVER_ENDPOINT_RESOURCE_PATH = "/test/action";
+ private static final String MOCK_SERVER_AUTH_BASIC_USERNAME = "test";
+ private static final String MOCK_SERVER_AUTH_BASIC_PASSWORD = "test";
+ private static final String PASSWORD_GRANT_TYPE = "password";
+ private CloseableHttpClient client;
+ private SCIM2RestClient scim2RestClient;
+ private List requestedScopes;
+ private String clientId;
+ private String clientSecret;
+ private String actionId;
+ private String applicationId;
+ private String userId;
+ private final TestUserMode userMode;
+ private ActionsMockServer actionsMockServer;
+ private final ActionResponse actionResponse;
+ private final ExpectedTokenResponse expectedTokenResponse;
+
+ @Factory(dataProvider = "testExecutionContextProvider")
+ public PreIssueAccessTokenActionFailurePasswordGrantTestCase(TestUserMode testUserMode,
+ ActionResponse actionResponse,
+ ExpectedTokenResponse expectedTokenResponse) {
+
+ this.userMode = testUserMode;
+ this.actionResponse = actionResponse;
+ this.expectedTokenResponse = expectedTokenResponse;
+ }
+
+ @DataProvider(name = "testExecutionContextProvider")
+ public static Object[][] getTestExecutionContext() throws Exception {
+
+ return new Object[][]{
+ {TestUserMode.SUPER_TENANT_USER, new ActionResponse(200,
+ FileUtils.readFileInClassPathAsString("actions/response/failure-response.json")),
+ new ExpectedTokenResponse(400, "Some failure reason", "Some description")},
+ {TestUserMode.TENANT_USER, new ActionResponse(200,
+ FileUtils.readFileInClassPathAsString("actions/response/failure-response.json")),
+ new ExpectedTokenResponse(400, "Some failure reason", "Some description")},
+ {TestUserMode.TENANT_USER, new ActionResponse(500,
+ FileUtils.readFileInClassPathAsString("actions/response/error-response.json")),
+ new ExpectedTokenResponse(500, "server_error", "Internal Server Error.")},
+ {TestUserMode.TENANT_USER, new ActionResponse(401, "Unauthorized"),
+ new ExpectedTokenResponse(500, "server_error", "Internal Server Error.")},
+ };
+ }
+
+ @BeforeClass(alwaysRun = true)
+ public void testInit() throws Exception {
+
+ super.init(userMode);
+ client = HttpClientBuilder.create().build();
+
+ scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo);
+ ApplicationResponseModel application = addApplicationWithGrantType(PASSWORD_GRANT_TYPE);
+ applicationId = application.getId();
+ OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(applicationId);
+ clientId = oidcConfig.getClientId();
+ clientSecret = oidcConfig.getClientSecret();
+ actionId = createPreIssueAccessTokenAction();
+
+ addUser();
+
+ requestedScopes = new ArrayList<>(Arrays.asList("openid", "profile"));
+
+ actionsMockServer = new ActionsMockServer();
+ actionsMockServer.startServer();
+ actionsMockServer.setupStub(MOCK_SERVER_ENDPOINT_RESOURCE_PATH,
+ "Basic " + getBase64EncodedString(MOCK_SERVER_AUTH_BASIC_USERNAME, MOCK_SERVER_AUTH_BASIC_PASSWORD),
+ actionResponse.getResponseBody(), actionResponse.getStatusCode());
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void atEnd() throws Exception {
+
+ actionsMockServer.stopServer();
+
+ deleteAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionId);
+ deleteApp(applicationId);
+ scim2RestClient.deleteUser(userId);
+
+ restClient.closeHttpClient();
+ scim2RestClient.closeHttpClient();
+ actionsRestClient.closeHttpClient();
+ client.close();
+
+ actionsMockServer = null;
+ }
+
+ @Test(groups = "wso2.is", description = "Verify token response when pre-issue access token action fails with " +
+ "password grant type.")
+ public void testPreIssueAccessTokenActionFailure() throws Exception {
+
+ HttpResponse response = sendTokenRequestForPasswordGrant();
+
+ assertNotNull(response);
+ assertEquals(response.getStatusLine().getStatusCode(), expectedTokenResponse.getStatusCode());
+
+ String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+ JSONObject jsonResponse = new JSONObject(responseString);
+ assertEquals(jsonResponse.getString("error"), expectedTokenResponse.getErrorMessage());
+ assertEquals(jsonResponse.getString("error_description"), expectedTokenResponse.getErrorDescription());
+ }
+
+ private HttpResponse sendTokenRequestForPasswordGrant() throws Exception {
+
+ List parameters = new ArrayList<>();
+ parameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_RESOURCE_OWNER));
+ parameters.add(new BasicNameValuePair("username", TEST_USER));
+ parameters.add(new BasicNameValuePair("password", TEST_WSO2));
+
+ String scopes = String.join(" ", requestedScopes);
+ parameters.add(new BasicNameValuePair("scope", scopes));
+
+ List headers = new ArrayList<>();
+ headers.add(new BasicHeader(AUTHORIZATION_HEADER, OAuth2Constant.BASIC_HEADER + " " +
+ getBase64EncodedString(clientId, clientSecret)));
+ headers.add(new BasicHeader("Content-Type", "application/x-www-form-urlencoded"));
+ headers.add(new BasicHeader("User-Agent", OAuth2Constant.USER_AGENT));
+
+ return sendPostRequest(client, headers, parameters,
+ getTenantQualifiedURL(ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
+ }
+
+ private String createPreIssueAccessTokenAction() throws IOException {
+
+ AuthenticationType authenticationType = new AuthenticationType();
+ authenticationType.setType(AuthenticationType.TypeEnum.BASIC);
+ Map authProperties = new HashMap<>();
+ authProperties.put(USERNAME_PROPERTY, MOCK_SERVER_AUTH_BASIC_USERNAME);
+ authProperties.put(PASSWORD_PROPERTY, MOCK_SERVER_AUTH_BASIC_PASSWORD);
+ authenticationType.setProperties(authProperties);
+
+ Endpoint endpoint = new Endpoint();
+ endpoint.setUri(EXTERNAL_SERVICE_URI);
+ endpoint.setAuthentication(authenticationType);
+
+ ActionModel actionModel = new ActionModel();
+ actionModel.setName("Access Token Pre Issue");
+ actionModel.setDescription("This is a test pre issue access token type");
+ actionModel.setEndpoint(endpoint);
+
+ return createAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionModel);
+ }
+
+ private void addUser() throws Exception {
+
+ UserObject userInfo = new UserObject();
+ userInfo.setUserName(TEST_USER);
+ userInfo.setPassword(TEST_WSO2);
+ userInfo.setName(new Name().givenName("test_user_given_name"));
+ userInfo.getName().setFamilyName("test_user_last_name");
+ userInfo.addEmail(new Email().value("test.user@gmail.com"));
+ userId = scim2RestClient.createUser(userInfo);
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionFailureRefreshTokenGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionFailureRefreshTokenGrantTestCase.java
new file mode 100644
index 00000000000..56f2c235489
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionFailureRefreshTokenGrantTestCase.java
@@ -0,0 +1,387 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (http://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.identity.integration.test.actions;
+
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.DefaultRedirectStrategy;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONObject;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Factory;
+import org.testng.annotations.Test;
+import org.wso2.carbon.automation.engine.context.TestUserMode;
+import org.wso2.identity.integration.test.actions.dataprovider.model.ActionResponse;
+import org.wso2.identity.integration.test.actions.dataprovider.model.ExpectedTokenResponse;
+import org.wso2.identity.integration.test.actions.mockserver.ActionsMockServer;
+import org.wso2.identity.integration.test.oauth2.dataprovider.model.ApplicationConfig;
+import org.wso2.identity.integration.test.oauth2.dataprovider.model.UserClaimConfig;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.ActionModel;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.AuthenticationType;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.Endpoint;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration;
+import org.wso2.identity.integration.test.rest.api.user.common.model.Email;
+import org.wso2.identity.integration.test.rest.api.user.common.model.Name;
+import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject;
+import org.wso2.identity.integration.test.restclients.SCIM2RestClient;
+import org.wso2.identity.integration.test.utils.DataExtractUtil;
+import org.wso2.identity.integration.test.utils.FileUtils;
+import org.wso2.identity.integration.test.utils.OAuth2Constant;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.ACCESS_TOKEN_ENDPOINT;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.AUTHORIZATION_HEADER;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.AUTHORIZE_ENDPOINT_URL;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE;
+
+/**
+ * Tests the pre-issue access token action success scenarios with refresh token grant type.
+ */
+public class PreIssueAccessTokenActionFailureRefreshTokenGrantTestCase extends ActionsBaseTestCase {
+
+ private static final String USERNAME_PROPERTY = "username";
+ private static final String PASSWORD_PROPERTY = "password";
+ private static final String TEST_USER = "test_user";
+ private static final String TEST_WSO2 = "Test@wso2";
+ private static final String EXTERNAL_SERVICE_URI = "http://localhost:8587/test/action";
+ private static final String PRE_ISSUE_ACCESS_TOKEN_API_PATH = "preIssueAccessToken";
+ private static final String MOCK_SERVER_ENDPOINT_RESOURCE_PATH = "/test/action";
+ private static final String MOCK_SERVER_AUTH_BASIC_USERNAME = "test";
+ private static final String MOCK_SERVER_AUTH_BASIC_PASSWORD = "test";
+ private static final int APP_CONFIGURED_EXPIRY_TIME = 3600;
+ private CloseableHttpClient client;
+ private SCIM2RestClient scim2RestClient;
+ private List requestedScopes;
+ private String sessionDataKey;
+ private String authorizationCode;
+ private String clientId;
+ private String clientSecret;
+ private String actionId;
+ private String applicationId;
+ private String userId;
+ private String refreshToken;
+ private final TestUserMode userMode;
+ private final ActionResponse actionResponse;
+ private final ExpectedTokenResponse expectedResponse;
+ private ActionsMockServer actionsMockServer;
+
+ @Factory(dataProvider = "testExecutionContextProvider")
+ public PreIssueAccessTokenActionFailureRefreshTokenGrantTestCase(TestUserMode testUserMode,
+ ActionResponse actionResponse,
+ ExpectedTokenResponse expectedResponse) {
+
+ this.userMode = testUserMode;
+ this.actionResponse = actionResponse;
+ this.expectedResponse = expectedResponse;
+ }
+
+ @DataProvider(name = "testExecutionContextProvider")
+ public static Object[][] getTestExecutionContext() throws Exception {
+
+ return new Object[][]{
+ {TestUserMode.SUPER_TENANT_USER, new ActionResponse(200,
+ FileUtils.readFileInClassPathAsString("actions/response/failure-response.json")),
+ new ExpectedTokenResponse(400, "Some failure reason", "Some description")},
+ {TestUserMode.TENANT_USER, new ActionResponse(200,
+ FileUtils.readFileInClassPathAsString("actions/response/failure-response.json")),
+ new ExpectedTokenResponse(400, "Some failure reason", "Some description")},
+ {TestUserMode.TENANT_USER, new ActionResponse(500,
+ FileUtils.readFileInClassPathAsString("actions/response/error-response.json")),
+ new ExpectedTokenResponse(500, "server_error", "Internal Server Error.")},
+ {TestUserMode.TENANT_USER, new ActionResponse(401, "Unauthorized"),
+ new ExpectedTokenResponse(500, "server_error", "Internal Server Error.")},
+ };
+ }
+
+ @BeforeClass(alwaysRun = true)
+ public void testInit() throws Exception {
+
+ super.init(userMode);
+ client = HttpClientBuilder.create()
+ .setRedirectStrategy(new DefaultRedirectStrategy() {
+ @Override
+ protected boolean isRedirectable(String method) {
+
+ return false;
+ }
+ }).build();
+
+ scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo);
+ applicationId = createOIDCAppWithClaims();
+ actionId = createPreIssueAccessTokenAction();
+ addUser();
+
+ requestedScopes = new ArrayList<>(Arrays.asList("openid", "profile"));
+
+ actionsMockServer = new ActionsMockServer();
+ actionsMockServer.startServer();
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void atEnd() throws Exception {
+
+ actionsMockServer.stopServer();
+
+ deleteAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionId);
+ deleteApp(applicationId);
+ scim2RestClient.deleteUser(userId);
+
+ restClient.closeHttpClient();
+ scim2RestClient.closeHttpClient();
+ actionsRestClient.closeHttpClient();
+ client.close();
+
+ actionsMockServer = null;
+ authorizationCode = null;
+ }
+
+ @BeforeMethod
+ public void setupMockServerStub(Method method) throws Exception {
+
+ if (method.getName().equals("testGetAccessTokenWithCodeGrant")) {
+ actionsMockServer.setupStub(MOCK_SERVER_ENDPOINT_RESOURCE_PATH,
+ "Basic " + getBase64EncodedString(MOCK_SERVER_AUTH_BASIC_USERNAME, MOCK_SERVER_AUTH_BASIC_PASSWORD),
+ FileUtils.readFileInClassPathAsString(
+ "actions/response/pre-issue-access-token-response-code-before-refresh.json"), 200);
+ } else if (method.getName().equals("testPreIssueAccessTokenActionFailureForRefreshGrant")) {
+ actionsMockServer.setupStub(MOCK_SERVER_ENDPOINT_RESOURCE_PATH,
+ "Basic " + getBase64EncodedString(MOCK_SERVER_AUTH_BASIC_USERNAME, MOCK_SERVER_AUTH_BASIC_PASSWORD),
+ actionResponse.getResponseBody(), actionResponse.getStatusCode());
+ }
+ }
+
+ @Test(groups = "wso2.is", description =
+ "Get access token with authorization code grant when pre-issue access token action is successful")
+ public void testGetAccessTokenWithCodeGrant() throws Exception {
+
+ sendAuthorizeRequest();
+ performUserLogin();
+ HttpResponse response = sendTokenRequestForCodeGrant();
+
+ String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+ JSONObject jsonResponse = new JSONObject(responseString);
+
+ assertTrue(jsonResponse.has("access_token"), "Access token not found in the token response.");
+ assertTrue(jsonResponse.has("refresh_token"), "Refresh token not found in the token response.");
+ assertTrue(jsonResponse.has("expires_in"), "Expiry time not found in the token response.");
+ assertTrue(jsonResponse.has("token_type"), "Token type not found in the token response.");
+
+ String accessToken = jsonResponse.getString("access_token");
+ assertNotNull(accessToken, "Access token is null.");
+
+ refreshToken = jsonResponse.getString("refresh_token");
+ assertNotNull(refreshToken, "Refresh token is null.");
+
+ int expiresIn = jsonResponse.getInt("expires_in");
+ assertEquals(expiresIn, APP_CONFIGURED_EXPIRY_TIME, "Invalid expiry time for the access token.");
+
+ String tokenType = jsonResponse.getString("token_type");
+ assertEquals(tokenType, "Bearer", "Invalid token type for the access token.");
+ }
+
+ @Test(groups = "wso2.is", description =
+ "Get access token from refresh token when pre-issue access token action is successful",
+ dependsOnMethods = "testGetAccessTokenWithCodeGrant")
+ public void testPreIssueAccessTokenActionFailureForRefreshGrant() throws Exception {
+
+ HttpResponse response = sendTokenRequestForRefreshGrant();
+ assertNotNull(response);
+ assertEquals(response.getStatusLine().getStatusCode(), expectedResponse.getStatusCode());
+
+ String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+ JSONObject jsonResponse = new JSONObject(responseString);
+ assertEquals(jsonResponse.getString("error"), expectedResponse.getErrorMessage());
+ assertEquals(jsonResponse.getString("error_description"), expectedResponse.getErrorDescription());
+ }
+
+ private HttpResponse sendTokenRequestForRefreshGrant() throws IOException {
+
+ List parameters = new ArrayList<>();
+ parameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_REFRESH_TOKEN));
+ parameters.add(new BasicNameValuePair(OAuth2Constant.OAUTH2_GRANT_TYPE_REFRESH_TOKEN, refreshToken));
+
+ List headers = new ArrayList<>();
+ headers.add(new BasicHeader(AUTHORIZATION_HEADER,
+ OAuth2Constant.BASIC_HEADER + " " + getBase64EncodedString(clientId, clientSecret)));
+ headers.add(new BasicHeader("Content-Type", "application/x-www-form-urlencoded"));
+ headers.add(new BasicHeader("User-Agent", OAuth2Constant.USER_AGENT));
+
+ return sendPostRequest(client, headers, parameters,
+ getTenantQualifiedURL(ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
+ }
+
+ private void sendAuthorizeRequest() throws Exception {
+
+ List urlParameters = new ArrayList<>();
+ urlParameters.add(new BasicNameValuePair("response_type", OAuth2Constant.OAUTH2_GRANT_TYPE_CODE));
+ urlParameters.add(new BasicNameValuePair("client_id", clientId));
+ urlParameters.add(new BasicNameValuePair("redirect_uri", OAuth2Constant.CALLBACK_URL));
+
+ String scopes = String.join(" ", requestedScopes);
+ urlParameters.add(new BasicNameValuePair("scope", scopes));
+
+ HttpResponse response = sendPostRequestWithParameters(client, urlParameters,
+ getTenantQualifiedURL(AUTHORIZE_ENDPOINT_URL, tenantInfo.getDomain()));
+
+ Header locationHeader = response.getFirstHeader(OAuth2Constant.HTTP_RESPONSE_HEADER_LOCATION);
+ assertNotNull(locationHeader, "Location header expected for authorize request is not available");
+ EntityUtils.consume(response.getEntity());
+
+ response = sendGetRequest(client, locationHeader.getValue());
+
+ Map keyPositionMap = new HashMap<>(1);
+ keyPositionMap.put("name=\"sessionDataKey\"", 1);
+ List keyValues =
+ DataExtractUtil.extractDataFromResponse(response, keyPositionMap);
+ assertNotNull(keyValues, "SessionDataKey key value is null");
+
+ sessionDataKey = keyValues.get(0).getValue();
+ assertNotNull(sessionDataKey, "Session data key is null");
+ EntityUtils.consume(response.getEntity());
+ }
+
+ public void performUserLogin() throws Exception {
+
+ HttpResponse response = sendLoginPostForCustomUsers(client, sessionDataKey, TEST_USER, TEST_WSO2);
+
+ Header locationHeader = response.getFirstHeader(OAuth2Constant.HTTP_RESPONSE_HEADER_LOCATION);
+ assertNotNull(locationHeader, "Location header expected post login is not available.");
+ EntityUtils.consume(response.getEntity());
+
+ response = sendGetRequest(client, locationHeader.getValue());
+ locationHeader = response.getFirstHeader(OAuth2Constant.HTTP_RESPONSE_HEADER_LOCATION);
+ assertNotNull(locationHeader, "Redirection URL to the application with authorization code is null.");
+ EntityUtils.consume(response.getEntity());
+
+ authorizationCode = getAuthorizationCodeFromURL(locationHeader.getValue());
+ assertNotNull(authorizationCode);
+ }
+
+ private HttpResponse sendTokenRequestForCodeGrant() throws Exception {
+
+ List urlParameters = new ArrayList<>();
+ urlParameters.add(new BasicNameValuePair("code", authorizationCode));
+ urlParameters.add(new BasicNameValuePair("grant_type", OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE));
+ urlParameters.add(new BasicNameValuePair("redirect_uri", OAuth2Constant.CALLBACK_URL));
+ urlParameters.add(new BasicNameValuePair("client_id", clientId));
+
+ String scopes = String.join(" ", requestedScopes);
+ urlParameters.add(new BasicNameValuePair("scope", scopes));
+
+ List headers = new ArrayList<>();
+ headers.add(new BasicHeader(AUTHORIZATION_HEADER,
+ OAuth2Constant.BASIC_HEADER + " " + getBase64EncodedString(clientId, clientSecret)));
+ headers.add(new BasicHeader("Content-Type", "application/x-www-form-urlencoded"));
+ headers.add(new BasicHeader("User-Agent", OAuth2Constant.USER_AGENT));
+
+ return sendPostRequest(client, headers, urlParameters,
+ getTenantQualifiedURL(ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
+ }
+
+ private String getAuthorizationCodeFromURL(String location) {
+
+ URI uri = URI.create(location);
+ return URLEncodedUtils.parse(uri, StandardCharsets.UTF_8).stream()
+ .filter(param -> "code".equals(param.getName()))
+ .map(NameValuePair::getValue)
+ .findFirst()
+ .orElse(null);
+ }
+
+ private String createPreIssueAccessTokenAction() throws IOException {
+
+ AuthenticationType authenticationType = new AuthenticationType();
+ authenticationType.setType(AuthenticationType.TypeEnum.BASIC);
+ Map authProperties = new HashMap<>();
+ authProperties.put(USERNAME_PROPERTY, MOCK_SERVER_AUTH_BASIC_USERNAME);
+ authProperties.put(PASSWORD_PROPERTY, MOCK_SERVER_AUTH_BASIC_PASSWORD);
+ authenticationType.setProperties(authProperties);
+
+ Endpoint endpoint = new Endpoint();
+ endpoint.setUri(EXTERNAL_SERVICE_URI);
+ endpoint.setAuthentication(authenticationType);
+
+ ActionModel actionModel = new ActionModel();
+ actionModel.setName("Access Token Pre Issue");
+ actionModel.setDescription("This is a test pre issue access token type");
+ actionModel.setEndpoint(endpoint);
+
+ return createAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionModel);
+ }
+
+ private void addUser() throws Exception {
+
+ UserObject userInfo = new UserObject();
+ userInfo.setUserName(TEST_USER);
+ userInfo.setPassword(TEST_WSO2);
+ userInfo.setName(new Name().givenName("test_user_given_name"));
+ userInfo.getName().setFamilyName("test_user_last_name");
+ userInfo.addEmail(new Email().value("test.user@gmail.com"));
+ userId = scim2RestClient.createUser(userInfo);
+ }
+
+ private String createOIDCAppWithClaims() throws Exception {
+
+ List userClaimConfigs = Arrays.asList(
+ new UserClaimConfig.Builder().localClaimUri("http://wso2.org/claims/givenname").
+ oidcClaimUri("given_name").build(),
+ new UserClaimConfig.Builder().localClaimUri("http://wso2.org/claims/lastname").
+ oidcClaimUri("family_name").build()
+ );
+
+ ApplicationConfig applicationConfig = new ApplicationConfig.Builder()
+ .claimsList(userClaimConfigs)
+ .grantTypes(new ArrayList<>(Arrays.asList("authorization_code", "refresh_token")))
+ .tokenType(ApplicationConfig.TokenType.JWT)
+ .expiryTime(APP_CONFIGURED_EXPIRY_TIME)
+ .skipConsent(true)
+ .build();
+
+ ApplicationResponseModel application = addApplication(applicationConfig);
+ String applicationIdentifier = application.getId();
+
+ OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(applicationIdentifier);
+ clientId = oidcConfig.getClientId();
+ clientSecret = oidcConfig.getClientSecret();
+
+ return applicationIdentifier;
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenClientCredentialsGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionSuccessClientCredentialsGrantTestCase.java
similarity index 99%
rename from modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenClientCredentialsGrantTestCase.java
rename to modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionSuccessClientCredentialsGrantTestCase.java
index b9803ae552a..5a65ef702d8 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenClientCredentialsGrantTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionSuccessClientCredentialsGrantTestCase.java
@@ -86,7 +86,7 @@
* This test case extends {@link ActionsBaseTestCase} and focuses on scenarios related
* to scopes and claims modifications through an external service.
*/
-public class PreIssueAccessTokenClientCredentialsGrantTestCase extends ActionsBaseTestCase {
+public class PreIssueAccessTokenActionSuccessClientCredentialsGrantTestCase extends ActionsBaseTestCase {
private static final String USERNAME_PROPERTY = "username";
private static final String PASSWORD_PROPERTY = "password";
@@ -137,7 +137,7 @@ public class PreIssueAccessTokenClientCredentialsGrantTestCase extends ActionsBa
private ActionsMockServer actionsMockServer;
@Factory(dataProvider = "testExecutionContextProvider")
- public PreIssueAccessTokenClientCredentialsGrantTestCase(TestUserMode testUserMode) {
+ public PreIssueAccessTokenActionSuccessClientCredentialsGrantTestCase(TestUserMode testUserMode) {
this.userMode = testUserMode;
this.tenantId = testUserMode == TestUserMode.SUPER_TENANT_USER ? "-1234" : "1";
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenCodeGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionSuccessCodeGrantTestCase.java
similarity index 99%
rename from modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenCodeGrantTestCase.java
rename to modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionSuccessCodeGrantTestCase.java
index ca71adf6743..1e6041e4b5e 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenCodeGrantTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionSuccessCodeGrantTestCase.java
@@ -59,7 +59,6 @@
import org.wso2.identity.integration.test.actions.model.User;
import org.wso2.identity.integration.test.actions.model.UserStore;
import org.wso2.identity.integration.test.oauth2.dataprovider.model.ApplicationConfig;
-import org.wso2.identity.integration.test.oauth2.dataprovider.model.TokenScopes;
import org.wso2.identity.integration.test.oauth2.dataprovider.model.UserClaimConfig;
import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.ActionModel;
import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.AuthenticationType;
@@ -107,7 +106,7 @@
* This test case extends {@link ActionsBaseTestCase} and focuses on scenarios related
* to scopes and claims modifications through an external service.
*/
-public class PreIssueAccessTokenCodeGrantTestCase extends ActionsBaseTestCase {
+public class PreIssueAccessTokenActionSuccessCodeGrantTestCase extends ActionsBaseTestCase {
private static final String USERS = "users";
private static final String USERNAME_PROPERTY = "username";
@@ -171,7 +170,7 @@ public class PreIssueAccessTokenCodeGrantTestCase extends ActionsBaseTestCase {
private ActionsMockServer actionsMockServer;
@Factory(dataProvider = "testExecutionContextProvider")
- public PreIssueAccessTokenCodeGrantTestCase(TestUserMode testUserMode) {
+ public PreIssueAccessTokenActionSuccessCodeGrantTestCase(TestUserMode testUserMode) {
this.userMode = testUserMode;
this.tenantId = testUserMode == TestUserMode.SUPER_TENANT_USER ? "-1234" : "1";
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenPasswordGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionSuccessPasswordGrantTestCase.java
similarity index 99%
rename from modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenPasswordGrantTestCase.java
rename to modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionSuccessPasswordGrantTestCase.java
index c030bfcb708..146c7733255 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenPasswordGrantTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionSuccessPasswordGrantTestCase.java
@@ -99,7 +99,7 @@
* This test case extends {@link ActionsBaseTestCase} and focuses on scenarios related
* to scopes and claims modifications through an external service.
*/
-public class PreIssueAccessTokenPasswordGrantTestCase extends ActionsBaseTestCase {
+public class PreIssueAccessTokenActionSuccessPasswordGrantTestCase extends ActionsBaseTestCase {
private static final String USERS = "users";
private static final String USERNAME_PROPERTY = "username";
@@ -158,7 +158,7 @@ public class PreIssueAccessTokenPasswordGrantTestCase extends ActionsBaseTestCas
private ActionsMockServer actionsMockServer;
@Factory(dataProvider = "testExecutionContextProvider")
- public PreIssueAccessTokenPasswordGrantTestCase(TestUserMode testUserMode) {
+ public PreIssueAccessTokenActionSuccessPasswordGrantTestCase(TestUserMode testUserMode) {
this.userMode = testUserMode;
this.tenantId = testUserMode == TestUserMode.SUPER_TENANT_USER ? "-1234" : "1";
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionSuccessRefreshTokenGrantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionSuccessRefreshTokenGrantTestCase.java
new file mode 100644
index 00000000000..354bc794b87
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/PreIssueAccessTokenActionSuccessRefreshTokenGrantTestCase.java
@@ -0,0 +1,501 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (http://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.identity.integration.test.actions;
+
+import com.nimbusds.jwt.JWTClaimsSet;
+import com.nimbusds.jwt.SignedJWT;
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.DefaultRedirectStrategy;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONObject;
+import org.testng.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Factory;
+import org.testng.annotations.Test;
+import org.wso2.carbon.automation.engine.context.TestUserMode;
+import org.wso2.identity.integration.test.actions.mockserver.ActionsMockServer;
+import org.wso2.identity.integration.test.oauth2.dataprovider.model.ApplicationConfig;
+import org.wso2.identity.integration.test.oauth2.dataprovider.model.UserClaimConfig;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.ActionModel;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.AuthenticationType;
+import org.wso2.identity.integration.test.rest.api.server.action.management.v1.model.Endpoint;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationResponseModel;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.OpenIDConnectConfiguration;
+import org.wso2.identity.integration.test.rest.api.user.common.model.Email;
+import org.wso2.identity.integration.test.rest.api.user.common.model.Name;
+import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject;
+import org.wso2.identity.integration.test.restclients.SCIM2RestClient;
+import org.wso2.identity.integration.test.utils.DataExtractUtil;
+import org.wso2.identity.integration.test.utils.FileUtils;
+import org.wso2.identity.integration.test.utils.OAuth2Constant;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.ACCESS_TOKEN_ENDPOINT;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.AUTHORIZATION_HEADER;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.AUTHORIZE_ENDPOINT_URL;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE;
+
+/**
+ * Tests the pre-issue access token action success scenarios with refresh token grant type.
+ */
+public class PreIssueAccessTokenActionSuccessRefreshTokenGrantTestCase extends ActionsBaseTestCase {
+
+ private static final String USERNAME_PROPERTY = "username";
+ private static final String PASSWORD_PROPERTY = "password";
+ private static final String TEST_USER = "test_user";
+ private static final String TEST_WSO2 = "Test@wso2";
+ private static final String EXTERNAL_SERVICE_URI = "http://localhost:8587/test/action";
+ private static final String PRE_ISSUE_ACCESS_TOKEN_API_PATH = "preIssueAccessToken";
+ private static final String MOCK_SERVER_ENDPOINT_RESOURCE_PATH = "/test/action";
+ private static final String MOCK_SERVER_AUTH_BASIC_USERNAME = "test";
+ private static final String MOCK_SERVER_AUTH_BASIC_PASSWORD = "test";
+ private static final int APP_CONFIGURED_EXPIRY_TIME = 3600;
+ private static final int UPDATED_EXPIRY_TIME_BY_ACTION = 7200;
+ private CloseableHttpClient client;
+ private SCIM2RestClient scim2RestClient;
+ private List requestedScopes;
+ private String sessionDataKey;
+ private String authorizationCode;
+ private String clientId;
+ private String clientSecret;
+ private String actionId;
+ private String applicationId;
+ private String userId;
+ private String accessToken;
+ private String refreshToken;
+ private JWTClaimsSet accessTokenClaims;
+ private final TestUserMode userMode;
+ private ActionsMockServer actionsMockServer;
+
+ @Factory(dataProvider = "testExecutionContextProvider")
+ public PreIssueAccessTokenActionSuccessRefreshTokenGrantTestCase(TestUserMode testUserMode) {
+
+ this.userMode = testUserMode;
+ }
+
+ @DataProvider(name = "testExecutionContextProvider")
+ public static Object[][] getTestExecutionContext() {
+
+ return new Object[][]{
+ {TestUserMode.SUPER_TENANT_USER},
+ {TestUserMode.TENANT_USER}
+ };
+ }
+
+ @BeforeClass(alwaysRun = true)
+ public void testInit() throws Exception {
+
+ super.init(userMode);
+ client = HttpClientBuilder.create()
+ .setRedirectStrategy(new DefaultRedirectStrategy() {
+ @Override
+ protected boolean isRedirectable(String method) {
+
+ return false;
+ }
+ }).build();
+
+ scim2RestClient = new SCIM2RestClient(serverURL, tenantInfo);
+ applicationId = createOIDCAppWithClaims();
+ actionId = createPreIssueAccessTokenAction();
+ addUser();
+
+ requestedScopes = new ArrayList<>(Arrays.asList("openid", "profile"));
+
+ actionsMockServer = new ActionsMockServer();
+ actionsMockServer.startServer();
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void atEnd() throws Exception {
+
+ actionsMockServer.stopServer();
+
+ deleteAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionId);
+ deleteApp(applicationId);
+ scim2RestClient.deleteUser(userId);
+
+ restClient.closeHttpClient();
+ scim2RestClient.closeHttpClient();
+ actionsRestClient.closeHttpClient();
+ client.close();
+
+ actionsMockServer = null;
+ authorizationCode = null;
+ }
+
+ @BeforeMethod
+ public void setupMockServerStub(Method method) throws Exception {
+
+ if (method.getName().equals("testGetAccessTokenWithCodeGrant")) {
+ actionsMockServer.setupStub(MOCK_SERVER_ENDPOINT_RESOURCE_PATH,
+ "Basic " + getBase64EncodedString(MOCK_SERVER_AUTH_BASIC_USERNAME, MOCK_SERVER_AUTH_BASIC_PASSWORD),
+ FileUtils.readFileInClassPathAsString(
+ "actions/response/pre-issue-access-token-response-code-before-refresh.json"), 200);
+ } else if (method.getName().equals("testGetAccessTokenFromRefreshToken")) {
+ actionsMockServer.setupStub(MOCK_SERVER_ENDPOINT_RESOURCE_PATH,
+ "Basic " + getBase64EncodedString(MOCK_SERVER_AUTH_BASIC_USERNAME, MOCK_SERVER_AUTH_BASIC_PASSWORD),
+ FileUtils.readFileInClassPathAsString("actions/response/pre-issue-access-token-response.json"),
+ 200);
+ }
+ }
+
+ @Test(groups = "wso2.is", description =
+ "Get access token with authorization code grant when pre-issue access token action is successful")
+ public void testGetAccessTokenWithCodeGrant() throws Exception {
+
+ sendAuthorizeRequest();
+ performUserLogin();
+ HttpResponse response = sendTokenRequestForCodeGrant();
+
+ String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+ JSONObject jsonResponse = new JSONObject(responseString);
+
+ assertTrue(jsonResponse.has("access_token"), "Access token not found in the token response.");
+ assertTrue(jsonResponse.has("refresh_token"), "Refresh token not found in the token response.");
+ assertTrue(jsonResponse.has("expires_in"), "Expiry time not found in the token response.");
+ assertTrue(jsonResponse.has("token_type"), "Token type not found in the token response.");
+
+ accessToken = jsonResponse.getString("access_token");
+ assertNotNull(accessToken, "Access token is null.");
+
+ refreshToken = jsonResponse.getString("refresh_token");
+ assertNotNull(refreshToken, "Refresh token is null.");
+
+ int expiresIn = jsonResponse.getInt("expires_in");
+ assertEquals(expiresIn, APP_CONFIGURED_EXPIRY_TIME, "Invalid expiry time for the access token.");
+
+ String tokenType = jsonResponse.getString("token_type");
+ assertEquals(tokenType, "Bearer", "Invalid token type for the access token.");
+
+ accessTokenClaims = getJWTClaimSetFromToken(accessToken);
+ assertNotNull(accessTokenClaims);
+ }
+
+ @Test(groups = "wso2.is", description = "Verify the custom string claim in the access token added by action",
+ dependsOnMethods = "testGetAccessTokenWithCodeGrant")
+ public void testClaimAddOperationFromPreIssueAccessTokenActionForCodeGrant() throws Exception {
+
+ String claimValue = accessTokenClaims.getStringClaim("custom_claim_string_0");
+ Assert.assertEquals(claimValue, "testCustomClaim0");
+ }
+
+ @Test(groups = "wso2.is", description =
+ "Get access token from refresh token when pre-issue access token action is successful",
+ dependsOnMethods = "testGetAccessTokenWithCodeGrant")
+ public void testGetAccessTokenFromRefreshToken() throws Exception {
+
+ HttpResponse response = sendTokenRequestForRefreshGrant();
+
+ String responseString = EntityUtils.toString(response.getEntity(), "UTF-8");
+ JSONObject jsonResponse = new JSONObject(responseString);
+
+ assertTrue(jsonResponse.has("access_token"), "Access token not found in the token response.");
+ assertTrue(jsonResponse.has("refresh_token"), "Refresh token not found in the token response.");
+ assertTrue(jsonResponse.has("expires_in"), "Expiry time not found in the token response.");
+ assertTrue(jsonResponse.has("token_type"), "Token type not found in the token response.");
+
+ accessToken = jsonResponse.getString("access_token");
+ assertNotNull(accessToken, "Access token is null.");
+
+ refreshToken = jsonResponse.getString("refresh_token");
+ assertNotNull(refreshToken, "Refresh token is null.");
+
+ int expiresIn = jsonResponse.getInt("expires_in");
+ assertEquals(expiresIn, UPDATED_EXPIRY_TIME_BY_ACTION, "Invalid expiry time for the access token.");
+
+ String tokenType = jsonResponse.getString("token_type");
+ assertEquals(tokenType, "Bearer", "Invalid token type for the access token.");
+
+ accessTokenClaims = getJWTClaimSetFromToken(accessToken);
+ assertNotNull(accessTokenClaims);
+ }
+
+ @Test(groups = "wso2.is", description = "Verify the custom string claim added by action in " +
+ "code grant is available in the access token", dependsOnMethods = "testGetAccessTokenFromRefreshToken")
+ public void testClaimAddForAccessTokenFromPreIssueAccessTokenActionForRefreshTokenGrant()
+ throws Exception {
+
+ testClaimAddOperationFromPreIssueAccessTokenActionForCodeGrant();
+ }
+
+ @Test(groups = "wso2.is", description = "Verify the custom boolean claim added by action in the access token",
+ dependsOnMethods = "testGetAccessTokenFromRefreshToken")
+ public void testBooleanClaimAddOperationFromPreIssueAccessTokenActionForRefreshTokenGrant() throws Exception {
+
+ boolean claimValue = accessTokenClaims.getBooleanClaim("custom_claim_boolean_1");
+ Assert.assertTrue(claimValue);
+ }
+
+ @Test(groups = "wso2.is", description = "Verify the custom string claim added by action in the access token",
+ dependsOnMethods = "testGetAccessTokenFromRefreshToken")
+ public void testStringClaimAddOperationFromPreIssueAccessTokenActionForRefreshTokenGrant() throws Exception {
+
+ String claimValue = accessTokenClaims.getStringClaim("custom_claim_string_1");
+ Assert.assertEquals(claimValue, "testCustomClaim1");
+ }
+
+ @Test(groups = "wso2.is", description = "Verify the custom number claim added by action in the access token",
+ dependsOnMethods = "testGetAccessTokenFromRefreshToken")
+ public void testNumberClaimAddOperationFromPreIssueAccessTokenActionForRefreshTokenGrant() throws Exception {
+
+ int claimValue = accessTokenClaims.getIntegerClaim("custom_claim_number_1");
+ Assert.assertEquals(claimValue, 78);
+ }
+
+ @Test(groups = "wso2.is", description = "Verify the custom string array claim added by action in the " +
+ "access token", dependsOnMethods = "testGetAccessTokenFromRefreshToken")
+ public void testClaimArrayAddOperationFromPreIssueAccessTokenActionForRefreshTokenGrant()
+ throws Exception {
+
+ String[] expectedClaimArrayInToken = {"TestCustomClaim1", "TestCustomClaim2", "TestCustomClaim3"};
+
+ String[] addedClaimArrayToToken = accessTokenClaims.getStringArrayClaim("custom_claim_string_array_1");
+ Assert.assertEquals(addedClaimArrayToToken, expectedClaimArrayInToken);
+ }
+
+ @Test(groups = "wso2.is", description = "Verify the given_name claim replaced by the action in " +
+ "access token", dependsOnMethods = "testGetAccessTokenFromRefreshToken")
+ public void testGivenNameReplaceOperationFromPreIssueAccessTokenActionForRefreshTokenGrant()
+ throws Exception {
+
+ String givenNameClaim = accessTokenClaims.getStringClaim("given_name");
+ Assert.assertEquals(givenNameClaim, "replaced_given_name");
+ }
+
+ @Test(groups = "wso2.is", description = "Verify the 'aud' claim updated by action in the " +
+ "access token", dependsOnMethods = "testGetAccessTokenFromRefreshToken")
+ public void testAUDUpdateOperationsFromPreIssueAccessTokenActionForRefreshTokenGrant() throws Exception {
+
+ String[] audValueArray = accessTokenClaims.getStringArrayClaim("aud");
+
+ Assert.assertTrue(ArrayUtils.contains(audValueArray, "zzz1.com"));
+ Assert.assertTrue(ArrayUtils.contains(audValueArray, "zzz2.com"));
+ Assert.assertTrue(ArrayUtils.contains(audValueArray, "zzz3.com"));
+ Assert.assertTrue(ArrayUtils.contains(audValueArray, "zzzR.com"));
+ Assert.assertFalse(ArrayUtils.contains(audValueArray, clientId));
+ }
+
+ @Test(groups = "wso2.is", description = "Verify the scopes updated by action in the access token ",
+ dependsOnMethods = "testGetAccessTokenFromRefreshToken")
+ public void testScopeUpdateOperationsFromPreIssueAccessTokenActionForRefreshTokenGrant() throws Exception {
+
+ String[] scopes = accessTokenClaims.getStringClaim("scope").split("\\s+");
+
+ Assert.assertTrue(ArrayUtils.contains(scopes, "new_test_custom_scope_1"));
+ Assert.assertTrue(ArrayUtils.contains(scopes, "new_test_custom_scope_2"));
+ Assert.assertTrue(ArrayUtils.contains(scopes, "new_test_custom_scope_3"));
+ Assert.assertTrue(ArrayUtils.contains(scopes, "replaced_scope"));
+ }
+
+ @Test(groups = "wso2.is", description = "Verify the 'expires_in' claim updated by action in the access token",
+ dependsOnMethods = "testGetAccessTokenFromRefreshToken")
+ public void testExpiresInClaimReplaceOperationFromPreIssueAccessTokenActionForRefreshTokenGrant() throws Exception {
+
+ Date exp = accessTokenClaims.getDateClaim("exp");
+ Date iat = accessTokenClaims.getDateClaim("iat");
+ long expiresIn = (exp.getTime() - iat.getTime()) / 1000;
+
+ Assert.assertEquals(expiresIn, UPDATED_EXPIRY_TIME_BY_ACTION);
+ }
+
+ private HttpResponse sendTokenRequestForRefreshGrant() throws IOException {
+
+ List parameters = new ArrayList<>();
+ parameters.add(new BasicNameValuePair("grant_type", OAuth2Constant.OAUTH2_GRANT_TYPE_REFRESH_TOKEN));
+ parameters.add(new BasicNameValuePair(OAuth2Constant.OAUTH2_GRANT_TYPE_REFRESH_TOKEN, refreshToken));
+
+ List headers = new ArrayList<>();
+ headers.add(new BasicHeader(AUTHORIZATION_HEADER,
+ OAuth2Constant.BASIC_HEADER + " " + getBase64EncodedString(clientId, clientSecret)));
+ headers.add(new BasicHeader("Content-Type", "application/x-www-form-urlencoded"));
+ headers.add(new BasicHeader("User-Agent", OAuth2Constant.USER_AGENT));
+
+ return sendPostRequest(client, headers, parameters,
+ getTenantQualifiedURL(ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
+ }
+
+ private void sendAuthorizeRequest() throws Exception {
+
+ List urlParameters = new ArrayList<>();
+ urlParameters.add(new BasicNameValuePair("response_type", OAuth2Constant.OAUTH2_GRANT_TYPE_CODE));
+ urlParameters.add(new BasicNameValuePair("client_id", clientId));
+ urlParameters.add(new BasicNameValuePair("redirect_uri", OAuth2Constant.CALLBACK_URL));
+
+ String scopes = String.join(" ", requestedScopes);
+ urlParameters.add(new BasicNameValuePair("scope", scopes));
+
+ HttpResponse response = sendPostRequestWithParameters(client, urlParameters,
+ getTenantQualifiedURL(AUTHORIZE_ENDPOINT_URL, tenantInfo.getDomain()));
+
+ Header locationHeader = response.getFirstHeader(OAuth2Constant.HTTP_RESPONSE_HEADER_LOCATION);
+ assertNotNull(locationHeader, "Location header expected for authorize request is not available");
+ EntityUtils.consume(response.getEntity());
+
+ response = sendGetRequest(client, locationHeader.getValue());
+
+ Map keyPositionMap = new HashMap<>(1);
+ keyPositionMap.put("name=\"sessionDataKey\"", 1);
+ List keyValues =
+ DataExtractUtil.extractDataFromResponse(response, keyPositionMap);
+ assertNotNull(keyValues, "SessionDataKey key value is null");
+
+ sessionDataKey = keyValues.get(0).getValue();
+ assertNotNull(sessionDataKey, "Session data key is null");
+ EntityUtils.consume(response.getEntity());
+ }
+
+ public void performUserLogin() throws Exception {
+
+ HttpResponse response = sendLoginPostForCustomUsers(client, sessionDataKey, TEST_USER, TEST_WSO2);
+
+ Header locationHeader = response.getFirstHeader(OAuth2Constant.HTTP_RESPONSE_HEADER_LOCATION);
+ assertNotNull(locationHeader, "Location header expected post login is not available.");
+ EntityUtils.consume(response.getEntity());
+
+ response = sendGetRequest(client, locationHeader.getValue());
+ locationHeader = response.getFirstHeader(OAuth2Constant.HTTP_RESPONSE_HEADER_LOCATION);
+ assertNotNull(locationHeader, "Redirection URL to the application with authorization code is null.");
+ EntityUtils.consume(response.getEntity());
+
+ authorizationCode = getAuthorizationCodeFromURL(locationHeader.getValue());
+ assertNotNull(authorizationCode);
+ }
+
+ private HttpResponse sendTokenRequestForCodeGrant() throws Exception {
+
+ List urlParameters = new ArrayList<>();
+ urlParameters.add(new BasicNameValuePair("code", authorizationCode));
+ urlParameters.add(new BasicNameValuePair("grant_type", OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE));
+ urlParameters.add(new BasicNameValuePair("redirect_uri", OAuth2Constant.CALLBACK_URL));
+ urlParameters.add(new BasicNameValuePair("client_id", clientId));
+
+ String scopes = String.join(" ", requestedScopes);
+ urlParameters.add(new BasicNameValuePair("scope", scopes));
+
+ List headers = new ArrayList<>();
+ headers.add(new BasicHeader(AUTHORIZATION_HEADER,
+ OAuth2Constant.BASIC_HEADER + " " + getBase64EncodedString(clientId, clientSecret)));
+ headers.add(new BasicHeader("Content-Type", "application/x-www-form-urlencoded"));
+ headers.add(new BasicHeader("User-Agent", OAuth2Constant.USER_AGENT));
+
+ return sendPostRequest(client, headers, urlParameters,
+ getTenantQualifiedURL(ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
+ }
+
+ private String getAuthorizationCodeFromURL(String location) {
+
+ URI uri = URI.create(location);
+ return URLEncodedUtils.parse(uri, StandardCharsets.UTF_8).stream()
+ .filter(param -> "code".equals(param.getName()))
+ .map(NameValuePair::getValue)
+ .findFirst()
+ .orElse(null);
+ }
+
+ private String createPreIssueAccessTokenAction() throws IOException {
+
+ AuthenticationType authenticationType = new AuthenticationType();
+ authenticationType.setType(AuthenticationType.TypeEnum.BASIC);
+ Map authProperties = new HashMap<>();
+ authProperties.put(USERNAME_PROPERTY, MOCK_SERVER_AUTH_BASIC_USERNAME);
+ authProperties.put(PASSWORD_PROPERTY, MOCK_SERVER_AUTH_BASIC_PASSWORD);
+ authenticationType.setProperties(authProperties);
+
+ Endpoint endpoint = new Endpoint();
+ endpoint.setUri(EXTERNAL_SERVICE_URI);
+ endpoint.setAuthentication(authenticationType);
+
+ ActionModel actionModel = new ActionModel();
+ actionModel.setName("Access Token Pre Issue");
+ actionModel.setDescription("This is a test pre issue access token type");
+ actionModel.setEndpoint(endpoint);
+
+ return createAction(PRE_ISSUE_ACCESS_TOKEN_API_PATH, actionModel);
+ }
+
+ private void addUser() throws Exception {
+
+ UserObject userInfo = new UserObject();
+ userInfo.setUserName(TEST_USER);
+ userInfo.setPassword(TEST_WSO2);
+ userInfo.setName(new Name().givenName("test_user_given_name"));
+ userInfo.getName().setFamilyName("test_user_last_name");
+ userInfo.addEmail(new Email().value("test.user@gmail.com"));
+ userId = scim2RestClient.createUser(userInfo);
+ }
+
+ private String createOIDCAppWithClaims() throws Exception {
+
+ List userClaimConfigs = Arrays.asList(
+ new UserClaimConfig.Builder().localClaimUri("http://wso2.org/claims/givenname").
+ oidcClaimUri("given_name").build(),
+ new UserClaimConfig.Builder().localClaimUri("http://wso2.org/claims/lastname").
+ oidcClaimUri("family_name").build()
+ );
+
+ ApplicationConfig applicationConfig = new ApplicationConfig.Builder()
+ .claimsList(userClaimConfigs)
+ .grantTypes(new ArrayList<>(Arrays.asList("authorization_code", "refresh_token")))
+ .tokenType(ApplicationConfig.TokenType.JWT)
+ .expiryTime(APP_CONFIGURED_EXPIRY_TIME)
+ .skipConsent(true)
+ .build();
+
+ ApplicationResponseModel application = addApplication(applicationConfig);
+ String applicationId = application.getId();
+
+ OpenIDConnectConfiguration oidcConfig = getOIDCInboundDetailsOfApplication(applicationId);
+ clientId = oidcConfig.getClientId();
+ clientSecret = oidcConfig.getClientSecret();
+
+ return applicationId;
+ }
+
+ private JWTClaimsSet getJWTClaimSetFromToken(String jwtToken) throws ParseException {
+
+ SignedJWT signedJWT = SignedJWT.parse(jwtToken);
+ return signedJWT.getJWTClaimsSet();
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/dataprovider/model/ActionResponse.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/dataprovider/model/ActionResponse.java
new file mode 100644
index 00000000000..3ea145ab3fd
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/dataprovider/model/ActionResponse.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (http://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.identity.integration.test.actions.dataprovider.model;
+
+/**
+ * This class is used to represent the response from the extension, when an action is invoked.
+ */
+public class ActionResponse {
+
+ private final int statusCode;
+ private final String responseBody;
+
+ public ActionResponse(int statusCode, String responseBody) {
+
+ this.statusCode = statusCode;
+ this.responseBody = responseBody;
+ }
+
+ public int getStatusCode() {
+
+ return statusCode;
+ }
+
+ public String getResponseBody() {
+
+ return responseBody;
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/dataprovider/model/ExpectedTokenResponse.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/dataprovider/model/ExpectedTokenResponse.java
new file mode 100644
index 00000000000..c2ac527af72
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/dataprovider/model/ExpectedTokenResponse.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (http://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.identity.integration.test.actions.dataprovider.model;
+
+/**
+ * This class is used to represent the response from the token api, in a pre issue access token action invocation.
+ */
+public class ExpectedTokenResponse {
+
+ private final int statusCode;
+ private final String errorMessage;
+ private final String errorDescription;
+
+ public ExpectedTokenResponse(int statusCode, String errorMessage, String errorDescription) {
+
+ this.statusCode = statusCode;
+ this.errorMessage = errorMessage;
+ this.errorDescription = errorDescription;
+ }
+
+ public int getStatusCode() {
+
+ return statusCode;
+ }
+
+ public String getErrorMessage() {
+
+ return errorMessage;
+ }
+
+ public String getErrorDescription() {
+
+ return errorDescription;
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/mockserver/ActionsMockServer.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/mockserver/ActionsMockServer.java
index d49b0e36c56..102d8bc265b 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/mockserver/ActionsMockServer.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/actions/mockserver/ActionsMockServer.java
@@ -39,6 +39,7 @@
public class ActionsMockServer {
private WireMockServer wireMockServer;
+
public void startServer() {
wireMockServer = new WireMockServer(WireMockConfiguration.wireMockConfig().port(8587));
@@ -63,6 +64,17 @@ public void setupStub(String url, String authMethod, String responseBody) {
.withBody(responseBody)));
}
+ public void setupStub(String url, String authMethod, String responseBody, int statusCode) {
+
+ wireMockServer.stubFor(post(urlEqualTo(url))
+ .withHeader("Authorization", matching(authMethod))
+ .willReturn(aResponse()
+ .withStatus(statusCode)
+ .withHeader("Content-Type", "application/json")
+ .withHeader("Connection", "Close")
+ .withBody(responseBody)));
+ }
+
public String getReceivedRequestPayload(String url) {
List requestList = wireMockServer.findAll(postRequestedFor(urlEqualTo(url)));
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/application/authz/AbstractApplicationAuthzTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/application/authz/AbstractApplicationAuthzTestCase.java
deleted file mode 100644
index 5032fd1967b..00000000000
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/application/authz/AbstractApplicationAuthzTestCase.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. 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.identity.integration.test.application.authz;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpResponse;
-import org.apache.http.NameValuePair;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.entity.UrlEncodedFormEntity;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.config.Lookup;
-import org.apache.http.cookie.CookieSpecProvider;
-import org.apache.http.message.BasicNameValuePair;
-import org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig;
-import org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig;
-import org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig;
-import org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider;
-import org.wso2.carbon.identity.entitlement.stub.EntitlementPolicyAdminServiceEntitlementException;
-import org.wso2.carbon.identity.entitlement.stub.dto.PolicyDTO;
-import org.wso2.carbon.identity.sso.saml.stub.IdentitySAMLSSOConfigServiceIdentityException;
-import org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO;
-import org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient;
-import org.wso2.identity.integration.common.clients.entitlement.EntitlementPolicyServiceClient;
-import org.wso2.identity.integration.common.clients.sso.saml.SAMLSSOConfigServiceClient;
-import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient;
-import org.wso2.identity.integration.common.utils.ISIntegrationTest;
-import org.wso2.identity.integration.test.utils.CommonConstants;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Abstract test class for application authorization based on XACML policy.
- */
-public class AbstractApplicationAuthzTestCase extends ISIntegrationTest {
-
- // SAML Application attributes
- protected static final String USER_AGENT = "Apache-HttpClient/4.2.5 (java 1.5)";
- protected static final String INBOUND_AUTH_TYPE = "samlsso";
- protected static final String ACS_URL = "http://localhost:" + CommonConstants.DEFAULT_TOMCAT_PORT + "/%s/home.jsp";
- protected static final String COMMON_AUTH_URL = "https://localhost:" + CommonConstants.IS_DEFAULT_HTTPS_PORT + "/commonauth";
- protected static final String SAML_SSO_LOGIN_URL = "http://localhost:" + CommonConstants.DEFAULT_TOMCAT_PORT + "/%s/samlsso?SAML2.HTTPBinding=%s";
- protected static final String NAMEID_FORMAT = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress";
- protected static final String LOGIN_URL = "/carbon/admin/login.jsp";
- private static final Log log = LogFactory.getLog(AbstractApplicationAuthzTestCase.class);
-
- protected ApplicationManagementServiceClient applicationManagementServiceClient;
- protected SAMLSSOConfigServiceClient ssoConfigServiceClient;
- protected RemoteUserStoreManagerServiceClient remoteUSMServiceClient;
- protected EntitlementPolicyServiceClient entitlementPolicyClient;
-
- protected HttpClient httpClientAzUser;
- protected HttpClient httpClientNonAzUser;
-
- protected Lookup cookieSpecRegistry;
- protected RequestConfig requestConfig;
-
- protected HttpResponse sendSAMLMessage(String url, String samlMsgKey, String samlMsgValue) throws IOException {
-
- List urlParameters = new ArrayList<>();
- HttpPost post = new HttpPost(url);
- post.setHeader("User-Agent", USER_AGENT);
- urlParameters.add(new BasicNameValuePair(samlMsgKey, samlMsgValue));
- post.setEntity(new UrlEncodedFormEntity(urlParameters));
- return httpClientAzUser.execute(post);
- }
-
- protected String extractDataFromResponse(HttpResponse response) throws IOException {
-
- BufferedReader rd = new BufferedReader(
- new InputStreamReader(response.getEntity().getContent()));
- StringBuilder result = new StringBuilder();
- String line;
- while ((line = rd.readLine()) != null) {
- result.append(line);
- }
- rd.close();
- return result.toString();
- }
-
- protected void createApplication(String applicationName) throws Exception {
-
- ServiceProvider serviceProvider = new ServiceProvider();
- serviceProvider.setApplicationName(applicationName);
- serviceProvider.setDescription("This is a test Service Provider for AZ test");
- applicationManagementServiceClient.createApplication(serviceProvider);
-
- serviceProvider = applicationManagementServiceClient.getApplication(applicationName);
-
- InboundAuthenticationRequestConfig requestConfig = new InboundAuthenticationRequestConfig();
- requestConfig.setInboundAuthType(INBOUND_AUTH_TYPE);
- requestConfig.setInboundAuthKey(applicationName);
-
-
- InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig();
- inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs(
- new InboundAuthenticationRequestConfig[]{requestConfig});
-
- serviceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig);
-
- LocalAndOutboundAuthenticationConfig outboundAuthConfig = new LocalAndOutboundAuthenticationConfig();
- outboundAuthConfig.setEnableAuthorization(true);
- serviceProvider.setLocalAndOutBoundAuthenticationConfig(outboundAuthConfig);
- applicationManagementServiceClient.updateApplicationData(serviceProvider);
- }
-
- protected void deleteApplication(String applicationName) throws Exception {
-
- applicationManagementServiceClient.deleteApplication(applicationName);
- ssoConfigServiceClient.removeServiceProvider(applicationName);
- }
-
- protected void createRole(String roleName) throws Exception {
-
- log.info("Creating role " + roleName);
- remoteUSMServiceClient.addRole(roleName, new String[0], null);
- }
-
- protected void deleteRole(String roleName) throws Exception {
-
- log.info("Deleting role " + roleName);
- remoteUSMServiceClient.deleteRole(roleName);
- }
-
- protected void createUser(String username, String password, String[] roles) throws Exception {
-
- log.info("Creating User " + username);
- remoteUSMServiceClient.addUser(username, password, roles, null, null, true);
- }
-
- protected void deleteUser(String username) throws Exception {
-
- log.info("Deleting User " + username);
- remoteUSMServiceClient.deleteUser(username);
- }
-
- protected void createSAMLApp(String applicationName, boolean singleLogout, boolean signResponse, boolean signAssertion)
- throws RemoteException, IdentitySAMLSSOConfigServiceIdentityException {
-
- SAMLSSOServiceProviderDTO samlssoServiceProviderDTO = new SAMLSSOServiceProviderDTO();
- samlssoServiceProviderDTO.setIssuer(applicationName);
- samlssoServiceProviderDTO.setAssertionConsumerUrls(new String[]{String.format(ACS_URL,
- applicationName)});
- samlssoServiceProviderDTO.setDefaultAssertionConsumerUrl(String.format(ACS_URL, applicationName));
- samlssoServiceProviderDTO.setNameIDFormat(NAMEID_FORMAT);
- samlssoServiceProviderDTO.setDoSingleLogout(singleLogout);
- samlssoServiceProviderDTO.setLoginPageURL(LOGIN_URL);
- samlssoServiceProviderDTO.setDoSignResponse(signResponse);
- samlssoServiceProviderDTO.setDoSignAssertions(signAssertion);
- ssoConfigServiceClient.addServiceProvider(samlssoServiceProviderDTO);
- }
-
- protected void setupXACMLPolicy(String policyId, String xacmlPolicy)
- throws InterruptedException, RemoteException, EntitlementPolicyAdminServiceEntitlementException {
-
- PolicyDTO policy = new PolicyDTO();
- policy.setPolicy(xacmlPolicy);
- policy.setPolicy(policy.getPolicy().replaceAll(">\\s+<", "><").trim());
- policy.setVersion("3.0");
- policy.setPolicyId(policyId);
- entitlementPolicyClient.addPolicy(policy);
- Thread.sleep(5000); // waiting for the policy to deploy
- entitlementPolicyClient
- .publishPolicies(new String[]{policyId}, new String[]{"PDP Subscriber"}, "CREATE", true, null, 1);
- }
-}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/application/authz/ApplicationAuthzTenantTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/application/authz/ApplicationAuthzTenantTestCase.java
deleted file mode 100644
index 9021c996edd..00000000000
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/application/authz/ApplicationAuthzTenantTestCase.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. 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.identity.integration.test.application.authz;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.config.CookieSpecs;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.cookie.CookieSpecProvider;
-import org.apache.http.impl.client.BasicCookieStore;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.cookie.RFC6265CookieSpecProvider;
-import org.apache.http.util.EntityUtils;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-import org.wso2.carbon.automation.engine.context.TestUserMode;
-import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
-import org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient;
-import org.wso2.identity.integration.common.clients.entitlement.EntitlementPolicyServiceClient;
-import org.wso2.identity.integration.common.clients.sso.saml.SAMLSSOConfigServiceClient;
-import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient;
-import org.wso2.identity.integration.common.utils.ISIntegrationTest;
-import org.wso2.identity.integration.test.util.Utils;
-import org.wso2.identity.integration.test.utils.CommonConstants;
-import org.wso2.identity.integration.test.utils.UserUtil;
-
-import java.io.File;
-import java.net.URL;
-
-/**
- * Test class to test tenant authorization based on XACML policy.
- */
-public class ApplicationAuthzTenantTestCase extends AbstractApplicationAuthzTestCase {
-
- private static final String AZ_TEST_TENANT_ROLE = "Internal/azTestTenantRole";
- private static final String HTTP_REDIRECT = "HTTP-Redirect";
- private static final String AZ_TEST_TENANT_USER = "azTestTenantUser";
- private static final String AZ_TEST_TENANT_USER_PW = "azTest@123";
- private static final String NON_AZ_TEST_TENANT_USER = "nonAzTestTenantUser";
- private static final String NON_AZ_TEST_TENANT_USER_PW = "nonAzTest@123";
- private static final Log log = LogFactory.getLog(ApplicationAuthzTenantTestCase.class);
- private static final String APPLICATION_NAME = "travelocity.com-saml-tenantwithoutsigning";
- private static final String POLICY_ID = "spTenantAuthPolicy";
- private static final String POLICY =
- "\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " " +
- APPLICATION_NAME + "\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " " +
- AZ_TEST_TENANT_ROLE + "\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- "";
-
- private String userId;
- private String tenantQualifiedCommonAuthURL;
-
- @BeforeClass(alwaysRun = true)
- public void testInit() throws Exception {
-
- super.init(TestUserMode.TENANT_ADMIN);
- tenantQualifiedCommonAuthURL = getTenantQualifiedURL(COMMON_AUTH_URL, tenantInfo.getDomain());
- ConfigurationContext configContext = ConfigurationContextFactory
- .createConfigurationContextFromFileSystem(null, null);
- applicationManagementServiceClient =
- new ApplicationManagementServiceClient(sessionCookie, backendURL, configContext);
- ssoConfigServiceClient =
- new SAMLSSOConfigServiceClient(backendURL, sessionCookie);
- remoteUSMServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie);
- entitlementPolicyClient = new EntitlementPolicyServiceClient(backendURL, sessionCookie);
-
- cookieSpecRegistry = RegistryBuilder.create()
- .register(CookieSpecs.DEFAULT, new RFC6265CookieSpecProvider())
- .build();
- requestConfig = RequestConfig.custom()
- .setCookieSpec(CookieSpecs.DEFAULT)
- .build();
- httpClientAzUser = HttpClientBuilder.create().setDefaultCookieStore(new BasicCookieStore())
- .setDefaultRequestConfig(requestConfig)
- .setDefaultCookieSpecRegistry(cookieSpecRegistry)
- .build();
- httpClientNonAzUser = HttpClientBuilder.create().setDefaultCookieStore(new BasicCookieStore())
- .setDefaultRequestConfig(requestConfig)
- .setDefaultCookieSpecRegistry(cookieSpecRegistry)
- .build();
-
- createRole(AZ_TEST_TENANT_ROLE);
- createUser(AZ_TEST_TENANT_USER, AZ_TEST_TENANT_USER_PW, new String[]{AZ_TEST_TENANT_ROLE});
- userId = UserUtil.getUserId(MultitenantUtils.getTenantAwareUsername(AZ_TEST_TENANT_USER), isServer.getContextTenant());
-
- createUser(NON_AZ_TEST_TENANT_USER, NON_AZ_TEST_TENANT_USER_PW, new String[0]);
- createApplication(APPLICATION_NAME);
- createSAMLApp(APPLICATION_NAME, true, false, false);
- setupXACMLPolicy(POLICY_ID, POLICY);
- }
-
- @AfterClass(alwaysRun = true)
- public void testClear() throws Exception {
-
- deleteUser(AZ_TEST_TENANT_USER);
- deleteUser(NON_AZ_TEST_TENANT_USER);
- deleteRole(AZ_TEST_TENANT_ROLE);
- deleteApplication(APPLICATION_NAME);
- entitlementPolicyClient.publishPolicies(new String[]{POLICY_ID}, new String[]{"PDP " +
- "Subscriber"}, "DELETE", true, null, 1);
- entitlementPolicyClient.removePolicy(POLICY_ID);
-
- ssoConfigServiceClient = null;
- applicationManagementServiceClient = null;
- remoteUSMServiceClient = null;
- httpClientAzUser = null;
- }
-
- @Test(alwaysRun = true, description = "Test authorized tenant user login by evaluating the policy", groups = "wso2.is")
- public void testAuthorizedTenantSAMLSSOLogin() throws Exception {
-
- HttpResponse response;
- response =
- Utils.sendGetRequest(String.format(SAML_SSO_LOGIN_URL, APPLICATION_NAME, HTTP_REDIRECT), USER_AGENT,
- httpClientAzUser);
- String sessionKey = Utils.extractDataFromResponse(response, CommonConstants.SESSION_DATA_KEY, 1);
- response = Utils.sendPOSTMessage(sessionKey, tenantQualifiedCommonAuthURL, USER_AGENT, ACS_URL, APPLICATION_NAME,
- AZ_TEST_TENANT_USER, AZ_TEST_TENANT_USER_PW, httpClientAzUser, tenantQualifiedCommonAuthURL);
-
- String locationHeader = Utils.getRedirectUrl(response);
- if (Utils.requestMissingClaims(response)) {
- String pastrCookie = Utils.getPastreCookie(response);
- Assert.assertNotNull(pastrCookie, "pastr cookie not found in response.");
- EntityUtils.consume(response.getEntity());
-
- response = Utils.sendPOSTConsentMessage(response, tenantQualifiedCommonAuthURL, USER_AGENT, locationHeader,
- httpClientAzUser, pastrCookie);
- }
- EntityUtils.consume(response.getEntity());
-
- if (Utils.requestMissingClaims(response)) {
- String pastrCookie = Utils.getPastreCookie(response);
- Assert.assertNotNull(pastrCookie, "pastr cookie not found in response.");
- EntityUtils.consume(response.getEntity());
-
- response = Utils.sendPOSTConsentMessage(response, tenantQualifiedCommonAuthURL, USER_AGENT,
- String.format(ACS_URL, APPLICATION_NAME),
- httpClientAzUser, pastrCookie);
- EntityUtils.consume(response.getEntity());
- }
-
- response = Utils.sendRedirectRequest(response, USER_AGENT, ACS_URL, APPLICATION_NAME,
- httpClientAzUser);
- String samlResponse = Utils.extractDataFromResponse(response, CommonConstants.SAML_RESPONSE_PARAM, 5);
- response = sendSAMLMessage(String.format(ACS_URL, APPLICATION_NAME), CommonConstants
- .SAML_RESPONSE_PARAM, samlResponse);
- String resultPage = extractDataFromResponse(response);
- Assert.assertTrue(resultPage.contains("You are logged in as " + userId),
- "SAML SSO Login should be successful and page should have a message \"You are logged in as " + userId + "\"");
- }
-
- @Test(alwaysRun = true, description = "Test unauthorized tenant user login by evaluating the policy", groups = "wso2.is")
- public void testUnauthorizedTenantSAMLSSOLogin() throws Exception {
-
- HttpResponse response = Utils.sendGetRequest(String.format(SAML_SSO_LOGIN_URL, APPLICATION_NAME,
- HTTP_REDIRECT), USER_AGENT, httpClientNonAzUser);
- String sessionKey = Utils.extractDataFromResponse(response, CommonConstants.SESSION_DATA_KEY, 1);
- response = Utils.sendPOSTMessage(sessionKey, tenantQualifiedCommonAuthURL, USER_AGENT, ACS_URL, APPLICATION_NAME,
- NON_AZ_TEST_TENANT_USER, NON_AZ_TEST_TENANT_USER_PW, httpClientNonAzUser,
- tenantQualifiedCommonAuthURL);
-
- String redirectUrl = Utils.getRedirectUrl(response);
- if (Utils.requestMissingClaims(response)) {
- String pastrCookie = Utils.getPastreCookie(response);
- Assert.assertNotNull(pastrCookie, "pastr cookie not found in response.");
- EntityUtils.consume(response.getEntity());
-
- response = Utils.sendPOSTConsentMessage(response, tenantQualifiedCommonAuthURL, USER_AGENT, redirectUrl,
- httpClientNonAzUser, pastrCookie);
- redirectUrl = Utils.getRedirectUrl(response);
- }
- EntityUtils.consume(response.getEntity());
- response = Utils.sendGetRequest(redirectUrl, USER_AGENT, httpClientNonAzUser);
- String responseString = extractDataFromResponse(response);
- Assert.assertTrue(responseString.contains("Authorization Failed"),
- "SAML SSO Login should be unsuccessful and page should have a message \"Authorization failed for " + NON_AZ_TEST_TENANT_USER + "\"");
- }
-}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/application/authz/ApplicationAuthzTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/application/authz/ApplicationAuthzTestCase.java
deleted file mode 100644
index 4731f53edc1..00000000000
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/application/authz/ApplicationAuthzTestCase.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. 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.identity.integration.test.application.authz;
-
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.config.CookieSpecs;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.cookie.CookieSpecProvider;
-import org.apache.http.impl.client.BasicCookieStore;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.cookie.RFC6265CookieSpecProvider;
-import org.apache.http.util.EntityUtils;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-import org.wso2.carbon.automation.engine.context.TestUserMode;
-import org.wso2.carbon.identity.entitlement.stub.EntitlementPolicyAdminServiceEntitlementException;
-import org.wso2.carbon.identity.entitlement.stub.dto.PolicyDTO;
-import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
-import org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient;
-import org.wso2.identity.integration.common.clients.entitlement.EntitlementPolicyServiceClient;
-import org.wso2.identity.integration.common.clients.sso.saml.SAMLSSOConfigServiceClient;
-import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient;
-import org.wso2.identity.integration.test.util.Utils;
-import org.wso2.identity.integration.test.utils.CommonConstants;
-import org.wso2.identity.integration.test.utils.UserUtil;
-
-import java.rmi.RemoteException;
-
-public class ApplicationAuthzTestCase extends AbstractApplicationAuthzTestCase {
-
- private static final String AZ_TEST_ROLE = "Internal/azTestRole";
- private static final String HTTP_REDIRECT = "HTTP-Redirect";
- private static final String AZ_TEST_USER = "azTestUser";
- private static final String AZ_TEST_USER_PW = "azTest@123";
- private static final String NON_AZ_TEST_USER = "nonAzTestUser";
- private static final String NON_AZ_TEST_USER_PW = "nonAzTest@123";
- private static final Log log = LogFactory.getLog(ApplicationAuthzTestCase.class);
- private static final String APPLICATION_NAME = "travelocity.com";
- private static final String POLICY_ID = "spAuthPolicy";
- private static final String POLICY =
- "\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " " +
- APPLICATION_NAME + "\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " " +
- AZ_TEST_ROLE + "\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- "";
-
- private String userId;
-
- @BeforeClass(alwaysRun = true)
- public void testInit() throws Exception {
-
- super.init(TestUserMode.SUPER_TENANT_ADMIN);
-
- ConfigurationContext configContext = ConfigurationContextFactory
- .createConfigurationContextFromFileSystem(null, null);
- applicationManagementServiceClient =
- new ApplicationManagementServiceClient(sessionCookie, backendURL, configContext);
- ssoConfigServiceClient =
- new SAMLSSOConfigServiceClient(backendURL, sessionCookie);
- remoteUSMServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie);
- entitlementPolicyClient = new EntitlementPolicyServiceClient(backendURL, sessionCookie);
-
- cookieSpecRegistry = RegistryBuilder.create()
- .register(CookieSpecs.DEFAULT, new RFC6265CookieSpecProvider())
- .build();
- requestConfig = RequestConfig.custom()
- .setCookieSpec(CookieSpecs.DEFAULT)
- .build();
- httpClientAzUser = HttpClientBuilder.create().setDefaultCookieStore(new BasicCookieStore())
- .setDefaultRequestConfig(requestConfig)
- .setDefaultCookieSpecRegistry(cookieSpecRegistry)
- .build();
- httpClientNonAzUser = HttpClientBuilder.create().setDefaultCookieStore(new BasicCookieStore())
- .setDefaultRequestConfig(requestConfig)
- .setDefaultCookieSpecRegistry(cookieSpecRegistry)
- .build();
-
- createRole(AZ_TEST_ROLE);
- createUser(AZ_TEST_USER, AZ_TEST_USER_PW, new String[]{AZ_TEST_ROLE});
- userId = UserUtil.getUserId(MultitenantUtils.getTenantAwareUsername(AZ_TEST_USER), isServer.getContextTenant());
-
- createUser(NON_AZ_TEST_USER, NON_AZ_TEST_USER_PW, new String[0]);
- createApplication(APPLICATION_NAME);
- createSAMLApp(APPLICATION_NAME, true, true, true);
- setupXACMLPolicy(POLICY_ID, POLICY);
- }
-
- protected void setupXACMLPolicy(String policyId, String xacmlPolicy)
- throws InterruptedException, RemoteException, EntitlementPolicyAdminServiceEntitlementException {
-
- PolicyDTO policy = new PolicyDTO();
- policy.setPolicy(xacmlPolicy);
- policy.setPolicy(policy.getPolicy().replaceAll(">\\s+<", "><").trim());
- policy.setVersion("3.0");
- policy.setPolicyId(policyId);
- entitlementPolicyClient.addPolicy(policy);
- Thread.sleep(5000); // waiting for the policy to deploy
- entitlementPolicyClient
- .publishPolicies(new String[]{policyId}, new String[]{"PDP Subscriber"}, "CREATE", true, null, 1);
-
- }
-
- @AfterClass(alwaysRun = true)
- public void testClear() throws Exception {
-
- deleteUser(AZ_TEST_USER);
- deleteUser(NON_AZ_TEST_USER);
- deleteRole(AZ_TEST_ROLE);
- deleteApplication(APPLICATION_NAME);
- entitlementPolicyClient.publishPolicies(new String[]{POLICY_ID}, new String[]{"PDP " +
- "Subscriber"}, "DELETE", true, null, 1);
- entitlementPolicyClient.removePolicy(POLICY_ID);
-
- ssoConfigServiceClient = null;
- applicationManagementServiceClient = null;
- remoteUSMServiceClient = null;
- httpClientAzUser = null;
- }
-
-
- @Test(alwaysRun = true, description = "Testing authorized user login", groups = "wso2.is")
- public void testAuthorizedSAMLSSOLogin() throws Exception {
-
- HttpResponse response;
- response =
- Utils.sendGetRequest(String.format(SAML_SSO_LOGIN_URL, APPLICATION_NAME, HTTP_REDIRECT), USER_AGENT,
- httpClientAzUser);
-
- String sessionKey = Utils.extractDataFromResponse(response, CommonConstants.SESSION_DATA_KEY, 1);
- response = Utils.sendPOSTMessage(sessionKey, COMMON_AUTH_URL, USER_AGENT, ACS_URL, APPLICATION_NAME,
- AZ_TEST_USER, AZ_TEST_USER_PW, httpClientAzUser);
-
- String locationHeader = Utils.getRedirectUrl(response);
- if (Utils.requestMissingClaims(response)) {
- String pastrCookie = Utils.getPastreCookie(response);
- Assert.assertNotNull(pastrCookie, "pastr cookie not found in response.");
- EntityUtils.consume(response.getEntity());
-
- response = Utils.sendPOSTConsentMessage(response, COMMON_AUTH_URL, USER_AGENT, locationHeader,
- httpClientAzUser, pastrCookie);
- }
- EntityUtils.consume(response.getEntity());
-
- if (Utils.requestMissingClaims(response)) {
- String pastrCookie = Utils.getPastreCookie(response);
- Assert.assertNotNull(pastrCookie, "pastr cookie not found in response.");
- EntityUtils.consume(response.getEntity());
-
- response = Utils.sendPOSTConsentMessage(response, COMMON_AUTH_URL, USER_AGENT,
- String.format(ACS_URL, APPLICATION_NAME),
- httpClientAzUser, pastrCookie);
- EntityUtils.consume(response.getEntity());
- }
-
- response = Utils.sendRedirectRequest(response, USER_AGENT, ACS_URL, APPLICATION_NAME, httpClientAzUser);
- String samlResponse = Utils.extractDataFromResponse(response, CommonConstants.SAML_RESPONSE_PARAM, 5);
-
- response = sendSAMLMessage(String.format(ACS_URL, APPLICATION_NAME), CommonConstants
- .SAML_RESPONSE_PARAM, samlResponse);
- String resultPage = extractDataFromResponse(response);
-
- Assert.assertTrue(resultPage.contains("You are logged in as " + userId),
- "SAML SSO Login should be successful and page should have a message \"You are logged in as\" " + userId);
-
- }
-
- @Test(alwaysRun = true, description = "Testing unauthorized user login", groups = "wso2.is")
- public void testUnauthorizedSAMLSSOLogin() throws Exception {
-
- HttpResponse response = Utils.sendGetRequest(String.format(SAML_SSO_LOGIN_URL, APPLICATION_NAME,
- HTTP_REDIRECT), USER_AGENT, httpClientNonAzUser);
- String sessionKey = Utils.extractDataFromResponse(response, CommonConstants.SESSION_DATA_KEY, 1);
- response = Utils.sendPOSTMessage(sessionKey, COMMON_AUTH_URL, USER_AGENT, ACS_URL, APPLICATION_NAME,
- NON_AZ_TEST_USER, NON_AZ_TEST_USER_PW, httpClientNonAzUser);
-
- String locationHeader = Utils.getRedirectUrl(response);
- if (Utils.requestMissingClaims(response)) {
- String pastrCookie = Utils.getPastreCookie(response);
- Assert.assertNotNull(pastrCookie, "pastr cookie not found in response.");
- EntityUtils.consume(response.getEntity());
-
- response = Utils.sendPOSTConsentMessage(response, COMMON_AUTH_URL, USER_AGENT, locationHeader,
- httpClientNonAzUser, pastrCookie);
- }
- String redirectUrl = Utils.getRedirectUrl(response);
- EntityUtils.consume(response.getEntity());
- response = Utils.sendGetRequest(redirectUrl, USER_AGENT, httpClientNonAzUser);
- String responseString = extractDataFromResponse(response);
- Assert.assertTrue(responseString.contains("Authorization Failed"),
- "SAML SSO Login should be unsuccessful and page should have a message \"Authorization failed for\" " + NON_AZ_TEST_USER);
-
- }
-}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/auth/PasswordlessSMSOTPAuthTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/auth/PasswordlessSMSOTPAuthTestCase.java
new file mode 100644
index 00000000000..85de57987ae
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/auth/PasswordlessSMSOTPAuthTestCase.java
@@ -0,0 +1,293 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (http://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.identity.integration.test.auth;
+
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.CookieSpecs;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.config.Lookup;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.cookie.CookieSpecProvider;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.LaxRedirectStrategy;
+import org.apache.http.impl.cookie.RFC6265CookieSpecProvider;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.util.EntityUtils;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Factory;
+import org.testng.annotations.Test;
+import org.wso2.carbon.automation.engine.context.TestUserMode;
+import org.wso2.identity.integration.test.base.MockApplicationServer;
+import org.wso2.identity.integration.test.base.MockSMSProvider;
+import org.wso2.identity.integration.test.oidc.OIDCAbstractIntegrationTest;
+import org.wso2.identity.integration.test.oidc.OIDCUtilTest;
+import org.wso2.identity.integration.test.oidc.bean.OIDCApplication;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.ApplicationModel;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.AuthenticationSequence;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.AuthenticationStep;
+import org.wso2.identity.integration.test.rest.api.server.application.management.v1.model.Authenticator;
+import org.wso2.identity.integration.test.rest.api.server.notification.sender.v1.model.Properties;
+import org.wso2.identity.integration.test.rest.api.server.notification.sender.v1.model.SMSSender;
+import org.wso2.identity.integration.test.rest.api.user.common.model.Name;
+import org.wso2.identity.integration.test.rest.api.user.common.model.PhoneNumbers;
+import org.wso2.identity.integration.test.rest.api.user.common.model.UserObject;
+import org.wso2.identity.integration.test.restclients.NotificationSenderRestClient;
+import org.wso2.identity.integration.test.utils.DataExtractUtil;
+import org.wso2.identity.integration.test.utils.OAuth2Constant;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.ACCESS_TOKEN_ENDPOINT;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.AUTHORIZATION_HEADER;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.AUTHORIZE_ENDPOINT_URL;
+import static org.wso2.identity.integration.test.utils.OAuth2Constant.OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE;
+
+/**
+ * This class includes the test cases for passwordless SMS OTP authentication.
+ */
+public class PasswordlessSMSOTPAuthTestCase extends OIDCAbstractIntegrationTest {
+
+ public static final String USERNAME = "passwordlessuser";
+ public static final String PASSWORD = "Oidcsessiontestuser@123";
+ public static final String MOBILE = "+941111111111";
+ public static final String SMS_SENDER_REQUEST_FORMAT = "{\"content\": {{body}}, \"to\": {{mobile}} }";
+
+ private HttpClient client;
+
+ NotificationSenderRestClient notificationSenderRestClient;
+
+ private OIDCApplication oidcApplication;
+ private UserObject userObject;
+ private String sessionDataKey;
+ private String authorizationCode;
+
+ private MockSMSProvider mockSMSProvider;
+ private MockApplicationServer mockApplicationServer;
+
+ private TestUserMode userMode;
+
+ @Factory(dataProvider = "testExecutionContextProvider")
+ public PasswordlessSMSOTPAuthTestCase(TestUserMode userMode) {
+
+ this.userMode = userMode;
+ }
+
+ @DataProvider(name = "testExecutionContextProvider")
+ public static Object[][] getTestExecutionContext() throws Exception {
+
+ return new Object[][]{
+ {TestUserMode.SUPER_TENANT_USER},
+ {TestUserMode.TENANT_USER},
+ };
+ }
+
+ @BeforeClass(alwaysRun = true)
+ public void testInit() throws Exception {
+
+ super.init(userMode);
+ mockSMSProvider = new MockSMSProvider();
+ mockSMSProvider.start();
+
+ mockApplicationServer = new MockApplicationServer();
+ mockApplicationServer.start();
+
+ super.init();
+
+ Lookup cookieSpecRegistry = RegistryBuilder.create()
+ .register(CookieSpecs.DEFAULT, new RFC6265CookieSpecProvider())
+ .build();
+ RequestConfig requestConfig = RequestConfig.custom()
+ .setCookieSpec(CookieSpecs.DEFAULT)
+ .build();
+ client = HttpClientBuilder.create()
+ .setDefaultRequestConfig(requestConfig)
+ .setDefaultCookieSpecRegistry(cookieSpecRegistry)
+ .setRedirectStrategy(new LaxRedirectStrategy())
+ .build();
+
+ backendURL = backendURL.replace("services/", "");
+
+ oidcApplication = initOIDCApplication();
+ ApplicationModel applicationModel = initApplication();
+ createApplication(applicationModel, oidcApplication);
+
+ userObject = initUser();
+ createUser(userObject);
+
+ notificationSenderRestClient = new NotificationSenderRestClient(backendURL, tenantInfo);
+ SMSSender smsSender = initSMSSender();
+ notificationSenderRestClient.createSMSProvider(smsSender);
+ }
+
+ private static SMSSender initSMSSender() {
+
+ SMSSender smsSender = new SMSSender();
+ smsSender.setProvider(MockSMSProvider.SMS_SENDER_PROVIDER_TYPE);
+ smsSender.setProviderURL(MockSMSProvider.SMS_SENDER_URL);
+ smsSender.contentType(SMSSender.ContentTypeEnum.JSON);
+ ArrayList properties = new ArrayList<>();
+ properties.add(new Properties().key("body").value(SMS_SENDER_REQUEST_FORMAT));
+ smsSender.setProperties(properties);
+ return smsSender;
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void atEnd() throws Exception {
+
+ deleteApplication(oidcApplication);
+ deleteUser(userObject);
+ notificationSenderRestClient.deleteSMSProvider();
+ notificationSenderRestClient.closeHttpClient();
+ restClient.closeHttpClient();
+ scim2RestClient.closeHttpClient();
+
+ mockSMSProvider.stop();
+ mockApplicationServer.stop();
+ }
+
+ @Test(groups = "wso2.is", description = "Test passwordless authentication with SMS OTP")
+ public void testPasswordlessAuthentication() throws Exception {
+
+ sendAuthorizeRequest();
+ performUserLogin();
+ HttpResponse response = sendTokenRequestForCodeGrant();
+
+ assertNotNull(response);
+ assertEquals(response.getStatusLine().getStatusCode(), 200);
+ }
+
+ private void sendAuthorizeRequest() throws Exception {
+
+ List urlParameters = new ArrayList<>();
+ urlParameters.add(new BasicNameValuePair("response_type", OAuth2Constant.OAUTH2_GRANT_TYPE_CODE));
+ urlParameters.add(new BasicNameValuePair("client_id", oidcApplication.getClientId()));
+ urlParameters.add(new BasicNameValuePair("redirect_uri", oidcApplication.getCallBackURL()));
+
+ urlParameters.add(new BasicNameValuePair("scope", "openid"));
+
+ HttpResponse response = sendPostRequestWithParameters(client, urlParameters,
+ getTenantQualifiedURL(AUTHORIZE_ENDPOINT_URL, tenantInfo.getDomain()));
+
+ Map keyPositionMap = new HashMap<>(1);
+ keyPositionMap.put("name=\"sessionDataKey\"", 1);
+ List keyValues = DataExtractUtil.extractDataFromResponse(response, keyPositionMap);
+ assertNotNull(keyValues, "Session data key");
+
+ sessionDataKey = keyValues.get(0).getValue();
+ assertNotNull(sessionDataKey, "Session data key");
+ EntityUtils.consume(response.getEntity());
+ }
+
+ private void performUserLogin() throws Exception {
+
+ sendLoginPostForIdentifier(client, sessionDataKey, userObject.getUserName());
+ HttpResponse response = sendLoginPostForOtp(client, sessionDataKey, mockSMSProvider.getOTP());
+ EntityUtils.consume(response.getEntity());
+
+ authorizationCode = mockApplicationServer.getAuthorizationCodeForApp(oidcApplication.getApplicationName());
+ assertNotNull(authorizationCode);
+ }
+
+ private void sendLoginPostForIdentifier(HttpClient client, String sessionDataKey, String username)
+ throws IOException {
+
+ List urlParameters = new ArrayList<>();
+ urlParameters.add(new BasicNameValuePair("username", username));
+ urlParameters.add(new BasicNameValuePair("sessionDataKey", sessionDataKey));
+ sendPostRequestWithParameters(client, urlParameters,
+ getTenantQualifiedURL(OAuth2Constant.COMMON_AUTH_URL, tenantInfo.getDomain()));
+ }
+
+ private HttpResponse sendLoginPostForOtp(HttpClient client, String sessionDataKey, String otp)
+ throws IOException {
+
+ List urlParameters = new ArrayList<>();
+ urlParameters.add(new BasicNameValuePair("OTPcode", otp));
+ urlParameters.add(new BasicNameValuePair("sessionDataKey", sessionDataKey));
+ return sendPostRequestWithParameters(client, urlParameters,
+ getTenantQualifiedURL(OAuth2Constant.COMMON_AUTH_URL, tenantInfo.getDomain()));
+ }
+
+ private HttpResponse sendTokenRequestForCodeGrant() throws Exception {
+
+ List urlParameters = new ArrayList<>();
+ urlParameters.add(new BasicNameValuePair("code", authorizationCode));
+ urlParameters.add(new BasicNameValuePair("grant_type", OAUTH2_GRANT_TYPE_AUTHORIZATION_CODE));
+ urlParameters.add(new BasicNameValuePair("redirect_uri", oidcApplication.getCallBackURL()));
+ urlParameters.add(new BasicNameValuePair("client_id", oidcApplication.getClientSecret()));
+
+ urlParameters.add(new BasicNameValuePair("scope", "openid"));
+
+ List headers = new ArrayList<>();
+ headers.add(new BasicHeader(AUTHORIZATION_HEADER,
+ OAuth2Constant.BASIC_HEADER + " " + getBase64EncodedString(oidcApplication.getClientId(),
+ oidcApplication.getClientSecret())));
+ headers.add(new BasicHeader("Content-Type", "application/x-www-form-urlencoded"));
+ headers.add(new BasicHeader("User-Agent", OAuth2Constant.USER_AGENT));
+
+ return sendPostRequest(client, headers, urlParameters,
+ getTenantQualifiedURL(ACCESS_TOKEN_ENDPOINT, tenantInfo.getDomain()));
+ }
+
+ private OIDCApplication initOIDCApplication() {
+
+ OIDCApplication playgroundApp = new OIDCApplication(MockApplicationServer.Constants.APP1.NAME,
+ MockApplicationServer.Constants.APP1.CALLBACK_URL);
+ return playgroundApp;
+ }
+
+ private ApplicationModel initApplication() {
+
+ ApplicationModel application = new ApplicationModel();
+ AuthenticationSequence authenticationSequence = new AuthenticationSequence();
+ AuthenticationStep stepsItem = new AuthenticationStep();
+ stepsItem.setId(1);
+ Authenticator optionsItem = new Authenticator();
+ optionsItem.setAuthenticator("sms-otp-authenticator");
+ optionsItem.setIdp("LOCAL");
+ stepsItem.addOptionsItem(optionsItem);
+ authenticationSequence.addStepsItem(stepsItem);
+ authenticationSequence.setType(AuthenticationSequence.TypeEnum.USER_DEFINED);
+ authenticationSequence.setSubjectStepId(1);
+ application.setAuthenticationSequence(authenticationSequence);
+ return application;
+ }
+
+ protected UserObject initUser() {
+
+ UserObject user = new UserObject();
+ user.setUserName(USERNAME);
+ user.setPassword(PASSWORD);
+ user.setName(new Name().givenName(OIDCUtilTest.firstName).familyName(OIDCUtilTest.lastName));
+ user.addPhoneNumbers(new PhoneNumbers().value(MOBILE).type("mobile"));
+ return user;
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/auth/SecondaryStoreUserLoginTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/auth/SecondaryStoreUserLoginTestCase.java
index 598c449f16a..e23be6dec76 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/auth/SecondaryStoreUserLoginTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/auth/SecondaryStoreUserLoginTestCase.java
@@ -208,7 +208,7 @@ private void checkAuthorizationCode(String sessionDataKeyConsent) throws Excepti
private void createAndRegisterPlaygroundApplication() throws Exception {
- playgroundApp = new OIDCApplication(PLAYGROUND_APP_NAME, PLAYGROUND_APP_CONTEXT, PLAYGROUND_APP_CALLBACK_URI);
+ playgroundApp = new OIDCApplication(PLAYGROUND_APP_NAME, PLAYGROUND_APP_CALLBACK_URI);
playgroundApp.addRequiredClaim(OIDCUtilTest.emailClaimUri);
playgroundApp.addRequiredClaim(OIDCUtilTest.firstNameClaimUri);
playgroundApp.addRequiredClaim(OIDCUtilTest.lastNameClaimUri);
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/MockApplicationServer.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/MockApplicationServer.java
new file mode 100644
index 00000000000..ab5455d8fd8
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/MockApplicationServer.java
@@ -0,0 +1,231 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (http://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.identity.integration.test.base;
+
+import com.github.tomakehurst.wiremock.WireMockServer;
+import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
+import com.github.tomakehurst.wiremock.extension.ResponseTransformerV2;
+import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer;
+import com.github.tomakehurst.wiremock.http.Response;
+import com.github.tomakehurst.wiremock.stubbing.ServeEvent;
+import org.wso2.identity.integration.common.utils.ISIntegrationTest;
+import org.wso2.identity.integration.test.util.Utils;
+
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.matching;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+
+/**
+ * Mock application server to test OIDC related flows.
+ */
+public class MockApplicationServer {
+
+ public static class MockClient {
+ private final AtomicReference authorizationCode = new AtomicReference<>();
+ private final AtomicReference errorCode = new AtomicReference<>();
+
+ public AtomicReference getAuthorizationCode() {
+ return authorizationCode;
+ }
+
+ public AtomicReference getErrorCode() {
+ return errorCode;
+ }
+ }
+
+ public static class Constants {
+ public static class APP1 {
+ public static final String CALLBACK_URL = "https://localhost:8091/dummyApp/oauth2client";
+ public static final String NAME = "playground.appone";
+ public static final String CALLBACK_URL_PATH = "/dummyApp/oauth2client";
+ }
+
+ public static class APP2 {
+ public static final String CALLBACK_URL = "https://localhost:8091/dummyApp2/oauth2client";
+ public static final String NAME = "playground.apptwo";
+ public static final String CALLBACK_URL_PATH = "/dummyApp2/oauth2client";
+ }
+ }
+
+ private final Map apps = new HashMap<>();
+
+ private WireMockServer wireMockServer;
+
+ public MockApplicationServer() {
+
+ MockClient app1 = new MockClient();
+ MockClient app2 = new MockClient();
+ apps.put(Constants.APP1.NAME, app1);
+ apps.put(Constants.APP2.NAME, app2);
+ }
+
+ public void start() {
+
+ wireMockServer = new WireMockServer(WireMockConfiguration.wireMockConfig()
+ .httpsPort(8091)
+ .httpDisabled(true)
+ .keystorePath(Paths.get(Utils.getResidentCarbonHome(), "repository", "resources", "security",
+ ISIntegrationTest.KEYSTORE_NAME).toAbsolutePath().toString())
+ .keystorePassword("wso2carbon")
+ .keyManagerPassword("wso2carbon")
+ .extensions(new ResponseTemplateTransformer(null, true, null, null),
+ new ResponseTransformerV2() {
+
+ @Override
+ public Response transform(Response response, ServeEvent serveEvent) {
+
+ AtomicReference authorizationCode
+ = (AtomicReference) serveEvent.getTransformerParameters().get("code");
+ authorizationCode.set(serveEvent.getRequest().getQueryParams().get("code")
+ .firstValue());
+ return response;
+ }
+
+ @Override
+ public boolean applyGlobally() {
+ return false;
+ }
+
+ @Override
+ public String getName() {
+ return "authz-code-transformer";
+ }
+ },
+ new ResponseTransformerV2() {
+
+ @Override
+ public Response transform(Response response, ServeEvent serveEvent) {
+
+ AtomicReference errorCode
+ = (AtomicReference) serveEvent.getTransformerParameters().get("error");
+ errorCode.set(serveEvent.getRequest().getQueryParams().get("error").firstValue());
+ return response;
+ }
+
+ @Override
+ public boolean applyGlobally() {
+ return false;
+ }
+
+ @Override
+ public String getName() {
+ return "error-code-transformer";
+ }
+ }));
+
+ wireMockServer.start();
+
+ // Configure the mock client endpoints for App 1
+ configureMockEndpointsForApp(Constants.APP1.CALLBACK_URL_PATH, apps.get(Constants.APP1.NAME));
+ // Configure the mock client endpoints for App 2
+ configureMockEndpointsForApp(Constants.APP2.CALLBACK_URL_PATH, apps.get(Constants.APP2.NAME));
+ }
+
+ public void stop() {
+
+ if (wireMockServer != null) {
+ wireMockServer.stop();
+ }
+ }
+
+ private void configureMockEndpointsForApp(String urlPath, MockClient app) {
+
+ try {
+ wireMockServer.stubFor(get(urlPathEqualTo(urlPath))
+ .withQueryParam("code", matching(".*"))
+ .willReturn(aResponse()
+ .withTransformers("response-template", "authz-code-transformer")
+ .withTransformerParameter("code", app.getAuthorizationCode())
+ .withTransformerParameter("error", app.getErrorCode())
+ .withStatus(200)));
+ wireMockServer.stubFor(post(urlPathEqualTo(urlPath))
+ .withQueryParam("code", matching(".*"))
+ .willReturn(aResponse()
+ .withTransformers("response-template", "authz-code-transformer")
+ .withTransformerParameter("code", app.getAuthorizationCode())
+ .withTransformerParameter("error", app.getErrorCode())
+ .withStatus(200)));
+ wireMockServer.stubFor(get(urlPathEqualTo(urlPath))
+ .withQueryParam("code", matching(".*"))
+ .withQueryParam("session_state", matching(".*"))
+ .willReturn(aResponse()
+ .withTransformers("response-template", "authz-code-transformer")
+ .withTransformerParameter("code", app.getAuthorizationCode())
+ .withTransformerParameter("error", app.getErrorCode())
+ .withStatus(200)));
+ wireMockServer.stubFor(post(urlPathEqualTo(urlPath))
+ .withQueryParam("code", matching(".*"))
+ .withQueryParam("session_state", matching(".*"))
+ .willReturn(aResponse()
+ .withTransformers("response-template", "authz-code-transformer")
+ .withTransformerParameter("code", app.getAuthorizationCode())
+ .withTransformerParameter("error", app.getErrorCode())
+ .withStatus(200)));
+ wireMockServer.stubFor(get(urlPathEqualTo(urlPath))
+ .withQueryParam("error_description", matching(".*"))
+ .withQueryParam("error", matching(".*"))
+ .willReturn(aResponse()
+ .withTransformers("response-template", "error-code-transformer")
+ .withTransformerParameter("code", app.getAuthorizationCode())
+ .withTransformerParameter("error", app.getErrorCode())
+ .withStatus(200)));
+ wireMockServer.stubFor(get(urlEqualTo(urlPath))
+ .willReturn(aResponse()
+ .withTransformers("response-template")
+ .withStatus(200)));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void verifyLogoutRedirectionForApp(String appName) {
+
+ wireMockServer.verify(getRequestedFor(urlEqualTo(getCallbackUrlPath(appName))));
+ }
+
+ public String getAuthorizationCodeForApp(String appName) {
+
+ return apps.get(appName).getAuthorizationCode().get();
+ }
+
+ public String getErrorCode(String appName) {
+
+ return apps.get(appName).getErrorCode().get();
+ }
+
+ private String getCallbackUrlPath(String appName) {
+ switch (appName) {
+ case Constants.APP1.NAME:
+ return Constants.APP1.CALLBACK_URL_PATH;
+ case Constants.APP2.NAME:
+ return Constants.APP2.CALLBACK_URL_PATH;
+ default:
+ throw new IllegalArgumentException("Unknown app name: " + appName);
+ }
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/MockOIDCIdentityProvider.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/MockOIDCIdentityProvider.java
index 59533900bd1..b3e985570f8 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/MockOIDCIdentityProvider.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/MockOIDCIdentityProvider.java
@@ -30,6 +30,8 @@
import com.nimbusds.jose.crypto.RSASSASigner;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.SignedJWT;
+import org.wso2.carbon.utils.security.KeystoreUtils;
+import org.wso2.identity.integration.common.utils.ISIntegrationTest;
import org.wso2.identity.integration.test.util.Utils;
import java.io.FileInputStream;
@@ -69,8 +71,9 @@ public void start() {
wireMockServer = new WireMockServer(WireMockConfiguration.wireMockConfig()
.httpsPort(8089)
+ .httpDisabled(true)
.keystorePath(Paths.get(Utils.getResidentCarbonHome(), "repository", "resources", "security",
- "wso2carbon.p12").toAbsolutePath().toString())
+ ISIntegrationTest.KEYSTORE_NAME).toAbsolutePath().toString())
.keystorePassword("wso2carbon")
.keyManagerPassword("wso2carbon")
.extensions(
@@ -178,7 +181,7 @@ public void verifyForLogoutFlow() {
private String buildIdToken() throws Exception {
- KeyStore wso2KeyStore = getKeyStoreFromFile("wso2carbon.p12", "wso2carbon",
+ KeyStore wso2KeyStore = getKeyStoreFromFile(ISIntegrationTest.KEYSTORE_NAME, "wso2carbon",
Utils.getResidentCarbonHome());
RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) wso2KeyStore.getKey("wso2carbon", "wso2carbon".toCharArray());
@@ -212,7 +215,7 @@ private KeyStore getKeyStoreFromFile(String keystoreName, String password, Strin
Path tenantKeystorePath = Paths.get(home, "repository", "resources", "security", keystoreName);
FileInputStream file = new FileInputStream(tenantKeystorePath.toString());
- KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
+ KeyStore keystore = KeystoreUtils.getKeystoreInstance(ISIntegrationTest.KEYSTORE_TYPE);
keystore.load(file, password.toCharArray());
return keystore;
}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/MockSMSProvider.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/MockSMSProvider.java
new file mode 100644
index 00000000000..646c131c0b1
--- /dev/null
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/MockSMSProvider.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2024, WSO2 LLC. (http://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.identity.integration.test.base;
+
+import com.github.tomakehurst.wiremock.WireMockServer;
+import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
+import com.github.tomakehurst.wiremock.extension.ResponseTransformerV2;
+import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer;
+import com.github.tomakehurst.wiremock.http.Response;
+import com.github.tomakehurst.wiremock.stubbing.ServeEvent;
+import com.jayway.jsonpath.JsonPath;
+import org.wso2.identity.integration.common.utils.ISIntegrationTest;
+import org.wso2.identity.integration.test.util.Utils;
+
+import java.nio.file.Paths;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+
+/**
+ * Mock SMS Provider for testing SMS related flows.
+ */
+public class MockSMSProvider {
+
+ public static final String SMS_SENDER_URL = "https://localhost:8090/sms/send";
+ public static final String SMS_SENDER_PROVIDER_TYPE = "Custom";
+
+ private WireMockServer wireMockServer;
+ private final AtomicReference otp = new AtomicReference<>();
+
+ public void start() {
+
+ wireMockServer = new WireMockServer(WireMockConfiguration.wireMockConfig()
+ .httpsPort(8090)
+ .httpDisabled(true)
+ .keystorePath(Paths.get(Utils.getResidentCarbonHome(), "repository", "resources", "security",
+ ISIntegrationTest.KEYSTORE_NAME).toAbsolutePath().toString())
+ .keystorePassword("wso2carbon")
+ .keyManagerPassword("wso2carbon")
+ .extensions(
+ new ResponseTemplateTransformer(null, true, null, null),
+ new ResponseTransformerV2() {
+ @Override
+ public Response transform(Response response, ServeEvent serveEvent) {
+
+ // Extract the content value from the request body.
+ String content =
+ JsonPath.parse(serveEvent.getRequest().getBodyAsString()).read("$.content");
+
+ String regex = "\\b\\d{6}\\b";
+
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher(content);
+
+ if (matcher.find()) {
+ String extractedOtp = matcher.group();
+ // Store the content value for later use.
+ otp.set(extractedOtp);
+ }
+ return response;
+ }
+
+ @Override
+ public boolean applyGlobally() {
+ return false;
+ }
+
+ @Override
+ public String getName() {
+ return "otp-transformer";
+ }
+ }));
+
+ wireMockServer.start();
+
+ // Configure the mock SMS endpoints.
+ configureMockEndpoints();
+ }
+
+ public void stop() {
+
+ if (wireMockServer != null) {
+ wireMockServer.stop();
+ }
+ }
+
+ private void configureMockEndpoints() {
+
+ try {
+ wireMockServer.stubFor(post(urlEqualTo("/sms/send"))
+ .withRequestBody(matchingJsonPath("$.content"))
+ .withRequestBody(matchingJsonPath("$.to"))
+ .willReturn(aResponse()
+ .withTransformers("response-template", "otp-transformer")
+ .withStatus(200)));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getOTP() {
+
+ return otp.get();
+ }
+}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/TomcatInitializerTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/TomcatInitializerTestCase.java
index a51b660a1f3..2fdc751b53c 100644
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/TomcatInitializerTestCase.java
+++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/base/TomcatInitializerTestCase.java
@@ -43,16 +43,7 @@ public class TomcatInitializerTestCase extends ISIntegrationTest {
"travelocity.com-registrymount",
"avis.com",
"PassiveSTSSampleApp",
- "playground.appone",
- "playground.apptwo",
- "playground2",
- // TODO: Check and remove the following with openid tests
- "travelocity.com-openid-smartconsumerwithclaims",
- "travelocity.com-openid-smartconsumerwithoutclaims",
- "travelocity.com-openid-dumbconsumerwithclaims",
- "travelocity.com-openid-dumbconsumerwithoutclaims"
- // TODO: End of openid apps
-
+ "playground2"
};
private static final Log LOG = LogFactory.getLog(TomcatInitializerTestCase.class);
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/entitlement/EntitlementAdminServiceTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/entitlement/EntitlementAdminServiceTestCase.java
deleted file mode 100644
index ce3ea0f88f0..00000000000
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/entitlement/EntitlementAdminServiceTestCase.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
-* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-* WSO2 Inc. 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.identity.integration.test.entitlement;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-import org.testng.Assert;
-import org.wso2.identity.integration.common.clients.entitlement.EntitlementAdminServiceClient;
-import org.wso2.identity.integration.common.utils.ISIntegrationTest;
-
-public class EntitlementAdminServiceTestCase extends ISIntegrationTest{
-
- private EntitlementAdminServiceClient entitlementAdminClient;
- private static final Log log = LogFactory.getLog(EntitlementAdminServiceTestCase.class);
- private static final String REQUEST_1 = " admin http://localhost:8280/services/echo read ";
-
- @BeforeClass(alwaysRun = true)
- public void testInit() throws Exception {
- super.init();
- entitlementAdminClient = new EntitlementAdminServiceClient(backendURL, sessionCookie);
- }
-
- @AfterClass(alwaysRun = true)
- public void atEnd() throws Exception {
-
- }
-
- @Test(groups = "wso2.is", description = "Check get policy algorithm")
- public void testGetGlobalPolicyAlgorithm() throws Exception {
- Assert.assertNotNull(entitlementAdminClient.getGlobalPolicyAlgorithm(), "Getting the policy algorithm has failed with null return.");
- }
-
- @Test(groups = "wso2.is", description = "Check get pdp data", dependsOnMethods="testGetGlobalPolicyAlgorithm")
- public void testGetPDPData() throws Exception {
- entitlementAdminClient.getPDPData();
- }
-
- @Test(groups = "wso2.is", description = "Check policy request", dependsOnMethods="testGetPDPData")
- public void testDoTestRequest() throws Exception {
- Assert.assertNotNull(entitlementAdminClient.doTestRequest(REQUEST_1), "Testing the policy request has failed with null return.");
- }
-
- @Test(groups = "wso2.is", description = "Check get PIP attribute finder data", dependsOnMethods="testDoTestRequest")
- public void testGetPIPAttributeFinderData() throws Exception {
- entitlementAdminClient.getPIPAttributeFinderData("urn:oasis:names:tc:xacml:1.0:subject:subject-id");
-// TODO - fix request
-// Assert.assertNotNull(entitlementAdminClient.getPIPAttributeFinderData("urn:oasis:names:tc:xacml:1.0:subject:subject-id"), "Getting PIP attribute finder data has failed with null return.");
- }
-
- @Test(groups = "wso2.is", description = "Check get PIP resource finder data", dependsOnMethods="testGetPIPAttributeFinderData")
- public void testGetPIPResourceFinderData() throws Exception {
- Assert.assertNotNull(entitlementAdminClient.getPIPResourceFinderData("urn:oasis:names:tc:xacml:1.0:resource:resource-id"), "Getting PIP resouce finder data has failed with null return.");
- }
-
- @Test(groups = "wso2.is", description = "Check get policy finder data", dependsOnMethods="testGetPIPResourceFinderData")
- public void testGetPolicyFinderData() throws Exception {
- entitlementAdminClient.getPolicyFinderData("");
-// TODO - fix request
-// Assert.assertNotNull(entitlementAdminClient.getPolicyFinderData(""), "Getting policy finder data has failed with null return.");
- }
-
- @Test(groups = "wso2.is", description = "Check refresh attribute finder", dependsOnMethods="testGetPolicyFinderData")
- public void testRefreshAttributeFinder() throws Exception {
- entitlementAdminClient.refreshAttributeFinder("*");
- }
-
- @Test(groups = "wso2.is", description = "Check refresh policy finder", dependsOnMethods="testRefreshAttributeFinder")
- public void testRefreshPolicyFinders() throws Exception {
- entitlementAdminClient.refreshPolicyFinders("*");
- }
-
- @Test(groups = "wso2.is", description = "Check refresh resouce finder", dependsOnMethods="testRefreshPolicyFinders")
- public void testRefreshResourceFinder() throws Exception {
- entitlementAdminClient.refreshResourceFinder("*");
- }
-
- @Test(groups = "wso2.is", description = "Check set global policy algorithm", dependsOnMethods="testRefreshResourceFinder")
- public void testSetGlobalPolicyAlgorithm() throws Exception {
- entitlementAdminClient.setGlobalPolicyAlgorithm("Algo");
- }
-}
diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/entitlement/EntitlementJSONSupportMultiDecisionProfileTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/entitlement/EntitlementJSONSupportMultiDecisionProfileTestCase.java
deleted file mode 100644
index 6bb97bc2735..00000000000
--- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/entitlement/EntitlementJSONSupportMultiDecisionProfileTestCase.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * WSO2 Inc. 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.identity.integration.test.entitlement;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-import org.wso2.carbon.identity.entitlement.stub.dto.PolicyDTO;
-import org.wso2.identity.integration.common.clients.entitlement.EntitlementPolicyServiceClient;
-import org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient;
-import org.wso2.identity.integration.common.utils.ISIntegrationTest;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Scanner;
-import java.util.Set;
-
-/**
- * This is to test the full flow of XACML Multi Decision Profile scenario
- */
-public class EntitlementJSONSupportMultiDecisionProfileTestCase extends ISIntegrationTest {
-
- private static final Log log = LogFactory.getLog(EntitlementJSONSupportMultiDecisionProfileTestCase.class);
- private EntitlementPolicyServiceClient entitlementPolicyClient;
- private RemoteUserStoreManagerServiceClient remoteUserStoreManagerServiceClient;
- private final static String ENDPOINT_ADDRESS = "https://localhost:9853/api/identity/entitlement/decision";
- private final static String PASSWORD = "Wso2@test123";
- private final static String ROLE = "admin";
-
-
- private static final String POLICY_ID = "urn:oasis:names:tc:xacml:3.0:web-filter-policy";
- private static final String POLICY = "\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " index.jsp\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " publicUser\n" +
- " " +
- "\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " view-welcome\n" +
- " view-summary\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " internalUser\n" +
- " " +
- "\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " view-status\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " adminUser\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " modify-welcome\n" +
- " modify-summary\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " You can access the" +
- " resource index.jsp\n" +
- " \n" +
- " \n" +
- " \n" +
- " ";
-
- @BeforeClass(alwaysRun = true)
- public void testInit() throws Exception {
- super.init();
- entitlementPolicyClient = new EntitlementPolicyServiceClient(backendURL, sessionCookie);
- remoteUserStoreManagerServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie);
- PolicyDTO policy = new PolicyDTO();
- policy.setPolicy(POLICY);
- entitlementPolicyClient.addPolicy(policy);
- entitlementPolicyClient.publishPolicies(new String[]{POLICY_ID}, new String[]{"PDP Subscriber"}, "CREATE",
- true, null, 1);
- remoteUserStoreManagerServiceClient.addUser("adminUser",PASSWORD, new String[]{ROLE}, null,
- "adminUser",false);
- remoteUserStoreManagerServiceClient.addUser("publicUser",PASSWORD, new String[]{ROLE}, null,
- "publicUser",false);
- remoteUserStoreManagerServiceClient.addUser("localUser",PASSWORD, new String[]{ROLE}, null,
- "localUser",false);
- }
-
- @Test(groups = "wso2-is", description = "A simple JSON request sample")
- public void testPdpJSONSimpleRequest() throws JSONException {
-
- WebClient client = WebClient.create(ENDPOINT_ADDRESS);
-
- client.header("Authorization", "Basic YWRtaW46YWRtaW4=");
- client.type("application/json");
- client.accept("application/json");
-
- client.path("pdp");
-
- String request = readReource("entitlement/json/simpleRequest.json");
- String response = readReource("entitlement/json/simpleResponse.json");
- JSONObject objExpected = new JSONObject(response);
-
- String webRespose = client.post(request, String.class);
- JSONObject objReturn = new JSONObject(webRespose);
- Assert.assertTrue(areJSONObjectsEqual(objExpected, objReturn), "The response is wrong it should be :"+ response + " But" +
- " the response is :" + webRespose);
- }
-
- @Test(groups = "wso2-is", description = "A complex multi-decision JSON request sample")
- public void testPdpJSONMultiDecisionRequest() throws JSONException {
-
- WebClient client = WebClient.create(ENDPOINT_ADDRESS);
-
- client.header("Authorization", "Basic YWRtaW46YWRtaW4=");
- client.type("application/json");
- client.accept("application/json");
-
- client.path("pdp");
-
- String request = readReource("entitlement/json/complexMDPRequest.json");
- String response = readReource("entitlement/json/complexMDPResponse.json");
- JSONObject objExpected = new JSONObject(response);
-
- String webRespose = client.post(request, String.class);
- JSONObject objReturn = new JSONObject(webRespose);
- Assert.assertTrue(areJSONObjectsEqual(objExpected, objReturn), "The response is wrong it should be :"+ response + " But" +
- " the response is :" + webRespose);
-
- }
-
- @Test(groups = "wso2-is", description = "A complex multi-decision JSON request sample in simple form")
- public void testPdpJSONMultiDecisionRequestSimpleForm() throws JSONException {
-
- WebClient client = WebClient.create(ENDPOINT_ADDRESS);
-
- client.header("Authorization", "Basic YWRtaW46YWRtaW4=");
- client.type("application/json");
- client.accept("application/json");
-
- client.path("pdp");
-
- String request = readReource("entitlement/json/simpleMDPRequest.json");
- String response = readReource("entitlement/json/simpleMDPResponse.json");
- JSONObject objExpected = new JSONObject(response);
-
- String webRespose = client.post(request, String.class);
- JSONObject objReturn = new JSONObject(webRespose);
- Assert.assertTrue(areJSONObjectsEqual(objExpected, objReturn), "The response is wrong it should be :"+ response + " But" +
- " the response is :" + webRespose);
- }
-
- @AfterClass(alwaysRun = true)
- public void destroy() throws Exception {
-
- // Remove added policy
- entitlementPolicyClient = new EntitlementPolicyServiceClient(backendURL, sessionCookie);
- remoteUserStoreManagerServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie);
- entitlementPolicyClient.enableDisablePolicy(POLICY_ID, false);
- entitlementPolicyClient.removePolicy(POLICY_ID);
- remoteUserStoreManagerServiceClient.deleteUser("adminUser");
- remoteUserStoreManagerServiceClient.deleteUser("publicUser");
- remoteUserStoreManagerServiceClient.deleteUser("localUser");
- }
-
- public static boolean areJSONObjectsEqual(Object ob1, Object ob2) throws JSONException {
-
- Object obj1Converted = convertJsonElement(ob1);
- Object obj2Converted = convertJsonElement(ob2);
- return obj1Converted.equals(obj2Converted);
- }
-
- private static Object convertJsonElement(Object elem) throws JSONException {
-
- if (elem instanceof JSONObject) {
- JSONObject obj = (JSONObject) elem;
- Iterator keys = obj.keys();
- Map jsonMap = new HashMap<>();
- while (keys.hasNext()) {
- String key = keys.next();
- jsonMap.put(key, convertJsonElement(obj.get(key)));
- }
- return jsonMap;
- } else if (elem instanceof JSONArray) {
- JSONArray arr = (JSONArray) elem;
- Set