diff --git a/.github/workflows/db-test.yml b/.github/workflows/db-test.yml new file mode 100644 index 0000000000..c3ed7de2b3 --- /dev/null +++ b/.github/workflows/db-test.yml @@ -0,0 +1,37 @@ +name: PostgreSQL Test + +on: + release: + types: [published] + pull_request: + types: [opened, reopened, synchronize] + workflow_dispatch: + inputs: + message: + description: 'Message for manually triggering' + required: false + default: 'Triggered for Updates' + type: string + push: + branches: + - '!release-branch' + - release* + - master + - 1.* + - develop* + - MOSIP* + paths: + - 'db_scripts/**' + +jobs: + build-db-test: + strategy: + matrix: + include: + - DB_LOCATION: 'db_scripts/mosip_pms' + DB_NAME: 'mosip_pms' + fail-fast: false + name: ${{ matrix.DB_NAME }} + uses: mosip/kattu/.github/workflows/db-test.yml@master + with: + DB_LOCATION: ${{ matrix.DB_LOCATION}} diff --git a/.github/workflows/mavenpublish.yml b/.github/workflows/mavenpublish.yml deleted file mode 100644 index 331c817d32..0000000000 --- a/.github/workflows/mavenpublish.yml +++ /dev/null @@ -1,214 +0,0 @@ -# This workflow will build a package using Maven and then publish it nexus when a pull request is merged -# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path - -name: Maven Package upon a pull request - -on: - pull_request: - types: [closed] - -jobs: - build: - - runs-on: ubuntu-latest - if: github.event.pull_request.merged == true - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - ref: ${{ github.ref }} - java-version: 11 - server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Setup branch and GPG public key - run: | - # Strip git ref prefix from version - echo "::set-env name=BRANCH_NAME::$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" - echo ${{ env.BRANCH_NAME }} - echo "::set-env name=GPG_TTY::$(tty)" - echo ${{ env.GPG_TTY }} - sudo apt-get --yes install gnupg2 - gpg2 --import ./.github/keys/mosipgpgkey_pub.gpg - gpg2 --quiet --batch --passphrase=${{secrets.gpg_secret}} --allow-secret-key-import --import ./.github/keys/mosipgpgkey_sec.gpg - - - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven-${{ env.BRANCH_NAME }} - - - name: Setup the settings file for ossrh server - run: echo " ossrh ${{secrets.ossrh_user}} ${{secrets.ossrh_secret}} ossrh true gpg2 ${{secrets.gpg_secret}} allow-snapshots true snapshots-repo https://oss.sonatype.org/content/repositories/snapshots false true releases-repo https://oss.sonatype.org/service/local/staging/deploy/maven2 true false " > $GITHUB_WORKSPACE/settings.xml - - - name: Build with Maven - run: | - cd partner - mvn -B package --file pom.xml -s $GITHUB_WORKSPACE/settings.xml - - - name: Ready the springboot artifacts - run: find -name '*.jar' -executable -type f -exec zip release.zip {} + - - - name: Upload the springboot jars - uses: actions/upload-artifact@v1 - with: - name: release - path: ./release.zip - - - publish_to_nexus: - - runs-on: ubuntu-latest - if: github.event.pull_request.merged == true - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - ref: ${{ github.ref }} - java-version: 11 - server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Setup branch and GPG public key - run: | - # Strip git ref prefix from version - echo "::set-env name=BRANCH_NAME::$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" - echo ${{ env.BRANCH_NAME }} - echo "::set-env name=GPG_TTY::$(tty)" - echo ${{ env.GPG_TTY }} - sudo apt-get --yes install gnupg2 - gpg2 --import ./.github/keys/mosipgpgkey_pub.gpg - gpg2 --quiet --batch --passphrase=${{secrets.gpg_secret}} --allow-secret-key-import --import ./.github/keys/mosipgpgkey_sec.gpg - - - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven-${{ env.BRANCH_NAME }} - - - name: Setup the settings file for ossrh server - run: echo " ossrh ${{secrets.ossrh_user}} ${{secrets.ossrh_secret}} ossrh true gpg2 ${{secrets.gpg_secret}} allow-snapshots true snapshots-repo https://oss.sonatype.org/content/repositories/snapshots false true releases-repo https://oss.sonatype.org/service/local/staging/deploy/maven2 true false " > $GITHUB_WORKSPACE/settings.xml - - - name: Install xmllint - run: | - sudo apt-get update - sudo apt-get install libxml2-utils - - - name: Build with Maven - run: cd partner && mvn -B package --file pom.xml -s $GITHUB_WORKSPACE/settings.xml - - - name: Publish the maven package - run: | - chmod +x ./deploy.sh - ./deploy.sh partner $GITHUB_WORKSPACE/settings.xml SNAPSHOT - env: - GPG_TTY: $(tty) - - docker-policy-management-service: - needs: build - - runs-on: ubuntu-latest - env: - NAMESPACE: mosipdev - SERVICE_NAME: policy-management-service - SERVICE_LOCATION: partner/policy-management-service - - steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v1 - with: - name: release - path: ./ - - - name: Setup branch name - run: | - # Strip git ref prefix from version - echo "::set-env name=BRANCH_NAME::$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" - echo ${{ env.BRANCH_NAME }} - - - name: Get version info from pom - id: getPomVersion - uses: mavrosxristoforos/get-xml-info@1.0 - with: - xml-file: ./${{ env.SERVICE_LOCATION }}/pom.xml - xpath: /*[local-name()="project"]/*[local-name()="version"] - - - name: Unzip and extract the policy-management-service - run: unzip -uj "release.zip" "${{ env.SERVICE_LOCATION }}/target/*" -d "./${{ env.SERVICE_LOCATION }}/target" - - - name: Build image - run: | - cd "./${{env.SERVICE_LOCATION}}" - docker build . --file Dockerfile --tag ${{ env.SERVICE_NAME }} - - name: Log into registry - run: echo "${{ secrets.release_docker_hub }}" | docker login -u ${{ secrets.actor_docker_hub }} --password-stdin - - - name: Push image - run: | - IMAGE_ID=$NAMESPACE/$SERVICE_NAME - - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - echo "push version ${{steps.getPomVersion.outputs.info}}" - VERSION=$BRANCH_NAME - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $SERVICE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION - docker-partner-management-service: - needs: build - - runs-on: ubuntu-latest - env: - NAMESPACE: mosipdev - SERVICE_NAME: partner-management-service - SERVICE_LOCATION: partner/partner-management-service - - steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v1 - with: - name: release - path: ./ - - - name: Setup branch name - run: | - # Strip git ref prefix from version - echo "::set-env name=BRANCH_NAME::$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" - echo ${{ env.BRANCH_NAME }} - - - name: Get version info from pom - id: getPomVersion - uses: mavrosxristoforos/get-xml-info@1.0 - with: - xml-file: ./${{ env.SERVICE_LOCATION }}/pom.xml - xpath: /*[local-name()="project"]/*[local-name()="version"] - - - name: Unzip and extract the partner-management-service - run: unzip -uj "release.zip" "${{ env.SERVICE_LOCATION }}/target/*" -d "./${{ env.SERVICE_LOCATION }}/target" - - - name: Build image - run: | - cd "./${{env.SERVICE_LOCATION}}" - docker build . --file Dockerfile --tag ${{ env.SERVICE_NAME }} - - name: Log into registry - run: echo "${{ secrets.release_docker_hub }}" | docker login -u ${{ secrets.actor_docker_hub }} --password-stdin - - - name: Push image - run: | - IMAGE_ID=$NAMESPACE/$SERVICE_NAME - - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - echo "push version ${{steps.getPomVersion.outputs.info}}" - VERSION=$BRANCH_NAME - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $SERVICE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION \ No newline at end of file diff --git a/.github/workflows/postgres-init_trigger.yml b/.github/workflows/postgres-init_trigger.yml deleted file mode 100644 index 3de4c6f32c..0000000000 --- a/.github/workflows/postgres-init_trigger.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Trigger postgres-init repo upon db scripts updates - -on: - push: - branches: - - master - - 1.* - - develop - - release* - paths: - - db_release_scripts/** - - db_scripts/** - -jobs: - paths-filter: - runs-on: ubuntu-latest - outputs: - db_release_scripts: ${{ steps.filter.outputs.db_release_scripts }} - db_scripts: ${{ steps.filter.outputs.db_scripts }} - steps: - - uses: actions/checkout@v2 - - uses: dorny/paths-filter@v2 - id: filter - with: - base: ${{ github.ref }} - filters: | - db_release_scripts: - - 'db_release_scripts/**' - db_scripts: - - 'db_scripts/**' - - # run only if 'db_release_scripts' files were changed - db_release_scripts_updates: - needs: paths-filter - if: needs.paths-filter.outputs.db_release_scripts == 'true' - runs-on: ubuntu-latest - steps: - - name: Check for updates - run: echo "Updates are present in db_release_scripts directory, Triggering postgres-init repo" - - uses: 8398a7/action-slack@v3 - with: - status: ${{ job.status }} - fields: repo,message,commit,author,job,took,ref # selectable (default: repo,message) - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_DEVOPS }} # required - if: success() # Pick up events when the job is successful. - - # run only if not 'db_release_scripts' files were changed - - name: Check for no updates - if: needs.paths-filter.outputs.db_release_scripts != 'true' - run: echo "Updates are not present in db_release_scripts directory" - - # run only if 'db_scripts' files were changed - db_scripts_updates: - needs: paths-filter - if: needs.paths-filter.outputs.db_scripts == 'true' - runs-on: ubuntu-latest - steps: - - name: Check for updates - run: echo "Updates are present in db_scripts directory, Triggering postgres-init repo" - - uses: 8398a7/action-slack@v3 - with: - status: ${{ job.status }} - fields: repo,message,commit,author,job,took,ref # selectable (default: repo,message) - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_DEVOPS }} # required - if: success() # Pick up events when the job is successful. - - # run only if not 'db_scripts' files were changed - - name: Check for no updates - if: needs.paths-filter.outputs.db_scripts != 'true' - run: echo "Updates are not present in db_scripts directory" - - # This job is to trigger postgres-init repo. - trigger-postgres_init_repo: - runs-on: ubuntu-latest - steps: - - uses: peter-evans/repository-dispatch@v2 - with: - token: ${{ secrets.ACTION_PAT }} - repository: mosip/postgres-init - base: ${{ github.ref }} - event-type: db-event diff --git a/.github/workflows/push-trigger.yml b/.github/workflows/push-trigger.yml new file mode 100644 index 0000000000..6e58022b18 --- /dev/null +++ b/.github/workflows/push-trigger.yml @@ -0,0 +1,88 @@ +name: Maven Package upon a push + +on: + release: + types: [published] + pull_request: + types: [opened, reopened, synchronize] + workflow_dispatch: + inputs: + message: + description: 'Message for manually triggering' + required: false + default: 'Triggered for Updates' + type: string + push: + branches: + - '!release-branch' + - release* + - master + - 1.* + - develop + - MOSIP* + +jobs: + build-maven-partner: + uses: mosip/kattu/.github/workflows/maven-build.yml@master + with: + SERVICE_LOCATION: ./partner + BUILD_ARTIFACT: partner + secrets: + OSSRH_USER: ${{ secrets.OSSRH_USER }} + OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} + OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} + GPG_SECRET: ${{ secrets.GPG_SECRET }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + publish_to_nexus: + if: "${{ !contains(github.ref, 'master') && github.event_name != 'pull_request' && github.event_name != 'release' && github.event_name != 'prerelease' && github.event_name != 'publish' }}" + needs: build-maven-partner + uses: mosip/kattu/.github/workflows/maven-publish-to-nexus.yml@master + with: + SERVICE_LOCATION: ./partner + secrets: + OSSRH_USER: ${{ secrets.OSSRH_USER }} + OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} + OSSRH_URL: ${{ secrets.OSSRH_SNAPSHOT_URL }} + OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} + GPG_SECRET: ${{ secrets.GPG_SECRET }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + build-dockers: + needs: build-maven-partner + strategy: + matrix: + include: + - SERVICE_LOCATION: 'partner/partner-management-service' + SERVICE_NAME: 'partner-management-service' + BUILD_ARTIFACT: 'partner' + - SERVICE_LOCATION: 'partner/policy-management-service' + SERVICE_NAME: 'policy-management-service' + BUILD_ARTIFACT: 'partner' + fail-fast: false + name: ${{ matrix.SERVICE_NAME }} + uses: mosip/kattu/.github/workflows/docker-build.yml@master + with: + SERVICE_LOCATION: ${{ matrix.SERVICE_LOCATION }} + SERVICE_NAME: ${{ matrix.SERVICE_NAME }} + BUILD_ARTIFACT: ${{ matrix.BUILD_ARTIFACT }} + secrets: + DEV_NAMESPACE_DOCKER_HUB: ${{ secrets.DEV_NAMESPACE_DOCKER_HUB }} + ACTOR_DOCKER_HUB: ${{ secrets.ACTOR_DOCKER_HUB }} + RELEASE_DOCKER_HUB: ${{ secrets.RELEASE_DOCKER_HUB }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + sonar_analysis: + needs: build-maven-partner + if: "${{ github.event_name != 'pull_request' }}" + uses: mosip/kattu/.github/workflows/maven-sonar-analysis.yml@master + with: + SERVICE_LOCATION: ./partner + secrets: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + ORG_KEY: ${{ secrets.ORG_KEY }} + OSSRH_USER: ${{ secrets.OSSRH_USER }} + OSSRH_SECRET: ${{ secrets.OSSRH_SECRET }} + OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} + GPG_SECRET: ${{ secrets.GPG_SECRET }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} diff --git a/.github/workflows/push_trigger.yml b/.github/workflows/push_trigger.yml deleted file mode 100644 index d2a76d7f9e..0000000000 --- a/.github/workflows/push_trigger.yml +++ /dev/null @@ -1,311 +0,0 @@ -name: Maven Package upon a push - -on: - push: - branches: - - '!release-branch' - - release-1* - - master - - 1.* - - develop - -jobs: - build: - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - ref: ${{ github.ref }} - java-version: 11 - server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - - name: Setup branch and env - run: | - # Strip git ref prefix from version - echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV - echo "GPG_TTY=$(tty)" >> $GITHUB_ENV - - - name: Setup branch and GPG public key - run: | - # Strip git ref prefix from version - - echo ${{ env.BRANCH_NAME }} - echo ${{ env.GPG_TTY }} - sudo apt-get --yes install gnupg2 - gpg2 --import ./.github/keys/mosipgpgkey_pub.gpg - gpg2 --quiet --batch --passphrase=${{secrets.gpg_secret}} --allow-secret-key-import --import ./.github/keys/mosipgpgkey_sec.gpg - - - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven-${{ env.BRANCH_NAME }} - - - name: Setup the settings file for ossrh server - run: echo " ossrh ${{secrets.ossrh_user}} ${{secrets.ossrh_secret}} ossrh true gpg2 ${{secrets.gpg_secret}} allow-snapshots true snapshots-repo https://oss.sonatype.org/content/repositories/snapshots false true releases-repo https://oss.sonatype.org/service/local/staging/deploy/maven2 true false sonar . https://sonarcloud.io false " > $GITHUB_WORKSPACE/settings.xml - - - name: Build with Maven - run: | - cd partner - mvn -B package --file pom.xml -s $GITHUB_WORKSPACE/settings.xml - - - name: Ready the springboot artifacts - run: find -name '*.jar' -executable -type f -exec zip release.zip {} + - - - name: Upload the springboot jars - uses: actions/upload-artifact@v1 - with: - name: release - path: ./release.zip - - uses: 8398a7/action-slack@v3 - with: - status: ${{ job.status }} - fields: repo,message,commit,workflow,job # selectable (default: repo,message) - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required - if: failure() # Pick up events even if the job fails or is canceled. - - publish_to_nexus: - if: "!contains(github.ref, 'master')" - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - ref: ${{ github.ref }} - java-version: 11 - server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Setup branch and env - run: | - # Strip git ref prefix from version - echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV - echo "GPG_TTY=$(tty)" >> $GITHUB_ENV - - - name: Setup branch and GPG public key - run: | - # Strip git ref prefix from version - echo ${{ env.BRANCH_NAME }} - echo ${{ env.GPG_TTY }} - sudo apt-get --yes install gnupg2 - gpg2 --import ./.github/keys/mosipgpgkey_pub.gpg - gpg2 --quiet --batch --passphrase=${{secrets.gpg_secret}} --allow-secret-key-import --import ./.github/keys/mosipgpgkey_sec.gpg - - - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven-${{ env.BRANCH_NAME }} - - - name: Setup the settings file for ossrh server - run: echo " ossrh ${{secrets.ossrh_user}} ${{secrets.ossrh_secret}} ossrh true gpg2 ${{secrets.gpg_secret}} allow-snapshots true snapshots-repo https://oss.sonatype.org/content/repositories/snapshots false true releases-repo https://oss.sonatype.org/service/local/staging/deploy/maven2 true false " > $GITHUB_WORKSPACE/settings.xml - - - name: Install xmllint - run: | - sudo apt-get update - sudo apt-get install libxml2-utils - - name: Build with Maven - run: cd partner && mvn -B package --file pom.xml -s $GITHUB_WORKSPACE/settings.xml - - - name: Publish the maven package - run: | - chmod +x ./deploy.sh - cd partner && mvn deploy -s $GITHUB_WORKSPACE/settings.xml -f pom.xml - env: - GPG_TTY: $(tty) - # - uses: 8398a7/action-slack@v3 - # with: - # status: ${{ job.status }} - # fields: repo,message,commit,workflow,job # selectable (default: repo,message) - # env: - # SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEVOPS_WEBHOOK }} # required - # if: failure() # Pick up events even if the job fails or is canceled.D - - docker-policy-management-service: - needs: build - - runs-on: ubuntu-latest - env: - NAMESPACE: ${{ secrets.dev_namespace_docker_hub }} - SERVICE_NAME: policy-management-service - SERVICE_LOCATION: partner/policy-management-service - - steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v1 - with: - name: release - path: ./ - - - name: Setup branch name - run: | - # Strip git ref prefix from version - echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV - echo ${{ env.BRANCH_NAME }} - - - name: Get version info from pom - id: getPomVersion - uses: mavrosxristoforos/get-xml-info@1.0 - with: - xml-file: ./${{ env.SERVICE_LOCATION }}/pom.xml - xpath: /*[local-name()="project"]/*[local-name()="version"] - - - name: Unzip and extract the policy-management-service - run: unzip -uj "release.zip" "${{ env.SERVICE_LOCATION }}/target/*" -d "./${{ env.SERVICE_LOCATION }}/target" - - - name: Get current date - id: date - run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - - - name: Build image - run: | - cd "./${{env.SERVICE_LOCATION}}" - docker build . --build-arg SOURCE=mosip --build-arg COMMIT_HASH=$(git rev-parse HEAD) --build-arg COMMIT_ID=$(git rev-parse --short HEAD) --build-arg BUILD_TIME=${{steps.date.outputs.date}} --file Dockerfile --tag ${{ env.SERVICE_NAME }} - - name: Log into registry - run: echo "${{ secrets.release_docker_hub }}" | docker login -u ${{ secrets.actor_docker_hub }} --password-stdin - - - name: Push image - run: | - IMAGE_ID=$NAMESPACE/$SERVICE_NAME - - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - echo "push version ${{steps.getPomVersion.outputs.info}}" - if [[ $BRANCH_NAME == master ]]; then - VERSION=latest - else - VERSION=$BRANCH_NAME - fi - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $SERVICE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION - - uses: 8398a7/action-slack@v3 - with: - status: ${{ job.status }} - fields: repo,message,commit,workflow,job # selectable (default: repo,message) - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEVOPS_WEBHOOK }} # required - if: failure() # Pick up events even if the job fails or is canceled. - - docker-partner-management-service: - needs: build - - runs-on: ubuntu-latest - env: - NAMESPACE: ${{ secrets.dev_namespace_docker_hub }} - SERVICE_NAME: partner-management-service - SERVICE_LOCATION: partner/partner-management-service - - steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v1 - with: - name: release - path: ./ - - - name: Setup branch name - run: | - # Strip git ref prefix from version - echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV - echo ${{ env.BRANCH_NAME }} - - - name: Get version info from pom - id: getPomVersion - uses: mavrosxristoforos/get-xml-info@1.0 - with: - xml-file: ./${{ env.SERVICE_LOCATION }}/pom.xml - xpath: /*[local-name()="project"]/*[local-name()="version"] - - - name: Unzip and extract the partner-management-service - run: unzip -uj "release.zip" "${{ env.SERVICE_LOCATION }}/target/*" -d "./${{ env.SERVICE_LOCATION }}/target" - - - name: Get current date - id: date - run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - - - name: Build image - run: | - cd "./${{env.SERVICE_LOCATION}}" - docker build . --build-arg SOURCE=mosip --build-arg COMMIT_HASH=$(git rev-parse HEAD) --build-arg COMMIT_ID=$(git rev-parse --short HEAD) --build-arg BUILD_TIME=${{steps.date.outputs.date}} --file Dockerfile --tag ${{ env.SERVICE_NAME }} - - name: Log into registry - run: echo "${{ secrets.release_docker_hub }}" | docker login -u ${{ secrets.actor_docker_hub }} --password-stdin - - - name: Push image - run: | - IMAGE_ID=$NAMESPACE/$SERVICE_NAME - - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - echo "push version ${{steps.getPomVersion.outputs.info}}" - if [[ $BRANCH_NAME == master ]]; then - VERSION=latest - else - VERSION=$BRANCH_NAME - fi - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $SERVICE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION - - uses: 8398a7/action-slack@v3 - with: - status: ${{ job.status }} - fields: repo,message,commit,workflow,job # selectable (default: repo,message) - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEVOPS_WEBHOOK }} # required - if: failure() # Pick up events even if the job fails or is canceled. - sonar_analysis: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - ref: ${{ github.ref }} - java-version: 11 - server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Setup branch and env - run: | - # Strip git ref prefix from version - echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV - echo "GPG_TTY=$(tty)" >> $GITHUB_ENV - - - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven-${{ env.BRANCH_NAME }} - - - name: Setup the settings file for ossrh server - run: echo " ossrh ${{secrets.ossrh_user}} ${{secrets.ossrh_secret}} ossrh true gpg2 ${{secrets.gpg_secret}} allow-snapshots true snapshots-repo https://oss.sonatype.org/content/repositories/snapshots false true releases-repo https://oss.sonatype.org/service/local/staging/deploy/maven2 true false sonar . https://sonarcloud.io false " > $GITHUB_WORKSPACE/settings.xml - - - name: Build with Maven - run: | - cd partner - mvn -B package --file pom.xml -s $GITHUB_WORKSPACE/settings.xml - - - name: Analyze with SonarCloud - run: | - cd partner - mvn -B -Dgpg.skip verify sonar:sonar -Dsonar.projectKey=mosip_${{ github.event.repository.name }} -Dsonar.organization=${{ secrets.ORG_KEY }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - - - diff --git a/.github/workflows/release_changes.yml b/.github/workflows/release_changes.yml deleted file mode 100644 index cc9c2956d9..0000000000 --- a/.github/workflows/release_changes.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Release/pre-release Preparation. - -on: - workflow_dispatch: - inputs: - message: - description: 'Triggered for release or pe-release' - required: false - default: 'Release Preparation' - releaseTags: - description: 'tag to update' - required: true - snapshotTags: - description: 'tag to be replaced' - required: true - base: - description: 'base branch for PR' - required: true -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup branch and env - run: | - # Strip git ref prefix from version - echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV - echo "GPG_TTY=$(tty)" >> $GITHUB_ENV - - - name: Mannualy changing the pom versions - run: find . -type f -name "*pom.xml" -print0 | xargs -0 sed -i "s/${{ github.event.inputs.snapshotTags }}/${{ github.event.inputs.releaseTags }}/g" - - - name: Updating the Release URL in POM - run: | - cd .github/workflows - sed -i 's/OSSRH_SNAPSHOT_URL/RELEASE_URL/g' push_trigger.yml - - - name: Updating libs-snapshot-local to libs-release local for artifactory URL's. - run: find . -type f -name "*Dockerfile" -print0 | xargs -0 sed -i "s/libs-snapshot-local/libs-release-local/g" - - - name: removing -DskipTests - run: find . -type f -name "*push_trigger.yml" -print0 | xargs -0 sed -i "s/"-DskipTests"//g" - -# - name: removing --Dgpg.skip -# run: find . -type f -name "*push_trigger.yml" -print0 | xargs -0 sed -i "s/"-Dgpg.skip"//g" - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 - with: - token: ${{ secrets.ACTION_PAT }} - commit-message: Updated Pom versions for release changes - title: Release changes - body: Automated PR for ${{ github.event.inputs.releaseTags }} release. - branch: release-branch - delete-branch: true - base: ${{ github.event.inputs.base }} diff --git a/.github/workflows/release_trigger.yml b/.github/workflows/release_trigger.yml deleted file mode 100644 index 16c505237f..0000000000 --- a/.github/workflows/release_trigger.yml +++ /dev/null @@ -1,209 +0,0 @@ -name: Release maven packages and docker upon a release - -on: - release: - types: [published] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - ref: ${{ github.ref }} - java-version: 11 - server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Setup branch and GPG public key - run: | - # Strip git ref prefix from version - echo "::set-env name=BRANCH_NAME::$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" - echo ${{ env.BRANCH_NAME }} - echo "::set-env name=GPG_TTY::$(tty)" - echo ${{ env.GPG_TTY }} - sudo apt-get --yes install gnupg2 - gpg2 --import ./.github/keys/mosipgpgkey_pub.gpg - gpg2 --quiet --batch --passphrase=${{secrets.gpg_secret}} --allow-secret-key-import --import ./.github/keys/mosipgpgkey_sec.gpg - - - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven-${{ env.BRANCH_NAME }} - - - name: Setup the settings file for ossrh server - run: echo " ossrh ${{secrets.ossrh_user}} ${{secrets.ossrh_secret}} ossrh true gpg2 ${{secrets.gpg_secret}} allow-snapshots true snapshots-repo https://oss.sonatype.org/content/repositories/snapshots false true releases-repo https://oss.sonatype.org/service/local/staging/deploy/maven2 true false " > $GITHUB_WORKSPACE/settings.xml - - - name: Build with Maven - run: | - cd partner - mvn -B package --file pom.xml -s $GITHUB_WORKSPACE/settings.xml - - - name: Ready the springboot artifacts - run: find -name '*.jar' -executable -type f -exec zip release.zip {} + - - - name: Upload the springboot jars - uses: actions/upload-artifact@v1 - with: - name: release - path: ./release.zip - - - publish_to_nexus: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 11 - uses: actions/setup-java@v1 - with: - ref: ${{ github.ref }} - java-version: 11 - server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Setup branch and GPG public key - run: | - # Strip git ref prefix from version - echo "::set-env name=BRANCH_NAME::$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" - echo ${{ env.BRANCH_NAME }} - echo "::set-env name=GPG_TTY::$(tty)" - echo ${{ env.GPG_TTY }} - sudo apt-get --yes install gnupg2 - gpg2 --import ./.github/keys/mosipgpgkey_pub.gpg - gpg2 --quiet --batch --passphrase=${{secrets.gpg_secret}} --allow-secret-key-import --import ./.github/keys/mosipgpgkey_sec.gpg - - - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-maven-${{ env.BRANCH_NAME }} - - - name: Setup the settings file for ossrh server - run: echo " ossrh ${{secrets.ossrh_user}} ${{secrets.ossrh_secret}} ossrh true gpg2 ${{secrets.gpg_secret}} allow-snapshots true snapshots-repo https://oss.sonatype.org/content/repositories/snapshots false true releases-repo https://oss.sonatype.org/service/local/staging/deploy/maven2 true false " > $GITHUB_WORKSPACE/settings.xml - - - name: Install xmllint - run: | - sudo apt-get update - sudo apt-get install libxml2-utils - - - name: Build with Maven - run: cd partner && mvn -B package --file pom.xml -s $GITHUB_WORKSPACE/settings.xml - - - name: Publish the maven package - run: | - chmod +x ./deploy.sh - ./deploy.sh partner $GITHUB_WORKSPACE/settings.xml .* - env: - GPG_TTY: $(tty) - - docker-policy-management-service: - needs: build - - runs-on: ubuntu-latest - env: - NAMESPACE: mosipdev - SERVICE_NAME: policy-management-service - SERVICE_LOCATION: partner/policy-management-service - - steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v1 - with: - name: release - path: ./ - - - name: Setup branch name - run: | - # Strip git ref prefix from version - echo "::set-env name=BRANCH_NAME::$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" - echo ${{ env.BRANCH_NAME }} - - - name: Get version info from pom - id: getPomVersion - uses: mavrosxristoforos/get-xml-info@1.0 - with: - xml-file: ./${{ env.SERVICE_LOCATION }}/pom.xml - xpath: /*[local-name()="project"]/*[local-name()="version"] - - - name: Unzip and extract the policy-management-service - run: unzip -uj "release.zip" "${{ env.SERVICE_LOCATION }}/target/*" -d "./${{ env.SERVICE_LOCATION }}/target" - - - name: Build image - run: | - cd "./${{env.SERVICE_LOCATION}}" - docker build . --file Dockerfile --tag ${{ env.SERVICE_NAME }} - - name: Log into registry - run: echo "${{ secrets.release_docker_hub }}" | docker login -u ${{ secrets.actor_docker_hub }} --password-stdin - - - name: Push image - run: | - IMAGE_ID=$NAMESPACE/$SERVICE_NAME - - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - echo "push version ${{steps.getPomVersion.outputs.info}}" - VERSION=$BRANCH_NAME - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $SERVICE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION - docker-partner-management-service: - needs: build - - runs-on: ubuntu-latest - env: - NAMESPACE: mosipdev - SERVICE_NAME: partner-management-service - SERVICE_LOCATION: partner/partner-management-service - - steps: - - uses: actions/checkout@v2 - - uses: actions/download-artifact@v1 - with: - name: release - path: ./ - - - name: Setup branch name - run: | - # Strip git ref prefix from version - echo "::set-env name=BRANCH_NAME::$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" - echo ${{ env.BRANCH_NAME }} - - - name: Get version info from pom - id: getPomVersion - uses: mavrosxristoforos/get-xml-info@1.0 - with: - xml-file: ./${{ env.SERVICE_LOCATION }}/pom.xml - xpath: /*[local-name()="project"]/*[local-name()="version"] - - - name: Unzip and extract the partner-management-service - run: unzip -uj "release.zip" "${{ env.SERVICE_LOCATION }}/target/*" -d "./${{ env.SERVICE_LOCATION }}/target" - - - name: Build image - run: | - cd "./${{env.SERVICE_LOCATION}}" - docker build . --file Dockerfile --tag ${{ env.SERVICE_NAME }} - - name: Log into registry - run: echo "${{ secrets.release_docker_hub }}" | docker login -u ${{ secrets.actor_docker_hub }} --password-stdin - - - name: Push image - run: | - IMAGE_ID=$NAMESPACE/$SERVICE_NAME - - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - echo "push version ${{steps.getPomVersion.outputs.info}}" - VERSION=$BRANCH_NAME - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $SERVICE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION \ No newline at end of file diff --git a/db_release_scripts/mosip_pms/sql/1.2.0.1-B2_to_1.2.0.1-B3_upgrade.sql b/db_release_scripts/mosip_pms/sql/1.2.0.1-B2_to_1.2.0.1-B3_upgrade.sql new file mode 100644 index 0000000000..0961a3c016 --- /dev/null +++ b/db_release_scripts/mosip_pms/sql/1.2.0.1-B2_to_1.2.0.1-B3_upgrade.sql @@ -0,0 +1,17 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_pms +-- Release Version : 1.2.1 +-- Purpose : Database Alter scripts for the release for PMS DB. +-- Create By : Balaji A +-- Created Date : Mar-2023 +-- +-- Modified Date Modified By Comments / Remarks +-- ------------------------------------------------------------------------------------------------- + + + + +\c mosip_pms sysadmin + +INSERT INTO pms.partner_type (code,partner_description,is_policy_required,is_active,cr_by,cr_dtimes,upd_by,upd_dtimes,is_deleted,del_dtimes) VALUES + ('Binding_Partner','Binding Partner',true,true,'superadmin',now(),NULL,NULL,false,NULL) ON CONFLICT (code) DO NOTHING; \ No newline at end of file diff --git a/db_release_scripts/mosip_pms/sql/1.2.0.1-B3_to_1.2.0.1-B2_revoke.sql b/db_release_scripts/mosip_pms/sql/1.2.0.1-B3_to_1.2.0.1-B2_revoke.sql new file mode 100644 index 0000000000..163e283db3 --- /dev/null +++ b/db_release_scripts/mosip_pms/sql/1.2.0.1-B3_to_1.2.0.1-B2_revoke.sql @@ -0,0 +1,15 @@ +-- ------------------------------------------------------------------------------------------------- +-- Database Name: mosip_pms +-- Release Version : 1.2.1 +-- Purpose : Revoking Database Alter deployement done for release in PMS DB. +-- Create By : Balaji A +-- Created Date : Mar-2023 +-- +-- Modified Date Modified By Comments / Remarks +-- ------------------------------------------------------------------------------------------------- + + + +\c mosip_pms sysadmin + +DELETE FROM pms.partner_type WHERE code = 'Binding_Partner'; \ No newline at end of file diff --git a/db_release_scripts/mosip_pms/sql/1.2.0.1_to_1.2.0.1-B2_upgrade.sql b/db_release_scripts/mosip_pms/sql/1.2.0.1_to_1.2.0.1-B2_upgrade.sql index 5019373207..4805e0c829 100644 --- a/db_release_scripts/mosip_pms/sql/1.2.0.1_to_1.2.0.1-B2_upgrade.sql +++ b/db_release_scripts/mosip_pms/sql/1.2.0.1_to_1.2.0.1-B2_upgrade.sql @@ -44,7 +44,7 @@ VALUES('mpolicy-default-digitalcard', 'mpolicygroup-deafult-digitalcard', 'mpoli INSERT INTO pms.auth_policy (id, policy_group_id, "name", descr, policy_file_id, policy_type, "version", policy_schema, valid_from_date, valid_to_date, is_active, cr_by, cr_dtimes, upd_by, upd_dtimes, is_deleted, del_dtimes) -VALUES('mpolicy-default-PDFCard', 'mpolicygroup-deafult-digitalcard', 'string', 'string', '{"shareableAttributes":[{"attributeName":"fullName","source":[{"attribute":"firstName","filter":[{"language":"eng"}]},{"attribute":"middleName","filter":[{"language":"eng"}]},{"attribute":"lastName","filter":[{"language":"eng"}]}],"encrypted":false},{"attributeName":"dateOfBirth","source":[{"attribute":"dateOfBirth"}],"encrypted":false,"format":"YYYY"},{"attributeName":"gender","source":[{"attribute":"gender"}],"encrypted":false},{"attributeName":"phone","source":[{"attribute":"mobileno"}],"encrypted":false},{"attributeName":"email","source":[{"attribute":"email"}],"encrypted":false},{"attributeName":"addressLine1","source":[{"attribute":"permanentAddressLine1"}],"encrypted":false},{"attributeName":"addressLine2","source":[{"attribute":"presentAddressLine1"}],"encrypted":false},{"attributeName":"addressLine3","source":[{"attribute":"addressLine3"}],"encrypted":false},{"attributeName":"province","source":[{"attribute":"presentProvince"},{"attribute":"permanentProvince"}],"encrypted":false},{"attributeName":"city","source":[{"attribute":"permanentCity"},{"attribute":"presentCity"}],"encrypted":false},{"attributeName":"UIN","source":[{"attribute":"UIN"}],"encrypted":false},{"attributeName":"postalCode","source":[{"attribute":"presentZipcode","filter":[{"language":"eng"}]},{"attribute":"permanentZipcode","filter":[{"language":"eng"}]}],"encrypted":false},{"attributeName":"biometrics","group":"CBEFF","source":[{"attribute":"individualBiometrics","filter":[{"type":"Face"}]}],"encrypted":false,"format":"extraction"}],"dataSharePolicies":{"typeOfShare":"direct","validForInMinutes":"30","transactionsAllowed":"2","encryptionType":"Partner Based","shareDomain":"datashare.datashare","source":"ID Repository"}}', 'DataShare', 'string', 'https://schemas.mosip.io/v1/auth-policy', '2020-12-16 12:30:14.183', '2025-04-28 09:37:00.000', true, 'admin', '2020-12-16 12:30:14.183', 'service-account-mosip-creser-client', '2021-02-09 06:50:22.065', false, NULL) ON CONFLICT (id) DO NOTHING; +VALUES('mpolicy-default-PDFCard', 'mpolicygroup-deafult-digitalcard', 'string', 'string', '{"dataSharePolicies":{"typeOfShare":"direct","validForInMinutes":"30","transactionsAllowed":"2","encryptionType":"Partner Based","shareDomain":"datashare.datashare","source":"ID Repository"},"shareableAttributes":[{"attributeName":"fullName","source":[{"attribute":"fullName"}],"encrypted":true},{"attributeName":"dateOfBirth","source":[{"attribute":"dateOfBirth"}],"encrypted":false,"format":"DD/MM/YYYY"},{"attributeName":"gender","source":[{"attribute":"gender"}],"encrypted":false},{"attributeName":"phone","source":[{"attribute":"phone"}],"encrypted":false},{"attributeName":"email","source":[{"attribute":"email"}],"encrypted":false},{"attributeName":"addressLine1","source":[{"attribute":"addressLine1"}],"encrypted":false},{"attributeName":"addressLine2","source":[{"attribute":"addressLine2"}],"encrypted":false},{"attributeName":"addressLine3","source":[{"attribute":"addressLine3"}],"encrypted":false},{"attributeName":"region","source":[{"attribute":"region"}],"encrypted":false},{"attributeName":"province","source":[{"attribute":"province"}],"encrypted":false},{"attributeName":"city","source":[{"attribute":"city"}],"encrypted":false},{"attributeName":"UIN","source":[{"attribute":"UIN"}],"encrypted":false},{"attributeName":"PCN","source":[{"attribute":"VID","filter":[{"type":"PERPETUAL"}]}],"encrypted":false,"format":"RETRIEVE"},{"attributeName":"postalCode","source":[{"attribute":"postalCode"}],"encrypted":false},{"attributeName":"bestTwoFingers","group":"CBEFF","source":[{"attribute":"individualBiometrics","filter":[{"type":"Finger"}]}],"encrypted":false,"format":"bestTwoFingers"},{"attributeName":"biometrics","group":"CBEFF","source":[{"attribute":"individualBiometrics","filter":[{"type":"Face"},{"type":"Finger","subType":["Left Thumb","Right Thumb"]}]}],"encrypted":false,"format":"extraction"}]}', 'DataShare', 'string', 'https://schemas.mosip.io/v1/auth-policy', NOW(), NOW() + INTERVAL '5 year', true, 'admin', NOW(), 'service-account-mosip-creser-client', NULL, false, NULL) ON CONFLICT (id) DO NOTHING; INSERT INTO pms.auth_policy_h (id, eff_dtimes, policy_group_id, "name", descr, policy_file_id, policy_type, "version", policy_schema, valid_from_date, valid_to_date, is_active, cr_by, cr_dtimes, upd_by, upd_dtimes, is_deleted, del_dtimes) diff --git a/db_scripts/mosip_pms/ddl/pms-misp_license.sql b/db_scripts/mosip_pms/ddl/pms-misp_license.sql index e218452624..0c9b0219dc 100644 --- a/db_scripts/mosip_pms/ddl/pms-misp_license.sql +++ b/db_scripts/mosip_pms/ddl/pms-misp_license.sql @@ -19,7 +19,7 @@ CREATE TABLE pms.misp_license( misp_id character varying(36) NOT NULL, license_key character varying(128) NOT NULL, - policy_id character varying(128) NULL, + policy_id character varying(36) NULL, valid_from_date timestamp NOT NULL, valid_to_date timestamp, is_active boolean NOT NULL, diff --git a/db_scripts/mosip_pms/ddl/pms-oidc_client.sql b/db_scripts/mosip_pms/ddl/pms-oidc_client.sql index 90d77f5e5b..dd7ec35e8f 100644 --- a/db_scripts/mosip_pms/ddl/pms-oidc_client.sql +++ b/db_scripts/mosip_pms/ddl/pms-oidc_client.sql @@ -38,28 +38,27 @@ CREATE TABLE pms.oidc_client( CONSTRAINT uq_oidc_client_public_key UNIQUE (public_key) ); -- ddl-end -- -COMMENT ON TABLE oidc_client.id IS 'Client ID: Unique id assigned to registered OIDC client.'; +COMMENT ON TABLE pms.oidc_client IS 'Client ID: Unique id assigned to registered OIDC client.'; -- ddl-end -- -COMMENT ON COLUMN oidc_client.name IS 'Client Name: Registered name of OIDC client.'; +COMMENT ON COLUMN pms.oidc_client.name IS 'Client Name: Registered name of OIDC client.'; -- ddl-end -- -COMMENT ON COLUMN oidc_client.logo_uri IS 'Client Logo URL: Client logo to be displayed on IDP UI.'; +COMMENT ON COLUMN pms.oidc_client.logo_uri IS 'Client Logo URL: Client logo to be displayed on IDP UI.'; -- ddl-end -- -COMMENT ON COLUMN oidc_client.redirect_uris IS 'Recirect URLS: Comma separated list of client redirect URLs.'; +COMMENT ON COLUMN pms.oidc_client.redirect_uris IS 'Recirect URLS: Comma separated list of client redirect URLs.'; -- ddl-end -- -COMMENT ON COLUMN oidc_client.rp_id IS 'Relaying Party Id: Id of the partner id who has created this OIDC client.'; +COMMENT ON COLUMN pms.oidc_client.rp_id IS 'Relaying Party Id: Id of the partner id who has created this OIDC client.'; -- ddl-end -- -COMMENT ON COLUMN oidc_client.policy_id IS 'Policy Id: Id of the policy '; +COMMENT ON COLUMN pms.oidc_client.policy_id IS 'Policy Id: Id of the policy '; -- ddl-end -- -COMMENT ON COLUMN oidc_client.status IS 'Client status: Allowed values - ACTIVE / INACTIVE.'; +COMMENT ON COLUMN pms.oidc_client.status IS 'Client status: Allowed values - ACTIVE / INACTIVE.'; -- ddl-end -- -COMMENT ON COLUMN oidc_client.public_key IS 'Public key: JWK data.'; +COMMENT ON COLUMN pms.oidc_client.public_key IS 'Public key: JWK data.'; -- ddl-end -- -COMMENT ON COLUMN oidc_client.grant_types IS 'Grant Types: Allowed grant types for the client.'; +COMMENT ON COLUMN pms.oidc_client.grant_types IS 'Grant Types: Allowed grant types for the client.'; -- ddl-end -- -COMMENT ON COLUMN oidc_client.auth_methods IS 'Client Auth methods: Allowed token endpoint authentication methods.'; +COMMENT ON COLUMN pms.oidc_client.auth_methods IS 'Client Auth methods: Allowed token endpoint authentication methods.'; -- ddl-end -- -COMMENT ON COLUMN oidc_client.claims IS 'Requested Claims: claims json as per policy defined for relaying party.'; +COMMENT ON COLUMN pms.oidc_client.claims IS 'Requested Claims: claims json as per policy defined for relaying party.'; -- ddl-end -- -COMMENT ON COLUMN oidc_client.acr_values IS 'Allowed Authentication context References(acr) json'; +COMMENT ON COLUMN pms.oidc_client.acr_values IS 'Allowed Authentication context References(acr) json'; -- ddl-end -- - diff --git a/db_scripts/mosip_pms/deploy.sh b/db_scripts/mosip_pms/deploy.sh index 3660793a44..0d0c3a8097 100644 --- a/db_scripts/mosip_pms/deploy.sh +++ b/db_scripts/mosip_pms/deploy.sh @@ -1,4 +1,4 @@ -#!/bin/sh + ## Properties file set -e properties_file="$1" @@ -16,32 +16,31 @@ else fi ## Terminate existing connections -echo "Terminating active connections" -CONN=$(PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "SELECT count(pg_terminate_backend(pg_stat_activity.pid)) FROM pg_stat_activity WHERE datname = '$MOSIP_DB_NAME' AND pid <> pg_backend_pid()";exit;) +echo "Terminating active connections" +CONN=$(PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -t -c "SELECT count(pg_terminate_backend(pg_stat_activity.pid)) FROM pg_stat_activity WHERE datname = '$MOSIP_DB_NAME' AND pid <> pg_backend_pid()";exit;) echo "Terminated connections" ## Drop db and role echo "Dropping DB" -PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f drop_db.sql +PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f drop_db.sql echo "Dropping user" -PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f drop_role.sql +PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f drop_role.sql ## Create users -echo `date "+%m/%d/%Y %H:%M:%S"` ": Creating database users" -PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f role_dbuser.sql -v dbuserpwd=\'$DBUSER_PWD\' +echo `date "+%m/%d/%Y %H:%M:%S"` ": Creating database users" +PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f role_dbuser.sql -v dbuserpwd=\'$DBUSER_PWD\' ## Create DB echo "Creating DB" -PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f db.sql -PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f ddl.sql +PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f db.sql +PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f ddl.sql ## Grants -PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f grants.sql +PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -f grants.sql ## Populate tables if [ ${DML_FLAG} == 1 ] then - echo `date "+%m/%d/%Y %H:%M:%S"` ": Deploying DML for ${MOSIP_DB_NAME} database" - PGPASSWORD=$SU_USER_PWD psql --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f dml.sql + echo `date "+%m/%d/%Y %H:%M:%S"` ": Deploying DML for ${MOSIP_DB_NAME} database" + PGPASSWORD=$SU_USER_PWD psql -v ON_ERROR_STOP=1 --username=$SU_USER --host=$DB_SERVERIP --port=$DB_PORT --dbname=$DEFAULT_DB_NAME -a -b -f dml.sql fi - diff --git a/db_scripts/mosip_pms/dml/pms-auth_policy.csv b/db_scripts/mosip_pms/dml/pms-auth_policy.csv index 030579ca1c..9779b04761 100644 --- a/db_scripts/mosip_pms/dml/pms-auth_policy.csv +++ b/db_scripts/mosip_pms/dml/pms-auth_policy.csv @@ -1,14 +1,14 @@ id,policy_group_id,name,descr,policy_file_id,policy_type,version,policy_schema,valid_from_date,valid_to_date,is_active,cr_by,cr_dtimes,upd_by,upd_dtimes -mpolicy-default-auth,mpolicygroup-default-auth,mpolicy-default-auth,mpolicy-default-auth,"{""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName""}],""encrypted"":true},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":true},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":true},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":true},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":true},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":true},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":true},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":true},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":true},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":true},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":true},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":true},{""attributeName"":""zone"",""source"":[{""attribute"":""zone""}],""encrypted"":true},{""attributeName"":""preferredLang"",""source"":[{""attribute"":""preferredLang""}],""encrypted"":false},{""attributeName"":""individualBiometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics""}],""encrypted"":true,""format"":""extraction""}],""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""}}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),4/28/2025 9:37,TRUE,admin,now(),admin,now() -mpolicy-default-abis,mpolicygroup-default-abis,mpolicy-default-abis,mpolicy-default-abis,"{""shareableAttributes"":[{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""registration-client\/NEW\/individualBiometrics"",""filter"":[{""type"":""Iris""}]},{""attribute"":""CNIE\/verification\/biometrics"",""filter"":[{""type"":""Finger""}]},{""attribute"":""CNIE\/verification\/biometrics"",""filter"":[{""type"":""Face""}]}],""encrypted"":true,""format"":""extraction""}],""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""Packet Manager""}}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),4/28/2025 9:37,TRUE,admin,now(),admin,now() -mpolicy-default-qrcode,mpolicygroup-default-print,mpolicy-default-qrcode,mpolicy-default-qrcode,"{""dataSharePolicies"":{""typeOfShare"":""direct"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""},""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName"",""filter"":[{""language"":""eng""}]}],""encrypted"":false},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""},{""type"":""Finger"",""subType"":[""Left Thumb"",""Right Thumb""]}]}],""encrypted"":true,""format"":""extraction""}]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),4/28/2025 9:37,TRUE,admin,now(),admin,now() -mpolicy-default-euin,mpolicygroup-default-print,mpolicy-default-euin,mpolicy-default-euin,"{""dataSharePolicies"":{""typeOfShare"":""direct"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""},""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName"",""filter"":[{""language"":""eng""}]}],""encrypted"":false},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""},{""type"":""Finger"",""subType"":[""Left Thumb"",""Right Thumb""]}]}],""encrypted"":true,""format"":""extraction""}]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),4/28/2025 9:37,TRUE,admin,now(),admin,now() -mpolicy-default-reprint,mpolicygroup-default-print,mpolicy-default-reprint,mpolicy-default-reprint,"{""dataSharePolicies"":{""typeOfShare"":""direct"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""},""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName"",""filter"":[{""language"":""eng""}]}],""encrypted"":false},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""},{""type"":""Finger"",""subType"":[""Left Thumb"",""Right Thumb""]}]}],""encrypted"":true,""format"":""extraction""}]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),4/28/2025 9:37,TRUE,admin,now(),admin,now() -mpolicy-default-resident,mpolicygroup-default-resident,mpolicy-default-resident,mpolicy-default-resident,"{""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""Print""},""shareableAttributes"":[]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),4/28/2025 9:37,TRUE,admin,now(),admin,now() -mpolicy-default-adjudication,mpolicygroup-default-adjudication,mpolicy-default-adjudication,mpolicy-default-adjudication,"{""shareableAttributes"":[{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""registration-client\/NEW\/individualBiometrics"",""filter"":[{""type"":""Iris""}]},{""attribute"":""CNIE\/verification\/biometrics"",""filter"":[{""type"":""Finger""}]},{""attribute"":""CNIE\/verification\/biometrics"",""filter"":[{""type"":""Face""}]}],""encrypted"":true,""format"":""extraction""},{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName""}],""encrypted"":true},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":true},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":true},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":true},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":true},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":true},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":true},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":true},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":true},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":true},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":true},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":true}],""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""30"",""transactionsAllowed"":""100000"",""encryptionType"":""none"",""shareDomain"":""datashare.datashare"",""source"":""Packet Manager""}}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),4/28/2025 9:37,TRUE,admin,now(),admin,now() -mpolicy-default-cert,mpolicygroup-default-cert,mpolicy-default-cert,mpolicy-default-cert,"{""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName""}],""encrypted"":true},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":true},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":true},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":true},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":true},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":true},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":true},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":true},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":true},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":true},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":true},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":true},{""attributeName"":""individualBiometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics""}],""encrypted"":true,""format"":""extraction""}],""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""none"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""}}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),4/28/2025 9:37,TRUE,admin,now(),admin,now() -mpolicy-default-eUIN_with_QR,mpolicygroup-default-print,mpolicy-default-eUIN_with_QR,mpolicy-default-eUIN_with_QR,"{""dataSharePolicies"":{""typeOfShare"":""direct"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""},""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName"",""filter"":[{""language"":""eng""}]}],""encrypted"":false},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""},{""type"":""Finger"",""subType"":[""Left Thumb"",""Right Thumb""]}]}],""encrypted"":true,""format"":""extraction""}]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),4/28/2025 9:37,TRUE,admin,now(),admin,now() -mpolicy-default-eUIN_with_faceQR,mpolicygroup-default-print,mpolicy-default-eUIN_with_faceQR,mpolicy-default-eUIN_with_faceQR,"{""dataSharePolicies"":{""typeOfShare"":""direct"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""},""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName"",""filter"":[{""language"":""eng""}]}],""encrypted"":false},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""},{""type"":""Finger"",""subType"":[""Left Thumb"",""Right Thumb""]}]}],""encrypted"":true,""format"":""extraction""}]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),4/28/2025 9:37,TRUE,admin,now(),admin,now() -mpolicy-default-PDFCard,mpolicygroup-default-digitalcard,mpolicy-default-PDFCard,mpolicy-default-PDFCard,"{""dataSharePolicies"":{""typeOfShare"":""direct"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""},""shareableAttributes"":[{""attributeName"":""firstName"",""source"":[{""attribute"":""firstName""}],""encrypted"":true},{""attributeName"":""middleName"",""source"":[{""attribute"":""middleName""}],""encrypted"":true},{""attributeName"":""lastName"",""source"":[{""attribute"":""lastName""}],""encrypted"":true},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""PCN"",""source"":[{""attribute"":""VID"",""filter"":[{""type"":""PERPETUAL""}]}],""encrypted"":false,""format"":""RETRIEVE""},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""bestTwoFingers"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Finger""}]}],""encrypted"":false,""format"":""bestTwoFingers""},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""},{""type"":""Finger"",""subType"":[""Left Thumb"",""Right Thumb""]}]}],""encrypted"":false,""format"":""extraction""}]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),4/28/2025 9:37,TRUE,admin,now(),admin,now() -mpolicy-default-digitalcard,mpolicygroup-default-digitalcard,mpolicy-default-digitalcard,mpolicy-default-digitalcard,"{""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""250"",""transactionsAllowed"":""10000"",""encryptionType"":""none"",""shareDomain"":""datashare.datashare"",""source"":""Print""},""shareableAttributes"":[]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),4/28/2025 9:37,TRUE,admin,now(),admin,now() -mpolicy-default-mobile,mpolicygroup-default-mobile,mpolicy-default-mobile,mpolicy-default-mobile,"{""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName""}],""encrypted"":false},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""}]}],""encrypted"":false,""format"":""extraction""}],""dataSharePolicies"":{""typeOfShare"":""direct"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""}}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),4/28/2025 9:37,TRUE,admin,now(),admin,now() +mpolicy-default-auth,mpolicygroup-default-auth,mpolicy-default-auth,mpolicy-default-auth,"{""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName""}],""encrypted"":true},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":true},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":true},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":true},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":true},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":true},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":true},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":true},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":true},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":true},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":true},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":true},{""attributeName"":""zone"",""source"":[{""attribute"":""zone""}],""encrypted"":true},{""attributeName"":""preferredLang"",""source"":[{""attribute"":""preferredLang""}],""encrypted"":false},{""attributeName"":""individualBiometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics""}],""encrypted"":true,""format"":""extraction""}],""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""}}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),'2028-12-16 12:30:14.183',TRUE,admin,now(),admin,now() +mpolicy-default-abis,mpolicygroup-default-abis,mpolicy-default-abis,mpolicy-default-abis,"{""shareableAttributes"":[{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""registration-client\/NEW\/individualBiometrics"",""filter"":[{""type"":""Iris""}]},{""attribute"":""CNIE\/verification\/biometrics"",""filter"":[{""type"":""Finger""}]},{""attribute"":""CNIE\/verification\/biometrics"",""filter"":[{""type"":""Face""}]}],""encrypted"":true,""format"":""extraction""}],""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""Packet Manager""}}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),'2028-12-16 12:30:14.183',TRUE,admin,now(),admin,now() +mpolicy-default-qrcode,mpolicygroup-default-print,mpolicy-default-qrcode,mpolicy-default-qrcode,"{""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""},""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName"",""filter"":[{""language"":""eng""}]}],""encrypted"":false},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""},{""type"":""Finger"",""subType"":[""Left Thumb"",""Right Thumb""]}]}],""encrypted"":true,""format"":""extraction""}]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),'2028-12-16 12:30:14.183',TRUE,admin,now(),admin,now() +mpolicy-default-euin,mpolicygroup-default-print,mpolicy-default-euin,mpolicy-default-euin,"{""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""},""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName"",""filter"":[{""language"":""eng""}]}],""encrypted"":false},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""},{""type"":""Finger"",""subType"":[""Left Thumb"",""Right Thumb""]}]}],""encrypted"":true,""format"":""extraction""}]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),'2028-12-16 12:30:14.183',TRUE,admin,now(),admin,now() +mpolicy-default-reprint,mpolicygroup-default-print,mpolicy-default-reprint,mpolicy-default-reprint,"{""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""},""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName"",""filter"":[{""language"":""eng""}]}],""encrypted"":false},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""},{""type"":""Finger"",""subType"":[""Left Thumb"",""Right Thumb""]}]}],""encrypted"":true,""format"":""extraction""}]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),'2028-12-16 12:30:14.183',TRUE,admin,now(),admin,now() +mpolicy-default-resident,mpolicygroup-default-resident,mpolicy-default-resident,mpolicy-default-resident,"{""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""Print""},""shareableAttributes"":[]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),'2028-12-16 12:30:14.183',TRUE,admin,now(),admin,now() +mpolicy-default-adjudication,mpolicygroup-default-adjudication,mpolicy-default-adjudication,mpolicy-default-adjudication,"{""shareableAttributes"":[{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""registration-client\/NEW\/individualBiometrics"",""filter"":[{""type"":""Iris""}]},{""attribute"":""CNIE\/verification\/biometrics"",""filter"":[{""type"":""Finger""}]},{""attribute"":""CNIE\/verification\/biometrics"",""filter"":[{""type"":""Face""}]}],""encrypted"":true,""format"":""extraction""},{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName""}],""encrypted"":true},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":true},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":true},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":true},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":true},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":true},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":true},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":true},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":true},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":true},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":true},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":true}],""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""30"",""transactionsAllowed"":""100000"",""encryptionType"":""none"",""shareDomain"":""datashare.datashare"",""source"":""Packet Manager""}}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),'2028-12-16 12:30:14.183',TRUE,admin,now(),admin,now() +mpolicy-default-cert,mpolicygroup-default-cert,mpolicy-default-cert,mpolicy-default-cert,"{""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName""}],""encrypted"":true},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":true},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":true},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":true},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":true},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":true},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":true},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":true},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":true},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":true},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":true},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":true},{""attributeName"":""individualBiometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics""}],""encrypted"":true,""format"":""extraction""}],""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""none"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""}}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),'2028-12-16 12:30:14.183',TRUE,admin,now(),admin,now() +mpolicy-default-eUIN_with_QR,mpolicygroup-default-print,mpolicy-default-eUIN_with_QR,mpolicy-default-eUIN_with_QR,"{""dataSharePolicies"":{""typeOfShare"":""direct"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""},""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName"",""filter"":[{""language"":""eng""}]}],""encrypted"":false},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""},{""type"":""Finger"",""subType"":[""Left Thumb"",""Right Thumb""]}]}],""encrypted"":true,""format"":""extraction""}]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),'2028-12-16 12:30:14.183',TRUE,admin,now(),admin,now() +mpolicy-default-eUIN_with_faceQR,mpolicygroup-default-print,mpolicy-default-eUIN_with_faceQR,mpolicy-default-eUIN_with_faceQR,"{""dataSharePolicies"":{""typeOfShare"":""direct"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""},""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName"",""filter"":[{""language"":""eng""}]}],""encrypted"":false},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""},{""type"":""Finger"",""subType"":[""Left Thumb"",""Right Thumb""]}]}],""encrypted"":true,""format"":""extraction""}]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),'2028-12-16 12:30:14.183',TRUE,admin,now(),admin,now() +mpolicy-default-PDFCard,mpolicygroup-default-digitalcard,mpolicy-default-PDFCard,mpolicy-default-PDFCard,"{""dataSharePolicies"":{""typeOfShare"":""direct"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""},""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName""}],""encrypted"":true},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""PCN"",""source"":[{""attribute"":""VID"",""filter"":[{""type"":""PERPETUAL""}]}],""encrypted"":false,""format"":""RETRIEVE""},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""bestTwoFingers"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Finger""}]}],""encrypted"":false,""format"":""bestTwoFingers""},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""},{""type"":""Finger"",""subType"":[""Left Thumb"",""Right Thumb""]}]}],""encrypted"":false,""format"":""extraction""}]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),'2028-12-16 12:30:14.183',TRUE,admin,now(),admin,now() +mpolicy-default-digitalcard,mpolicygroup-default-digitalcard,mpolicy-default-digitalcard,mpolicy-default-digitalcard,"{""dataSharePolicies"":{""typeOfShare"":""Data Share"",""validForInMinutes"":""250"",""transactionsAllowed"":""10000"",""encryptionType"":""none"",""shareDomain"":""datashare.datashare"",""source"":""Print""},""shareableAttributes"":[]}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),'2028-12-16 12:30:14.183',TRUE,admin,now(),admin,now() +mpolicy-default-mobile,mpolicygroup-default-mobile,mpolicy-default-mobile,mpolicy-default-mobile,"{""shareableAttributes"":[{""attributeName"":""fullName"",""source"":[{""attribute"":""fullName""}],""encrypted"":false},{""attributeName"":""dateOfBirth"",""source"":[{""attribute"":""dateOfBirth""}],""encrypted"":false,,""format"":""YYYY""},{""attributeName"":""gender"",""source"":[{""attribute"":""gender""}],""encrypted"":false},{""attributeName"":""phone"",""source"":[{""attribute"":""phone""}],""encrypted"":false},{""attributeName"":""email"",""source"":[{""attribute"":""email""}],""encrypted"":false},{""attributeName"":""addressLine1"",""source"":[{""attribute"":""addressLine1""}],""encrypted"":false},{""attributeName"":""addressLine2"",""source"":[{""attribute"":""addressLine2""}],""encrypted"":false},{""attributeName"":""addressLine3"",""source"":[{""attribute"":""addressLine3""}],""encrypted"":false},{""attributeName"":""region"",""source"":[{""attribute"":""region""}],""encrypted"":false},{""attributeName"":""province"",""source"":[{""attribute"":""province""}],""encrypted"":false},{""attributeName"":""city"",""source"":[{""attribute"":""city""}],""encrypted"":false},{""attributeName"":""UIN"",""source"":[{""attribute"":""UIN""}],""encrypted"":false},{""attributeName"":""postalCode"",""source"":[{""attribute"":""postalCode""}],""encrypted"":false},{""attributeName"":""biometrics"",""group"":""CBEFF"",""source"":[{""attribute"":""individualBiometrics"",""filter"":[{""type"":""Face""}]}],""encrypted"":false,""format"":""extraction""}],""dataSharePolicies"":{""typeOfShare"":""direct"",""validForInMinutes"":""30"",""transactionsAllowed"":""2"",""encryptionType"":""Partner Based"",""shareDomain"":""datashare.datashare"",""source"":""ID Repository""}}",DataShare,1,https://schemas.mosip.io/v1/auth-policy,now(),'2028-12-16 12:30:14.183',TRUE,admin,now(),admin,now() diff --git a/db_scripts/mosip_pms/dml/pms-partner_policy_bioextract.csv b/db_scripts/mosip_pms/dml/pms-partner_policy_bioextract.csv index e55356be37..020d043cb6 100644 --- a/db_scripts/mosip_pms/dml/pms-partner_policy_bioextract.csv +++ b/db_scripts/mosip_pms/dml/pms-partner_policy_bioextract.csv @@ -1,22 +1,22 @@ id,part_id,policy_id,attribute_name,extractor_provider,extractor_provider_version,biometric_modality,biometric_sub_types,cr_by,cr_dtimes,upd_by,upd_dtimes -146098,mpartner-default-auth,mpolicy-default-auth,photo,mock,1.1,face,,admin,now(),admin,now() -146099,mpartner-default-auth,mpolicy-default-auth,iris,mock,1.1,iris,,admin,now(),admin,now() -146100,mpartner-default-auth,mpolicy-default-auth,fingerprint,mock,1.1,finger,,admin,now(),admin,now() -146101,mpartner-default-print,mpolicy-default-qrcode,photo,mock,1.1,face,,admin,now(),admin,now() -146102,mpartner-default-print,mpolicy-default-qrcode,iris,mock,1.1,iris,,admin,now(),admin,now() -146103,mpartner-default-print,mpolicy-default-qrcode,fingerprint,mock,1.1,finger,,admin,now(),admin,now() -146104,mpartner-default-print,mpolicy-default-euin,photo,mock,1.1,face,,admin,now(),admin,now() -146105,mpartner-default-print,mpolicy-default-euin,iris,mock,1.1,iris,,admin,now(),admin,now() -146106,mpartner-default-print,mpolicy-default-euin,fingerprint,mock,1.1,finger,,admin,now(),admin,now() -146107,mpartner-default-print,mpolicy-default-reprint,photo,mock,1.1,face,,admin,now(),admin,now() -146108,mpartner-default-print,mpolicy-default-reprint,iris,mock,1.1,iris,,admin,now(),admin,now() -146109,mpartner-default-print,mpolicy-default-reprint,fingerprint,mock,1.1,finger,,admin,now(),admin,now() -146110,mpartner-default-print,mpolicy-default-eUIN_with_QR,photo,mock,1.1,face,,admin,now(),admin,now() -146111,mpartner-default-print,mpolicy-default-eUIN_with_QR,iris,mock,1.1,iris,,admin,now(),admin,now() -146112,mpartner-default-print,mpolicy-default-eUIN_with_QR,fingerprint,mock,1.1,finger,,admin,now(),admin,now() -146113,mpartner-default-print,mpolicy-default-eUIN_with_faceQR,photo,mock,1.1,face,,admin,now(),admin,now() -146114,mpartner-default-print,mpolicy-default-eUIN_with_faceQR,iris,mock,1.1,iris,,admin,now(),admin,now() -146115,mpartner-default-print,mpolicy-default-eUIN_with_faceQR,fingerprint,mock,1.1,finger,,admin,now(),admin,now() -146116,mpartner-default-digitalcard,mpolicy-default-PDFCard,photo,mock,1.1,face,,admin,now(),admin,now() -146117,mpartner-default-digitalcard,mpolicy-default-PDFCard,iris,mock,1.1,iris,,admin,now(),admin,now() -146118,mpartner-default-digitalcard,mpolicy-default-PDFCard,fingerprint,mock,1.1,finger,,admin,now(),admin,now() +146098,mpartner-default-auth,mpolicy-default-auth,individualBiometrics,mock,1.1,face,,admin,now(),admin,now() +146099,mpartner-default-auth,mpolicy-default-auth,individualBiometrics,mock,1.1,iris,,admin,now(),admin,now() +146100,mpartner-default-auth,mpolicy-default-auth,individualBiometrics,mock,1.1,finger,,admin,now(),admin,now() +146101,mpartner-default-print,mpolicy-default-qrcode,individualBiometrics,mock,1.1,face,,admin,now(),admin,now() +146102,mpartner-default-print,mpolicy-default-qrcode,individualBiometrics,mock,1.1,iris,,admin,now(),admin,now() +146103,mpartner-default-print,mpolicy-default-qrcode,individualBiometrics,mock,1.1,finger,,admin,now(),admin,now() +146104,mpartner-default-print,mpolicy-default-euin,individualBiometrics,mock,1.1,face,,admin,now(),admin,now() +146105,mpartner-default-print,mpolicy-default-euin,individualBiometrics,mock,1.1,iris,,admin,now(),admin,now() +146106,mpartner-default-print,mpolicy-default-euin,individualBiometrics,mock,1.1,finger,,admin,now(),admin,now() +146107,mpartner-default-print,mpolicy-default-reprint,individualBiometrics,mock,1.1,face,,admin,now(),admin,now() +146108,mpartner-default-print,mpolicy-default-reprint,individualBiometrics,mock,1.1,iris,,admin,now(),admin,now() +146109,mpartner-default-print,mpolicy-default-reprint,individualBiometrics,mock,1.1,finger,,admin,now(),admin,now() +146110,mpartner-default-print,mpolicy-default-eUIN_with_QR,individualBiometrics,mock,1.1,face,,admin,now(),admin,now() +146111,mpartner-default-print,mpolicy-default-eUIN_with_QR,individualBiometrics,mock,1.1,iris,,admin,now(),admin,now() +146112,mpartner-default-print,mpolicy-default-eUIN_with_QR,individualBiometrics,mock,1.1,finger,,admin,now(),admin,now() +146113,mpartner-default-print,mpolicy-default-eUIN_with_faceQR,individualBiometrics,mock,1.1,face,,admin,now(),admin,now() +146114,mpartner-default-print,mpolicy-default-eUIN_with_faceQR,individualBiometrics,mock,1.1,iris,,admin,now(),admin,now() +146115,mpartner-default-print,mpolicy-default-eUIN_with_faceQR,individualBiometrics,mock,1.1,finger,,admin,now(),admin,now() +146116,mpartner-default-digitalcard,mpolicy-default-PDFCard,individualBiometrics,mock,1.1,face,,admin,now(),admin,now() +146117,mpartner-default-digitalcard,mpolicy-default-PDFCard,individualBiometrics,mock,1.1,iris,,admin,now(),admin,now() +146118,mpartner-default-digitalcard,mpolicy-default-PDFCard,individualBiometrics,mock,1.1,finger,,admin,now(),admin,now() diff --git a/db_scripts/mosip_pms/dml/pms-partner_type.csv b/db_scripts/mosip_pms/dml/pms-partner_type.csv index 79f7fb83a1..6c6e015c43 100644 --- a/db_scripts/mosip_pms/dml/pms-partner_type.csv +++ b/db_scripts/mosip_pms/dml/pms-partner_type.csv @@ -7,7 +7,8 @@ FTM_Provider,FTM Provider,TRUE,superadmin,now(),FALSE Online_Verification_Partner,Online_Verification_Partner,TRUE,superadmin,now(),TRUE ABIS_Partner,ABIS Partner,TRUE,superadmin,now(),TRUE Manual_Adjudication,Manual Adjudication,TRUE,superadmin,now(),TRUE -MISP_Partner,MISP_Partner,TRUE,superadmin,now(),TRUE +MISP_Partner,MISP_Partner,TRUE,superadmin,now(),FALSE Internal_Partner,Used internally to share certs,TRUE,superadmin,now(),TRUE SDK_Partner,SDK Partner,TRUE,superadmin,now(),FALSE Print_Partner,Print Partner,TRUE,superadmin,now(),TRUE +Binding_Partner,Binding Partner,TRUE,superadmin,now(),TRUE diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/device/util/AuditUtil.java b/partner/partner-management-service/src/main/java/io/mosip/pms/device/util/AuditUtil.java index e77fe5c535..6fee1c51f9 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/device/util/AuditUtil.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/device/util/AuditUtil.java @@ -35,11 +35,11 @@ import io.mosip.kernel.core.exception.ExceptionUtils; import io.mosip.kernel.core.exception.ServiceError; import io.mosip.kernel.core.util.DateUtils; +import io.mosip.pms.common.constant.AuditErrorCode; import io.mosip.pms.common.exception.ValidationException; import io.mosip.pms.common.request.dto.RequestWrapper; import io.mosip.pms.common.response.dto.ResponseWrapper; import io.mosip.pms.common.util.RestUtil; -import io.mosip.pms.device.constant.AuditErrorCode; import io.mosip.pms.device.exception.DeviceServiceException; import io.mosip.pms.device.util.dto.AuditRequestDto; import io.mosip.pms.device.util.dto.AuditResponseDto; diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/oidc/client/service/impl/ClientManagementServiceImpl.java b/partner/partner-management-service/src/main/java/io/mosip/pms/oidc/client/service/impl/ClientManagementServiceImpl.java index 3c7fb560bd..eccf2449d3 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/oidc/client/service/impl/ClientManagementServiceImpl.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/oidc/client/service/impl/ClientManagementServiceImpl.java @@ -79,6 +79,7 @@ public class ClientManagementServiceImpl implements ClientManagementService { private static final String AUTH_POLICY_TYPE = "Auth"; private static final String AUTH_PARTNER_TYPE = "Auth_Partner"; private static final String ERROR_MESSAGE = "errorMessage"; + public static final String ACTIVE = "ACTIVE"; @Autowired ObjectMapper objectMapper; @@ -203,7 +204,7 @@ public ClientDetailResponse createOIDCClient(ClientDetailCreateRequest createReq ErrorCode.PARTNER_HAVING_NO_ACRVALUES.getErrorMessage()); } clientDetail.setAcrValues( String.join(",",acrValues)); - clientDetail.setStatus("ACTIVE"); + clientDetail.setStatus(ACTIVE); clientDetail.setGrantTypes(String.join(",", createRequest.getGrantTypes())); clientDetail.setClientAuthMethods(String.join(",", createRequest.getClientAuthMethods())); clientDetail.setCreatedDateTime(LocalDateTime.now(ZoneId.of("UTC"))); @@ -400,7 +401,7 @@ public ClientDetailResponse updateOIDCClient(String clientId, ClientDetailUpdate clientDetail.setRedirectUris(String.join(",", updateRequest.getRedirectUris())); clientDetail.setGrantTypes(String.join(",", updateRequest.getGrantTypes())); clientDetail.setClientAuthMethods(String.join(",", updateRequest.getClientAuthMethods())); - clientDetail.setStatus(updateRequest.getStatus()); + clientDetail.setStatus(updateRequest.getStatus().toUpperCase()); clientDetail.setUpdatedDateTime(LocalDateTime.now(ZoneId.of("UTC"))); clientDetail.setUpdatedBy(getLoggedInUserId()); makeUpdateIDPServiceCall(clientDetail, environment.getProperty("mosip.pms.esignet.oidc-client-update-url")); @@ -532,4 +533,4 @@ private List convertStringToList(String commaSeparatedString){ private String getLoggedInUserId() { return UserDetailUtil.getLoggedInUserId(); } -} \ No newline at end of file +} diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/impl/PartnerManagementServiceImpl.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/impl/PartnerManagementServiceImpl.java index 67c3f9ad9b..2bcb22b33d 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/impl/PartnerManagementServiceImpl.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/manager/service/impl/PartnerManagementServiceImpl.java @@ -583,7 +583,18 @@ public APIKeyGenerateResponseDto generateAPIKey(String partnerId, APIKeyGenerate throw new PartnerManagerServiceException(ErrorCode.LOGGEDIN_USER_NOT_AUTHORIZED.getErrorCode(), ErrorCode.LOGGEDIN_USER_NOT_AUTHORIZED.getErrorMessage()); } - AuthPolicy validPolicy = authPolicyRepository.findByPolicyName(requestDto.getPolicyName()); + Optional partnerFromDb = partnerRepository.findById(partnerId); + if (partnerFromDb.isEmpty()) { + auditUtil.setAuditRequestDto(PartnerManageEnum.GENERATE_API_KEY_FAILURE, partnerId, "partnerId"); + throw new PartnerManagerServiceException(ErrorCode.PARTNER_ID_DOES_NOT_EXIST_EXCEPTION.getErrorCode(), + ErrorCode.PARTNER_ID_DOES_NOT_EXIST_EXCEPTION.getErrorMessage()); + } + if (!partnerFromDb.get().getIsActive()) { + auditUtil.setAuditRequestDto(PartnerManageEnum.GENERATE_API_KEY_FAILURE, partnerId, "partnerId"); + throw new PartnerManagerServiceException(ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorCode(), + ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorMessage()); + } + AuthPolicy validPolicy = authPolicyRepository.findByPolicyGroupIdAndName(partnerFromDb.get().getPolicyGroupId(),requestDto.getPolicyName()); if(validPolicy == null) { auditUtil.setAuditRequestDto(PartnerManageEnum.GENERATE_API_KEY_FAILURE, partnerId, "partnerId"); throw new PartnerManagerServiceException(ErrorCode.POLICY_NOT_EXIST_EXCEPTION.getErrorCode(), @@ -597,17 +608,6 @@ public APIKeyGenerateResponseDto generateAPIKey(String partnerId, APIKeyGenerate throw new PartnerManagerServiceException(ErrorCode.PARTNER_POLICY_MAPPING_NOT_EXISTS.getErrorCode(), ErrorCode.PARTNER_POLICY_MAPPING_NOT_EXISTS.getErrorMessage()); } - Optional partnerFromDb = partnerRepository.findById(partnerId); - if (partnerFromDb.isEmpty()) { - auditUtil.setAuditRequestDto(PartnerManageEnum.GENERATE_API_KEY_FAILURE, partnerId, "partnerId"); - throw new PartnerManagerServiceException(ErrorCode.PARTNER_ID_DOES_NOT_EXIST_EXCEPTION.getErrorCode(), - ErrorCode.PARTNER_ID_DOES_NOT_EXIST_EXCEPTION.getErrorMessage()); - } - if (!partnerFromDb.get().getIsActive()) { - auditUtil.setAuditRequestDto(PartnerManageEnum.GENERATE_API_KEY_FAILURE, partnerId, "partnerId"); - throw new PartnerManagerServiceException(ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorCode(), - ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorMessage()); - } PartnerPolicy policyByLabel = partnerPolicyRepository.findByPartnerIdPolicyIdAndLabel( partnerFromDb.get().getId(), validPolicy.getId(), requestDto.getLabel()); if(policyByLabel != null) { diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java index 78feaf5f24..562583d6e9 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java +++ b/partner/partner-management-service/src/main/java/io/mosip/pms/partner/service/impl/PartnerServiceImpl.java @@ -518,7 +518,7 @@ public PartnerResponse updatePartnerDetails(PartnerUpdateDto partnerUpdateReques } private AuthPolicy validatePolicyGroupAndPolicy(String policyGroupId, String policyName) { - AuthPolicy authPolicyFromDb = authPolicyRepository.findByPolicyGroupAndName(policyGroupId, policyName); + AuthPolicy authPolicyFromDb = authPolicyRepository.findByPolicyGroupIdAndName(policyGroupId, policyName); if (authPolicyFromDb == null) { auditUtil.setAuditRequestDto(PartnerServiceAuditEnum.SUBMIT_API_REQUEST_FAILURE, policyName, "policyName"); throw new PartnerServiceException(ErrorCode.POLICY_GROUP_POLICY_NOT_EXISTS.getErrorCode(), diff --git a/partner/partner-management-service/src/test/java/io/mosip/pms/test/device/service/impl/FTPChipDetailServiceTest.java b/partner/partner-management-service/src/test/java/io/mosip/pms/test/device/service/impl/FTPChipDetailServiceTest.java index 3879f26df4..f8728c6b8e 100644 --- a/partner/partner-management-service/src/test/java/io/mosip/pms/test/device/service/impl/FTPChipDetailServiceTest.java +++ b/partner/partner-management-service/src/test/java/io/mosip/pms/test/device/service/impl/FTPChipDetailServiceTest.java @@ -1,15 +1,28 @@ package io.mosip.pms.test.device.service.impl; -import static org.junit.Assert.assertTrue; +import static java.util.Collections.singletonList; +import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.io.IOException; +import java.io.InputStream; +import java.security.cert.Certificate; +import java.security.cert.CertificateFactory; +import java.sql.Timestamp; +import java.time.LocalDateTime; +import java.util.*; +import io.mosip.pms.common.constant.EventType; +import io.mosip.pms.common.dto.Type; +import io.mosip.pms.common.helper.WebSubPublisher; +import io.mosip.pms.common.request.dto.ErrorResponse; +import io.mosip.pms.device.response.dto.FtpCertDownloadResponeDto; +import io.mosip.pms.partner.dto.DataShareDto; +import io.mosip.pms.partner.dto.DataShareResponseDto; +import io.mosip.pms.partner.exception.PartnerServiceException; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -18,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.core.env.Environment; import org.springframework.data.domain.PageImpl; import org.springframework.http.MediaType; @@ -57,7 +71,7 @@ public class FTPChipDetailServiceTest { @InjectMocks private FtpChipDetailService ftpChipDetailService = new FTPChipDetailServiceImpl(); - + @Mock SearchHelper searchHelper; @@ -74,6 +88,15 @@ public class FTPChipDetailServiceTest { @Autowired private ObjectMapper objectMapper; + + @Autowired + private FTPChipDetailServiceImpl fTPChipDetailServiceImpl; + + @MockBean + private WebSubPublisher webSubPublisher; + + @MockBean + private AuditUtil auditUtil; @Autowired @Qualifier("selfTokenRestTemplate") @@ -373,4 +396,602 @@ private FtpChipCertificateRequestDto createUploadrequest(Boolean isItForRegistra FtpChipCertificateRequestDto.setPartnerDomain("doamin"); return FtpChipCertificateRequestDto; } + + @Test (expected = RequestException.class) + public void testGetDataShareurl1() { + when(environment.getProperty((String) any())).thenReturn("Property"); + when(restUtil.postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any())) + .thenThrow(new RequestException("An error occurred", "An error occurred")); + ReflectionTestUtils.invokeMethod(ftpChipDetailService,"getDataShareurl","https://pmp.partner.testgetdata.share.url"); + verify(environment).getProperty((String) any()); + verify(restUtil).postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any()); + } + + @Test + public void testGetDataShareurl2() { + when(environment.getProperty((String) any())).thenReturn("Property"); + + DataShareDto dataShareDto = new DataShareDto(); + dataShareDto.setPolicyId("policyId"); + dataShareDto.setSignature("certsChain"); + dataShareDto.setSubscriberId("42"); + dataShareDto.setTransactionsAllowed(7); + dataShareDto.setUrl("https://pmp.partner.testgetdata.share.url"); + dataShareDto.setValidForInMinutes(1); + + DataShareResponseDto dataShareResponseDto = new DataShareResponseDto(); + dataShareResponseDto.setDataShare(dataShareDto); + dataShareResponseDto.setErrors(new ArrayList<>()); + dataShareResponseDto.setId("id"); + dataShareResponseDto.setResponsetime("certsChain"); + dataShareResponseDto.setVersion("1.0"); + when(restUtil.postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any())).thenReturn(dataShareResponseDto); + assertEquals("https://pmp.partner.testgetdata.share.url", + ReflectionTestUtils.invokeMethod(ftpChipDetailService,"getDataShareurl","https://pmp.partner.testgetdata.share.url")); + verify(environment).getProperty((String) any()); + verify(restUtil).postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any()); + } + + @Test (expected = PartnerServiceException.class) + public void testGetDataShareurl3() { + when(environment.getProperty((String) any())).thenReturn("Property"); + when(restUtil.postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any())).thenReturn(null); + ReflectionTestUtils.invokeMethod(ftpChipDetailService,"getDataShareurl","https://pmp.partner.testgetdata.share.url"); + verify(environment).getProperty((String) any()); + verify(restUtil).postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any()); + } + + @Test (expected = PartnerServiceException.class) + public void testGetDataShareurl4() { + when(environment.getProperty((String) any())).thenReturn(""); + + DataShareDto dataShareDto = new DataShareDto(); + dataShareDto.setPolicyId("policyId"); + dataShareDto.setSignature("Signature"); + dataShareDto.setSubscriberId("id"); + dataShareDto.setTransactionsAllowed(1); + dataShareDto.setUrl("https://pmp.partner.testgetdata.share.url"); + dataShareDto.setValidForInMinutes(1); + + ErrorResponse errorResponse = new ErrorResponse(); + errorResponse.setErrorCode("An error occurred"); + errorResponse.setMessage("Not all who wander are lost"); + + ArrayList errorResponseList = new ArrayList<>(); + errorResponseList.add(errorResponse); + DataShareResponseDto dataShareResponseDto = mock(DataShareResponseDto.class); + when(dataShareResponseDto.getDataShare()).thenReturn(dataShareDto); + when(dataShareResponseDto.getErrors()).thenReturn(errorResponseList); + when(restUtil.postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any())).thenReturn(dataShareResponseDto); + ReflectionTestUtils.invokeMethod(ftpChipDetailService,"getDataShareurl","https://pmp.partner.testgetdata.share.url"); + verify(environment).getProperty((String) any()); + verify(restUtil).postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any()); + verify(dataShareResponseDto, atLeast(1)).getErrors(); + } + + @Test (expected = IllegalArgumentException.class) + public void testGetPartnerCertFromChain() throws Exception { + + ReflectionTestUtils.invokeMethod(ftpChipDetailService, "getPartnerCertFromChain", "Cert Chain"); + } + + @Test (expected = PartnerServiceException.class) + public void testGetPartnerCertFromChain2() throws Exception { + + ReflectionTestUtils.invokeMethod(ftpChipDetailService, "getPartnerCertFromChain", "PartnerServiceImpl"); + } + + @Test (expected = NullPointerException.class) + public void testGetPartnerCertFromChain3() throws Exception { + + ReflectionTestUtils.invokeMethod(ftpChipDetailService, "getPartnerCertFromChain", ""); + } + + @Test (expected = RequestException.class) + public void testUploadCertificate() throws IOException { + doNothing().when(auditUtil) + .auditRequest((String) any(), (String) any(), (String) any(), (String) any(), (String) any(), (String) any()); + + FTPChipDetail ftpChipDetail = new FTPChipDetail(); + ftpChipDetail.setActive(true); + ftpChipDetail.setApprovalStatus("Approval Status"); + ftpChipDetail.setCertificateAlias("Certificate Alias"); + ftpChipDetail.setCrBy("Cr By"); + ftpChipDetail.setCrDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDelDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDeleted(true); + ftpChipDetail.setFtpChipDetailId("ChipId"); + ftpChipDetail.setFtpProviderId("ProviderId"); + ftpChipDetail.setMake("Make"); + ftpChipDetail.setModel("Model"); + ftpChipDetail.setPartnerOrganizationName("Partner Organization Name"); + ftpChipDetail.setUpdBy("Upd By"); + ftpChipDetail.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + Optional ofResult = Optional.of(ftpChipDetail); + when(ftpChipDetailRepository.findById((String) any())).thenReturn(ofResult); + + Partner partner = new Partner(); + partner.setAdditionalInfo("Additional Info"); + partner.setAddress("abc"); + partner.setApprovalStatus("Approval Status"); + partner.setCertificateAlias("Certificate Alias"); + partner.setContactNo("Contact No"); + partner.setCrBy("Cr By"); + partner.setCrDtimes(mock(Timestamp.class)); + partner.setDelDtimes(mock(Timestamp.class)); + partner.setEmailId("emailId"); + partner.setId("Id"); + partner.setIsActive(true); + partner.setIsDeleted(false); + partner.setLangCode("eng"); + partner.setLogoUrl("https://pms.net/partner"); + partner.setName("Name"); + partner.setPartnerPolicies(new ArrayList<>()); + partner.setPartnerPolicyRequests(new ArrayList<>()); + partner.setPartnerTypeCode("Partner Type Code"); + partner.setPolicyGroupId("PolicyGroupId"); + partner.setUpdBy("Upd By"); + partner.setUpdDtimes(mock(Timestamp.class)); + partner.setUserId("UserId"); + when(partnerServiceRepository.findByIdAndIsDeletedFalseorIsDeletedIsNullAndIsActiveTrue((String) any())) + .thenReturn(partner); + ftpChipDetailService.uploadCertificate(new FtpChipCertificateRequestDto()); + verify(auditUtil).auditRequest((String) any(), (String) any(), (String) any(), (String) any(), (String) any(), + (String) any()); + verify(ftpChipDetailRepository).findById((String) any()); + verify(partnerServiceRepository).findByIdAndIsDeletedFalseorIsDeletedIsNullAndIsActiveTrue((String) any()); + } + + @Test (expected = RequestException.class) + public void testUploadCertificate2() throws IOException { + doNothing().when(auditUtil) + .auditRequest((String) any(), (String) any(), (String) any(), (String) any(), (String) any(), (String) any()); + when(ftpChipDetailRepository.findById((String) any())) + .thenThrow(new RequestException("An error occurred", "An error occurred")); + + Partner partner = new Partner(); + partner.setAdditionalInfo("Additional Info"); + partner.setAddress("abc"); + partner.setApprovalStatus("Approval Status"); + partner.setCertificateAlias("Certificate Alias"); + partner.setContactNo("Contact No"); + partner.setCrBy("Cr By"); + partner.setCrDtimes(mock(Timestamp.class)); + partner.setDelDtimes(mock(Timestamp.class)); + partner.setEmailId("emailId"); + partner.setId("Id"); + partner.setIsActive(true); + partner.setIsDeleted(false); + partner.setLangCode("eng"); + partner.setLogoUrl("https://pms.net/partner"); + partner.setName("Name"); + partner.setPartnerPolicies(new ArrayList<>()); + partner.setPartnerPolicyRequests(new ArrayList<>()); + partner.setPartnerTypeCode("Partner Type Code"); + partner.setPolicyGroupId("PolicyGroupId"); + partner.setUpdBy("Upd By"); + partner.setUpdDtimes(mock(Timestamp.class)); + partner.setUserId("UserId"); + when(partnerServiceRepository.findByIdAndIsDeletedFalseorIsDeletedIsNullAndIsActiveTrue((String) any())) + .thenReturn(partner); + ftpChipDetailService.uploadCertificate(new FtpChipCertificateRequestDto()); + verify(ftpChipDetailRepository).findById((String) any()); + verify(partnerServiceRepository).findByIdAndIsDeletedFalseorIsDeletedIsNullAndIsActiveTrue((String) any()); + } + + @Test (expected = RequestException.class) + public void testUploadCertificate3() throws IOException { + doNothing().when(auditUtil) + .auditRequest((String) any(), (String) any(), (String) any(), (String) any(), (String) any(), (String) any()); + when(ftpChipDetailRepository.findById((String) any())).thenReturn(Optional.empty()); + FTPChipDetail ftpChipDetail = mock(FTPChipDetail.class); + when(ftpChipDetail.getFtpProviderId()).thenReturn("Id"); + doNothing().when(ftpChipDetail).setActive(anyBoolean()); + doNothing().when(ftpChipDetail).setApprovalStatus((String) any()); + doNothing().when(ftpChipDetail).setCertificateAlias((String) any()); + doNothing().when(ftpChipDetail).setCrBy((String) any()); + doNothing().when(ftpChipDetail).setCrDtimes((LocalDateTime) any()); + doNothing().when(ftpChipDetail).setDelDtimes((LocalDateTime) any()); + doNothing().when(ftpChipDetail).setDeleted(anyBoolean()); + doNothing().when(ftpChipDetail).setFtpChipDetailId((String) any()); + doNothing().when(ftpChipDetail).setFtpProviderId((String) any()); + doNothing().when(ftpChipDetail).setMake((String) any()); + doNothing().when(ftpChipDetail).setModel((String) any()); + doNothing().when(ftpChipDetail).setPartnerOrganizationName((String) any()); + doNothing().when(ftpChipDetail).setUpdBy((String) any()); + doNothing().when(ftpChipDetail).setUpdDtimes((LocalDateTime) any()); + ftpChipDetail.setActive(true); + ftpChipDetail.setApprovalStatus("Approval Status"); + ftpChipDetail.setCertificateAlias("Certificate Alias"); + ftpChipDetail.setCrBy("Cr By"); + ftpChipDetail.setCrDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDelDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDeleted(false); + ftpChipDetail.setFtpChipDetailId("ChipId"); + ftpChipDetail.setFtpProviderId("ProviderId"); + ftpChipDetail.setMake("Make"); + ftpChipDetail.setModel("Model"); + ftpChipDetail.setPartnerOrganizationName("Partner Organization Name"); + ftpChipDetail.setUpdBy("Upd By"); + ftpChipDetail.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + + Partner partner = new Partner(); + partner.setAdditionalInfo("Additional Info"); + partner.setAddress("abc"); + partner.setApprovalStatus("Approval Status"); + partner.setCertificateAlias("Certificate Alias"); + partner.setContactNo("9087654321"); + partner.setCrBy("Cr By"); + partner.setCrDtimes(mock(Timestamp.class)); + partner.setDelDtimes(mock(Timestamp.class)); + partner.setEmailId("emailId"); + partner.setId("Id"); + partner.setIsActive(true); + partner.setIsDeleted(false); + partner.setLangCode("eng"); + partner.setLogoUrl("https://pms.net/partner"); + partner.setName("Name"); + partner.setPartnerPolicies(new ArrayList<>()); + partner.setPartnerPolicyRequests(new ArrayList<>()); + partner.setPartnerTypeCode("Partner Type Code"); + partner.setPolicyGroupId("PolicyGroupId"); + partner.setUpdBy("Upd By"); + partner.setUpdDtimes(mock(Timestamp.class)); + partner.setUserId("UserId"); + when(partnerServiceRepository.findByIdAndIsDeletedFalseorIsDeletedIsNullAndIsActiveTrue((String) any())) + .thenReturn(partner); + ftpChipDetailService.uploadCertificate(new FtpChipCertificateRequestDto()); + verify(auditUtil).auditRequest((String) any(), (String) any(), (String) any(), (String) any(), (String) any(), + (String) any()); + verify(ftpChipDetailRepository).findById((String) any()); + verify(ftpChipDetail).setActive(anyBoolean()); + verify(ftpChipDetail).setApprovalStatus((String) any()); + verify(ftpChipDetail).setCertificateAlias((String) any()); + verify(ftpChipDetail).setCrBy((String) any()); + verify(ftpChipDetail).setCrDtimes((LocalDateTime) any()); + verify(ftpChipDetail).setDelDtimes((LocalDateTime) any()); + verify(ftpChipDetail).setDeleted(anyBoolean()); + verify(ftpChipDetail).setFtpChipDetailId((String) any()); + verify(ftpChipDetail).setFtpProviderId((String) any()); + verify(ftpChipDetail).setMake((String) any()); + verify(ftpChipDetail).setModel((String) any()); + verify(ftpChipDetail).setPartnerOrganizationName((String) any()); + verify(ftpChipDetail).setUpdBy((String) any()); + verify(ftpChipDetail).setUpdDtimes((LocalDateTime) any()); + verify(partnerServiceRepository).findByIdAndIsDeletedFalseorIsDeletedIsNullAndIsActiveTrue((String) any()); + } + + @Test (expected = RequestException.class) + public void testUploadCertificate4() throws IOException { + doNothing().when(auditUtil) + .auditRequest((String) any(), (String) any(), (String) any(), (String) any(), (String) any(), (String) any()); + when(environment.getProperty((String) any())).thenReturn("Property"); + FTPChipDetail ftpChipDetail = mock(FTPChipDetail.class); + when(ftpChipDetail.getFtpChipDetailId()).thenReturn("ChipId"); + when(ftpChipDetail.getFtpProviderId()).thenReturn("ProviderId"); + doNothing().when(ftpChipDetail).setActive(anyBoolean()); + doNothing().when(ftpChipDetail).setApprovalStatus((String) any()); + doNothing().when(ftpChipDetail).setCertificateAlias((String) any()); + doNothing().when(ftpChipDetail).setCrBy((String) any()); + doNothing().when(ftpChipDetail).setCrDtimes((LocalDateTime) any()); + doNothing().when(ftpChipDetail).setDelDtimes((LocalDateTime) any()); + doNothing().when(ftpChipDetail).setDeleted(anyBoolean()); + doNothing().when(ftpChipDetail).setFtpChipDetailId((String) any()); + doNothing().when(ftpChipDetail).setFtpProviderId((String) any()); + doNothing().when(ftpChipDetail).setMake((String) any()); + doNothing().when(ftpChipDetail).setModel((String) any()); + doNothing().when(ftpChipDetail).setPartnerOrganizationName((String) any()); + doNothing().when(ftpChipDetail).setUpdBy((String) any()); + doNothing().when(ftpChipDetail).setUpdDtimes((LocalDateTime) any()); + ftpChipDetail.setActive(true); + ftpChipDetail.setApprovalStatus("Approval Status"); + ftpChipDetail.setCertificateAlias("Certificate Alias"); + ftpChipDetail.setCrBy("Cr By"); + ftpChipDetail.setCrDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDelDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDeleted(false); + ftpChipDetail.setFtpChipDetailId("ChipId"); + ftpChipDetail.setFtpProviderId("ProviderId"); + ftpChipDetail.setMake("Make"); + ftpChipDetail.setModel("Model"); + ftpChipDetail.setPartnerOrganizationName("Partner Organization Name"); + ftpChipDetail.setUpdBy("Upd By"); + ftpChipDetail.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + Optional ofResult = Optional.of(ftpChipDetail); + when(ftpChipDetailRepository.findById((String) any())).thenReturn(ofResult); + + Partner partner = new Partner(); + partner.setAdditionalInfo("Additional Info"); + partner.setAddress("abc"); + partner.setApprovalStatus("Approval Status"); + partner.setCertificateAlias("Certificate Alias"); + partner.setContactNo("9087654321"); + partner.setCrBy("Cr By"); + partner.setCrDtimes(mock(Timestamp.class)); + partner.setDelDtimes(mock(Timestamp.class)); + partner.setEmailId("emailId"); + partner.setId("Id"); + partner.setIsActive(true); + partner.setIsDeleted(false); + partner.setLangCode("eng"); + partner.setLogoUrl("https://pms.net/partner"); + partner.setName("Name"); + partner.setPartnerPolicies(new ArrayList<>()); + partner.setPartnerPolicyRequests(new ArrayList<>()); + partner.setPartnerTypeCode("Partner Type Code"); + partner.setPolicyGroupId("PolicyGroupId"); + partner.setUpdBy("Upd By"); + partner.setUpdDtimes(mock(Timestamp.class)); + partner.setUserId("UserId"); + when(partnerServiceRepository.findByIdAndIsDeletedFalseorIsDeletedIsNullAndIsActiveTrue((String) any())) + .thenReturn(partner); + when(restUtil.postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any())) + .thenThrow(new RequestException("An error occurred", "An error occurred")); + ftpChipDetailService.uploadCertificate(new FtpChipCertificateRequestDto("ProviderId", "ChipId", true, "Certificate Data", + "Organization Name", "Partner Domain")); + verify(environment).getProperty((String) any()); + verify(ftpChipDetailRepository).findById((String) any()); + verify(ftpChipDetail).getFtpChipDetailId(); + verify(ftpChipDetail).getFtpProviderId(); + verify(ftpChipDetail).setActive(anyBoolean()); + verify(ftpChipDetail).setApprovalStatus((String) any()); + verify(ftpChipDetail).setCertificateAlias((String) any()); + verify(ftpChipDetail).setCrBy((String) any()); + verify(ftpChipDetail).setCrDtimes((LocalDateTime) any()); + verify(ftpChipDetail).setDelDtimes((LocalDateTime) any()); + verify(ftpChipDetail).setDeleted(anyBoolean()); + verify(ftpChipDetail).setFtpChipDetailId((String) any()); + verify(ftpChipDetail).setFtpProviderId((String) any()); + verify(ftpChipDetail).setMake((String) any()); + verify(ftpChipDetail).setModel((String) any()); + verify(ftpChipDetail).setPartnerOrganizationName((String) any()); + verify(ftpChipDetail).setUpdBy((String) any()); + verify(ftpChipDetail).setUpdDtimes((LocalDateTime) any()); + verify(partnerServiceRepository).findByIdAndIsDeletedFalseorIsDeletedIsNullAndIsActiveTrue((String) any()); + verify(restUtil).postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any()); + } + + @Test (expected = RequestException.class) + public void testGetCertificate() throws IOException { + doNothing().when(auditUtil) + .auditRequest((String) any(), (String) any(), (String) any(), (String) any(), (String) any(), (String) any()); + when(environment.getProperty((String) any())).thenReturn("Property"); + + FTPChipDetail ftpChipDetail = new FTPChipDetail(); + ftpChipDetail.setActive(true); + ftpChipDetail.setApprovalStatus("Approval Status"); + ftpChipDetail.setCertificateAlias("Certificate Alias"); + ftpChipDetail.setCrBy("Cr By"); + ftpChipDetail.setCrDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDelDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDeleted(false); + ftpChipDetail.setFtpChipDetailId("ChipId"); + ftpChipDetail.setFtpProviderId("ProviderId"); + ftpChipDetail.setMake("Make"); + ftpChipDetail.setModel("Model"); + ftpChipDetail.setPartnerOrganizationName("Partner Organization Name"); + ftpChipDetail.setUpdBy("Upd By"); + ftpChipDetail.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + Optional ofResult = Optional.of(ftpChipDetail); + when(ftpChipDetailRepository.findById((String) any())).thenReturn(ofResult); + when(restUtil.getApi((String) any(), (Map) any(), (Class) any())) + .thenThrow(new RequestException("An error occurred", "An error occurred")); + ftpChipDetailService.getCertificate(new FtpChipCertDownloadRequestDto("ChipId")); + verify(environment).getProperty((String) any()); + verify(ftpChipDetailRepository).findById((String) any()); + verify(restUtil).getApi((String) any(), (Map) any(), (Class) any()); + } + + @Test (expected = RequestException.class) + public void testGetCertificate2() throws IOException { + doNothing().when(auditUtil) + .auditRequest((String) any(), (String) any(), (String) any(), (String) any(), (String) any(), (String) any()); + when(environment.getProperty((String) any())).thenReturn("Property"); + FTPChipDetail ftpChipDetail = mock(FTPChipDetail.class); + when(ftpChipDetail.getCertificateAlias()).thenReturn(null); + doNothing().when(ftpChipDetail).setActive(anyBoolean()); + doNothing().when(ftpChipDetail).setApprovalStatus((String) any()); + doNothing().when(ftpChipDetail).setCertificateAlias((String) any()); + doNothing().when(ftpChipDetail).setCrBy((String) any()); + doNothing().when(ftpChipDetail).setCrDtimes((LocalDateTime) any()); + doNothing().when(ftpChipDetail).setDelDtimes((LocalDateTime) any()); + doNothing().when(ftpChipDetail).setDeleted(anyBoolean()); + doNothing().when(ftpChipDetail).setFtpChipDetailId((String) any()); + doNothing().when(ftpChipDetail).setFtpProviderId((String) any()); + doNothing().when(ftpChipDetail).setMake((String) any()); + doNothing().when(ftpChipDetail).setModel((String) any()); + doNothing().when(ftpChipDetail).setPartnerOrganizationName((String) any()); + doNothing().when(ftpChipDetail).setUpdBy((String) any()); + doNothing().when(ftpChipDetail).setUpdDtimes((LocalDateTime) any()); + ftpChipDetail.setActive(true); + ftpChipDetail.setApprovalStatus("Approval Status"); + ftpChipDetail.setCertificateAlias("Certificate Alias"); + ftpChipDetail.setCrBy("Cr By"); + ftpChipDetail.setCrDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDelDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDeleted(false); + ftpChipDetail.setFtpChipDetailId("ChipId"); + ftpChipDetail.setFtpProviderId("ProviderId"); + ftpChipDetail.setMake("Make"); + ftpChipDetail.setModel("Model"); + ftpChipDetail.setPartnerOrganizationName("Partner Organization Name"); + ftpChipDetail.setUpdBy("Upd By"); + ftpChipDetail.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + Optional ofResult = Optional.of(ftpChipDetail); + when(ftpChipDetailRepository.findById((String) any())).thenReturn(ofResult); + when(restUtil.getApi((String) any(), (Map) any(), (Class) any())).thenReturn("Api"); + ftpChipDetailService.getCertificate(new FtpChipCertDownloadRequestDto("ChipId")); + verify(auditUtil).auditRequest((String) any(), (String) any(), (String) any(), (String) any(), (String) any(), + (String) any()); + verify(ftpChipDetailRepository).findById((String) any()); + verify(ftpChipDetail).getCertificateAlias(); + verify(ftpChipDetail).setActive(anyBoolean()); + verify(ftpChipDetail).setApprovalStatus((String) any()); + verify(ftpChipDetail).setCertificateAlias((String) any()); + verify(ftpChipDetail).setCrBy((String) any()); + verify(ftpChipDetail).setCrDtimes((LocalDateTime) any()); + verify(ftpChipDetail).setDelDtimes((LocalDateTime) any()); + verify(ftpChipDetail).setDeleted(anyBoolean()); + verify(ftpChipDetail).setFtpChipDetailId((String) any()); + verify(ftpChipDetail).setFtpProviderId((String) any()); + verify(ftpChipDetail).setMake((String) any()); + verify(ftpChipDetail).setModel((String) any()); + verify(ftpChipDetail).setPartnerOrganizationName((String) any()); + verify(ftpChipDetail).setUpdBy((String) any()); + verify(ftpChipDetail).setUpdDtimes((LocalDateTime) any()); + } + + @Test (expected = RequestException.class) + public void testGetCertificate4() throws IOException { + doNothing().when(auditUtil) + .auditRequest((String) any(), (String) any(), (String) any(), (String) any(), (String) any(), (String) any()); + when(environment.getProperty((String) any())).thenReturn("Property"); + when(ftpChipDetailRepository.findById((String) any())).thenReturn(Optional.empty()); + FTPChipDetail ftpChipDetail = mock(FTPChipDetail.class); + when(ftpChipDetail.getCertificateAlias()).thenReturn("Certificate Alias"); + doNothing().when(ftpChipDetail).setActive(anyBoolean()); + doNothing().when(ftpChipDetail).setApprovalStatus((String) any()); + doNothing().when(ftpChipDetail).setCertificateAlias((String) any()); + doNothing().when(ftpChipDetail).setCrBy((String) any()); + doNothing().when(ftpChipDetail).setCrDtimes((LocalDateTime) any()); + doNothing().when(ftpChipDetail).setDelDtimes((LocalDateTime) any()); + doNothing().when(ftpChipDetail).setDeleted(anyBoolean()); + doNothing().when(ftpChipDetail).setFtpChipDetailId((String) any()); + doNothing().when(ftpChipDetail).setFtpProviderId((String) any()); + doNothing().when(ftpChipDetail).setMake((String) any()); + doNothing().when(ftpChipDetail).setModel((String) any()); + doNothing().when(ftpChipDetail).setPartnerOrganizationName((String) any()); + doNothing().when(ftpChipDetail).setUpdBy((String) any()); + doNothing().when(ftpChipDetail).setUpdDtimes((LocalDateTime) any()); + ftpChipDetail.setActive(true); + ftpChipDetail.setApprovalStatus("Approval Status"); + ftpChipDetail.setCertificateAlias("Certificate Alias"); + ftpChipDetail.setCrBy("Cr By"); + ftpChipDetail.setCrDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDelDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDeleted(false); + ftpChipDetail.setFtpChipDetailId("ChipId"); + ftpChipDetail.setFtpProviderId("ProviderId"); + ftpChipDetail.setMake("Make"); + ftpChipDetail.setModel("Model"); + ftpChipDetail.setPartnerOrganizationName("Partner Organization Name"); + ftpChipDetail.setUpdBy("Upd By"); + ftpChipDetail.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + when(restUtil.getApi((String) any(), (Map) any(), (Class) any())).thenReturn("Api"); + ftpChipDetailService.getCertificate(new FtpChipCertDownloadRequestDto("ChipId")); + verify(auditUtil).auditRequest((String) any(), (String) any(), (String) any(), (String) any(), (String) any(), + (String) any()); + verify(ftpChipDetailRepository).findById((String) any()); + verify(ftpChipDetail).setActive(anyBoolean()); + verify(ftpChipDetail).setApprovalStatus((String) any()); + verify(ftpChipDetail).setCertificateAlias((String) any()); + verify(ftpChipDetail).setCrBy((String) any()); + verify(ftpChipDetail).setCrDtimes((LocalDateTime) any()); + verify(ftpChipDetail).setDelDtimes((LocalDateTime) any()); + verify(ftpChipDetail).setDeleted(anyBoolean()); + verify(ftpChipDetail).setFtpChipDetailId((String) any()); + verify(ftpChipDetail).setFtpProviderId((String) any()); + verify(ftpChipDetail).setMake((String) any()); + verify(ftpChipDetail).setModel((String) any()); + verify(ftpChipDetail).setPartnerOrganizationName((String) any()); + verify(ftpChipDetail).setUpdBy((String) any()); + verify(ftpChipDetail).setUpdDtimes((LocalDateTime) any()); + } + + + @Test (expected = IllegalArgumentException.class) + @Ignore + public void testGetCertificate5() throws IOException { + doNothing().when(auditUtil) + .auditRequest((String) any(), (String) any(), (String) any(), (String) any(), (String) any(), (String) any()); + when(environment.getProperty((String) any())).thenReturn("Property"); + FTPChipDetail ftpChipDetail = mock(FTPChipDetail.class); + when(ftpChipDetail.getCertificateAlias()).thenReturn("Certificate Alias"); + doNothing().when(ftpChipDetail).setActive(anyBoolean()); + doNothing().when(ftpChipDetail).setApprovalStatus((String) any()); + doNothing().when(ftpChipDetail).setCertificateAlias((String) any()); + doNothing().when(ftpChipDetail).setCrBy((String) any()); + doNothing().when(ftpChipDetail).setCrDtimes((LocalDateTime) any()); + doNothing().when(ftpChipDetail).setDelDtimes((LocalDateTime) any()); + doNothing().when(ftpChipDetail).setDeleted(anyBoolean()); + doNothing().when(ftpChipDetail).setFtpChipDetailId((String) any()); + doNothing().when(ftpChipDetail).setFtpProviderId((String) any()); + doNothing().when(ftpChipDetail).setMake((String) any()); + doNothing().when(ftpChipDetail).setModel((String) any()); + doNothing().when(ftpChipDetail).setPartnerOrganizationName((String) any()); + doNothing().when(ftpChipDetail).setUpdBy((String) any()); + doNothing().when(ftpChipDetail).setUpdDtimes((LocalDateTime) any()); + ftpChipDetail.setActive(true); + ftpChipDetail.setApprovalStatus("Approval Status"); + ftpChipDetail.setCertificateAlias("Certificate Alias"); + ftpChipDetail.setCrBy("Cr By"); + ftpChipDetail.setCrDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDelDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + ftpChipDetail.setDeleted(false); + ftpChipDetail.setFtpChipDetailId("ChipId"); + ftpChipDetail.setFtpProviderId("ProviderId"); + ftpChipDetail.setMake("Make"); + ftpChipDetail.setModel("Model"); + ftpChipDetail.setPartnerOrganizationName("Partner Organization Name"); + ftpChipDetail.setUpdBy("Upd By"); + ftpChipDetail.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + Optional ofResult = Optional.of(ftpChipDetail); + when(ftpChipDetailRepository.findById((String) any())).thenReturn(ofResult); + + FtpCertDownloadResponeDto ftpCertDownloadResponeDto = new FtpCertDownloadResponeDto(); + ftpCertDownloadResponeDto.setCertificateData("Certificate Data"); + ftpCertDownloadResponeDto.setTimestamp(LocalDateTime.of(1, 1, 1, 1, 1)); + when(objectMapper.readValue((String) any(), (Class) any())) + .thenReturn(ftpCertDownloadResponeDto); + when(objectMapper.writeValueAsString((Object) any())).thenReturn("42"); + when(restUtil.getApi((String) any(), (Map) any(), (Class) any())) + .thenReturn(new HashMap<>()); + assertSame(ftpCertDownloadResponeDto, + ftpChipDetailService.getCertificate(new FtpChipCertDownloadRequestDto("ChipId"))); + verify(environment).getProperty((String) any()); + verify(ftpChipDetailRepository).findById((String) any()); + verify(ftpChipDetail, atLeast(1)).getCertificateAlias(); + verify(ftpChipDetail).setActive(anyBoolean()); + verify(ftpChipDetail).setApprovalStatus((String) any()); + verify(ftpChipDetail).setCertificateAlias((String) any()); + verify(ftpChipDetail).setCrBy((String) any()); + verify(ftpChipDetail).setCrDtimes((LocalDateTime) any()); + verify(ftpChipDetail).setDelDtimes((LocalDateTime) any()); + verify(ftpChipDetail).setDeleted(anyBoolean()); + verify(ftpChipDetail).setFtpChipDetailId((String) any()); + verify(ftpChipDetail).setFtpProviderId((String) any()); + verify(ftpChipDetail).setMake((String) any()); + verify(ftpChipDetail).setModel((String) any()); + verify(ftpChipDetail).setPartnerOrganizationName((String) any()); + verify(ftpChipDetail).setUpdBy((String) any()); + verify(ftpChipDetail).setUpdDtimes((LocalDateTime) any()); + verify(objectMapper).readValue((String) any(), (Class) any()); + verify(objectMapper).writeValueAsString((Object) any()); + verify(restUtil).getApi((String) any(), (Map) any(), (Class) any()); + } + + @Test (expected = Exception.class) + public void testNotify() { + doNothing().when(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + ReflectionTestUtils.invokeMethod(fTPChipDetailServiceImpl,"notify","Cert Data", "Partner Domain"); + verify(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + } + + @Test (expected = Exception.class) + public void testNotify2() { + doThrow(new RequestException("An error occurred", "An error occurred")).when(webSubPublisher) + .notify((EventType) any(), (Map) any(), (Type) any()); + ReflectionTestUtils.invokeMethod(fTPChipDetailServiceImpl,"notify","Cert Data", "Partner Domain"); + verify(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + } } diff --git a/partner/partner-management-service/src/test/java/io/mosip/pms/test/oidc/service/impl/ClientManagementServiceImplTest.java b/partner/partner-management-service/src/test/java/io/mosip/pms/test/oidc/service/impl/ClientManagementServiceImplTest.java index 0373a3c8f0..f318d94c61 100644 --- a/partner/partner-management-service/src/test/java/io/mosip/pms/test/oidc/service/impl/ClientManagementServiceImplTest.java +++ b/partner/partner-management-service/src/test/java/io/mosip/pms/test/oidc/service/impl/ClientManagementServiceImplTest.java @@ -1,13 +1,36 @@ package io.mosip.pms.test.oidc.service.impl; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.UndeclaredThrowableException; +import java.sql.Ref; +import java.sql.Timestamp; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.*; + +import io.mosip.pms.device.util.AuditUtil; +import io.mosip.pms.oidc.client.contant.ClientServiceAuditEnum; +import com.fasterxml.jackson.core.JsonProcessingException; +import io.mosip.pms.common.constant.EventType; +import io.mosip.pms.common.dto.ClientPublishDto; +import io.mosip.pms.common.dto.PartnerDataPublishDto; +import io.mosip.pms.common.dto.PolicyPublishDto; +import io.mosip.pms.common.dto.Type; +import io.mosip.pms.common.entity.AuthPolicy; +import io.mosip.pms.common.entity.ClientDetail; +import io.mosip.pms.common.entity.Partner; +import io.mosip.pms.common.entity.PolicyGroup; +import io.mosip.pms.common.exception.ApiAccessibleException; +import io.mosip.pms.common.repository.PartnerRepository; +import io.mosip.pms.common.util.MapperUtils; import io.mosip.pms.device.util.AuditUtil; import io.mosip.pms.oidc.client.contant.ClientServiceAuditEnum; +import io.mosip.pms.oidc.client.dto.*; +import io.mosip.pms.partner.response.dto.PartnerCertDownloadResponeDto; +import org.json.simple.JSONObject; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -16,9 +39,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.core.env.Environment; +import org.springframework.http.MediaType; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.util.ReflectionTestUtils; -import static org.junit.Assert.assertTrue; + +import static io.mosip.pms.common.util.UserDetailUtil.getLoggedInUserId; +import static org.junit.Assert.*; +import static org.mockito.Mockito.*; import com.fasterxml.jackson.databind.ObjectMapper; @@ -27,10 +55,10 @@ import io.mosip.pms.common.repository.ClientDetailRepository; import io.mosip.pms.common.repository.PartnerPolicyRequestRepository; import io.mosip.pms.common.util.RestUtil; -import io.mosip.pms.oidc.client.dto.ClientDetailCreateRequest; import io.mosip.pms.oidc.client.service.impl.ClientManagementServiceImpl; import io.mosip.pms.partner.constant.ErrorCode; import io.mosip.pms.partner.exception.PartnerServiceException; +import org.springframework.web.multipart.MultipartFile; @RunWith(SpringRunner.class) @SpringBootTest @@ -39,6 +67,12 @@ public class ClientManagementServiceImplTest { @Autowired private ClientManagementServiceImpl serviceImpl; + @Mock + private Environment environment; + + @Mock + PartnerRepository partnerRepository; + @Mock ClientDetailRepository clientDetailRepository; @@ -48,6 +82,9 @@ public class ClientManagementServiceImplTest { @Mock PartnerPolicyRequestRepository partnerPolicyRequestRepository; + @MockBean + private AuditUtil auditUtil; + @MockBean private RestUtil restUtil; @@ -101,4 +138,879 @@ public void createClientTest() throws Exception { } } + @Test (expected = Exception.class) + public void testCreateOIDCClient02() throws Exception { + ClientDetailCreateRequest clientDetailCreateRequest = new ClientDetailCreateRequest(); + clientDetailCreateRequest.setPublicKey(new HashMap<>()); + serviceImpl.createOIDCClient(clientDetailCreateRequest); + } + + @Test (expected = Exception.class) + public void testCreateOIDCClient03() throws Exception { + ClientDetailCreateRequest clientDetailCreateRequest = mock(ClientDetailCreateRequest.class); + when(clientDetailCreateRequest.getPublicKey()).thenReturn(new HashMap<>()); + serviceImpl.createOIDCClient(clientDetailCreateRequest); + verify(clientDetailCreateRequest).getPublicKey(); + } + + @Test (expected = PartnerServiceException.class) + public void testCreateOIDCClient04() throws Exception { + ClientDetailCreateRequest createRequest = new ClientDetailCreateRequest(); + createRequest.setName("ClientName"); + createRequest.setAuthPartnerId("AuthPartnerId"); + createRequest.setPolicyId("PolicyID"); + List clientAuthMethods = new ArrayList(); + clientAuthMethods.add("private_key_jwt"); + createRequest.setClientAuthMethods(clientAuthMethods); + List setGrantTypes = new ArrayList(); + setGrantTypes.add("authorization_code"); + createRequest.setGrantTypes(setGrantTypes); + createRequest.setLogoUri("https://testcase.pms.net/browse/OIDCClient.png"); + List setRedirectUris = new ArrayList(); + setRedirectUris.add("https://testcase.pms.net/browse/OIDCClient"); + createRequest.setRedirectUris(setRedirectUris); + createRequest.setPublicKey(public_key); + + serviceImpl.createOIDCClient(createRequest); + } + + @Test (expected = PartnerServiceException.class) + public void testCreateOIDCClient05() throws Exception { + ClientDetailCreateRequest createRequest = new ClientDetailCreateRequest(); + createRequest.setName("ClientName"); + createRequest.setAuthPartnerId("AuthPartnerId"); + createRequest.setPolicyId("PolicyID"); + List clientAuthMethods = new ArrayList(); + clientAuthMethods.add("private_key_jwt"); + createRequest.setClientAuthMethods(clientAuthMethods); + List setGrantTypes = new ArrayList(); + setGrantTypes.add("authorization_code"); + createRequest.setGrantTypes(setGrantTypes); + createRequest.setLogoUri("https://testcase.pms.net/browse/OIDCClient.png"); + List setRedirectUris = new ArrayList(); + setRedirectUris.add("https://testcase.pms.net/browse/OIDCClient"); + createRequest.setRedirectUris(setRedirectUris); + createRequest.setPublicKey(public_key); + + ClientDetail clientDetail = new ClientDetail(); + clientDetail.setPublicKey("public_key"); + clientDetail.setId("clientId"); + clientDetail.setName(createRequest.getName()); + clientDetail.setRpId(createRequest.getAuthPartnerId()); + clientDetail.setPolicyId(createRequest.getPolicyId()); + clientDetail.setLogoUri(createRequest.getLogoUri()); + clientDetail.setRedirectUris(String.join(",", createRequest.getRedirectUris())); + clientDetail.setClaims("claims"); + clientDetail.setAcrValues( "acrValues"); + clientDetail.setStatus("ACTIVE"); + clientDetail.setGrantTypes(String.join(",", createRequest.getGrantTypes())); + clientDetail.setClientAuthMethods(String.join(",", createRequest.getClientAuthMethods())); + clientDetail.setCreatedDateTime(LocalDateTime.now(ZoneId.of("UTC"))); + clientDetail.setCreatedBy(getLoggedInUserId()); + + serviceImpl.createOIDCClient(createRequest); + assertEquals(createRequest,clientDetail); + } + + + @Test (expected = PartnerServiceException.class) + public void testCreateOIDCClient06() throws Exception { + + ClientDetailCreateRequest createRequest = new ClientDetailCreateRequest(); + createRequest.setName("ClientName"); + createRequest.setAuthPartnerId("AuthPartnerId"); + createRequest.setPolicyId("PolicyID"); + List clientAuthMethods = new ArrayList(); + clientAuthMethods.add("private_key_jwt"); + createRequest.setClientAuthMethods(clientAuthMethods); + List setGrantTypes = new ArrayList(); + setGrantTypes.add("authorization_code"); + createRequest.setGrantTypes(setGrantTypes); + createRequest.setLogoUri("https://testcase.pms.net/browse/OIDCClient.png"); + List setRedirectUris = new ArrayList(); + setRedirectUris.add("https://testcase.pms.net/browse/OIDCClient"); + createRequest.setRedirectUris(setRedirectUris); + createRequest.setPublicKey(public_key); + + when(environment.getProperty(any(String.class))).thenReturn("https://testcase.pms.net/browse/OIDCClient.png"); + when(clientDetailRepository.findById(any(String.class))).thenReturn(Optional.empty()); + when(partnerRepository.findById(any(String.class))).thenReturn(Optional.of(new Partner())); + + ClientDetailResponse response = serviceImpl.createOIDCClient(createRequest); + + assertNotNull(response); + } + + @Test (expected = PartnerServiceException.class) + public void testCreateOIDCClient07() throws Exception { + + when(environment.getProperty("auth.url")).thenReturn("https://pms.net/partner"); + when(clientDetailRepository.findById(anyString())).thenReturn(Optional.empty()); + when(partnerRepository.findById(anyString())).thenReturn(Optional.of(new Partner())); + + ClientDetailCreateRequest createRequest = new ClientDetailCreateRequest(); + createRequest.setName("ClientName"); + createRequest.setAuthPartnerId("AuthPartnerId"); + createRequest.setPolicyId("PolicyID"); + List clientAuthMethods = new ArrayList(); + clientAuthMethods.add("private_key_jwt"); + createRequest.setClientAuthMethods(clientAuthMethods); + List setGrantTypes = new ArrayList(); + setGrantTypes.add("authorization_code"); + createRequest.setGrantTypes(setGrantTypes); + createRequest.setLogoUri("https://testcase.pms.net/browse/OIDCClient.png"); + List setRedirectUris = new ArrayList(); + setRedirectUris.add("https://testcase.pms.net/browse/OIDCClient"); + createRequest.setRedirectUris(setRedirectUris); + createRequest.setPublicKey(public_key); + + ClientDetailResponse response = serviceImpl.createOIDCClient(createRequest); + + assertNotNull(response); + } + + @Test(expected = PartnerServiceException.class) + public void testCreateOIDCClient08() throws Exception { + + when(clientDetailRepository.findById(anyString())).thenReturn(Optional.of(new ClientDetail())); + + ClientDetailCreateRequest createRequest = new ClientDetailCreateRequest(); + createRequest.setName("ClientName"); + createRequest.setAuthPartnerId("AuthPartnerId"); + createRequest.setPolicyId("PolicyID"); + List clientAuthMethods = new ArrayList(); + clientAuthMethods.add("private_key_jwt"); + createRequest.setClientAuthMethods(clientAuthMethods); + List setGrantTypes = new ArrayList(); + setGrantTypes.add("authorization_code"); + createRequest.setGrantTypes(setGrantTypes); + createRequest.setLogoUri("https://testcase.pms.net/browse/OIDCClient.png"); + List setRedirectUris = new ArrayList(); + setRedirectUris.add("https://testcase.pms.net/browse/OIDCClient"); + createRequest.setRedirectUris(setRedirectUris); + createRequest.setPublicKey(public_key); + + serviceImpl.createOIDCClient(createRequest); + } + + @Test + public void testUpdateOIDCClient() throws Exception { + doNothing().when(auditUtil).setAuditRequestDto((ClientServiceAuditEnum) any()); + + ClientDetail clientDetail = new ClientDetail(); + clientDetail.setAcrValues("value"); + clientDetail.setClaims("Claims"); + clientDetail.setClientAuthMethods("Client Auth Methods"); + clientDetail.setCreatedBy("Cr By"); + clientDetail.setCreatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + clientDetail.setGrantTypes("Grant Types"); + clientDetail.setId("Id"); + clientDetail.setIsDeleted(false); + clientDetail.setLogoUri("Logo Uri"); + clientDetail.setName("Name"); + clientDetail.setPolicyId("PolicyId"); + clientDetail.setPublicKey("Public Key"); + clientDetail.setRedirectUris("Redirect Uris"); + clientDetail.setRpId("RpId"); + clientDetail.setStatus("Status"); + clientDetail.setUpdatedBy("UpdatedBy"); + clientDetail.setUpdatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + Optional ofResult = Optional.of(clientDetail); + + ClientDetail clientDetail1 = new ClientDetail(); + clientDetail1.setAcrValues("value"); + clientDetail1.setClaims("Claims"); + clientDetail1.setClientAuthMethods("Client Auth Methods"); + clientDetail1.setCreatedBy("Cr By"); + clientDetail1.setCreatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + clientDetail1.setGrantTypes("Grant Types"); + clientDetail1.setId("Id"); + clientDetail1.setIsDeleted(false); + clientDetail1.setLogoUri("Logo Uri"); + clientDetail1.setName("Name"); + clientDetail1.setPolicyId("PolicyId"); + clientDetail1.setPublicKey("Public Key"); + clientDetail1.setRedirectUris("Redirect Uris"); + clientDetail1.setRpId("RpId"); + clientDetail1.setStatus("Status"); + clientDetail1.setUpdatedBy("UpdatedBy"); + clientDetail1.setUpdatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + when(environment.getProperty(any(String.class))).thenReturn("Property"); + when(clientDetailRepository.save((ClientDetail) any())).thenReturn(clientDetail1); + when(clientDetailRepository.findById((String) any())).thenReturn(ofResult); + doNothing().when(restUtil) + .putApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), (Object) any(), + (Class) any()); + doNothing().when(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + + ClientDetailUpdateRequest clientDetailUpdateRequest = new ClientDetailUpdateRequest(); + clientDetailUpdateRequest.setClientAuthMethods(new ArrayList<>()); + clientDetailUpdateRequest.setClientName("ClientName"); + clientDetailUpdateRequest.setGrantTypes(new ArrayList<>()); + clientDetailUpdateRequest.setLogoUri("Logo Uri"); + clientDetailUpdateRequest.setRedirectUris(new ArrayList<>()); + clientDetailUpdateRequest.setStatus("Status"); + ClientDetailResponse actualUpdateOIDCClientResult = serviceImpl.updateOIDCClient("Id", + clientDetailUpdateRequest); + assertEquals("Id", actualUpdateOIDCClientResult.getClientId()); + assertEquals("Status", actualUpdateOIDCClientResult.getStatus()); + verify(auditUtil).setAuditRequestDto((ClientServiceAuditEnum) any()); + verify(clientDetailRepository).save((ClientDetail) any()); + verify(clientDetailRepository).findById((String) any()); + verify(restUtil).putApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any()); + verify(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + } + + @Test (expected = PartnerServiceException.class) + public void testUpdateOIDCClient2() throws Exception { + doNothing().when(auditUtil).setAuditRequestDto((ClientServiceAuditEnum) any()); + + ClientDetail clientDetail = new ClientDetail(); + clientDetail.setAcrValues("value"); + clientDetail.setClaims("Claims"); + clientDetail.setClientAuthMethods("Client Auth Methods"); + clientDetail.setCreatedBy("Cr By"); + clientDetail.setCreatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + clientDetail.setGrantTypes("Grant Types"); + clientDetail.setId("Id"); + clientDetail.setIsDeleted(false); + clientDetail.setLogoUri("Logo Uri"); + clientDetail.setName("Name"); + clientDetail.setPolicyId("PolicyId"); + clientDetail.setPublicKey("Public Key"); + clientDetail.setRedirectUris("Redirect Uris"); + clientDetail.setRpId("RpId"); + clientDetail.setStatus("Status"); + clientDetail.setUpdatedBy("UpdatedBy"); + clientDetail.setUpdatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + Optional ofResult = Optional.of(clientDetail); + + ClientDetail clientDetail1 = new ClientDetail(); + clientDetail1.setAcrValues("value"); + clientDetail1.setClaims("Claims"); + clientDetail1.setClientAuthMethods("Client Auth Methods"); + clientDetail1.setCreatedBy("Cr By"); + clientDetail1.setCreatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + clientDetail1.setGrantTypes("Grant Types"); + clientDetail1.setId("Id"); + clientDetail1.setIsDeleted(false); + clientDetail1.setLogoUri("Logo Uri"); + clientDetail1.setName("Name"); + clientDetail1.setPolicyId("PolicyId"); + clientDetail1.setPublicKey("Public Key"); + clientDetail1.setRedirectUris("Redirect Uris"); + clientDetail1.setRpId("RpId"); + clientDetail1.setStatus("Status"); + clientDetail1.setUpdatedBy("UpdatedBy"); + clientDetail1.setUpdatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + when(clientDetailRepository.save((ClientDetail) any())).thenReturn(clientDetail1); + when(clientDetailRepository.findById((String) any())).thenReturn(ofResult); + when(environment.getProperty((String) any())).thenReturn("Property"); + doNothing().when(restUtil) + .putApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any()); + doThrow(new PartnerServiceException("An error occurred", "An error occurred")).when(webSubPublisher) + .notify((EventType) any(), (Map) any(), (Type) any()); + + ClientDetailUpdateRequest clientDetailUpdateRequest = new ClientDetailUpdateRequest(); + clientDetailUpdateRequest.setClientAuthMethods(new ArrayList<>()); + clientDetailUpdateRequest.setClientName("ClientName"); + clientDetailUpdateRequest.setGrantTypes(new ArrayList<>()); + clientDetailUpdateRequest.setLogoUri("Logo Uri"); + clientDetailUpdateRequest.setRedirectUris(new ArrayList<>()); + clientDetailUpdateRequest.setStatus("Status"); + serviceImpl.updateOIDCClient("Id", clientDetailUpdateRequest); + verify(clientDetailRepository).save((ClientDetail) any()); + verify(clientDetailRepository).findById((String) any()); + verify(environment).getProperty((String) any()); + verify(restUtil).putApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any()); + verify(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + } + + @Test + public void testGetClientDetails() { + PolicyGroup policyGroup = new PolicyGroup(); + policyGroup.setCrBy("Cr By"); + policyGroup.setCrDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + policyGroup.setDelDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + policyGroup.setDesc("The characteristics of someone or something"); + policyGroup.setId("Id"); + policyGroup.setIsActive(true); + policyGroup.setIsDeleted(false); + policyGroup.setName("Name"); + policyGroup.setUpdBy("Upd By"); + policyGroup.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + policyGroup.setUserId("UserId"); + + AuthPolicy authPolicy = new AuthPolicy(); + authPolicy.SetVersion("1.0"); + authPolicy.setCrBy("Cr By"); + authPolicy.setCrDtimes(mock(Timestamp.class)); + authPolicy.setDelDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + authPolicy.setDescr("Descr"); + authPolicy.setId("Id"); + authPolicy.setIsActive(true); + authPolicy.setIsDeleted(false); + authPolicy.setName("Name"); + authPolicy.setPolicyFileId("Field"); + authPolicy.setPolicyGroup(policyGroup); + authPolicy.setPolicySchema("Schema"); + authPolicy.setPolicy_type("Policy Type"); + authPolicy.setUpdBy("Upd By"); + authPolicy.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + authPolicy.setValidFromDate(LocalDateTime.of(1, 1, 1, 1, 1)); + authPolicy.setValidToDate(LocalDateTime.of(1, 1, 1, 1, 1)); + Optional ofResult = Optional.of(authPolicy); + when(authPolicyRepository.findById((String) any())).thenReturn(ofResult); + + io.mosip.pms.common.entity.ClientDetail clientDetail = new io.mosip.pms.common.entity.ClientDetail(); + clientDetail.setAcrValues("values"); + clientDetail.setClaims("Claims"); + clientDetail.setClientAuthMethods("Client Auth Methods"); + clientDetail.setCreatedBy("Cr By"); + clientDetail.setCreatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + clientDetail.setGrantTypes("Grant Types"); + clientDetail.setId("Id"); + clientDetail.setIsDeleted(false); + clientDetail.setLogoUri("Logo Uri"); + clientDetail.setName("Name"); + clientDetail.setPolicyId("PolicyId"); + clientDetail.setPublicKey("Public Key"); + clientDetail.setRedirectUris("Redirect Uris"); + clientDetail.setRpId("RpId"); + clientDetail.setStatus("Status"); + clientDetail.setUpdatedBy("UpdatedBy"); + clientDetail.setUpdatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + Optional ofResult1 = Optional.of(clientDetail); + when(clientDetailRepository.findById((String) any())).thenReturn(ofResult1); + io.mosip.pms.oidc.client.dto.ClientDetail actualClientDetails = serviceImpl + .getClientDetails("Id"); + assertEquals(1, actualClientDetails.getAcrValues().size()); + assertEquals("Status", actualClientDetails.getStatus()); + assertEquals("RpId", actualClientDetails.getRelyingPartyId()); + assertEquals(1, actualClientDetails.getRedirectUris().size()); + assertEquals("Public Key", actualClientDetails.getPublicKey()); + assertEquals("Name", actualClientDetails.getPolicyName()); + assertEquals("PolicyId", actualClientDetails.getPolicyId()); + assertEquals("Name", actualClientDetails.getName()); + assertEquals("Logo Uri", actualClientDetails.getLogoUri()); + assertEquals("Id", actualClientDetails.getId()); + assertEquals(1, actualClientDetails.getGrantTypes().size()); + assertEquals(1, actualClientDetails.getClientAuthMethods().size()); + assertEquals(1, actualClientDetails.getClaims().size()); + verify(authPolicyRepository).findById((String) any()); + verify(clientDetailRepository).findById((String) any()); + } + + @Test (expected = PartnerServiceException.class) + public void testGetClientDetails2() { + when(authPolicyRepository.findById((String) any())) + .thenThrow(new PartnerServiceException("An error occurred", "An error occurred")); + + io.mosip.pms.common.entity.ClientDetail clientDetail = new io.mosip.pms.common.entity.ClientDetail(); + clientDetail.setAcrValues("values"); + clientDetail.setClaims("Claims"); + clientDetail.setClientAuthMethods("Client Auth Methods"); + clientDetail.setCreatedBy("Cr By"); + clientDetail.setCreatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + clientDetail.setGrantTypes("Grant Types"); + clientDetail.setId("Id"); + clientDetail.setIsDeleted(false); + clientDetail.setLogoUri("Logo Uri"); + clientDetail.setName("Name"); + clientDetail.setPolicyId("PolicyId"); + clientDetail.setPublicKey("Public Key"); + clientDetail.setRedirectUris("Redirect Uris"); + clientDetail.setRpId("RpId"); + clientDetail.setStatus("Status"); + clientDetail.setUpdatedBy("UpdatedBy"); + clientDetail.setUpdatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + Optional ofResult = Optional.of(clientDetail); + when(clientDetailRepository.findById((String) any())).thenReturn(ofResult); + serviceImpl.getClientDetails("Id"); + verify(authPolicyRepository).findById((String) any()); + verify(clientDetailRepository).findById((String) any()); + } + + @Test + public void testNotify() { + doNothing().when(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + + PartnerDataPublishDto partnerDataPublishDto = new PartnerDataPublishDto(); + partnerDataPublishDto.setCertificateData("Certificate Data"); + partnerDataPublishDto.setPartnerId("PartnerId"); + partnerDataPublishDto.setPartnerName("Partner Name"); + partnerDataPublishDto.setPartnerStatus("Partner Status"); + + PolicyPublishDto policyPublishDto = new PolicyPublishDto(); + policyPublishDto.setPolicy(new JSONObject()); + policyPublishDto.setPolicyCommenceOn(LocalDateTime.of(1, 1, 1, 1, 1)); + policyPublishDto.setPolicyDescription("Policy Description"); + policyPublishDto.setPolicyExpiresOn(LocalDateTime.of(1, 1, 1, 1, 1)); + policyPublishDto.setPolicyId("PolicyId"); + policyPublishDto.setPolicyName("Policy Name"); + policyPublishDto.setPolicyStatus("Policy Status"); + + ClientPublishDto clientPublishDto = new ClientPublishDto(); + clientPublishDto.setAuthContextRefs(new ArrayList<>()); + clientPublishDto.setClientAuthMethods(new ArrayList<>()); + clientPublishDto.setClientId("ClientId"); + clientPublishDto.setClientName("ClientName"); + clientPublishDto.setClientStatus("Client Status"); + clientPublishDto.setUserClaims(new ArrayList<>()); + ReflectionTestUtils.invokeMethod(serviceImpl, "notify", partnerDataPublishDto, policyPublishDto, clientPublishDto, + EventType.MISP_UPDATED); + verify(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + } + + @Test + public void testNotify2() { + doNothing().when(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + + PartnerDataPublishDto partnerDataPublishDto = new PartnerDataPublishDto(); + partnerDataPublishDto.setCertificateData("Certificate Data"); + partnerDataPublishDto.setPartnerId("PartnerId"); + partnerDataPublishDto.setPartnerName("Partner Name"); + partnerDataPublishDto.setPartnerStatus("Partner Status"); + + PolicyPublishDto policyPublishDto = new PolicyPublishDto(); + policyPublishDto.setPolicy(new JSONObject()); + policyPublishDto.setPolicyCommenceOn(LocalDateTime.of(1, 1, 1, 1, 1)); + policyPublishDto.setPolicyDescription("Policy Description"); + policyPublishDto.setPolicyExpiresOn(LocalDateTime.of(1, 1, 1, 1, 1)); + policyPublishDto.setPolicyId("PolicyId"); + policyPublishDto.setPolicyName("Policy Name"); + policyPublishDto.setPolicyStatus("Policy Status"); + + ClientPublishDto clientPublishDto = new ClientPublishDto(); + clientPublishDto.setAuthContextRefs(new ArrayList<>()); + clientPublishDto.setClientAuthMethods(new ArrayList<>()); + clientPublishDto.setClientId("ClientId"); + clientPublishDto.setClientName("ClientName"); + clientPublishDto.setClientStatus("Client Status"); + clientPublishDto.setUserClaims(new ArrayList<>()); + ReflectionTestUtils.invokeMethod(serviceImpl, "notify", partnerDataPublishDto, policyPublishDto, clientPublishDto, + EventType.POLICY_UPDATED); + verify(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + } + + @Test + public void testNotify3() { + doNothing().when(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + + PartnerDataPublishDto partnerDataPublishDto = new PartnerDataPublishDto(); + partnerDataPublishDto.setCertificateData("Certificate Data"); + partnerDataPublishDto.setPartnerId("PartnerId"); + partnerDataPublishDto.setPartnerName("Partner Name"); + partnerDataPublishDto.setPartnerStatus("Partner Status"); + + PolicyPublishDto policyPublishDto = new PolicyPublishDto(); + policyPublishDto.setPolicy(new JSONObject()); + policyPublishDto.setPolicyCommenceOn(LocalDateTime.of(1, 1, 1, 1, 1)); + policyPublishDto.setPolicyDescription("Policy Description"); + policyPublishDto.setPolicyExpiresOn(LocalDateTime.of(1, 1, 1, 1, 1)); + policyPublishDto.setPolicyId("PolicyId"); + policyPublishDto.setPolicyName("Policy Name"); + policyPublishDto.setPolicyStatus("Policy Status"); + + ClientPublishDto clientPublishDto = new ClientPublishDto(); + clientPublishDto.setAuthContextRefs(new ArrayList<>()); + clientPublishDto.setClientAuthMethods(new ArrayList<>()); + clientPublishDto.setClientId("ClientId"); + clientPublishDto.setClientName("ClientName"); + clientPublishDto.setClientStatus("Client Status"); + clientPublishDto.setUserClaims(new ArrayList<>()); + ReflectionTestUtils.invokeMethod(serviceImpl, "notify", partnerDataPublishDto, policyPublishDto, clientPublishDto, + EventType.APIKEY_UPDATED); + verify(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + } + + @Test + public void testNotify4() { + doNothing().when(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + + PartnerDataPublishDto partnerDataPublishDto = new PartnerDataPublishDto(); + partnerDataPublishDto.setCertificateData("Certificate Data"); + partnerDataPublishDto.setPartnerId("PartnerId"); + partnerDataPublishDto.setPartnerName("Partner Name"); + partnerDataPublishDto.setPartnerStatus("Partner Status"); + + PolicyPublishDto policyPublishDto = new PolicyPublishDto(); + policyPublishDto.setPolicy(new JSONObject()); + policyPublishDto.setPolicyCommenceOn(LocalDateTime.of(1, 1, 1, 1, 1)); + policyPublishDto.setPolicyDescription("Policy Description"); + policyPublishDto.setPolicyExpiresOn(LocalDateTime.of(1, 1, 1, 1, 1)); + policyPublishDto.setPolicyId("PolicyId"); + policyPublishDto.setPolicyName("Policy Name"); + policyPublishDto.setPolicyStatus("Policy Status"); + + ClientPublishDto clientPublishDto = new ClientPublishDto(); + clientPublishDto.setAuthContextRefs(new ArrayList<>()); + clientPublishDto.setClientAuthMethods(new ArrayList<>()); + clientPublishDto.setClientId("ClientId"); + clientPublishDto.setClientName("ClientName"); + clientPublishDto.setClientStatus("Client Status"); + clientPublishDto.setUserClaims(new ArrayList<>()); + ReflectionTestUtils.invokeMethod(serviceImpl, "notify", partnerDataPublishDto, policyPublishDto, clientPublishDto, + EventType.PARTNER_UPDATED); + verify(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + } + + @Test + public void testNotify5() { + doNothing().when(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + + PartnerDataPublishDto partnerDataPublishDto = new PartnerDataPublishDto(); + partnerDataPublishDto.setCertificateData("Certificate Data"); + partnerDataPublishDto.setPartnerId("PartnerId"); + partnerDataPublishDto.setPartnerName("Partner Name"); + partnerDataPublishDto.setPartnerStatus("Partner Status"); + + PolicyPublishDto policyPublishDto = new PolicyPublishDto(); + policyPublishDto.setPolicy(new JSONObject()); + policyPublishDto.setPolicyCommenceOn(LocalDateTime.of(1, 1, 1, 1, 1)); + policyPublishDto.setPolicyDescription("Policy Description"); + policyPublishDto.setPolicyExpiresOn(LocalDateTime.of(1, 1, 1, 1, 1)); + policyPublishDto.setPolicyId("PolicyId"); + policyPublishDto.setPolicyName("Policy Name"); + policyPublishDto.setPolicyStatus("Policy Status"); + + ClientPublishDto clientPublishDto = new ClientPublishDto(); + clientPublishDto.setAuthContextRefs(new ArrayList<>()); + clientPublishDto.setClientAuthMethods(new ArrayList<>()); + clientPublishDto.setClientId("ClientId"); + clientPublishDto.setClientName("ClientName"); + clientPublishDto.setClientStatus("Client Status"); + clientPublishDto.setUserClaims(new ArrayList<>()); + ReflectionTestUtils.invokeMethod(serviceImpl, "notify", partnerDataPublishDto, policyPublishDto, clientPublishDto, + EventType.CA_CERTIFICATE_UPLOADED); + verify(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + } + + @Test (expected = PartnerServiceException.class) + public void testNotify6() { + doThrow(new PartnerServiceException("An error occurred", "An error occurred")).when(webSubPublisher) + .notify((EventType) any(), (Map) any(), (Type) any()); + + PartnerDataPublishDto partnerDataPublishDto = new PartnerDataPublishDto(); + partnerDataPublishDto.setCertificateData("Certificate Data"); + partnerDataPublishDto.setPartnerId("PartnerId"); + partnerDataPublishDto.setPartnerName("Partner Name"); + partnerDataPublishDto.setPartnerStatus("Partner Status"); + + PolicyPublishDto policyPublishDto = new PolicyPublishDto(); + policyPublishDto.setPolicy(new JSONObject()); + policyPublishDto.setPolicyCommenceOn(LocalDateTime.of(1, 1, 1, 1, 1)); + policyPublishDto.setPolicyDescription("Policy Description"); + policyPublishDto.setPolicyExpiresOn(LocalDateTime.of(1, 1, 1, 1, 1)); + policyPublishDto.setPolicyId("PolicyId"); + policyPublishDto.setPolicyName("Policy Name"); + policyPublishDto.setPolicyStatus("Policy Status"); + + ClientPublishDto clientPublishDto = new ClientPublishDto(); + clientPublishDto.setAuthContextRefs(new ArrayList<>()); + clientPublishDto.setClientAuthMethods(new ArrayList<>()); + clientPublishDto.setClientId("ClientId"); + clientPublishDto.setClientName("ClientName"); + clientPublishDto.setClientStatus("Client Status"); + clientPublishDto.setUserClaims(new ArrayList<>()); + ReflectionTestUtils.invokeMethod(serviceImpl, "notify", partnerDataPublishDto, policyPublishDto, clientPublishDto, + EventType.MISP_UPDATED); + verify(webSubPublisher).notify((EventType) any(), (Map) any(), (Type) any()); + } + + @Test + public void testGetPolicyObject() { + ReflectionTestUtils.invokeMethod(serviceImpl,"getPolicyObject","Policy"); + ReflectionTestUtils.invokeMethod(serviceImpl,"getPolicyObject","Auth"); + ReflectionTestUtils.invokeMethod(serviceImpl,"getPolicyObject",""); + ReflectionTestUtils.invokeMethod(serviceImpl,"getPolicyObject","Policy123"); + ReflectionTestUtils.invokeMethod(serviceImpl,"getPolicyObject","123Policy"); + } + + @Test (expected = PartnerServiceException.class) + public void testPublishClientData() { + when(environment.getProperty((String) any())).thenReturn("Property"); + when(restUtil.getApi((String) any(), (Map) any(), (Class) any())) + .thenThrow(new PartnerServiceException("An error occurred", "An error occurred")); + + Partner partner = new Partner(); + partner.setAdditionalInfo("Additional Info"); + partner.setAddress("abc"); + partner.setApprovalStatus("Approval Status"); + partner.setCertificateAlias("Certificate Alias"); + partner.setContactNo("9087654321"); + partner.setCrBy("Cr By"); + partner.setCrDtimes(mock(Timestamp.class)); + partner.setDelDtimes(mock(Timestamp.class)); + partner.setEmailId("emailId"); + partner.setId("Id"); + partner.setIsActive(true); + partner.setIsDeleted(false); + partner.setLangCode("eng"); + partner.setLogoUrl("https://pms.net/partner"); + partner.setName("Name"); + partner.setPartnerPolicies(new ArrayList<>()); + partner.setPartnerPolicyRequests(new ArrayList<>()); + partner.setPartnerTypeCode("Partner Type Code"); + partner.setPolicyGroupId("PolicyGroupId"); + partner.setUpdBy("Upd By"); + partner.setUpdDtimes(mock(Timestamp.class)); + partner.setUserId("UserId"); + + PolicyGroup policyGroup = new PolicyGroup(); + policyGroup.setCrBy("Cr By"); + policyGroup.setCrDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + policyGroup.setDelDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + policyGroup.setDesc("The characteristics of someone or something"); + policyGroup.setId("Id"); + policyGroup.setIsActive(true); + policyGroup.setIsDeleted(false); + policyGroup.setName("Name"); + policyGroup.setUpdBy("Upd By"); + policyGroup.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + policyGroup.setUserId("UserId"); + + AuthPolicy authPolicy = new AuthPolicy(); + authPolicy.SetVersion("1.0"); + authPolicy.setCrBy("Cr By"); + authPolicy.setCrDtimes(mock(Timestamp.class)); + authPolicy.setDelDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + authPolicy.setDescr("Descr"); + authPolicy.setId("Id"); + authPolicy.setIsActive(true); + authPolicy.setIsDeleted(false); + authPolicy.setName("Name"); + authPolicy.setPolicyFileId("FileId"); + authPolicy.setPolicyGroup(policyGroup); + authPolicy.setPolicySchema("Schema"); + authPolicy.setPolicy_type("Policy Type"); + authPolicy.setUpdBy("Upd By"); + authPolicy.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + authPolicy.setValidFromDate(LocalDateTime.of(1, 1, 1, 1, 1)); + authPolicy.setValidToDate(LocalDateTime.of(1, 1, 1, 1, 1)); + + ClientDetail clientDetail = new ClientDetail(); + clientDetail.setAcrValues("values"); + clientDetail.setClaims("Claims"); + clientDetail.setClientAuthMethods("Client Auth Methods"); + clientDetail.setCreatedBy("Cr By"); + clientDetail.setCreatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + clientDetail.setGrantTypes("Grant Types"); + clientDetail.setId("Id"); + clientDetail.setIsDeleted(false); + clientDetail.setLogoUri("Logo Uri"); + clientDetail.setName("Name"); + clientDetail.setPolicyId("PolicyId"); + clientDetail.setPublicKey("Public Key"); + clientDetail.setRedirectUris("Redirect Uris"); + clientDetail.setRpId("RpId"); + clientDetail.setStatus("Status"); + clientDetail.setUpdatedBy("UpdatedBy"); + clientDetail.setUpdatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + ReflectionTestUtils.invokeMethod(serviceImpl,"publishClientData",partner,authPolicy,clientDetail); + verify(environment).getProperty((String) any()); + verify(restUtil).getApi((String) any(), (Map) any(), (Class) any()); + verify(MapperUtils.mapDataToPublishDto(partner, ReflectionTestUtils.invokeMethod(serviceImpl,"getPartnerCertificate",(partner.getCertificateAlias())))); + verify(MapperUtils.mapPolicyToPublishDto(authPolicy, ReflectionTestUtils.invokeMethod(serviceImpl,"getPolicyObject",(authPolicy.getPolicyFileId())))); + verify(MapperUtils.mapClientDataToPublishDto(clientDetail)); + verify(ReflectionTestUtils.invokeMethod(serviceImpl,"notify", (any(PartnerDataPublishDto.class)), any(PolicyPublishDto.class), any(ClientPublishDto.class), + eq(EventType.OIDC_CLIENT_CREATED))); + } + + @Test (expected = UndeclaredThrowableException.class) + public void testCallIdpService01() throws Exception { + when(objectMapper.readValue((String) any(), (Class>) any())).thenReturn(new HashMap<>()); + when(restUtil.postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any())) + .thenThrow(new PartnerServiceException("An error occurred", "An error occurred")); + + ClientDetail clientDetail = new ClientDetail(); + clientDetail.setAcrValues("values"); + clientDetail.setClaims("Claims"); + clientDetail.setClientAuthMethods("Client Auth Methods"); + clientDetail.setCreatedBy("Cr By"); + clientDetail.setCreatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + clientDetail.setGrantTypes("Grant Types"); + clientDetail.setId("Id"); + clientDetail.setIsDeleted(false); + clientDetail.setLogoUri("Logo Uri"); + clientDetail.setName("Name"); + clientDetail.setPolicyId("PolicyId"); + clientDetail.setPublicKey("Public Key"); + clientDetail.setRedirectUris("Redirect Uris"); + clientDetail.setRpId("RpId"); + clientDetail.setStatus("Status"); + clientDetail.setUpdatedBy("UpdatedBy"); + clientDetail.setUpdatedDateTime(LocalDateTime.of(1, 1, 1, 1, 1)); + + CreateClientRequestDto dto = new CreateClientRequestDto(); + dto.setClientId(clientDetail.getId()); + dto.setClientName(clientDetail.getName()); + dto.setRelyingPartyId(clientDetail.getRpId()); + dto.setLogoUri(clientDetail.getLogoUri()); + dto.setPublicKey(objectMapper.readValue(clientDetail.getPublicKey(), Map.class)); + dto.setUserClaims(Collections.singletonList((clientDetail.getClaims()))); + dto.setAuthContextRefs(Collections.singletonList(clientDetail.getAcrValues())); + dto.setRedirectUris(Collections.singletonList(clientDetail.getRedirectUris())); + dto.setGrantTypes(Collections.singletonList(clientDetail.getGrantTypes())); + dto.setClientAuthMethods(Collections.singletonList(clientDetail.getClientAuthMethods())); + ReflectionTestUtils.invokeMethod(serviceImpl,"callIdpService",clientDetail,"calleeApi",true); + verify(objectMapper).readValue((String) any(), (Class>) any()); + verify(restUtil).postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any()); + } + + @Test (expected = NullPointerException.class) + public void testGetReqAttributeFromPolicyJson() { + + JSONObject policyObject = new JSONObject(); + policyObject.put("id","001"); + policyObject.put("name","Policy"); + + ReflectionTestUtils.invokeMethod(serviceImpl,"getReqAttributeFromPolicyJson",policyObject,"Parent Attribute", "Child Attribute", + "Filter Attribute"); + } + + @Test (expected = ApiAccessibleException.class) + public void testMakeCreateIDPServiceCall01() throws JsonProcessingException { + ClientDetailResponse clientDetailResponse = new ClientDetailResponse(); + clientDetailResponse.setClientId("ClientId"); + clientDetailResponse.setStatus("Status"); + when(objectMapper.readValue((String) any(), (Class) any())) + .thenReturn(clientDetailResponse); + when(objectMapper.writeValueAsString((Object) any())).thenReturn("123"); + when(restUtil.postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any())).thenReturn(new HashMap<>()); + assertSame(clientDetailResponse, ReflectionTestUtils.invokeMethod(serviceImpl,"makeCreateIDPServiceCall","Request","Callee Api")); + verify(objectMapper).readValue((String) any(), (Class) any()); + verify(objectMapper).writeValueAsString((Object) any()); + verify(restUtil).postApi((String) any(), (List) any(), (String) any(), (String) any(), (MediaType) any(), + (Object) any(), (Class) any()); + } + + @Test (expected = PartnerServiceException.class) + public void testGetPartnerCertificate01() { + when(environment.getProperty((String) any())).thenReturn("Property"); + when(restUtil.getApi((String) any(), (Map) any(), (Class) any())) + .thenThrow(new PartnerServiceException("An error occurred", "An error occurred")); + ReflectionTestUtils.invokeMethod(serviceImpl,"getPartnerCertificate","Certificate Alias"); + verify(environment).getProperty((String) any()); + verify(restUtil).getApi((String) any(), (Map) any(), (Class) any()); + } + + @Test (expected = ApiAccessibleException.class) + public void testGetPartnerCertificate02() throws JsonProcessingException { + when(environment.getProperty((String) any())).thenReturn("Property"); + + PartnerCertDownloadResponeDto partnerCertDownloadResponeDto = new PartnerCertDownloadResponeDto(); + partnerCertDownloadResponeDto.setCertificateData("Certificate Data"); + partnerCertDownloadResponeDto.setTimestamp(LocalDateTime.of(1, 1, 1, 1, 1)); + when(objectMapper.readValue((String) any(), (Class) any())) + .thenReturn(partnerCertDownloadResponeDto); + when(objectMapper.writeValueAsString((Object) any())).thenReturn("123"); + when(restUtil.getApi((String) any(), (Map) any(), (Class) any())) + .thenReturn(new HashMap<>()); + assertEquals("Certificate Data", ReflectionTestUtils.invokeMethod(serviceImpl,"getPartnerCertificate","Certificate Alias")); + verify(environment).getProperty((String) any()); + verify(objectMapper).readValue((String) any(), (Class) any()); + verify(objectMapper).writeValueAsString((Object) any()); + verify(restUtil).getApi((String) any(), (Map) any(), (Class) any()); + } + + @Test (expected = PartnerServiceException.class) + //@Ignore + public void testCreateOIDCClient01() throws Exception { + + ClientDetailCreateRequest createRequest = new ClientDetailCreateRequest(); + createRequest.setName("ClientName"); + createRequest.setAuthPartnerId("mosip_partnerorg1665194709609"); + createRequest.setPolicyId("53704"); + List clientAuthMethods = new ArrayList(); + clientAuthMethods.add("private_key_jwt"); + createRequest.setClientAuthMethods(clientAuthMethods); + List setGrantTypes = new ArrayList(); + setGrantTypes.add("authorization_code"); + createRequest.setGrantTypes(setGrantTypes); + createRequest.setLogoUri("https://testcase.pms.net/browse/OIDCClient.png"); + List setRedirectUris = new ArrayList(); + setRedirectUris.add("https://testcase.pms.net/browse/OIDCClient"); + createRequest.setRedirectUris(setRedirectUris); + createRequest.setPublicKey(public_key); + + Partner partner = new Partner(); + partner.setAdditionalInfo("Additional Info"); + partner.setAddress("abc"); + partner.setApprovalStatus("Approval Status"); + partner.setCertificateAlias("Certificate Alias"); + partner.setContactNo("9087654321"); + partner.setCrBy("Cr By"); + partner.setCrDtimes(mock(Timestamp.class)); + partner.setDelDtimes(mock(Timestamp.class)); + partner.setEmailId("emailId"); + partner.setId("mosip_partnerorg1665194709609"); + partner.setIsActive(true); + partner.setIsDeleted(false); + partner.setLangCode("eng"); + partner.setLogoUrl("https://pms.net/partner"); + partner.setName("auth"); + partner.setPartnerPolicies(new ArrayList<>()); + partner.setPartnerPolicyRequests(new ArrayList<>()); + partner.setPartnerTypeCode("Auth_Policy"); + partner.setPolicyGroupId("mosip_partnerorg1665194709609"); + partner.setUpdBy("Upd By"); + partner.setUpdDtimes(mock(Timestamp.class)); + partner.setUserId("UserId"); + + PolicyGroup policyGroup = new PolicyGroup(); + policyGroup.setCrBy("Cr By"); + policyGroup.setCrDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + policyGroup.setDelDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + policyGroup.setDesc("The characteristics of someone or something"); + policyGroup.setId("mosip_partnerorg1665194709609"); + policyGroup.setIsActive(true); + policyGroup.setIsDeleted(false); + policyGroup.setName("Name"); + policyGroup.setUpdBy("Upd By"); + policyGroup.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + policyGroup.setUserId("UserId"); + + AuthPolicy authPolicy = new AuthPolicy(); + authPolicy.SetVersion("1.0"); + authPolicy.setCrBy("Cr By"); + authPolicy.setCrDtimes(mock(Timestamp.class)); + authPolicy.setDelDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + authPolicy.setDescr("Descr"); + authPolicy.setId("mosip_partnerorg1665194709609"); + authPolicy.setIsActive(true); + authPolicy.setIsDeleted(false); + authPolicy.setName("Name"); + authPolicy.setPolicyFileId("42"); + authPolicy.setPolicyGroup(policyGroup); + authPolicy.setPolicySchema("Schema"); + authPolicy.setPolicy_type("Policy Type"); + authPolicy.setUpdBy("Upd By"); + authPolicy.setUpdDtimes(LocalDateTime.of(1, 1, 1, 1, 1)); + authPolicy.setValidFromDate(LocalDateTime.of(1, 1, 1, 1, 1)); + authPolicy.setValidToDate(LocalDateTime.of(1, 1, 1, 1, 1)); + + when(clientDetailRepository.findById(anyString())).thenReturn(Optional.empty()); + when(partnerRepository.findById(anyString())).thenReturn(Optional.of(partner)); + when(authPolicyRepository.findById(anyString())).thenReturn(Optional.of(authPolicy)); + + ClientDetailResponse response = serviceImpl.createOIDCClient(createRequest); + + assertNotNull(response); + } + + @Test + public void testConvertStringToList01() { + String inputString = "id,name,email"; + List expectedList = Arrays.asList("id", "name", "email"); + List resultList = ReflectionTestUtils.invokeMethod(serviceImpl, "convertStringToList", inputString); + assertEquals(expectedList, resultList); + } + } diff --git a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/controller/PartnerManagementControllerTest.java b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/controller/PartnerManagementControllerTest.java index bd546b8648..df82f4b403 100644 --- a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/controller/PartnerManagementControllerTest.java +++ b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/controller/PartnerManagementControllerTest.java @@ -1,15 +1,22 @@ package io.mosip.pms.test.partner.controller; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.doNothing; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import java.time.LocalDateTime; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; import java.util.Optional; +import io.mosip.pms.partner.manager.controller.PartnerManagementController; +import lombok.SneakyThrows; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -218,4 +225,122 @@ public void activateDeactivatePartnerAPIKey() throws Exception { mockMvc.perform(MockMvcRequestBuilders.patch("/partners/1234/policy/456/apiKey/status").contentType(MediaType.APPLICATION_JSON_VALUE) .content(objectMapper.writeValueAsString(request))).andExpect(MockMvcResultMatchers.status().isOk()); } + + @Test (expected = Exception.class) + public void testGetPartnersDetails() { + PartnerManagementController partnerManagementController = new PartnerManagementController(); + partnerManagementController.getPartnersDeatils(Optional.of("1234")); + } + + @Test (expected = Exception.class) + public void testApproveRejectPolicyMappings() { + + PartnerManagementController partnerManagementController = new PartnerManagementController(); + + StatusRequestDto statusRequestDto = new StatusRequestDto(); + statusRequestDto.setStatus("Status"); + + RequestWrapper requestWrapper = new RequestWrapper<>(); + requestWrapper.setId("mosip.partnermanagement.partners.policy.mapping"); + requestWrapper.setMetadata("{}"); + requestWrapper.setRequest(statusRequestDto); + requestWrapper.setRequesttime(ZonedDateTime.now(ZoneOffset.UTC).toLocalDateTime()); + requestWrapper.setVersion("1.0"); + partnerManagementController.approveRejectPolicyMappings(requestWrapper, "MappingKey"); + } + + @Test (expected = Exception.class) + public void testApproveRejectPolicyMappings2() { + + PartnerManagementController partnerManagementController = new PartnerManagementController(); + + StatusRequestDto statusRequestDto = new StatusRequestDto(); + statusRequestDto.setStatus("Status"); + RequestWrapper requestWrapper = (RequestWrapper) mock(RequestWrapper.class); + when(requestWrapper.getId()).thenReturn("mosip.partnermanagement.partners.policy.mapping"); + when(requestWrapper.getVersion()).thenReturn("1.0"); + doNothing().when(requestWrapper).setId((String) any()); + doNothing().when(requestWrapper).setMetadata((Object) any()); + doNothing().when(requestWrapper).setRequest((StatusRequestDto) any()); + doNothing().when(requestWrapper).setRequesttime((LocalDateTime) any()); + doNothing().when(requestWrapper).setVersion((String) any()); + requestWrapper.setId("mosip.partnermanagement.partners.policy.mapping"); + requestWrapper.setMetadata("{}"); + requestWrapper.setRequest(statusRequestDto); + requestWrapper.setRequesttime(ZonedDateTime.now(ZoneOffset.UTC).toLocalDateTime()); + requestWrapper.setVersion("1.0"); + partnerManagementController.approveRejectPolicyMappings(requestWrapper, "MappingKey"); + } + + @SneakyThrows + @Test + public void testActivateDeactivatePartnerAPIKey() { + PartnerManagementController partnerManagementController = new PartnerManagementController(); + + APIkeyStatusUpdateRequestDto apIkeyStatusUpdateRequestDto = new APIkeyStatusUpdateRequestDto(); + apIkeyStatusUpdateRequestDto.setLabel("Label"); + apIkeyStatusUpdateRequestDto.setStatus("Status"); + + RequestWrapper requestWrapper = new RequestWrapper<>(); + requestWrapper.setId("mosip.partnermanagement.partners.policy.mapping"); + requestWrapper.setMetadata("{}"); + requestWrapper.setRequest(apIkeyStatusUpdateRequestDto); + requestWrapper.setRequesttime(ZonedDateTime.now(ZoneOffset.UTC).toLocalDateTime()); + requestWrapper.setVersion("1.0"); + Mockito.when(partnerManagementService.updateAPIKeyStatus("1234","456",apIkeyStatusUpdateRequestDto)) + .thenReturn("Success"); + mockMvc.perform(MockMvcRequestBuilders.patch("/partners/1234/policy/456/apiKey/status").contentType(MediaType.APPLICATION_JSON_VALUE) + .content(objectMapper.writeValueAsString(requestWrapper))).andExpect(MockMvcResultMatchers.status().isUnauthorized()); + } + + @SneakyThrows + @Test (expected = Exception.class) + public void testActivateDeactivatePartnerAPIKey2() { + + PartnerManagementController partnerManagementController = new PartnerManagementController(); + + APIkeyStatusUpdateRequestDto apIkeyStatusUpdateRequestDto = new APIkeyStatusUpdateRequestDto(); + apIkeyStatusUpdateRequestDto.setLabel("Label"); + apIkeyStatusUpdateRequestDto.setStatus("Status"); + RequestWrapper requestWrapper = (RequestWrapper) mock(RequestWrapper.class); + when(requestWrapper.getId()).thenReturn("id"); + when(requestWrapper.getVersion()).thenReturn("1.0"); + doNothing().when(requestWrapper).setId((String) any()); + doNothing().when(requestWrapper).setMetadata((Object) any()); + doNothing().when(requestWrapper).setRequest((APIkeyStatusUpdateRequestDto) any()); + doNothing().when(requestWrapper).setRequesttime((LocalDateTime) any()); + doNothing().when(requestWrapper).setVersion((String) any()); + requestWrapper.setId("mosip.partnermanagement.partners.policy.mapping"); + requestWrapper.setMetadata("{}"); + requestWrapper.setRequest(apIkeyStatusUpdateRequestDto); + requestWrapper.setRequesttime(ZonedDateTime.now(ZoneOffset.UTC).toLocalDateTime()); + requestWrapper.setVersion("1.0"); + Mockito.when(partnerManagementService.updateAPIKeyStatus("1234","456",apIkeyStatusUpdateRequestDto)) + .thenReturn("Success"); + + partnerManagementController.activateDeactivatePartnerAPIKey("1234", "456", requestWrapper); + + mockMvc.perform(MockMvcRequestBuilders.patch("/partners/1234/policy/456/apiKey/status").contentType(MediaType.APPLICATION_JSON_VALUE) + .content(objectMapper.writeValueAsString(requestWrapper))).andExpect(MockMvcResultMatchers.status().isOk()); + } + + @Test (expected = Exception.class) + public void testActivateDeactivatePartnerAPIKey3() { + + PartnerManagementController partnerManagementController = new PartnerManagementController(); + + APIkeyStatusUpdateRequestDto apIkeyStatusUpdateRequestDto = new APIkeyStatusUpdateRequestDto(); + apIkeyStatusUpdateRequestDto.setLabel("Label"); + apIkeyStatusUpdateRequestDto.setStatus("Status"); + + RequestWrapper requestWrapper = new RequestWrapper<>(); + requestWrapper.setId("mosip.partnermanagement.partners.policy.mapping"); + requestWrapper.setMetadata("{}"); + requestWrapper.setRequest(apIkeyStatusUpdateRequestDto); + requestWrapper.setRequesttime(ZonedDateTime.now(ZoneOffset.UTC).toLocalDateTime()); + requestWrapper.setVersion("1.0"); + partnerManagementController.activateDeactivatePartnerAPIKey("123", "456", requestWrapper); + + } + } diff --git a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerManagementServiceImplTest.java b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerManagementServiceImplTest.java index 40b26308dc..671e76e244 100644 --- a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerManagementServiceImplTest.java +++ b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerManagementServiceImplTest.java @@ -948,10 +948,11 @@ public void approveRejectPartnerPolicyMappingTest05() { public void generateAPIKeyTest() { APIKeyGenerateRequestDto request = new APIKeyGenerateRequestDto(); request.setLabel("unique"); - request.setPolicyName("policyName"); - Mockito.when(authPolicyRepository.findByPolicyName(request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); + request.setPolicyName("policyName"); + Optional newPartner = Optional.of(getPartner()); + Mockito.when(partnerRepository.findById("partner")).thenReturn(newPartner); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName(newPartner.get().getPolicyGroupId(),request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); Mockito.when((partnerPolicyRequestRepository.findByPartnerIdAndPolicyIdAndStatusCode(Mockito.any(),Mockito.any(),Mockito.any()))).thenReturn(List.of(getPartnerPolicyRequestData())); - Mockito.when(partnerRepository.findById("partner")).thenReturn(Optional.of(getPartner())); Mockito.when(partnerPolicyRepository.findByPartnerIdPolicyIdAndLabel("partner","234","unique")).thenReturn(getPartnerPolicy()); Map response = new HashMap<>(); response.put("response", getCertResponse()); @@ -964,39 +965,36 @@ public void generateAPIKeyTest() { }catch (PartnerManagerServiceException e) { assertTrue(e.getErrorCode().equals(ErrorCode.LOGGEDIN_USER_NOT_AUTHORIZED.getErrorCode())); } - - Mockito.when(authPolicyRepository.findByPolicyName(request.getPolicyName())).thenReturn(null); + Mockito.when(partnerRepository.findById("partner")).thenReturn(Optional.empty()); try { partnerManagementImpl.generateAPIKey("partner", request); }catch (PartnerManagerServiceException e) { - assertTrue(e.getErrorCode().equals(ErrorCode.POLICY_NOT_EXIST_EXCEPTION.getErrorCode())); + assertTrue(e.getErrorCode().equals(ErrorCode.PARTNER_ID_DOES_NOT_EXIST_EXCEPTION.getErrorCode())); } - Mockito.when(authPolicyRepository.findByPolicyName(request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); - Mockito.when((partnerPolicyRequestRepository.findByPartnerIdAndPolicyIdAndStatusCode(Mockito.any(),Mockito.any(),Mockito.any()))).thenReturn(Collections.emptyList()); + Optional partner = Optional.of(getPartner()); + partner.get().setIsActive(false); + Mockito.when(partnerRepository.findById("partner")).thenReturn(partner); try { partnerManagementImpl.generateAPIKey("partner", request); }catch (PartnerManagerServiceException e) { - assertTrue(e.getErrorCode().equals(ErrorCode.PARTNER_POLICY_MAPPING_NOT_EXISTS.getErrorCode())); + assertTrue(e.getErrorCode().equals(ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorCode())); } - Mockito.when(authPolicyRepository.findByPolicyName(request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); - Mockito.when((partnerPolicyRequestRepository.findByPartnerIdAndPolicyIdAndStatusCode(Mockito.any(),Mockito.any(),Mockito.any()))).thenReturn(List.of(getPartnerPolicyRequestData())); - Mockito.when(partnerRepository.findById("partner")).thenReturn(Optional.empty()); + Mockito.when(partnerRepository.findById("partner")).thenReturn(newPartner); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName(request.getPolicyName(),newPartner.get().getPolicyGroupId())).thenReturn(null); try { partnerManagementImpl.generateAPIKey("partner", request); }catch (PartnerManagerServiceException e) { - assertTrue(e.getErrorCode().equals(ErrorCode.PARTNER_ID_DOES_NOT_EXIST_EXCEPTION.getErrorCode())); - } - Mockito.when(authPolicyRepository.findByPolicyName(request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); - Mockito.when((partnerPolicyRequestRepository.findByPartnerIdAndPolicyIdAndStatusCode(Mockito.any(),Mockito.any(),Mockito.any()))).thenReturn(List.of(getPartnerPolicyRequestData())); - Optional partner = Optional.of(getPartner()); - partner.get().setIsActive(false); - Mockito.when(partnerRepository.findById("partner")).thenReturn(partner); + assertTrue(e.getErrorCode().equals(ErrorCode.POLICY_NOT_EXIST_EXCEPTION.getErrorCode())); + } + Mockito.when(partnerRepository.findById("partner")).thenReturn(newPartner); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName(newPartner.get().getPolicyGroupId(),request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); + Mockito.when((partnerPolicyRequestRepository.findByPartnerIdAndPolicyIdAndStatusCode(Mockito.any(),Mockito.any(),Mockito.any()))).thenReturn(Collections.emptyList()); try { partnerManagementImpl.generateAPIKey("partner", request); }catch (PartnerManagerServiceException e) { - assertTrue(e.getErrorCode().equals(ErrorCode.PARTNER_NOT_ACTIVE_EXCEPTION.getErrorCode())); + assertTrue(e.getErrorCode().equals(ErrorCode.PARTNER_POLICY_MAPPING_NOT_EXISTS.getErrorCode())); } - Mockito.when(authPolicyRepository.findByPolicyName(request.getPolicyName())).thenReturn(getAuthPolicies().get(0)); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName(request.getPolicyName(),newPartner.get().getPolicyGroupId())).thenReturn(getAuthPolicies().get(0)); Mockito.when((partnerPolicyRequestRepository.findByPartnerIdAndPolicyIdAndStatusCode(Mockito.any(),Mockito.any(),Mockito.any()))).thenReturn(List.of(getPartnerPolicyRequestData())); Mockito.when(partnerRepository.findById("partner")).thenReturn(Optional.of(getPartner())); Mockito.when(partnerPolicyRepository.findByPartnerIdPolicyIdAndLabel("123456","234","unique")).thenReturn(getPartnerPolicy()); diff --git a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerServiceImplTest.java b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerServiceImplTest.java index e67bbb27d5..65f8edc990 100644 --- a/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerServiceImplTest.java +++ b/partner/partner-management-service/src/test/java/io/mosip/pms/test/partner/service/impl/PartnerServiceImplTest.java @@ -789,7 +789,7 @@ public void mapPartnerPolicyCredentialType_001() { Mockito.when(partnerRepository.findById("12345")).thenReturn(partner); Mockito.when(authPolicyRepository.findById("12345")).thenReturn(Optional.of(createAuthPolicy())); Mockito.when(authPolicyRepository - .findByPolicyGroupAndName(Mockito.anyString(), Mockito.anyString())).thenReturn(createAuthPolicy()); + .findByPolicyGroupIdAndName(Mockito.anyString(), Mockito.anyString())).thenReturn(createAuthPolicy()); pserviceImpl.mapPartnerPolicyCredentialType("euin", "12345", "12345"); } @@ -879,7 +879,7 @@ public void requestForPolicyMappingTest() { Optional partner = Optional.of(createPartner(true)); partner.get().setPartnerTypeCode("Auth_Partner"); Mockito.when(partnerRepository.findById("12345")).thenReturn(partner); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","policyName")).thenReturn(createAuthPolicy()); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","policyName")).thenReturn(createAuthPolicy()); Mockito.when(partnerPolicyRequestRepository.findByPartnerIdAndPolicyId("12345","123")).thenReturn(List.of(createPartnerPolicyRequest("approved"))); pserviceImpl.requestForPolicyMapping(request, "12345"); partner.get().setPolicyGroupId(null); @@ -921,7 +921,7 @@ public void requestForPolicyMappingTest() { } partner.get().setIsActive(true); Mockito.when(partnerRepository.findById("12345")).thenReturn(partner); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","policyName")).thenReturn(null); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","policyName")).thenReturn(null); try { pserviceImpl.requestForPolicyMapping(request, "12345"); }catch (PartnerServiceException e) { @@ -929,7 +929,7 @@ public void requestForPolicyMappingTest() { } AuthPolicy authPolicy = createAuthPolicy(); authPolicy.setIsActive(false); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","policyName")).thenReturn(authPolicy); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","policyName")).thenReturn(authPolicy); try { pserviceImpl.requestForPolicyMapping(request, "12345"); }catch (PartnerServiceException e) { @@ -938,7 +938,7 @@ public void requestForPolicyMappingTest() { authPolicy = createAuthPolicy(); authPolicy.setIsActive(true); authPolicy.setValidToDate(LocalDateTime.now().minusMonths(3)); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","policyName")).thenReturn(authPolicy); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","policyName")).thenReturn(authPolicy); try { pserviceImpl.requestForPolicyMapping(request, "12345"); }catch (PartnerServiceException e) { @@ -947,7 +947,7 @@ public void requestForPolicyMappingTest() { authPolicy = createAuthPolicy(); authPolicy.setIsActive(true); authPolicy.getPolicyGroup().setIsActive(false); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","policyName")).thenReturn(authPolicy); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","policyName")).thenReturn(authPolicy); try { pserviceImpl.requestForPolicyMapping(request, "12345"); }catch (PartnerServiceException e) { @@ -1264,4 +1264,4 @@ private String caCertResponse() { } -} \ No newline at end of file +} diff --git a/partner/partner-management-service/src/main/java/io/mosip/pms/device/constant/AuditErrorCode.java b/partner/pms-common/src/main/java/io/mosip/pms/common/constant/AuditErrorCode.java similarity index 92% rename from partner/partner-management-service/src/main/java/io/mosip/pms/device/constant/AuditErrorCode.java rename to partner/pms-common/src/main/java/io/mosip/pms/common/constant/AuditErrorCode.java index da40be9511..01946e66e2 100644 --- a/partner/partner-management-service/src/main/java/io/mosip/pms/device/constant/AuditErrorCode.java +++ b/partner/pms-common/src/main/java/io/mosip/pms/common/constant/AuditErrorCode.java @@ -1,4 +1,4 @@ -package io.mosip.pms.device.constant; +package io.mosip.pms.common.constant; public enum AuditErrorCode { diff --git a/partner/pms-common/src/main/java/io/mosip/pms/common/repository/AuthPolicyRepository.java b/partner/pms-common/src/main/java/io/mosip/pms/common/repository/AuthPolicyRepository.java index 65344ae87b..1447139201 100644 --- a/partner/pms-common/src/main/java/io/mosip/pms/common/repository/AuthPolicyRepository.java +++ b/partner/pms-common/src/main/java/io/mosip/pms/common/repository/AuthPolicyRepository.java @@ -13,7 +13,7 @@ public interface AuthPolicyRepository extends JpaRepository{ @Query(value = "select * from auth_policy ap where ap.policy_group_id=?1 and ap.name = ?2",nativeQuery = true) - AuthPolicy findByPolicyGroupAndName(String policyGroupId, String name); + AuthPolicy findByPolicyGroupIdAndName(String policyGroupId, String name); @Query(value = "select * from auth_policy ap where ap.policy_group_id=?1 and ap.id = ?2",nativeQuery = true) AuthPolicy findByPolicyGroupAndId(String policyGroupId, String policyId); diff --git a/partner/pms-common/src/main/java/io/mosip/pms/common/util/AuthenticationContextRefUtil.java b/partner/pms-common/src/main/java/io/mosip/pms/common/util/AuthenticationContextRefUtil.java index 7b7ffadef9..7dd73b3807 100644 --- a/partner/pms-common/src/main/java/io/mosip/pms/common/util/AuthenticationContextRefUtil.java +++ b/partner/pms-common/src/main/java/io/mosip/pms/common/util/AuthenticationContextRefUtil.java @@ -101,7 +101,7 @@ private Map, String> getAllClaims() { Map, String> claimsMap = new HashMap<>(); List allowedClaims = getSupportedClaims(); for(String claim:allowedClaims) { - if(map.get(claim).getValue()!=null) { + if(map.containsKey(claim)) { claimsMap.put(convertStringToList(map.get(claim).getValue()),claim); } } @@ -166,4 +166,4 @@ public Set getPolicySupportedClaims(Set claimsFromPolicy) { private List convertStringToList(String commaSeparatedString){ return Arrays.asList(commaSeparatedString.split(",")); } -} \ No newline at end of file +} diff --git a/partner/policy-management-service/src/main/java/io/mosip/pms/policy/service/PolicyManagementService.java b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/service/PolicyManagementService.java index a1e237d646..95ab0c591c 100644 --- a/partner/policy-management-service/src/main/java/io/mosip/pms/policy/service/PolicyManagementService.java +++ b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/service/PolicyManagementService.java @@ -294,7 +294,7 @@ public PolicyCreateResponseDto updatePolicies(PolicyUpdateRequestDto requestDto, throw new PolicyManagementServiceException(ErrorMessages.PUBLISHED_POLICY_NOT_UPDATED.getErrorCode(), ErrorMessages.PUBLISHED_POLICY_NOT_UPDATED.getErrorMessage()); } - AuthPolicy mappedPolicy = authPolicyRepository.findByPolicyGroupAndName(policyGroup.getId(), + AuthPolicy mappedPolicy = authPolicyRepository.findByPolicyGroupIdAndName(policyGroup.getId(), requestDto.getName()); if (mappedPolicy != null && !mappedPolicy.getName().equals(authPolicy.getName())) { auditUtil.setAuditRequestDto(PolicyManageEnum.UPDATE_POLICY_FAILURE, requestDto.getName(), "policyName"); @@ -354,7 +354,7 @@ private PolicyGroupCreateResponseDto savePolicyGroup(PolicyGroup policyGroup) { * @return */ private void validateAuthPolicyName(String policyGroupId, String auth_policy_name) { - AuthPolicy auth_policy_by_name = authPolicyRepository.findByPolicyGroupAndName(policyGroupId, auth_policy_name); + AuthPolicy auth_policy_by_name = authPolicyRepository.findByPolicyGroupIdAndName(policyGroupId, auth_policy_name); if (auth_policy_by_name != null) { auditUtil.setAuditRequestDto(PolicyManageEnum.CREATE_POLICY_FAILURE, auth_policy_name, "policyName"); throw new PolicyManagementServiceException( @@ -445,7 +445,7 @@ private PolicyResponseDto mapPolicyAndPolicyGroup(AuthPolicy authPolicy) private PolicyCreateResponseDto savePolicy(JSONObject policyJson, String oldPolicyName, String newPolicyName, String policyDesc, String policyGroupId, String policyType, String policyGroupName, String version, String authPolicyId) throws PolicyManagementServiceException, Exception { - AuthPolicy authPolicy = authPolicyRepository.findByPolicyGroupAndName(policyGroupId, oldPolicyName); + AuthPolicy authPolicy = authPolicyRepository.findByPolicyGroupIdAndName(policyGroupId, oldPolicyName); if (authPolicy != null) { authPolicy.setId(authPolicy.getId()); authPolicy.setDescr(policyDesc); @@ -1049,4 +1049,4 @@ public List getActivePolicyDetailsByGroupName(String policyGro return policiesByGroupName; } -} \ No newline at end of file +} diff --git a/partner/policy-management-service/src/main/java/io/mosip/pms/policy/util/AuditUtil.java b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/util/AuditUtil.java index 3869a8a8be..496bb38e24 100644 --- a/partner/policy-management-service/src/main/java/io/mosip/pms/policy/util/AuditUtil.java +++ b/partner/policy-management-service/src/main/java/io/mosip/pms/policy/util/AuditUtil.java @@ -11,27 +11,37 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; -import org.springframework.http.MediaType; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.HttpServerErrorException; +import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.RestTemplate; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import io.mosip.kernel.core.authmanager.authadapter.model.AuthUserDetails; +import io.mosip.kernel.core.authmanager.exception.AuthNException; +import io.mosip.kernel.core.authmanager.exception.AuthZException; import io.mosip.kernel.core.exception.ExceptionUtils; import io.mosip.kernel.core.exception.ServiceError; import io.mosip.kernel.core.http.RequestWrapper; import io.mosip.kernel.core.http.ResponseWrapper; import io.mosip.kernel.core.logger.spi.Logger; import io.mosip.kernel.core.util.DateUtils; +import io.mosip.pms.common.constant.AuditErrorCode; import io.mosip.pms.common.exception.ValidationException; import io.mosip.pms.common.util.PMSLogger; import io.mosip.pms.common.util.RestUtil; import io.mosip.pms.policy.dto.AuditRequestDto; import io.mosip.pms.policy.dto.AuditResponseDto; import io.mosip.pms.policy.dto.PolicyManageEnum; +import io.mosip.pms.policy.errorMessages.PolicyManagementServiceException; @Component @@ -122,16 +132,18 @@ public void setAuditRequestDto(PolicyManageEnum PartnerManageEnum, String refId callAuditManager(auditRequestDto); } - private void callAuditManager(AuditRequestDto auditRequestDto) { + private void callAuditManager(AuditRequestDto auditRequestDto) { RequestWrapper auditReuestWrapper = new RequestWrapper<>(); auditReuestWrapper.setRequest(auditRequestDto); HttpEntity> httpEntity = new HttpEntity<>(auditReuestWrapper); - String response =null; + ResponseEntity response =null; try { - response = restUtil.postApi(auditUrl, null, "", "", MediaType.APPLICATION_JSON, httpEntity, String.class); - getAuditDetailsFromResponse(response); - } catch (Exception ex) { - log.error("Error occured while calling audit service", ex); + response = restTemplate.exchange(auditUrl, HttpMethod.POST, httpEntity, String.class); + getAuditDetailsFromResponse(response.getBody()); + } catch (HttpClientErrorException | HttpServerErrorException ex) { + handlException( ex); + } catch (Exception e) { + log.error("Failed to get response from audit manager", e); } } @@ -150,7 +162,8 @@ private AuditResponseDto getAuditDetailsFromResponse(String responseBody) throws }); auditResponseDto = responseObject.getResponse(); } catch (IOException | NullPointerException exception) { - throw exception; + throw new PolicyManagementServiceException(AuditErrorCode.AUDIT_PARSE_EXCEPTION.getErrorCode(), + AuditErrorCode.AUDIT_PARSE_EXCEPTION.getErrorMessage()); } return auditResponseDto; @@ -167,4 +180,27 @@ private String getUserId() { return SecurityContextHolder.getContext().getAuthentication().getName(); } } -} \ No newline at end of file + + private void handlException(HttpStatusCodeException ex) { + List validationErrorsList = ExceptionUtils.getServiceErrorList(ex.getResponseBodyAsString()); + + if (ex.getRawStatusCode() == 401) { + if (!validationErrorsList.isEmpty()) { + throw new AuthNException(validationErrorsList); + } else { + throw new BadCredentialsException("Authentication failed from AuthManager"); + } + } + if (ex.getRawStatusCode() == 403) { + if (!validationErrorsList.isEmpty()) { + throw new AuthZException(validationErrorsList); + } else { + throw new AccessDeniedException("Access denied from AuthManager"); + } + } + throw new PolicyManagementServiceException(AuditErrorCode.AUDIT_EXCEPTION.getErrorCode(), + AuditErrorCode.AUDIT_EXCEPTION.getErrorMessage() + ex); + + } + +} diff --git a/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/service/PolicyServiceTest.java b/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/service/PolicyServiceTest.java index 30155ea3c9..a2456cec2a 100644 --- a/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/service/PolicyServiceTest.java +++ b/partner/policy-management-service/src/test/java/io/mosip/pms/policy/test/service/PolicyServiceTest.java @@ -338,7 +338,7 @@ public void createPoliciesTest_S004() throws PolicyManagementServiceException, E PolicyCreateRequestDto request = createPoliciesRequest(); request.setPolicyType("Data_Share"); Mockito.when(policyGroupRepository.findByName("Test_Policy_Group_001")).thenReturn(policyGroupData()); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","Test_001")).thenReturn(getAuthPolicy()); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","Test_001")).thenReturn(getAuthPolicy()); service.createPolicies(request); } @@ -376,7 +376,7 @@ public void createPoliciesTest_S007() throws PolicyManagementServiceException, E Mockito.when(mapper.readValue(new URL("http://localhost:8999/schema"), JsonNode.class)).thenReturn(actualObj); Mockito.when(policyGroupRepository.findByName("Test_Policy_Group_001")).thenReturn(policyGroupData()); Mockito.when(authPolicyRepository.findByName("Test")).thenReturn(getAuthPolicy()); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345","Test")).thenReturn(getAuthPolicy()); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345","Test")).thenReturn(getAuthPolicy()); try { service.createPolicies(request); }catch (PolicyManagementServiceException e) { @@ -571,7 +571,7 @@ public void updatePolicies_PolicyNameDuplicateTest() throws PolicyManagementServ AuthPolicy authPolicyName = getAuthPolicy(); authPolicyName.getPolicyGroup().setId("12345"); authPolicyName.setName("Test_01"); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(authPolicyName); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(authPolicyName); service.updatePolicies(request, "12345"); } @@ -597,7 +597,7 @@ public void updatePolicies_Test_01() throws PolicyManagementServiceException, Ex AuthPolicy authPolicyName = getAuthPolicy(); authPolicyName.getPolicyGroup().setId("12345"); authPolicyName.setName("Test_01"); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(authPolicyName); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(authPolicyName); service.updatePolicies(request, "12345"); } @@ -625,7 +625,7 @@ public void updatePolicies_Test_02() throws PolicyManagementServiceException, Ex authPolicyName.setPolicySchema("localhost"); authPolicyName.getPolicyGroup().setId("12345"); authPolicyName.setName("Test_01"); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(authPolicyName); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(authPolicyName); service.updatePolicies(request, "12345"); } @@ -654,7 +654,7 @@ public void updatePolicies_Test_03() throws PolicyManagementServiceException, Ex authPolicyName.getPolicyGroup().setId("12345"); authPolicyName.setName("Test_01"); authPolicyName.setPolicy_type("Auth"); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(authPolicyName); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(authPolicyName); ObjectMapper objectMapper = new ObjectMapper(); JsonNode actualObj = objectMapper.readTree(authPolicySchema); Mockito.when(mapper.readValue(new URL("http://localhost:8999/schema"), JsonNode.class)).thenReturn(actualObj); @@ -686,7 +686,7 @@ public void updatePolicies_Test_04() throws PolicyManagementServiceException, Ex authPolicyName.getPolicyGroup().setId("12345"); authPolicyName.setName("Test_01"); authPolicyName.setPolicy_type("Auth"); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test_01")).thenReturn(authPolicyName); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test_01")).thenReturn(authPolicyName); ObjectMapper objectMapper = new ObjectMapper(); JsonNode actualObj = objectMapper.readTree(authPolicySchema); Mockito.when(mapper.readValue(new URL("http://localhost:8999/schema"), JsonNode.class)).thenReturn(actualObj); @@ -738,7 +738,7 @@ public void publishPolicy_PolicyPublishedTest() throws JsonParseException, JsonM Mockito.when(authPolicyRepository.findByName("Test")).thenReturn(authPolicy); Optional policy = Optional.of(policyGroup); Mockito.when(policyGroupRepository.findByName("Test")).thenReturn(policy.get()); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(getAuthPolicy()); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(getAuthPolicy()); service.publishPolicy("Test", "Test"); } @@ -762,7 +762,7 @@ public void publishPolicyTest() throws JsonParseException, JsonMappingException, Mockito.when(authPolicyRepository.findById("Test")).thenReturn(Optional.of(authPolicy)); Optional policy = Optional.of(policyGroup); Mockito.when(policyGroupRepository.findById("Test")).thenReturn(policy); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(getAuthPolicy()); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(getAuthPolicy()); Mockito.when(policyGroupRepository.findById("12345")).thenReturn(policy); service.publishPolicy("Test", "Test"); } @@ -788,7 +788,7 @@ public void publishPolicyTest_02() throws JsonParseException, JsonMappingExcepti Mockito.when(authPolicyRepository.findById("Test")).thenReturn(Optional.of(authPolicy)); Optional policy = Optional.of(policyGroup); Mockito.when(policyGroupRepository.findById("Test")).thenReturn(policy); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(getAuthPolicy()); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(getAuthPolicy()); Mockito.when(policyGroupRepository.findById("12345")).thenReturn(policy); try { service.publishPolicy("Test", "Test"); @@ -821,7 +821,7 @@ public void publishPolicyTest_01() throws JsonParseException, JsonMappingExcepti AuthPolicy authPolicy01 = getAuthPolicy(); authPolicy01.setIsActive(false); authPolicy01.setPolicySchema("localhost"); - Mockito.when(authPolicyRepository.findByPolicyGroupAndName("12345", "Test")).thenReturn(authPolicy01); + Mockito.when(authPolicyRepository.findByPolicyGroupIdAndName("12345", "Test")).thenReturn(authPolicy01); Mockito.when(policyGroupRepository.findById("12345")).thenReturn(policy); service.publishPolicy("Test", "Test"); } diff --git a/partner/policy-validator/src/main/java/io/mosip/pms/policy/validator/constants/PolicyValidatorErrorConstant.java b/partner/policy-validator/src/main/java/io/mosip/pms/policy/validator/constants/PolicyValidatorErrorConstant.java index ea8db37fac..1811515f6a 100644 --- a/partner/policy-validator/src/main/java/io/mosip/pms/policy/validator/constants/PolicyValidatorErrorConstant.java +++ b/partner/policy-validator/src/main/java/io/mosip/pms/policy/validator/constants/PolicyValidatorErrorConstant.java @@ -9,9 +9,9 @@ public enum PolicyValidatorErrorConstant { INVALID_POLICY_SCHEMA("PMS_PV_004", "Invalid policy schema"), - INVALID_INPUT_PARAMETER("PMS_PV_005", "Invalid input parameter - %s"), + INVALID_INPUT_PARAMETER("PMS_PV_005", "Invalid input parameter - %s in policy data"), - MISSING_INPUT_PARAMETER("PMS_PV_006", "Missing input parameter - %s"); + MISSING_INPUT_PARAMETER("PMS_PV_006", "Missing input parameter - %s in policy data"); private final String errorCode;