adding terraform and terragrunt files
This commit is contained in:
parent
39a36b8824
commit
3740172ef2
|
|
@ -0,0 +1,143 @@
|
|||
name: Deploy CD with Multitenancy-header
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
secrets:
|
||||
INNER_SOURCE_ACTIONS_APP_ID:
|
||||
required: true
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64:
|
||||
required: true
|
||||
GH_PAT_TOKEN:
|
||||
required: true
|
||||
HSDP_DOCKER_USER:
|
||||
required: true
|
||||
HSDP_DOCKER_PASSWORD:
|
||||
required: true
|
||||
CODESCENE_CI_CD_GITHUB_TOKEN:
|
||||
required: true
|
||||
ARM_CLIENT_ID:
|
||||
required: true
|
||||
ARM_CLIENT_SECRET:
|
||||
required: true
|
||||
|
||||
env:
|
||||
TF_IN_AUTOMATION: true
|
||||
ARM_SUBSCRIPTION_ID: 74d03f75-4bdb-4666-8095-500178a40764
|
||||
ARM_TENANT_ID: 1a407a2d-7675-4d17-8692-b3ac285306e4
|
||||
jobs:
|
||||
terragrunt-workflow-core:
|
||||
name: Terragrunt - core
|
||||
runs-on: ubuntu-20.04
|
||||
container: alpine/terragrunt:1.0.1
|
||||
outputs:
|
||||
core: ${{ steps.tf_output.outputs.core }}
|
||||
env:
|
||||
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
|
||||
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./deploy/CD/core
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- id: inner-source-action
|
||||
uses: ./.github/workflows/innersource-action
|
||||
with:
|
||||
GH_PAT_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
|
||||
INNER_SOURCE_ACTIONS_APP_ID: ${{ secrets.INNER_SOURCE_ACTIONS_APP_ID }}
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64: ${{ secrets.INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64 }}
|
||||
|
||||
- id: plan
|
||||
uses: ./../.actions/terragrunt-plan-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/core
|
||||
key: client-test-core-plan
|
||||
|
||||
- id: apply
|
||||
uses: ./../.actions/terragrunt-apply-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/core
|
||||
key: client-test-core-plan
|
||||
|
||||
- id: output
|
||||
uses: ./.github/workflows/terragrunt-output-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/core
|
||||
key: client-test-core-output
|
||||
|
||||
terragrunt-workflow-cloudfoundry:
|
||||
name: Terragrunt - cloudfoundry
|
||||
runs-on: ubuntu-20.04
|
||||
needs: [terragrunt-workflow-core]
|
||||
container: alpine/terragrunt:1.0.1
|
||||
env:
|
||||
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
|
||||
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./deploy/CD/cloudfoundry
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- id: inner-source-action
|
||||
uses: ./.github/workflows/innersource-action
|
||||
with:
|
||||
GH_PAT_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
|
||||
INNER_SOURCE_ACTIONS_APP_ID: ${{ secrets.INNER_SOURCE_ACTIONS_APP_ID }}
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64: ${{ secrets.INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64 }}
|
||||
|
||||
- id: plan
|
||||
uses: ./../.actions/terragrunt-plan-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/cloudfoundry
|
||||
key: client-test-cloudfoundry-plan
|
||||
|
||||
- id: apply
|
||||
uses: ./../.actions/terragrunt-apply-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/cloudfoundry
|
||||
key: client-test-cloudfoundry-plan
|
||||
|
||||
terragrunt-workflow-api-gateway:
|
||||
name: Terragrunt - api-gateway
|
||||
runs-on: ubuntu-20.04
|
||||
needs: [terragrunt-workflow-cloudfoundry]
|
||||
container: alpine/terragrunt:1.0.1
|
||||
env:
|
||||
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
|
||||
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
|
||||
CONFIG: ./envoyconfig_with_multitenancy.yml
|
||||
SOURCE: header
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./deploy/CD/api-gateway
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- id: inner-source-action
|
||||
uses: ./.github/workflows/innersource-action
|
||||
with:
|
||||
GH_PAT_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
|
||||
INNER_SOURCE_ACTIONS_APP_ID: ${{ secrets.INNER_SOURCE_ACTIONS_APP_ID }}
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64: ${{ secrets.INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64 }}
|
||||
|
||||
- id: plan
|
||||
uses: ./../.actions/terragrunt-plan-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/api-gateway
|
||||
key: client-test-api-gateway-plan
|
||||
|
||||
- id: apply
|
||||
uses: ./../.actions/terragrunt-apply-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/api-gateway
|
||||
key: client-test-api-gateway-plan
|
||||
|
||||
- id: output
|
||||
uses: ./.github/workflows/terragrunt-output-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/api-gateway
|
||||
key: client-test-api-gateway-output
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
name: Deploy CD with Multitenancy-Url
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
secrets:
|
||||
INNER_SOURCE_ACTIONS_APP_ID:
|
||||
required: true
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64:
|
||||
required: true
|
||||
GH_PAT_TOKEN:
|
||||
required: true
|
||||
HSDP_DOCKER_USER:
|
||||
required: true
|
||||
HSDP_DOCKER_PASSWORD:
|
||||
required: true
|
||||
CODESCENE_CI_CD_GITHUB_TOKEN:
|
||||
required: true
|
||||
ARM_CLIENT_ID:
|
||||
required: true
|
||||
ARM_CLIENT_SECRET:
|
||||
required: true
|
||||
|
||||
env:
|
||||
TF_IN_AUTOMATION: true
|
||||
ARM_SUBSCRIPTION_ID: 74d03f75-4bdb-4666-8095-500178a40764
|
||||
ARM_TENANT_ID: 1a407a2d-7675-4d17-8692-b3ac285306e4
|
||||
jobs:
|
||||
terragrunt-workflow-core:
|
||||
name: Terragrunt - core
|
||||
runs-on: ubuntu-20.04
|
||||
container: alpine/terragrunt:1.0.1
|
||||
outputs:
|
||||
core: ${{ steps.tf_output.outputs.core }}
|
||||
env:
|
||||
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
|
||||
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./deploy/CD/core
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- id: inner-source-action
|
||||
uses: ./.github/workflows/innersource-action
|
||||
with:
|
||||
GH_PAT_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
|
||||
INNER_SOURCE_ACTIONS_APP_ID: ${{ secrets.INNER_SOURCE_ACTIONS_APP_ID }}
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64: ${{ secrets.INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64 }}
|
||||
|
||||
- id: plan
|
||||
uses: ./../.actions/terragrunt-plan-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/core
|
||||
key: client-test-core-plan
|
||||
|
||||
- id: apply
|
||||
uses: ./../.actions/terragrunt-apply-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/core
|
||||
key: client-test-core-plan
|
||||
|
||||
- id: output
|
||||
uses: ./.github/workflows/terragrunt-output-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/core
|
||||
key: client-test-core-output
|
||||
|
||||
terragrunt-workflow-cloudfoundry:
|
||||
name: Terragrunt - cloudfoundry
|
||||
runs-on: ubuntu-20.04
|
||||
needs: [terragrunt-workflow-core]
|
||||
container: alpine/terragrunt:1.0.1
|
||||
env:
|
||||
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
|
||||
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./deploy/CD/cloudfoundry
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- id: inner-source-action
|
||||
uses: ./.github/workflows/innersource-action
|
||||
with:
|
||||
GH_PAT_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
|
||||
INNER_SOURCE_ACTIONS_APP_ID: ${{ secrets.INNER_SOURCE_ACTIONS_APP_ID }}
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64: ${{ secrets.INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64 }}
|
||||
|
||||
- id: plan
|
||||
uses: ./../.actions/terragrunt-plan-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/cloudfoundry
|
||||
key: client-test-cloudfoundry-plan
|
||||
|
||||
- id: apply
|
||||
uses: ./../.actions/terragrunt-apply-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/cloudfoundry
|
||||
key: client-test-cloudfoundry-plan
|
||||
|
||||
terragrunt-workflow-api-gateway:
|
||||
name: Terragrunt - api-gateway
|
||||
runs-on: ubuntu-20.04
|
||||
needs: [terragrunt-workflow-cloudfoundry]
|
||||
container: alpine/terragrunt:1.0.1
|
||||
env:
|
||||
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
|
||||
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
|
||||
CONFIG: ./envoyconfig_with_multitenancy.yml
|
||||
SOURCE: url
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./deploy/CD/api-gateway
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- id: inner-source-action
|
||||
uses: ./.github/workflows/innersource-action
|
||||
with:
|
||||
GH_PAT_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
|
||||
INNER_SOURCE_ACTIONS_APP_ID: ${{ secrets.INNER_SOURCE_ACTIONS_APP_ID }}
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64: ${{ secrets.INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64 }}
|
||||
|
||||
- id: plan
|
||||
uses: ./../.actions/terragrunt-plan-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/api-gateway
|
||||
key: client-test-api-gateway-plan
|
||||
|
||||
- id: apply
|
||||
uses: ./../.actions/terragrunt-apply-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/api-gateway
|
||||
key: client-test-api-gateway-plan
|
||||
|
||||
- id: output
|
||||
uses: ./.github/workflows/terragrunt-output-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/api-gateway
|
||||
key: client-test-api-gateway-output
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
name: Deploy CD without Multitenancy
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
secrets:
|
||||
INNER_SOURCE_ACTIONS_APP_ID:
|
||||
required: true
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64:
|
||||
required: true
|
||||
GH_PAT_TOKEN:
|
||||
required: true
|
||||
HSDP_DOCKER_USER:
|
||||
required: true
|
||||
HSDP_DOCKER_PASSWORD:
|
||||
required: true
|
||||
CODESCENE_CI_CD_GITHUB_TOKEN:
|
||||
required: true
|
||||
ARM_CLIENT_ID:
|
||||
required: true
|
||||
ARM_CLIENT_SECRET:
|
||||
required: true
|
||||
|
||||
env:
|
||||
TF_IN_AUTOMATION: true
|
||||
ARM_SUBSCRIPTION_ID: 74d03f75-4bdb-4666-8095-500178a40764
|
||||
ARM_TENANT_ID: 1a407a2d-7675-4d17-8692-b3ac285306e4
|
||||
jobs:
|
||||
terragrunt-workflow-core:
|
||||
name: Terragrunt - core
|
||||
runs-on: ubuntu-20.04
|
||||
container: alpine/terragrunt:1.0.1
|
||||
outputs:
|
||||
core: ${{ steps.tf_output.outputs.core }}
|
||||
env:
|
||||
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
|
||||
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./deploy/CD/core
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- id: inner-source-action
|
||||
uses: ./.github/workflows/innersource-action
|
||||
with:
|
||||
GH_PAT_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
|
||||
INNER_SOURCE_ACTIONS_APP_ID: ${{ secrets.INNER_SOURCE_ACTIONS_APP_ID }}
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64: ${{ secrets.INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64 }}
|
||||
|
||||
- id: plan
|
||||
uses: ./../.actions/terragrunt-plan-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/core
|
||||
key: client-test-core-plan
|
||||
|
||||
- id: apply
|
||||
uses: ./../.actions/terragrunt-apply-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/core
|
||||
key: client-test-core-plan
|
||||
|
||||
- id: output
|
||||
uses: ./.github/workflows/terragrunt-output-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/core
|
||||
key: client-test-core-output
|
||||
|
||||
terragrunt-workflow-cloudfoundry:
|
||||
name: Terragrunt - cloudfoundry
|
||||
runs-on: ubuntu-20.04
|
||||
needs: [terragrunt-workflow-core]
|
||||
container: alpine/terragrunt:1.0.1
|
||||
env:
|
||||
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
|
||||
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./deploy/CD/cloudfoundry
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- id: inner-source-action
|
||||
uses: ./.github/workflows/innersource-action
|
||||
with:
|
||||
GH_PAT_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
|
||||
INNER_SOURCE_ACTIONS_APP_ID: ${{ secrets.INNER_SOURCE_ACTIONS_APP_ID }}
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64: ${{ secrets.INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64 }}
|
||||
|
||||
- id: plan
|
||||
uses: ./../.actions/terragrunt-plan-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/cloudfoundry
|
||||
key: client-test-cloudfoundry-plan
|
||||
|
||||
- id: apply
|
||||
uses: ./../.actions/terragrunt-apply-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/cloudfoundry
|
||||
key: client-test-cloudfoundry-plan
|
||||
|
||||
terragrunt-workflow-api-gateway:
|
||||
name: Terragrunt - api-gateway
|
||||
runs-on: ubuntu-20.04
|
||||
needs: [terragrunt-workflow-cloudfoundry]
|
||||
container: alpine/terragrunt:1.0.1
|
||||
env:
|
||||
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
|
||||
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
|
||||
CONFIG: ./envoyconfig_without_multitenancy.yml
|
||||
SOURCE: url
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./deploy/CD/api-gateway
|
||||
strategy:
|
||||
fail-fast: false
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- id: inner-source-action
|
||||
uses: ./.github/workflows/innersource-action
|
||||
with:
|
||||
GH_PAT_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
|
||||
INNER_SOURCE_ACTIONS_APP_ID: ${{ secrets.INNER_SOURCE_ACTIONS_APP_ID }}
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64: ${{ secrets.INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64 }}
|
||||
|
||||
- id: plan
|
||||
uses: ./../.actions/terragrunt-plan-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/api-gateway
|
||||
key: client-test-api-gateway-plan
|
||||
|
||||
- id: apply
|
||||
uses: ./../.actions/terragrunt-apply-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/api-gateway
|
||||
key: client-test-api-gateway-plan
|
||||
|
||||
- id: output
|
||||
uses: ./.github/workflows/terragrunt-output-action
|
||||
with:
|
||||
working-directory: ./deploy/CD/api-gateway
|
||||
key: client-test-api-gateway-output
|
||||
|
|
@ -0,0 +1,449 @@
|
|||
name: CD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
Init:
|
||||
name: Initialize
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Extract branch name
|
||||
uses: vazco/github-actions-branch-name@v1
|
||||
id: branch
|
||||
|
||||
Build-Automation-Solution:
|
||||
needs: [Init]
|
||||
runs-on: builder_blr
|
||||
name: Build Automation Solution
|
||||
steps:
|
||||
- name: cleanup
|
||||
run: Remove-Item ${{ github.workspace }}\* -Recurse
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.GH_TOKEN_CI }}
|
||||
- name: Add msbuild to PATH
|
||||
uses: microsoft/setup-msbuild@v1.0.2
|
||||
with:
|
||||
vs-version: '[16.4,17.0)'
|
||||
- name: Add dotnet
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '3.1.x'
|
||||
- name: msbuild execute
|
||||
run: msbuild ${{ github.workspace }}\Build\api_automation_build.proj /t:build /p:configuration=release,platform=anycpu /nowarn:MSB4011,MSB4210
|
||||
- name: push nuget to artifactory
|
||||
run: dotnet nuget push ${{ github.workspace }}\AutomationTest\**\*.nupkg -s JFrogrepository --skip-duplicate
|
||||
|
||||
DeployCDWithoutMultitenancy:
|
||||
if: github.ref == 'refs/heads/terraform'
|
||||
needs: [Init]
|
||||
uses: ./.github/workflows/cd-deploy-without-multitenancy.yml
|
||||
secrets:
|
||||
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
|
||||
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
|
||||
HSDP_DOCKER_USER: ${{ secrets.HSDP_DOCKER_USER }}
|
||||
HSDP_DOCKER_PASSWORD: ${{ secrets.HSDP_DOCKER_PASSWORD }}
|
||||
CODESCENE_CI_CD_GITHUB_TOKEN: ${{ secrets.CODESCENE_CI_CD_GITHUB_TOKEN }}
|
||||
INNER_SOURCE_ACTIONS_APP_ID: ${{ secrets.INNER_SOURCE_ACTIONS_APP_ID }}
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64: ${{ secrets.INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64 }}
|
||||
GH_PAT_TOKEN: ${{secrets.GH_PAT_TOKEN}}
|
||||
|
||||
CI-Automation-Variables:
|
||||
if: github.ref == 'refs/heads/terraform'
|
||||
needs: [DeployCDWithoutMultitenancy]
|
||||
runs-on: ubuntu-20.04
|
||||
outputs:
|
||||
oauth_client_secret: ${{ steps.core-output.outputs.oauth_client_secret }}
|
||||
ci_service_private_key: ${{ steps.core-output.outputs.ci_service_private_key }}
|
||||
envoy_base_url: "https://${{ steps.gateway-output.outputs.gateway_url }}"
|
||||
deploy_user: ${{ steps.core-output.outputs.deploy_user }}
|
||||
deploy_password: ${{ steps.core-output.outputs.deploy_password }}
|
||||
ci_service_id: ${{ steps.core-output.outputs.ci_service_id }}
|
||||
oauth_client_id: ${{ steps.core-output.outputs.oauth_client_id }}
|
||||
steps:
|
||||
- name: Download Core output
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: client-test-core-output
|
||||
path: ${{ github.workspace}}/output/core
|
||||
- name: Download Gateway output
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: client-test-api-gateway-output
|
||||
path: ${{ github.workspace}}/output/gateway
|
||||
- name: Get Outputs from Core module
|
||||
working-directory: ${{ github.workspace}}/output/core
|
||||
id: core-output
|
||||
shell: bash
|
||||
run: |
|
||||
apt update && apt install jq -y
|
||||
core_output=$(cat output.json)
|
||||
|
||||
oauth_client_secret=$(echo $core_output | jq -r '.fdn_envoy_oauth_client_password.value')
|
||||
ci_service_private_key=$(echo $core_output | jq -r '.foundation_envoy_nightly_service_private_key.value')
|
||||
deploy_user=$(echo $core_output | jq -r '.cf_deploy_user.value')
|
||||
deploy_password=$(echo $core_output | jq -r '.cf_deploy_password.value')
|
||||
ci_service_id=$(echo $core_output | jq -r '.foundation_envoy_nightly_service_id.value')
|
||||
oauth_client_id=$(echo $core_output | jq -r '.fdn_envoy_oauth_client_id.value')
|
||||
|
||||
echo "::set-output name=oauth_client_secret::$oauth_client_secret"
|
||||
echo "::set-output name=ci_service_private_key::$ci_service_private_key"
|
||||
echo "::set-output name=oauth_client_id::$oauth_client_id"
|
||||
echo "::set-output name=deploy_user::$deploy_user"
|
||||
echo "::set-output name=deploy_password::$deploy_password"
|
||||
echo "::set-output name=ci_service_id::$ci_service_id"
|
||||
|
||||
- name: Get Outputs from Api Gateway
|
||||
working-directory: ${{ github.workspace}}/output/gateway
|
||||
id: gateway-output
|
||||
shell: bash
|
||||
run: |
|
||||
apt update && apt install jq -y
|
||||
output=$(cat output.json)
|
||||
|
||||
gateway_url=$(echo $output | jq -r '.api_gateway_url.value')
|
||||
echo $gateway_url
|
||||
|
||||
echo "::set-output name=gateway_url::$gateway_url"
|
||||
|
||||
TestwithoutMultitenancy:
|
||||
if: github.ref == 'refs/heads/terraform'
|
||||
needs: [Build-Automation-Solution, CI-Automation-Variables, DeployCDWithoutMultitenancy]
|
||||
runs-on: builder_blr
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.GH_TOKEN_CI }}
|
||||
|
||||
- name: Add dotnet
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '3.1.x'
|
||||
|
||||
- name: Restore Automation Test Project
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: |
|
||||
dotnet restore ${{ github.workspace }}\AutomationTest\automation.packages.proj --packages ./automation-dll
|
||||
|
||||
- uses: microsoft/variable-substitution@v1
|
||||
name: Update Env Json
|
||||
with:
|
||||
files: ${{ github.workspace }}/automation-dll/philips.edi.foundation.apigateway.automationtest/1.0.3/lib/net3.1/Env.json
|
||||
env:
|
||||
PipelineConfiguration.AuthUserName: "sai.chand@philips.com"
|
||||
PipelineConfiguration.AuthPassword: ${{ secrets.IAM_TEST_USER_PASSWORD }}
|
||||
PipelineConfiguration.APIGatewayBaseUrl: "https://envoycd-api-gateway.us-east.philips-healthsuite.com"
|
||||
PipelineConfiguration.ServiceID: ${{ needs.CI-Automation-Variables.outputs.ci_service_id }}
|
||||
PipelineConfiguration.ServiceIDPrivateKey: ${{ needs.CI-Automation-Variables.outputs.ci_service_private_key }}
|
||||
PipelineConfiguration.OauthClientID: ${{ needs.CI-Automation-Variables.outputs.oauth_client_id }}
|
||||
PipelineConfiguration.OauthClientSecret: ${{ needs.CI-Automation-Variables.outputs.oauth_client_secret }}
|
||||
PipelineConfiguration.CFOrgName: "client-EDI-SolutionAccelerator"
|
||||
PipelineConfiguration.CFSpaceName: "envoycd"
|
||||
PipelineConfiguration.CFUserName: ${{ secrets.CF_USERNAME }}
|
||||
PipelineConfiguration.CFPassword: ${{ secrets.CF_PASSWD }}
|
||||
PipelineConfiguration.CookieName: "edi_session_envoycd"
|
||||
PipelineConfiguration.CFOauthTokenUrl: "https://login.cloud.pcftest.com/oauth/token"
|
||||
PipelineConfiguration.CFBaseUrl: "https://api.cloud.pcftest.com/v3"
|
||||
PipelineConfiguration.CFAuthenticatorAppName: "authenticator_service"
|
||||
PipelineConfiguration.OauthProxyCookieTimeoutInSeconds: "25"
|
||||
PipelineConfiguration.AuthenticatorSessionExpireOffsetInPercent: "99"
|
||||
PipelineConfiguration.AccessTokenTestRoleName: "ENVOY-NIGHTLY-SERVICE-TF"
|
||||
PipelineConfiguration.OpenIdConfigurationBaseUrl: "https://foundation-client-test.us-east.philips-healthsuite.com"
|
||||
PipelineConfiguration.OrgSymmetricKey: ${{ secrets.ORG_SYMMETRIC_KEY }}
|
||||
PipelineConfiguration.OpenIdConfigOrganizationCertificateMapping: '[{"organizationId":"ed186a39-8b5f-4351-bebc-4e17779c293b","certificate":"-----BEGIN CERTIFICATE-----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-----END CERTIFICATE-----"},{"organizationId":"51e2503f-c1df-430d-a1ce-2524fa796cda","certificate":"-----BEGIN CERTIFICATE-----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-----END CERTIFICATE-----"}]'
|
||||
PipelineConfiguration.SSOTokenUserName: "user"
|
||||
PipelineConfiguration.TenantDetails: '{"ValidTenant": {"tenantName": "org1-envoycd-api-gateway", "iamOrganizationId": "51e2503f-c1df-430d-a1ce-2524fa796cda"}, "InvalidTenant":{"tenantName": "invalidorg-envoycd-api-gateway","iamOrganizationId": "1234"},"AccessTokenTenant":{"tenantName": "accesstokentestorg","iamOrganizationId": "db3ba3e1-b333-4528-80d0-41b0eeb533b0"}}'
|
||||
PipelineConfiguration.IAMAuthorizationUrl: "https://iam-client-test.us-east.philips-healthsuite.com/authorize/oauth2/token"
|
||||
PipelineConfiguration.IAMAccessTokenUrl: "https://iam-client-test.us-east.philips-healthsuite.com/oauth2/access_token"
|
||||
PipelineConfiguration.IDMClientBaseUrl: "https://idm-client-test.us-east.philips-healthsuite.com/authorize/identity"
|
||||
PipelineConfiguration.IAMGetUserUrl: "https://idm-client-test.us-east.philips-healthsuite.com/authorize/identity/User?profileType=membership&userId="
|
||||
PipelineConfiguration.CDRBaseUrl: "https://cdr-edisa-test.us-east.philips-healthsuite.com"
|
||||
|
||||
- name: Run Tests
|
||||
continue-on-error: true
|
||||
working-directory: ${{ github.workspace }}/automation-dll/philips.edi.foundation.apigateway.automationtest
|
||||
run: |
|
||||
dotnet test **/net3.1/*Test.dll --no-restore --filter TestCategory=PostDeployment --results-directory ${{ github.workspace }}/automation-dll/philips.edi.foundation.apigateway.automationtest/TestResults --logger trx
|
||||
dotnet test **/net3.1/*Test.dll --no-restore --filter TestCategory=WithoutMultitenancy --results-directory ${{ github.workspace }}/automation-dll/philips.edi.foundation.apigateway.automationtest/TestResults --logger trx
|
||||
|
||||
- name: email-notification
|
||||
continue-on-error: true
|
||||
working-directory: ${{ github.workspace }}/Build/PS
|
||||
run: |
|
||||
powershell -ExecutionPolicy RemoteSigned -NoExit -File email-notification.ps1 -BuildNumber ${{ github.run_id }} -ReportFolder ${{ github.workspace }}/automation-dll/philips.edi.foundation.apigateway.automationtest/TestResults -Subject Api-Gateway-WithoutMultitenancy
|
||||
|
||||
|
||||
DeployCDWithMultitenancyurl:
|
||||
if: github.ref == 'refs/heads/terraform'
|
||||
needs: [TestwithoutMultitenancy]
|
||||
uses: ./.github/workflows/cd-deploy-with-multitenancy-url.yml
|
||||
secrets:
|
||||
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
|
||||
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
|
||||
HSDP_DOCKER_USER: ${{ secrets.HSDP_DOCKER_USER }}
|
||||
HSDP_DOCKER_PASSWORD: ${{ secrets.HSDP_DOCKER_PASSWORD }}
|
||||
CODESCENE_CI_CD_GITHUB_TOKEN: ${{ secrets.CODESCENE_CI_CD_GITHUB_TOKEN }}
|
||||
INNER_SOURCE_ACTIONS_APP_ID: ${{ secrets.INNER_SOURCE_ACTIONS_APP_ID }}
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64: ${{ secrets.INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64 }}
|
||||
GH_PAT_TOKEN: ${{secrets.GH_PAT_TOKEN}}
|
||||
|
||||
CI-Automation-Variablesurl:
|
||||
if: github.ref == 'refs/heads/terraform'
|
||||
needs: [DeployCDWithMultitenancyurl]
|
||||
runs-on: ubuntu-20.04
|
||||
outputs:
|
||||
oauth_client_secret: ${{ steps.core-output.outputs.oauth_client_secret }}
|
||||
ci_service_private_key: ${{ steps.core-output.outputs.ci_service_private_key }}
|
||||
envoy_base_url: "https://${{ steps.gateway-output.outputs.gateway_url }}"
|
||||
deploy_user: ${{ steps.core-output.outputs.deploy_user }}
|
||||
deploy_password: ${{ steps.core-output.outputs.deploy_password }}
|
||||
ci_service_id: ${{ steps.core-output.outputs.ci_service_id }}
|
||||
oauth_client_id: ${{ steps.core-output.outputs.oauth_client_id }}
|
||||
steps:
|
||||
- name: Download Core output
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: client-test-core-output
|
||||
path: ${{ github.workspace}}/output/core
|
||||
- name: Download Gateway output
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: client-test-api-gateway-output
|
||||
path: ${{ github.workspace}}/output/gateway
|
||||
- name: Get Outputs from Core module
|
||||
working-directory: ${{ github.workspace}}/output/core
|
||||
id: core-output
|
||||
shell: bash
|
||||
run: |
|
||||
apt update && apt install jq -y
|
||||
core_output=$(cat output.json)
|
||||
|
||||
oauth_client_secret=$(echo $core_output | jq -r '.fdn_envoy_oauth_client_password.value')
|
||||
ci_service_private_key=$(echo $core_output | jq -r '.foundation_envoy_nightly_service_private_key.value')
|
||||
deploy_user=$(echo $core_output | jq -r '.cf_deploy_user.value')
|
||||
deploy_password=$(echo $core_output | jq -r '.cf_deploy_password.value')
|
||||
ci_service_id=$(echo $core_output | jq -r '.foundation_envoy_nightly_service_id.value')
|
||||
oauth_client_id=$(echo $core_output | jq -r '.fdn_envoy_oauth_client_id.value')
|
||||
|
||||
echo "::set-output name=oauth_client_secret::$oauth_client_secret"
|
||||
echo "::set-output name=ci_service_private_key::$ci_service_private_key"
|
||||
echo "::set-output name=oauth_client_id::$oauth_client_id"
|
||||
echo "::set-output name=deploy_user::$deploy_user"
|
||||
echo "::set-output name=deploy_password::$deploy_password"
|
||||
echo "::set-output name=ci_service_id::$ci_service_id"
|
||||
|
||||
- name: Get Outputs from Api Gateway
|
||||
working-directory: ${{ github.workspace}}/output/gateway
|
||||
id: gateway-output
|
||||
shell: bash
|
||||
run: |
|
||||
apt update && apt install jq -y
|
||||
output=$(cat output.json)
|
||||
|
||||
gateway_url=$(echo $output | jq -r '.api_gateway_url.value')
|
||||
echo $gateway_url
|
||||
|
||||
echo "::set-output name=gateway_url::$gateway_url"
|
||||
|
||||
TestwithMultitenancyurl:
|
||||
if: github.ref == 'refs/heads/terraform'
|
||||
needs: [Build-Automation-Solution, CI-Automation-Variablesurl, DeployCDWithMultitenancyurl]
|
||||
runs-on: builder_blr
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.GH_TOKEN_CI }}
|
||||
|
||||
- name: Add dotnet
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '3.1.x'
|
||||
|
||||
- name: Restore Automation Test Project
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: |
|
||||
dotnet restore ${{ github.workspace }}\AutomationTest\automation.packages.proj --packages ./automation-dll
|
||||
|
||||
- uses: microsoft/variable-substitution@v1
|
||||
name: Update Env Json
|
||||
with:
|
||||
files: ${{ github.workspace }}/automation-dll/philips.edi.foundation.apigateway.automationtest/1.0.3/lib/net3.1/Env.json
|
||||
env:
|
||||
PipelineConfiguration.AuthUserName: "sai.chand@philips.com"
|
||||
PipelineConfiguration.AuthPassword: ${{ secrets.IAM_TEST_USER_PASSWORD }}
|
||||
PipelineConfiguration.APIGatewayBaseUrl: "https://envoycd-api-gateway.us-east.philips-healthsuite.com"
|
||||
PipelineConfiguration.ServiceID: ${{ needs.CI-Automation-Variables.outputs.ci_service_id }}
|
||||
PipelineConfiguration.ServiceIDPrivateKey: ${{ needs.CI-Automation-Variables.outputs.ci_service_private_key }}
|
||||
PipelineConfiguration.OauthClientID: ${{ needs.CI-Automation-Variables.outputs.oauth_client_id }}
|
||||
PipelineConfiguration.OauthClientSecret: ${{ needs.CI-Automation-Variables.outputs.oauth_client_secret }}
|
||||
PipelineConfiguration.CFOrgName: "client-EDI-SolutionAccelerator"
|
||||
PipelineConfiguration.CFSpaceName: "envoycd"
|
||||
PipelineConfiguration.CFUserName: ${{ secrets.CF_USERNAME }}
|
||||
PipelineConfiguration.CFPassword: ${{ secrets.CF_PASSWD }}
|
||||
PipelineConfiguration.CookieName: "edi_session_envoycd"
|
||||
PipelineConfiguration.CFOauthTokenUrl: "https://login.cloud.pcftest.com/oauth/token"
|
||||
PipelineConfiguration.CFBaseUrl: "https://api.cloud.pcftest.com/v3"
|
||||
PipelineConfiguration.CFAuthenticatorAppName: "authenticator_service"
|
||||
PipelineConfiguration.OauthProxyCookieTimeoutInSeconds: "25"
|
||||
PipelineConfiguration.AuthenticatorSessionExpireOffsetInPercent: "99"
|
||||
PipelineConfiguration.AccessTokenTestRoleName: "ENVOY-NIGHTLY-SERVICE-TF"
|
||||
PipelineConfiguration.OpenIdConfigurationBaseUrl: "https://foundation-client-test.us-east.philips-healthsuite.com"
|
||||
PipelineConfiguration.OrgSymmetricKey: ${{ secrets.ORG_SYMMETRIC_KEY }}
|
||||
PipelineConfiguration.OpenIdConfigOrganizationCertificateMapping: '[{"organizationId":"ed186a39-8b5f-4351-bebc-4e17779c293b","certificate":"-----BEGIN CERTIFICATE-----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-----END CERTIFICATE-----"},{"organizationId":"51e2503f-c1df-430d-a1ce-2524fa796cda","certificate":"-----BEGIN CERTIFICATE-----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-----END CERTIFICATE-----"}]'
|
||||
PipelineConfiguration.SSOTokenUserName: "user"
|
||||
PipelineConfiguration.TenantDetails: '{"ValidTenant": {"tenantName": "org1-envoycd-api-gateway", "iamOrganizationId": "51e2503f-c1df-430d-a1ce-2524fa796cda"}, "InvalidTenant":{"tenantName": "invalidorg-envoycd-api-gateway","iamOrganizationId": "1234"},"AccessTokenTenant":{"tenantName": "accesstokentestorg","iamOrganizationId": "db3ba3e1-b333-4528-80d0-41b0eeb533b0"}}'
|
||||
PipelineConfiguration.IAMAuthorizationUrl: "https://iam-client-test.us-east.philips-healthsuite.com/authorize/oauth2/token"
|
||||
PipelineConfiguration.IAMAccessTokenUrl: "https://iam-client-test.us-east.philips-healthsuite.com/oauth2/access_token"
|
||||
PipelineConfiguration.IDMClientBaseUrl: "https://idm-client-test.us-east.philips-healthsuite.com/authorize/identity"
|
||||
PipelineConfiguration.IAMGetUserUrl: "https://idm-client-test.us-east.philips-healthsuite.com/authorize/identity/User?profileType=membership&userId="
|
||||
PipelineConfiguration.CDRBaseUrl: "https://cdr-edisa-test.us-east.philips-healthsuite.com"
|
||||
|
||||
- name: Run Tests
|
||||
working-directory: ${{ github.workspace }}/automation-dll/philips.edi.foundation.apigateway.automationtest
|
||||
run: |
|
||||
dotnet test **/net3.1/*Test.dll --no-restore --filter TestCategory=OrgNameInUrl --results-directory ${{ github.workspace }}/automation-dll/philips.edi.foundation.apigateway.automationtest/TestResults --logger trx
|
||||
|
||||
- name: email-notification
|
||||
working-directory: ${{ github.workspace }}/Build/PS
|
||||
run: |
|
||||
powershell -ExecutionPolicy RemoteSigned -NoExit -File email-notification.ps1 -BuildNumber ${{ github.run_id }} -ReportFolder ${{ github.workspace }}/automation-dll/philips.edi.foundation.apigateway.automationtest/TestResults -Subject Api-Gateway-WithMultitenancy-org-id-source-url
|
||||
|
||||
DeployCDWithMultitenancyheader:
|
||||
if: github.ref == 'refs/heads/terraform'
|
||||
needs: [DeployCDWithMultitenancyurl, TestwithMultitenancyurl]
|
||||
uses: ./.github/workflows/cd-deploy-with-multitenancy-header.yml
|
||||
secrets:
|
||||
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
|
||||
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
|
||||
HSDP_DOCKER_USER: ${{ secrets.HSDP_DOCKER_USER }}
|
||||
HSDP_DOCKER_PASSWORD: ${{ secrets.HSDP_DOCKER_PASSWORD }}
|
||||
CODESCENE_CI_CD_GITHUB_TOKEN: ${{ secrets.CODESCENE_CI_CD_GITHUB_TOKEN }}
|
||||
INNER_SOURCE_ACTIONS_APP_ID: ${{ secrets.INNER_SOURCE_ACTIONS_APP_ID }}
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64: ${{ secrets.INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64 }}
|
||||
GH_PAT_TOKEN: ${{secrets.GH_PAT_TOKEN}}
|
||||
|
||||
CI-Automation-Variablesheader:
|
||||
if: github.ref == 'refs/heads/terraform'
|
||||
needs: [DeployCDWithMultitenancyheader]
|
||||
runs-on: ubuntu-20.04
|
||||
outputs:
|
||||
oauth_client_secret: ${{ steps.core-output.outputs.oauth_client_secret }}
|
||||
ci_service_private_key: ${{ steps.core-output.outputs.ci_service_private_key }}
|
||||
envoy_base_url: "https://${{ steps.gateway-output.outputs.gateway_url }}"
|
||||
deploy_user: ${{ steps.core-output.outputs.deploy_user }}
|
||||
deploy_password: ${{ steps.core-output.outputs.deploy_password }}
|
||||
ci_service_id: ${{ steps.core-output.outputs.ci_service_id }}
|
||||
oauth_client_id: ${{ steps.core-output.outputs.oauth_client_id }}
|
||||
steps:
|
||||
- name: Download Core output
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: client-test-core-output
|
||||
path: ${{ github.workspace}}/output/core
|
||||
- name: Download Gateway output
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: client-test-api-gateway-output
|
||||
path: ${{ github.workspace}}/output/gateway
|
||||
- name: Get Outputs from Core module
|
||||
working-directory: ${{ github.workspace}}/output/core
|
||||
id: core-output
|
||||
shell: bash
|
||||
run: |
|
||||
apt update && apt install jq -y
|
||||
core_output=$(cat output.json)
|
||||
|
||||
oauth_client_secret=$(echo $core_output | jq -r '.fdn_envoy_oauth_client_password.value')
|
||||
ci_service_private_key=$(echo $core_output | jq -r '.foundation_envoy_nightly_service_private_key.value')
|
||||
deploy_user=$(echo $core_output | jq -r '.cf_deploy_user.value')
|
||||
deploy_password=$(echo $core_output | jq -r '.cf_deploy_password.value')
|
||||
ci_service_id=$(echo $core_output | jq -r '.foundation_envoy_nightly_service_id.value')
|
||||
oauth_client_id=$(echo $core_output | jq -r '.fdn_envoy_oauth_client_id.value')
|
||||
|
||||
echo "::set-output name=oauth_client_secret::$oauth_client_secret"
|
||||
echo "::set-output name=ci_service_private_key::$ci_service_private_key"
|
||||
echo "::set-output name=oauth_client_id::$oauth_client_id"
|
||||
echo "::set-output name=deploy_user::$deploy_user"
|
||||
echo "::set-output name=deploy_password::$deploy_password"
|
||||
echo "::set-output name=ci_service_id::$ci_service_id"
|
||||
|
||||
- name: Get Outputs from Api Gateway
|
||||
working-directory: ${{ github.workspace}}/output/gateway
|
||||
id: gateway-output
|
||||
shell: bash
|
||||
run: |
|
||||
apt update && apt install jq -y
|
||||
output=$(cat output.json)
|
||||
|
||||
gateway_url=$(echo $output | jq -r '.api_gateway_url.value')
|
||||
echo $gateway_url
|
||||
|
||||
echo "::set-output name=gateway_url::$gateway_url"
|
||||
|
||||
TestwithMultitenancyheader:
|
||||
if: github.ref == 'refs/heads/terraform'
|
||||
needs: [Build-Automation-Solution, CI-Automation-Variablesheader, DeployCDWithMultitenancyheader]
|
||||
runs-on: builder_blr
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.GH_TOKEN_CI }}
|
||||
|
||||
- name: Add dotnet
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: '3.1.x'
|
||||
|
||||
- name: Restore Automation Test Project
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: |
|
||||
dotnet restore ${{ github.workspace }}\AutomationTest\automation.packages.proj --packages ./automation-dll
|
||||
|
||||
- uses: microsoft/variable-substitution@v1
|
||||
name: Update Env Json
|
||||
with:
|
||||
files: ${{ github.workspace }}/automation-dll/philips.edi.foundation.apigateway.automationtest/1.0.3/lib/net3.1/Env.json
|
||||
env:
|
||||
PipelineConfiguration.AuthUserName: "sai.chand@philips.com"
|
||||
PipelineConfiguration.AuthPassword: ${{ secrets.IAM_TEST_USER_PASSWORD }}
|
||||
PipelineConfiguration.APIGatewayBaseUrl: "https://envoycd-api-gateway.us-east.philips-healthsuite.com"
|
||||
PipelineConfiguration.ServiceID: ${{ needs.CI-Automation-Variables.outputs.ci_service_id }}
|
||||
PipelineConfiguration.ServiceIDPrivateKey: ${{ needs.CI-Automation-Variables.outputs.ci_service_private_key }}
|
||||
PipelineConfiguration.OauthClientID: ${{ needs.CI-Automation-Variables.outputs.oauth_client_id }}
|
||||
PipelineConfiguration.OauthClientSecret: ${{ needs.CI-Automation-Variables.outputs.oauth_client_secret }}
|
||||
PipelineConfiguration.CFOrgName: "client-EDI-SolutionAccelerator"
|
||||
PipelineConfiguration.CFSpaceName: "envoycd"
|
||||
PipelineConfiguration.CFUserName: ${{ secrets.CF_USERNAME }}
|
||||
PipelineConfiguration.CFPassword: ${{ secrets.CF_PASSWD }}
|
||||
PipelineConfiguration.CookieName: "edi_session_envoycd"
|
||||
PipelineConfiguration.CFOauthTokenUrl: "https://login.cloud.pcftest.com/oauth/token"
|
||||
PipelineConfiguration.CFBaseUrl: "https://api.cloud.pcftest.com/v3"
|
||||
PipelineConfiguration.CFAuthenticatorAppName: "authenticator_service"
|
||||
PipelineConfiguration.OauthProxyCookieTimeoutInSeconds: "25"
|
||||
PipelineConfiguration.AuthenticatorSessionExpireOffsetInPercent: "99"
|
||||
PipelineConfiguration.AccessTokenTestRoleName: "ENVOY-NIGHTLY-SERVICE-TF"
|
||||
PipelineConfiguration.OpenIdConfigurationBaseUrl: "https://foundation-client-test.us-east.philips-healthsuite.com"
|
||||
PipelineConfiguration.OrgSymmetricKey: ${{ secrets.ORG_SYMMETRIC_KEY }}
|
||||
PipelineConfiguration.OpenIdConfigOrganizationCertificateMapping: '[{"organizationId":"ed186a39-8b5f-4351-bebc-4e17779c293b","certificate":"-----BEGIN CERTIFICATE-----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-----END CERTIFICATE-----"},{"organizationId":"51e2503f-c1df-430d-a1ce-2524fa796cda","certificate":"-----BEGIN CERTIFICATE-----MIIGaDCCBFCgAwIBAgIULlL9VXieeY/tgVYPtTqkJ5yAJSwwDQYJKoZIhvcNAQELBQAwHjEcMBoGA1UEAxMTcGhpbGlwcy1oZWFsdGhzdWl0ZTAeFw0yMjAyMTcwMTQzMzBaFw0yMzAxMTgwMTQzNTdaMB4xHDAaBgNVBAMTE3BoaWxpcHMtaGVhbHRoc3VpdGUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDBpvTseX7EK9HuET9K4uqBEbyHf9S7Oo5pD/IGk9JC6Jev1G3dQcO0O2MlhIGzFnFosl6jrP8sWWEsK1axGc4mT5NFu5eojDOlvkWCkx4RIy9iSDFEg+gupx3o1GpIrhQryRP8MMV+vzPdlixQrWgubH/CIPRtA126BkVW1tTktHIPjwnaV88h9P7RtRso+ECVkHsrWcGjBsipTqQP0Ck9whYIWWWwqJMkDuUFFMpaJFk/aVDQ4lt7fjRW7BhHUhUOo5YvRzRshz9qIezzxinaZ9dJsYhXbSfe+eMSzkm45DNEfzN6JAvssQN9dtPVP4GIl/AZAY/58k1fiwvt3D19gjfdZd9ujB8aGtZDNPnn/AsdfD+MiJmIE3oLYsToicW3xUIaqKJ8zuuhakX+pVuXIakhDDT9PrqEDUiS4RqDSpfzvAzI4t6bdFVaiWuHqUKiosEwo3GTW2TMSiTMLzgMS5Da11c6WU2SVetsEwyc2cVTkzaYIdGDGOAJW3RVrzQdgjg3XBeszKDLb+jJxbBCFCowz0QJQvyg0B89pLtanv+YgibirNEzL3pwiKqZ//Z7eINCpnGUnvkNXKWaOvtIr/7P8C+IhjqmPSA5RZRtI5SKlzYNHvxlWCCqf3lwRKQaah4WAL1CAvz33WqdC7UQPFiYIuyI50GmOlVC2IEDoQIDAQABo4IBnDCCAZgwDgYDVR0PAQH/BAQDAgOoMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAdBgNVHQ4EFgQU3k4ngZJ+6gr88Bc3gBq4ThW4nsswHwYDVR0jBBgwFoAUMy4Fg1gI7L5ECt863Z217+n2f+MwgYcGCCsGAQUFBwEBBHsweTB3BggrBgEFBQcwAoZraHR0cDovL3BraS1jbGllbnQtdGVzdC51cy1lYXN0LnBoaWxpcHMtaGVhbHRoc3VpdGUuY29tL2NvcmUvcGtpL2FwaS9jNjk5ZmRkZC1hNGQzLTQ4OWMtOWMxZS02OTAyMjBmZGFhNTEvY2EwHgYDVR0RBBcwFYITcGhpbGlwcy1oZWFsdGhzdWl0ZTB9BgNVHR8EdjB0MHKgcKBuhmxodHRwOi8vcGtpLWNsaWVudC10ZXN0LnVzLWVhc3QucGhpbGlwcy1oZWFsdGhzdWl0ZS5jb20vY29yZS9wa2kvYXBpL2M2OTlmZGRkLWE0ZDMtNDg5Yy05YzFlLTY5MDIyMGZkYWE1MS9jcmwwDQYJKoZIhvcNAQELBQADggIBAMwsfnvYf6YTLY6ZguUiwd+7Z9sW8gDBfUhtzPbwLMHIGLjKFOyZevZPNitzJj9eNZYaq2BfuYrIbOD1NSCKmf57UcuXRSAbkNNyMu6ncdY+FLN6dwt7yTnvEQ6oka/ObaBDyQh2BpiKneCHHlxG+lFsTt4XWQU4u5t6lI0gxsHpiYJWcg0HyrbBPcYJzYGjttY7HC0zF8GByEoFbunTC7/9IhZixGQNhUkajfzPV3Q8xcFCS794tmwBeNlpaWrKUMaErzSQuCHzlYyIb3oeYqjttKro3qz2zmSI1x8p2SGhOoVWVajeXl4OMeOo3O/BMK6zt2bOKtgU+exo003ve6J6A/rrALF4nQx86tlh5o50JGuImldNHfT58vHoxfJeXqk2cK+yJHHHW+M+xNVoKJ+KFKqFz2JW646SWnZzdz/Vd537eXjMiJVPuCGC48PFP5eXYxxnrPEyUl1q0FglxHvgaJJoTK4Oz95MpjubzgFaSnUj0TDQg46pircAQUW9oay6uTX377smYIBB6/yYKE0tfCKbKcDOgEWP+YKWe+G9Ha3uCdTVSRBC4MYeab5YVGCgW9Qj99jMuwl15xlUa5EdCv0l6QA16C5CoW5/cNOkb8G5wLN1VGY3g6J6FviJgVElF9LUNxRhpkRGaLIYFT5VxmMv8GNZNG9j4ffEIDpc-----END CERTIFICATE-----"}]'
|
||||
PipelineConfiguration.SSOTokenUserName: "user"
|
||||
PipelineConfiguration.TenantDetails: '{"ValidTenant": {"tenantName": "org1-envoycd-api-gateway", "iamOrganizationId": "51e2503f-c1df-430d-a1ce-2524fa796cda"}, "InvalidTenant":{"tenantName": "invalidorg-envoycd-api-gateway","iamOrganizationId": "1234"},"AccessTokenTenant":{"tenantName": "accesstokentestorg","iamOrganizationId": "db3ba3e1-b333-4528-80d0-41b0eeb533b0"}}'
|
||||
PipelineConfiguration.IAMAuthorizationUrl: "https://iam-client-test.us-east.philips-healthsuite.com/authorize/oauth2/token"
|
||||
PipelineConfiguration.IAMAccessTokenUrl: "https://iam-client-test.us-east.philips-healthsuite.com/oauth2/access_token"
|
||||
PipelineConfiguration.IDMClientBaseUrl: "https://idm-client-test.us-east.philips-healthsuite.com/authorize/identity"
|
||||
PipelineConfiguration.IAMGetUserUrl: "https://idm-client-test.us-east.philips-healthsuite.com/authorize/identity/User?profileType=membership&userId="
|
||||
PipelineConfiguration.CDRBaseUrl: "https://cdr-edisa-test.us-east.philips-healthsuite.com"
|
||||
|
||||
- name: Run Tests
|
||||
working-directory: ${{ github.workspace }}/automation-dll/philips.edi.foundation.apigateway.automationtest
|
||||
run: |
|
||||
dotnet test **/net3.1/*Test.dll --no-restore --filter TestCategory=OrgIdInHeader --results-directory ${{ github.workspace }}/automation-dll/philips.edi.foundation.apigateway.automationtest/TestResults --logger trx
|
||||
|
||||
- name: email-notification
|
||||
working-directory: ${{ github.workspace }}/Build/PS
|
||||
run: |
|
||||
powershell -ExecutionPolicy RemoteSigned -NoExit -File email-notification.ps1 -BuildNumber ${{ github.run_id }} -ReportFolder ${{ github.workspace }}/automation-dll/philips.edi.foundation.apigateway.automationtest/TestResults -Subject Api-Gateway-WithMultitenancy-org-id-source-header
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
name: 'Setup Innersource Actions'
|
||||
|
||||
inputs:
|
||||
GH_PAT_TOKEN:
|
||||
required: true
|
||||
INNER_SOURCE_ACTIONS_APP_ID:
|
||||
required: true
|
||||
INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64:
|
||||
required: true
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
# Setup inner source actions
|
||||
- name: Get Token
|
||||
id: token
|
||||
uses: philips-software/app-token-action@v1.0.2
|
||||
with:
|
||||
app_id: ${{ inputs.INNER_SOURCE_ACTIONS_APP_ID }}
|
||||
app_base64_private_key: ${{ inputs.INNER_SOURCE_ACTIONS_APP_PRIVATE_KEY_BASE64 }}
|
||||
auth_type: "installation"
|
||||
|
||||
- uses: philips-software/inner-source-checkout-action@v1.1.0
|
||||
with:
|
||||
token: ${{ steps.token.outputs.token }}
|
||||
base_dir: ../.actions
|
||||
repos: philips-internal/terragrunt-plan-action@v1, philips-internal/terragrunt-apply-action@v1
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: philips-labs/terraform-private-modules-action@v1.1
|
||||
with:
|
||||
org: philips-internal
|
||||
token: ${{ inputs.GH_PAT_TOKEN }}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
name: 'Terragrunt Output'
|
||||
|
||||
inputs:
|
||||
working-directory:
|
||||
description: "Working directory - path to your Terragrunt module"
|
||||
required: true
|
||||
key:
|
||||
description: "Key used to save plan file to artifacts"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- id: terragrunt_output
|
||||
shell: bash
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
run: |
|
||||
terragrunt output -json > /tmp/output.json
|
||||
|
||||
- name: Upload Output
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ inputs.key }}
|
||||
path: /tmp/output.json
|
||||
if-no-files-found: error
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
[*.cs]
|
||||
|
||||
# PH2028: Copyright Present
|
||||
dotnet_diagnostic.PH2028.severity = none
|
||||
|
||||
# PH2006: Namespace matches File Path
|
||||
dotnet_diagnostic.PH2006.severity = none
|
||||
|
||||
# PH 2071: change default token count for code duplication detection
|
||||
dotnet_code_quality.PH2071.token_count = 100
|
||||
|
||||
# PH2079: Specify the namespace prefix in the .editorconfig file
|
||||
dotnet_code_quality.PH2079.namespace_prefix = Philips.EDI.Foundation
|
||||
|
||||
# PH2019: TestCleanup methods not allowed
|
||||
dotnet_diagnostic.PH2019.severity = none
|
||||
|
||||
# PH2016: TestInitialize methods not allowed
|
||||
dotnet_diagnostic.PH2016.severity = none
|
||||
|
||||
dotnet_code_quality.PH2015.allowed_test_categories = TestCategory.GatedSanity,TestCategory.Nightly,TestCategory.PostDeployment,TestCategory.WithoutMultitenancy,TestCategory.MultitenancyWithOrgNameAsSubdomain,TestCategory.MultitenancyWithOrgIdInHeader
|
||||
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using Utilities;
|
||||
using Driver.UI.Common;
|
||||
using Driver.UI.Interfaces;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer
|
||||
{
|
||||
public class AuthenticationBL
|
||||
{
|
||||
private readonly IWebDriverUi _webDriver;
|
||||
|
||||
public AuthenticationBL(IWebDriverUi webDriver)
|
||||
{
|
||||
_webDriver = webDriver;
|
||||
}
|
||||
|
||||
public Cookies GetCookie(string cookieName)
|
||||
{
|
||||
Logger.InfoStartMethod();
|
||||
try
|
||||
{
|
||||
Logger.Info($"Get the cookie Named: {cookieName}");
|
||||
var cookies = _webDriver.GetAllCookies();
|
||||
return cookies.Find(x => x.CookieName.EqualsWithIgnoreCase(cookieName));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCookie(Cookies cookie)
|
||||
{
|
||||
Logger.InfoStartMethod();
|
||||
try
|
||||
{
|
||||
Logger.Info($"Cookie Name: {cookie.CookieName}");
|
||||
Logger.Info($"Cookie Value: {cookie.CookieValue}");
|
||||
_webDriver.DeleteCookieNamed(cookie.CookieName);
|
||||
_webDriver.AddNewCookie(cookie);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Utilities;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer
|
||||
{
|
||||
public class CommonBL
|
||||
{
|
||||
|
||||
public JObject GetImposterRecordedRequests(string apiGatewayBaseUrl, Dictionary<string, string> headers, string mockserviceJsonConfigFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
string mockserviceJsonConfigFilePath = Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Tests", "Data", "MockServiceConfigs", mockserviceJsonConfigFile);
|
||||
Logger.Info($"Mockservice json config file path: {mockserviceJsonConfigFilePath}");
|
||||
string port = JObject.Parse(File.ReadAllText(mockserviceJsonConfigFilePath))["port"].ToString();
|
||||
string imposterGetUrl = $"{apiGatewayBaseUrl}/imposters/{port}";
|
||||
Logger.Info($"Imposter Get Url: { imposterGetUrl}");
|
||||
return HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, imposterGetUrl, headers, null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public JToken GetUpstreamRecordedRequest(string apiGatewayBaseUrl, Dictionary<string, string> headers, string customUniqueRequestIdHeaderName, string customUniqueRequestIdHeaderValue, string mockserviceJsonConfigFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
var getResponseBody = GetImposterRecordedRequests(apiGatewayBaseUrl, headers, mockserviceJsonConfigFile);
|
||||
Logger.Info($"Response body: {getResponseBody}");
|
||||
JToken testRecordedRequest = getResponseBody["requests"].Where(x => x["headers"][customUniqueRequestIdHeaderName] != null && x["headers"][customUniqueRequestIdHeaderName].ToString() == customUniqueRequestIdHeaderValue).FirstOrDefault();
|
||||
return testRecordedRequest;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Utilities;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Utilities.Wait;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer
|
||||
{
|
||||
public class HSPIAMBusinessLayer
|
||||
{
|
||||
public string GetRoleId(string idmClientBaseUrl, Dictionary<string, string> headers, string OrgId, string roleName)
|
||||
{
|
||||
try
|
||||
{
|
||||
string idmClientRoleUrl = $"{idmClientBaseUrl}/Role?organizationId={OrgId}&name={roleName}";
|
||||
Logger.Info($"Get Role url: {idmClientRoleUrl}");
|
||||
headers.TryAdd("api-version", "1");
|
||||
var responseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, idmClientRoleUrl, headers, null);
|
||||
var entry = responseBody["entry"]?.FirstOrDefault();
|
||||
var roleId = entry?["id"]?.ToString();
|
||||
Logger.Info($"Role Id: {roleId}");
|
||||
return roleId;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> GetAllPersmissionsFromRole(string idmClientBaseUrl, Dictionary<string, string> headers, string roleID)
|
||||
{
|
||||
try
|
||||
{
|
||||
string idmClientPermissionsUrl = $"{idmClientBaseUrl}/Permission?roleId={roleID}";
|
||||
Logger.Info($"Get Permission url: {idmClientPermissionsUrl}");
|
||||
var responseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, idmClientPermissionsUrl, headers, null);
|
||||
return responseBody["entry"]?.Select(x => x["name"].ToString()).ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public bool AssignPermissionToRole(string idmClientBaseUrl, Dictionary<string, string> headers, string roleID, string permissionsJson)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ManipulatePersmissionsInRole(idmClientBaseUrl, "assign-permission", headers, roleID, permissionsJson);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public bool RemovePermissionFromRole(string idmClientBaseUrl, Dictionary<string, string> headers, string roleID, string permissionsJson)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ManipulatePersmissionsInRole(idmClientBaseUrl, "remove-permission", headers, roleID, permissionsJson);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private bool ManipulatePersmissionsInRole(string idmClientBaseUrl, string permissionType, Dictionary<string, string> headers, string roleID, string permissionsJson)
|
||||
{
|
||||
string iamClientRoleUrl = $"{idmClientBaseUrl}/Role/{roleID}/${permissionType}";
|
||||
Logger.Info($"Role manipulation url: {iamClientRoleUrl}");
|
||||
var httpContent = HttpClientUtility.CreateHttpContent(permissionsJson);
|
||||
var response = HttpClientUtility.ExecuteAsync(HttpMethod.Post, iamClientRoleUrl, headers, httpContent).Result;
|
||||
Sleep.Seconds(5);
|
||||
return response.StatusCode == HttpStatusCode.OK;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Getting the user details from IAM
|
||||
/// </summary>
|
||||
/// <param name="iamGetUserUrl">URL to get the user details form IAM</param>
|
||||
/// <param name="userMailId">user mail id to get details</param>
|
||||
/// <param name="headers">headers</param>
|
||||
/// <returns>List of usersUUID based on mail id</returns>
|
||||
public List<string> GetUserDetails(string iamGetUserUrl, string userMailId, Dictionary<string, string> headers)
|
||||
{
|
||||
string finalUrl = $"{iamGetUserUrl}{userMailId}";
|
||||
Logger.Info($"Get Users url: {finalUrl}");
|
||||
headers.TryAdd("api-version","2");
|
||||
var responseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, finalUrl, headers, null);
|
||||
if (responseBody != null)
|
||||
{
|
||||
List <string> userLoginId = responseBody["entry"]?.Where(x => x["id"] != null).Select(x => x["id"].ToString()).ToList();
|
||||
return userLoginId;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deleting the user based on userName and respective Organization ID
|
||||
/// </summary>
|
||||
/// <param name="iamGetUserUrl">URL to get the user details form IAM</param>
|
||||
/// <param name="idmClientBaseUrl">IDM client Base URL</param>
|
||||
/// <param name="userMailId">user mail id to be deleted</param>
|
||||
/// <param name="headers">headers</param>
|
||||
/// <returns>HttpMessage</returns>
|
||||
public HttpResponseMessage DeleteUser(string iamGetUserUrl, string idmClientBaseUrl, string userMailId, Dictionary<string, string> headers)
|
||||
{
|
||||
List<string> userIdtoDelete = GetUserDetails(iamGetUserUrl, userMailId.ToLower(), headers);
|
||||
headers.TryAdd("api-version", "2");
|
||||
headers.TryAdd("Accept", "application/json");
|
||||
if (userIdtoDelete.Count >= 1)
|
||||
{
|
||||
string deleteUrl = $"{idmClientBaseUrl}/User/{userIdtoDelete[0]}";
|
||||
return HttpClientUtility.ExecuteAsync(HttpMethod.Delete, deleteUrl, headers, null).Result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
using Driver.UI.Interfaces;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer
|
||||
{
|
||||
public class ReverseProxyBL
|
||||
{
|
||||
private readonly IWebDriverUi _webDriver;
|
||||
|
||||
public ReverseProxyBL(IWebDriverUi webDriver)
|
||||
{
|
||||
_webDriver = webDriver;
|
||||
}
|
||||
|
||||
public bool NavigateToImpostersPageAndGetIsMockServiceLinksDisplayed(string impostersUrl)
|
||||
{
|
||||
_webDriver.Goto(impostersUrl);
|
||||
_webDriver.TakeScreenshot();
|
||||
return _webDriver.IsDisplayed(_webDriver.FindElementByXPath("//table[@id='imposters']"));
|
||||
}
|
||||
public bool ClickOnImposterAndGetMockServiceContentIsDisplayed(string mockserviceName)
|
||||
{
|
||||
_webDriver.Click(_webDriver.FindElementByXPath($"//a[normalize-space(.)='{mockserviceName}']"));
|
||||
_webDriver.TakeScreenshot();
|
||||
return _webDriver.IsDisplayed(_webDriver.FindElementByXPath("//code[contains(.,'predicates')]"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Web;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer
|
||||
{
|
||||
public class VueSSOTokenBL
|
||||
{
|
||||
public string GenerateSsoToken(string username, string sessionTime, string symmetricKey)
|
||||
{
|
||||
var ssoToken = $"user_name={username}&session_time={sessionTime}";
|
||||
return EncryptSsoToken(ssoToken, symmetricKey);
|
||||
}
|
||||
|
||||
private static string EncryptSsoToken(string toBeEncryptedUrl, string symmetricKey)
|
||||
{
|
||||
byte[] encrypted;
|
||||
var Key = Convert.FromBase64String(symmetricKey);
|
||||
byte[] IV = new byte[16];
|
||||
using (AesManaged aes = new AesManaged())
|
||||
{
|
||||
ICryptoTransform encryptor = aes.CreateEncryptor(Key, IV);
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
using (CryptoStream cs = new CryptoStream(ms, encryptor, CryptoStreamMode.Write))
|
||||
{
|
||||
// Create StreamWriter and write data to a stream
|
||||
using (StreamWriter sw = new StreamWriter(cs))
|
||||
sw.Write(toBeEncryptedUrl);
|
||||
encrypted = ms.ToArray();
|
||||
return HttpUtility.UrlEncode(Convert.ToBase64String(encrypted));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"AppConfiguration": {
|
||||
"RootFolder": "C:\\AutomationOutput",
|
||||
"ReporterList": "html;word",
|
||||
"RootEvidencePath": "C:\\AutomationOutput\\Evidences",
|
||||
"DifidoFolderLocation": "difido-reports-common.jar",
|
||||
"ProductName": "API Gateway",
|
||||
"LessPayloadMockservice": "/mockserviceA/test",
|
||||
"HeavyPayloadMockservice": "/mockserviceB/test",
|
||||
"ServiceUnavailableMockservice": "/mockserviceX",
|
||||
"MultitenancyMockservice": "/mockserviceA/multitenancy",
|
||||
"LogoutPath": "/logout",
|
||||
"CDRSubscriptionUrlPath": "/store/fhir/OrgId/Subscription",
|
||||
"CDRImagingStudyUrlPath": "/store/fhir/OrgId/ImagingStudy",
|
||||
"QidoStudyLevelUrlPathWithoutOrgId": "/dicom/qido/studies",
|
||||
"IamBrokerConfigAPIRelativePath": "/IamTokenExchangeBroker/OrgId/config/",
|
||||
"OpenIdConfigurationUrlPath": "/tokenvalidator/OrgId/openid-configuration",
|
||||
"MountibankTimeoutinSeconds": "15"
|
||||
},
|
||||
"PipelineConfiguration": {
|
||||
"SSOTokenUserName": "",
|
||||
"OrgSymmetricKey": "",
|
||||
"AuthUserName": "",
|
||||
"AuthPassword": "",
|
||||
"ServiceID": "",
|
||||
"ServiceIDPrivateKey": "",
|
||||
"IAMAuthorizationUrl": "",
|
||||
"IAMAccessTokenUrl": "",
|
||||
"IDMClientBaseUrl": "",
|
||||
"IAMGetUserUrl": "",
|
||||
"CDRBaseUrl": "",
|
||||
"OauthClientID": "",
|
||||
"OauthClientSecret": "",
|
||||
"CFOrgName": "",
|
||||
"CFSpaceName": "",
|
||||
"CFUserName": "",
|
||||
"CFPassword": "",
|
||||
"CookieName": "",
|
||||
"CFOauthTokenUrl": "",
|
||||
"CFBaseUrl": "",
|
||||
"CFAuthenticatorAppName": "",
|
||||
"APIGatewayBaseUrl": "",
|
||||
"OauthProxyCookieTimeoutInSeconds": "",
|
||||
"AuthenticatorSessionExpireOffsetInPercent": "",
|
||||
"AccessTokenTestRoleName": "",
|
||||
"OpenIdConfigurationBaseUrl": "",
|
||||
"OpenIdConfigOrganizationCertificateMapping": "",
|
||||
"TenantDetails": ""
|
||||
},
|
||||
"ExecutionEnvironment": "Local"
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Models
|
||||
{
|
||||
public class AppConfiguration
|
||||
{
|
||||
public string RootFolder { get; set; }
|
||||
public string ReporterList { get; set; }
|
||||
public string RootEvidencePath { get; set; }
|
||||
public string DifidoFolderLocation { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
public string ProductVersion { get; set; }
|
||||
public string LessPayloadMockservice { get; set; }
|
||||
public string HeavyPayloadMockservice { get; set; }
|
||||
public string ServiceUnavailableMockservice { get; set; }
|
||||
public string MultitenancyMockservice { get; set; }
|
||||
public string LogoutPath { get; set; }
|
||||
public string CDRSubscriptionUrlPath { get; set; }
|
||||
public string QidoStudyLevelUrlPathWithoutOrgId { get; set; }
|
||||
public string CDRImagingStudyUrlPath { get; set; }
|
||||
public string IamBrokerConfigAPIRelativePath { get; set; }
|
||||
public string OpenIdConfigurationUrlPath { get; set; }
|
||||
public int MountibankTimeoutinSeconds { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Models
|
||||
{
|
||||
public class Constants
|
||||
{
|
||||
public const string CustomUniqueRequestHeaderName = "customuniquerequestheader";
|
||||
public const string AuthenticatorSessionExpireOffsetInPercent = "Authenticator_session__SessionExpireOffsetInPercent";
|
||||
public const string ValidTenantKey = "ValidTenant";
|
||||
public const string InvalidTenantKey = "InvalidTenant";
|
||||
public const string AccessTokenTenantKey = "AccessTokenTenant";
|
||||
public const string TimeStampFormat = "yyyy-MM-ddTHH:mm:ss";
|
||||
public const int RetryTimeOutInSeconds = 30;
|
||||
public const string SymmetricKeyName = "VUESSOSYMMETRICKEY";
|
||||
public const string TimeZoneKeyName = "VUESSOTIMEZONE";
|
||||
public const string TokyoTimeZone = "Tokyo Standard Time";
|
||||
public const string UTCTimeZone = "UTC";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Models
|
||||
{
|
||||
public enum TestCategory
|
||||
{
|
||||
GatedSanity,
|
||||
Nightly,
|
||||
PostDeployment,
|
||||
WithoutMultitenancy,
|
||||
OrgNameInUrl,
|
||||
OrgIdInHeader,
|
||||
UserAccessToken,
|
||||
ServiceIDAccessToken,
|
||||
BrowserLogout,
|
||||
SSOToken,
|
||||
IAMTokenExchangeBroker,
|
||||
IAMTokenExchangeBrokerPreCondition,
|
||||
IDTokenValidator,
|
||||
OnPrem,
|
||||
UpgradeSanity,
|
||||
IntegratedSanity
|
||||
|
||||
}
|
||||
|
||||
public enum ExecutionEnvironment
|
||||
{
|
||||
Local,
|
||||
Production
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using Newtonsoft.Json;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Models
|
||||
{
|
||||
public class OpenIdConfigOrganizationCertificateMapping
|
||||
{
|
||||
[JsonProperty("organizationId")]
|
||||
public string OrganizationId { get; set; }
|
||||
|
||||
[JsonProperty("certificate")]
|
||||
public string Certificate { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Models
|
||||
{
|
||||
public class PipelineConfiguration
|
||||
{
|
||||
public string AuthUserName { get; set; }
|
||||
public string AuthPassword { get; set; }
|
||||
public string APIGatewayBaseUrl { get; set; }
|
||||
public string OauthClientID { get; set; }
|
||||
public string OauthClientSecret { get; set; }
|
||||
public string CFOrgName { get; set; }
|
||||
public string CFSpaceName { get; set; }
|
||||
public string CFUserName { get; set; }
|
||||
public string CFPassword { get; set; }
|
||||
public string CookieName { get; set; }
|
||||
public string CFOauthTokenUrl { get; set; }
|
||||
public string CFBaseUrl { get; set; }
|
||||
public string CFAuthenticatorAppName { get; set; }
|
||||
public int OauthProxyCookieTimeoutInSeconds { get; set; }
|
||||
public string AuthenticatorSessionExpireOffsetInPercent { get; set; }
|
||||
public string AccessTokenTestRoleName { get; set; }
|
||||
public string IAMAuthorizationUrl { get; set; }
|
||||
public string IAMAccessTokenUrl { get; set; }
|
||||
public string ServiceID { get; set; }
|
||||
public string ServiceIDPrivateKey { get; set; }
|
||||
public string IDMClientBaseUrl { get; set; }
|
||||
public string OrgSymmetricKey { get; set; }
|
||||
public string CDRBaseUrl { get; set; }
|
||||
public string IAMGetUserUrl { get; set; }
|
||||
public string OpenIdConfigurationBaseUrl { get; set; }
|
||||
public string SSOTokenUserName { get; set; }
|
||||
public string OpenIdConfigOrganizationCertificateMapping { get; set; }
|
||||
public string TenantDetails { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
using Newtonsoft.Json;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Models
|
||||
{
|
||||
public class TenantMapping
|
||||
{
|
||||
[JsonProperty("tenantName")]
|
||||
public string TenantName { get; set; }
|
||||
[JsonProperty("iamOrganizationId")]
|
||||
public string IamOrganizationId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<NuspecFile>.\Philips.EDI.Foundation.APIGateway.AutomationTest.nuspec</NuspecFile>
|
||||
<NuspecProperties>version=$(version);id=$(MSBuildProjectName)</NuspecProperties>
|
||||
<NuspecBasePath>.\Bin\$(configuration)\$(TargetFramework)</NuspecBasePath>
|
||||
<IsPackable>true</IsPackable>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
||||
<NoWarn>PH2075</NoWarn>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Tests\Data\EnvoyConfigs\**" />
|
||||
<EmbeddedResource Remove="Tests\Data\EnvoyConfigs\**" />
|
||||
<None Remove="Tests\Data\EnvoyConfigs\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutomationFramework.Driver" Version="1.3.5" />
|
||||
<PackageReference Include="AutomationFramework.Reporters" Version="1.2.0" />
|
||||
<PackageReference Include="AutomationFramework.Utilities" Version="1.2.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.3" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.0.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
|
||||
<PackageReference Include="Philips.CodeAnalysis.DuplicateCodeAnalyzer" Version="1.1.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Philips.CodeAnalysis.MaintainabilityAnalyzers" Version="1.2.6.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Philips.CodeAnalysis.MoqAnalyzers" Version="1.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Philips.CodeAnalysis.MsTestAnalyzers" Version="1.1.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="90.0.4430.2400" />
|
||||
<PackageReference Include="TimeZoneConverter" Version="3.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Env.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="log4net.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Tests\Data\MockServiceConfigs\LessPayloadMockservice.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Tests\Data\MockServiceConfigs\HeavyPayloadMockservice.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="Tests\Data\MockserviceA.json" />
|
||||
<Resource Include="Tests\Data\MockserviceB.json" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"PipelineConfiguration": {
|
||||
"SSOTokenUserName": "",
|
||||
"OrgSymmetricKey": "",
|
||||
"AuthUserName": "sai.chand@philips.com",
|
||||
"AuthPassword": "",
|
||||
"ServiceID": "apigateway-nightly.apigateway-nightly.pf-nightly-tf@pf-nightly-tf.edi-platform-service.ediplatform.philips-healthsuite.com",
|
||||
"ServiceIDPrivateKey": "",
|
||||
|
||||
"IAMAuthorizationUrl": "https://iam-client-test.us-east.philips-healthsuite.com/authorize/oauth2/token",
|
||||
"IAMAccessTokenUrl": "https://iam-client-test.us-east.philips-healthsuite.com/oauth2/access_token",
|
||||
"IDMClientBaseUrl": "https://idm-client-test.us-east.philips-healthsuite.com/authorize/identity",
|
||||
"IAMGetUserUrl": "https://idm-client-test.us-east.philips-healthsuite.com/authorize/identity/User?profileType=membership&userId=",
|
||||
"CDRBaseUrl": "https://cdr-edisa-test.us-east.philips-healthsuite.com",
|
||||
"OauthClientID": "auto-mfpbc",
|
||||
"OauthClientSecret": "",
|
||||
|
||||
"CFOrgName": "client-EDI-SolutionAccelerator",
|
||||
"CFSpaceName": "",
|
||||
"CFUserName": "solutionaccelerator-cicd-svc",
|
||||
"CFPassword": "",
|
||||
"CookieName": "",
|
||||
"CFOauthTokenUrl": "https://login.cloud.pcftest.com/oauth/token",
|
||||
"CFBaseUrl": "https://api.cloud.pcftest.com/v3",
|
||||
"CFAuthenticatorAppName": "authenticator_service",
|
||||
|
||||
"APIGatewayBaseUrl": "",
|
||||
"OauthProxyCookieTimeoutInSeconds": "25",
|
||||
"AuthenticatorSessionExpireOffsetInPercent": "99",
|
||||
"AccessTokenTestRoleName": "TESTROLE",
|
||||
|
||||
"OpenIdConfigurationBaseUrl": "https://foundation-client-test.us-east.philips-healthsuite.com",
|
||||
"OpenIdConfigOrganizationCertificateMapping": "",
|
||||
"TenantDetails": ""
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
|
||||
<metadata>
|
||||
|
||||
<id>$id$</id>
|
||||
|
||||
<version>$version$</version>
|
||||
|
||||
<title />
|
||||
|
||||
<authors>Philips EDI Foundation APIGateway Automation</authors>
|
||||
|
||||
<owners />
|
||||
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
|
||||
<description>""</description>
|
||||
<dependencies>
|
||||
<group targetFramework="netcoreapp3.1" />
|
||||
</dependencies>
|
||||
|
||||
</metadata>
|
||||
|
||||
<files>
|
||||
|
||||
<file src="**" exclude="*pdb*" target="lib\net3.1\" />
|
||||
|
||||
|
||||
|
||||
</files>
|
||||
|
||||
</package>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30225.117
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Philips.EDI.Foundation.APIGateway.AutomationTest", "Philips.EDI.Foundation.APIGateway.AutomationTest.csproj", "{38895658-54E2-47D6-9AF9-552E658FBDDD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{38895658-54E2-47D6-9AF9-552E658FBDDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{38895658-54E2-47D6-9AF9-552E658FBDDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{38895658-54E2-47D6-9AF9-552E658FBDDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{38895658-54E2-47D6-9AF9-552E658FBDDD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A2BC2EB9-36EE-4105-86F7-2B8ECE632FAD}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
# API Gateway Automation
|
||||
|
||||
## Pre-Condition
|
||||
|
||||
Mountebank application should be deployed along with API Gateway deployment.
|
||||
Mountebank deployment with terrform: https://github.com/philips-internal/hds-auth-gateway/blob/master/Automation/deploy/cloud/app_monteback.tf
|
||||
|
||||
Allow Injection command should be passed while starting the mountebank application
|
||||
|
||||
command = "node bin/mb --allowInjection"
|
||||
|
||||
PostDeploymentTest has to executed first in order to create less payload and heavy payload mockservices for automation.
|
||||
(TestCategory = PostDeployment)
|
||||
|
||||
Mockservice configuration files https://github.com/philips-internal/hds-auth-gateway/tree/master/AutomationTest/Tests/Data/MockServiceConfigs
|
||||
|
||||
## Automation Configuration
|
||||
|
||||
https://github.com/philips-internal/hds-auth-gateway/blob/master/AutomationTest/Env.json
|
||||
|
||||
AppConfiguration section is for static confguration values and drive name can be changed from C:\ to other drive for automation word reports and screenshots.
|
||||
|
||||
"AppConfiguration": { }
|
||||
|
||||
PipelineConfiguration section is for dynamic configuration which will be filled from tfs pipeline or user can fill before executing the automation.
|
||||
|
||||
"PipelineConfiguration": { }
|
||||
|
||||
|
||||
| Key | Description | Type |
|
||||
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
|
||||
| AuthUserName | IAM login user email address, For browser based login tests and also for access token authenticator tests | String |
|
||||
| AuthPassword | IAM login password | String |
|
||||
| APIGatewayBaseUrl | BaseUrl fo the API gateway <br/>Examples:<br/>For Cloud: https://covid-ver2-api-gateway.us-east.philips-healthsuite.com<br/>For On-Prem: https://localhost (or) https://hostname | String |
|
||||
| OauthProxyCookieTimeoutInSeconds | Oauth proxy cookie time out in seconds ( default value: 15 ) | Integer |
|
||||
| TenantDetails | Tenant information with user-friendly tenant sub-domain name and its relevant Iam organization-ID. <br/>Default Values:<br/>"ValidTenant":{"tenantName":"","iamOrganizationId":""}<br>"InvalidTenant":{"tenantName":"invalidtenant","iamOrganizationId":""}<br>"AccessTokenTenant":{"tenantName":"accesstokentenant","iamOrganizationId":""} | String |
|
||||
| OauthClientID | IAM Oauth client id or User name. Used to get the Authorization Basic token, which will be used to get User or ServiceId Access token. | String |
|
||||
| OauthClientSecret | IAM Oauth client password | String |
|
||||
| CFSpaceName | Cloud foundry space name where the api gateway is deployed | String |
|
||||
| CFUserName | Cloud foundry user name | String |
|
||||
| CFPassword | Cloud foundry user password | String |
|
||||
| CookieName | OAuth2 Proxy cookie name | String |
|
||||
| CFLoginUrl | Cloud foundry login url (default: https://login.cloud.pcftest.com/oauth/token) | String |
|
||||
| CFAppsUrl | Cloud foundry apps url (default: https://api.cloud.pcftest.com/v3/apps) | String |
|
||||
| CFAuthenticatorAppName | Token Authenticator internal app name deployed in the space | String |
|
||||
| AuthenticatorSessionExpireOffsetInPercent | Redis cache clear timeout offset for Authenticator app (default: 10), eg: if set to 99, then Redis cache will get cleared in 18 seconds ( if IAM access token timeout: 30 minutes) | String |
|
||||
| ServiceID | Service identities ID in IAM | String |
|
||||
| ServiceIDPrivateKey | ServiceID's private key in IAM | String |
|
||||
| IDMClientBaseUrl | IDM client url till identiry (eg: https://idm-client-test.us-east.philips-healthsuite.com/authorize/identity) IAM | String |
|
||||
String |
|
||||
| IAMAuthorizationUrl | IAM client authorization url (eg: https://iam-client-test.us-east.philips-healthsuite.com/authorize/oauth2/token) IAM | String |
|
||||
| IAMAccessTokenUrl | IAM client access token url (eg: https://iam-client-test.us-east.philips-healthsuite.com/oauth2/access_token) IAM | String |
|
||||
| AccessTokenTestRoleName | Role with BASIC.READ permission created for an organization ( eg: RoleName: TESTROLE ) which is used for access token authenticator tests | String |
|
||||
|
||||
## Automation Test categories and corresponding Envoy configuration files to deploy
|
||||
|
||||
| TestCategory | Envoy file | Comments |
|
||||
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- |
|
||||
| WithoutMultitenancy | https://github.com/philips-internal/hds-auth-gateway/tree/master/AutomationTest/Tests/Data/EnvoyConfigs/envoyconfig_without_multitenancy.yaml | With Standalone Redis |
|
||||
| OrgNameInUrl | https://github.com/philips-internal/hds-auth-gateway/tree/master/AutomationTest/Tests/Data/EnvoyConfigs/envoyconfig_with_multitenancy.yaml | With Standalone Redis and APIGateway environment variable ORG_ID_SOURCE="url" |
|
||||
| OrgIdInHeader | https://github.com/philips-internal/hds-auth-gateway/tree/master/AutomationTest/Tests/Data/EnvoyConfigs/envoyconfig_with_multitenancy.yaml | With Cluster Redis and APIGateway environment variable ORG_ID_SOURCE="header" |
|
||||
| UserAccessToken | https://github.com/philips-internal/hds-auth-gateway/tree/master/AutomationTest/Tests/Data/EnvoyConfigs/envoyconfig_withoutMultitenancy_WithAuthenticator.yaml | With Standalone Redis" |
|
||||
| ServiceIDAccessToken | https://github.com/philips-internal/hds-auth-gateway/tree/master/AutomationTest/Tests/Data/EnvoyConfigs/envoyconfig_withoutMultitenancy_WithAuthenticator.yaml | With Standalone Redis" |
|
||||
|
||||
## Automation Test Reports
|
||||
Automation test reports will be available as word report and trx report file which is interated with tfs release pipeline and displayed in test results dashboard.
|
||||
https://tfsemea1.ta.philips.com/tfs/TPC_Region11/SAL/_dashboards/dashboard/76acadfe-3e1f-4225-9f4f-19af794bc95f
|
||||
|
||||
## Manual Test cases suite:
|
||||
https://tfsemea1.ta.philips.com/tfs/TPC_Region11/Healthcare%20IT/_testPlans/define?planId=1297712&suiteId=1298021
|
||||
|
|
@ -0,0 +1,532 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.CFUtilites;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.CFUtilites.Models;
|
||||
using Reporters;
|
||||
using Utilities;
|
||||
using Utilities.Wait;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.APITests.AccessTokenAuthenticationTests
|
||||
{
|
||||
[TestClass]
|
||||
public class AccessTokenAuthenticationTests : BaseTest
|
||||
{
|
||||
private readonly CFUtility _cfUtility = new CFUtility(pipelineConfigs.CFBaseUrl, pipelineConfigs.CFUserName, pipelineConfigs.CFPassword, pipelineConfigs.CFOauthTokenUrl);
|
||||
private readonly HSPIAMBusinessLayer _iamBL = new HSPIAMBusinessLayer();
|
||||
|
||||
private const string _permission = "BASIC.READ";
|
||||
private static string _permissionsJson = "{\"permissions\":[\"PermissionPlaceHolder\"]}".Replace("PermissionPlaceHolder", _permission);
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.UserAccessToken))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void APIGetCallWithUserAccessTokenTest()
|
||||
{
|
||||
var userAccessTokenHeader = CreateUserAccessTokenHeader();
|
||||
APIGetCallWithAccessToken(userAccessTokenHeader);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.UserAccessToken))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void APICallsWithMultipleUserAccessTokenAndVerifySpecificAccessTokenIntrospectValueTest()
|
||||
{
|
||||
var userAccessTokenHeader1 = CreateUserAccessTokenHeader();
|
||||
var userAccessTokenHeader2 = CreateUserAccessTokenHeader();
|
||||
var userAccessTokenHeader3 = CreateUserAccessTokenHeader();
|
||||
var userAccessTokenHeader4 = CreateUserAccessTokenHeader();
|
||||
var userAccessTokenHeader5 = CreateUserAccessTokenHeader();
|
||||
|
||||
APICallsWithMultipleAccessTokenAndVerifySpecificAccessTokenIntrospectValue(userAccessTokenHeader1, userAccessTokenHeader2, userAccessTokenHeader3, userAccessTokenHeader4, userAccessTokenHeader5);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.UserAccessToken))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void CRUDApiCallWithUserAccessTokenTest()
|
||||
{
|
||||
var userAccessTokenHeader = CreateUserAccessTokenHeader();
|
||||
CRUDApiCallWithAccessToken(userAccessTokenHeader);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.UserAccessToken))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void APIGetCallWithInvalidAccessTokenTest()
|
||||
{
|
||||
Report.Step(@"API call with access token", @"Should get the 401 Unauthorized response");
|
||||
var invalidAccessTokenHeader = new Dictionary<string, string>();
|
||||
invalidAccessTokenHeader.Add("Authorization", $"Bearer {Guid.NewGuid().ToString()}");
|
||||
var response = HttpClientUtility.ExecuteAsync(HttpMethod.Get, defaultEndpointUrl, invalidAccessTokenHeader, null).Result;
|
||||
AssertTest.IsTrue(response.StatusCode == HttpStatusCode.Unauthorized, failMsg: "Not received HttpStatusCode.Unauthorized", passMsg: "Received HttpStatusCode.Unauthorized");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.UserAccessToken))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void APIGetCallWithRefreshTokenTest()
|
||||
{
|
||||
Report.Step(@"API call with refresh token", @"Should get the 401 Unauthorized response");
|
||||
var userAccessTokenHeader = CreateUserAccessTokenHeader("refresh_token");
|
||||
var response = HttpClientUtility.ExecuteAsync(HttpMethod.Get, defaultEndpointUrl, userAccessTokenHeader, null).Result;
|
||||
AssertTest.IsTrue(response.StatusCode == HttpStatusCode.Unauthorized, failMsg: "Not received HttpStatusCode.Unauthorized", passMsg: "Received HttpStatusCode.Unauthorized");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.UserAccessToken))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void ChangePermissionInRoleAndVerifyUserAccessTokenPermissionsBeforeRedisCacheTimeoutTest()
|
||||
{
|
||||
var userAccessTokenHeader = CreateUserAccessTokenHeader();
|
||||
|
||||
AddPermissionInRole(userAccessTokenHeader, _permission);
|
||||
|
||||
ChangePermissionInRoleAndVerifyAccessTokenPermissionsBeforeRedisCacheTimeoutTest(userAccessTokenHeader, _permission);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.UserAccessToken))]
|
||||
[TestMethod]
|
||||
public void ChangePermissionInRoleAndVerifyUserAccessTokenPermissionsAfterRedisCacheTimeoutTest()
|
||||
{
|
||||
//By default Authenticator_session__SessionExpireOffsetInPercent is 10% and updating to 99%, so that the redis cache will clear in 18 seconds
|
||||
var userAccessTokenHeader = CreateUserAccessTokenHeader();
|
||||
|
||||
AddPermissionInRole(userAccessTokenHeader, _permission);
|
||||
|
||||
ChangePermissionInRoleAndVerifyAccessTokenPermissionsAfterRedisCacheTimeoutTest(userAccessTokenHeader, _permission);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.UserAccessToken))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void APIGetCallWithUserAccessTokenWithNoPermissionTest()
|
||||
{
|
||||
var accessTokenHeader = CreateUserAccessTokenHeader();
|
||||
APIGetCallWithAccessTokenWithNoPermission(accessTokenHeader);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.UserAccessToken))]
|
||||
[TestMethod]
|
||||
public void StopAccessTokenAuthenticatorAppAndMakeAPICallWithUserAccessTokenTest()
|
||||
{
|
||||
var userAccessTokenHeader = CreateUserAccessTokenHeader();
|
||||
StopAccessTokenAuthenticatorAppAndMakeAPICallWithAccessTokenTest(userAccessTokenHeader);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.ServiceIDAccessToken))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void APIGetCallWithServiceIDAccessTokenTest()
|
||||
{
|
||||
var serviceIDAccessTokenHeader = CreateServiceIDAccessTokenHeader();
|
||||
APIGetCallWithAccessToken(serviceIDAccessTokenHeader);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.ServiceIDAccessToken))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void CRUDApiCallWithServiceIDAccessTokenTest()
|
||||
{
|
||||
var serviceIDAccessTokenHeader = CreateServiceIDAccessTokenHeader();
|
||||
CRUDApiCallWithAccessToken(serviceIDAccessTokenHeader);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.ServiceIDAccessToken))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void APICallsWithMultipleServiceIDAccessTokenAndVerifySpecificAccessTokenIntrospectValueTest()
|
||||
{
|
||||
var serviceIDAccessTokenHeader1 = CreateServiceIDAccessTokenHeader();
|
||||
var serviceIDAccessTokenHeader2 = CreateServiceIDAccessTokenHeader();
|
||||
var serviceIDAccessTokenHeader3 = CreateServiceIDAccessTokenHeader();
|
||||
var serviceIDAccessTokenHeader4 = CreateServiceIDAccessTokenHeader();
|
||||
var serviceIDAccessTokenHeader5 = CreateServiceIDAccessTokenHeader();
|
||||
|
||||
APICallsWithMultipleAccessTokenAndVerifySpecificAccessTokenIntrospectValue(serviceIDAccessTokenHeader1, serviceIDAccessTokenHeader2, serviceIDAccessTokenHeader3, serviceIDAccessTokenHeader4, serviceIDAccessTokenHeader5);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.ServiceIDAccessToken))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void ChangePermissionInRoleAndVerifyServiceIDAccessTokenPermissionsBeforeRedisCacheTimeoutTest()
|
||||
{
|
||||
var serviceIDAccessTokenHeader = CreateServiceIDAccessTokenHeader();
|
||||
|
||||
AddPermissionInRole(serviceIDAccessTokenHeader, _permission);
|
||||
|
||||
ChangePermissionInRoleAndVerifyAccessTokenPermissionsBeforeRedisCacheTimeoutTest(serviceIDAccessTokenHeader, _permission);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.ServiceIDAccessToken))]
|
||||
[TestMethod]
|
||||
public void ChangePermissionInRoleAndVerifyServiceIDAccessTokenPermissionsAfterRedisCacheTimeoutTest()
|
||||
{
|
||||
//By default Authenticator_session__SessionExpireOffsetInPercent is 10% and updating to 99%, so that the redis cache will clear in 18 seconds
|
||||
var serviceIDAccessTokenHeader = CreateServiceIDAccessTokenHeader();
|
||||
|
||||
AddPermissionInRole(serviceIDAccessTokenHeader, _permission);
|
||||
|
||||
ChangePermissionInRoleAndVerifyAccessTokenPermissionsAfterRedisCacheTimeoutTest(serviceIDAccessTokenHeader, _permission);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.ServiceIDAccessToken))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void APIGetCallWithServiceIDAccessTokenWithNoPermissionTest()
|
||||
{
|
||||
var accessTokenHeader = CreateServiceIDAccessTokenHeader();
|
||||
APIGetCallWithAccessTokenWithNoPermission(accessTokenHeader);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.ServiceIDAccessToken))]
|
||||
[TestMethod]
|
||||
public void StopAccessTokenAuthenticatorAppAndMakeAPICallWithServiceIDAccessTokenTest()
|
||||
{
|
||||
var serviceIDAccessTokenHeader = CreateServiceIDAccessTokenHeader();
|
||||
StopAccessTokenAuthenticatorAppAndMakeAPICallWithAccessTokenTest(serviceIDAccessTokenHeader);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestMethod]
|
||||
public async Task HttpToHttpsRedirectionUsingAPIGatewayTest()
|
||||
{
|
||||
var apiGatewayUrl = pipelineConfigs.APIGatewayBaseUrl.Replace("https","http");
|
||||
AssertTest.IsFalse(apiGatewayUrl.Contains("https"), failMsg: "Invalid Url", passMsg: "Valid Url");
|
||||
var userAccessTokenHeader = CreateUserAccessTokenHeader();
|
||||
|
||||
var response = await HttpClientUtility.ExecuteAsyncWithoutHttpRedirection(HttpMethod.Get,apiGatewayUrl+appConfigs.LessPayloadMockservice, userAccessTokenHeader,null);
|
||||
Assert.AreEqual(HttpStatusCode.MovedPermanently, response.StatusCode);
|
||||
|
||||
var redirectedUrl = response.Headers.Location.AbsoluteUri;
|
||||
var redirectedResponse = HttpClientUtility.ExecuteAndGetResponse(response.RequestMessage.Method, redirectedUrl, userAccessTokenHeader, null);
|
||||
AssertTest.IsTrue(redirectedResponse != null && redirectedResponse["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received success response");
|
||||
|
||||
}
|
||||
|
||||
|
||||
#region Private methods
|
||||
|
||||
private void APIGetCallWithAccessToken(Dictionary<string, string> accessTokenHeader)
|
||||
{
|
||||
Report.Step(@"API call with access token", @"Should get the valid upstream response");
|
||||
|
||||
var responseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, defaultEndpointUrl, accessTokenHeader, null);
|
||||
AssertTest.IsTrue(responseBody != null && responseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received success response");
|
||||
}
|
||||
|
||||
private void CRUDApiCallWithAccessToken(Dictionary<string, string> accessTokenHeader)
|
||||
{
|
||||
Report.Step(@"GET API call with access token", @"Should get the valid upstream response");
|
||||
var getResponseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, defaultEndpointUrl, accessTokenHeader, null);
|
||||
AssertTest.IsTrue(getResponseBody != null && getResponseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received success response");
|
||||
|
||||
|
||||
Report.Step(@"POST API call with access token", @"Should post successfully");
|
||||
var content = HttpClientUtility.CreateHttpContent(getResponseBody.ToString());
|
||||
var postResponse = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Post, defaultEndpointUrl, accessTokenHeader, content);
|
||||
AssertTest.IsTrue(postResponse != null && postResponse["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received success response");
|
||||
|
||||
|
||||
Report.Step(@"PUT API call with access token", @"Should update successfully");
|
||||
string _heavyPayloadMockServiceUrl = $"{pipelineConfigs.APIGatewayBaseUrl}{ appConfigs.HeavyPayloadMockservice}";
|
||||
getResponseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, _heavyPayloadMockServiceUrl, accessTokenHeader, null);
|
||||
content = HttpClientUtility.CreateHttpContent(getResponseBody.ToString());
|
||||
var putResponse = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Put, defaultEndpointUrl, accessTokenHeader, content);
|
||||
AssertTest.IsTrue(putResponse != null && putResponse["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received success response");
|
||||
|
||||
|
||||
Report.Step(@"DELETE API call with access token", @"Should delete successfully");
|
||||
var deleteResponse = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Delete, _heavyPayloadMockServiceUrl, accessTokenHeader, null);
|
||||
AssertTest.IsTrue(deleteResponse != null && deleteResponse["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received success response");
|
||||
}
|
||||
|
||||
private void ChangePermissionInRoleAndVerifyAccessTokenPermissionsBeforeRedisCacheTimeoutTest(Dictionary<string, string> accessTokenHeader, string permission)
|
||||
{
|
||||
try
|
||||
{
|
||||
APIGetCallAndRemoveAccessTokenPermissionInRole(accessTokenHeader, permission);
|
||||
|
||||
List<JToken> permissionsFromIntrospectValue = APICallAndGetPermissionsFromIntrospectValue(accessTokenHeader);
|
||||
|
||||
Report.Step(@"Access token permissions should not change before redis cache timeout",
|
||||
@"The permissions should not be changed");
|
||||
AssertTest.IsTrue(permissionsFromIntrospectValue.Contains(permission), failMsg: $"Permission: {permission} removed is updated in redis cache", passMsg: $"Permission: {permission} removed is not updated in redis cache");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
AddPermissionInRole(accessTokenHeader, permission);
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangePermissionInRoleAndVerifyAccessTokenPermissionsAfterRedisCacheTimeoutTest(Dictionary<string, string> userAccessTokenHeader, string permission)
|
||||
{
|
||||
Report.Step($"Create/Update the Environment variable Authenticator_session__SessionExpireOffsetInPercent={pipelineConfigs.AuthenticatorSessionExpireOffsetInPercent}, for access token authenticator application in CF",
|
||||
@"Environment variable should get created/updated");
|
||||
|
||||
var response = _cfUtility.UpdateEnvironmentVariablesToCFApp(pipelineConfigs.CFOrgName, pipelineConfigs.CFSpaceName, pipelineConfigs.CFAuthenticatorAppName,
|
||||
new Dictionary<string, string> { { Constants.AuthenticatorSessionExpireOffsetInPercent, pipelineConfigs.AuthenticatorSessionExpireOffsetInPercent } });
|
||||
AssertTest.IsTrue(response[Constants.AuthenticatorSessionExpireOffsetInPercent] == pipelineConfigs.AuthenticatorSessionExpireOffsetInPercent, failMsg: "Env variable create/update failed", passMsg: "Env variable created/updated successfully");
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
APIGetCallAndRemoveAccessTokenPermissionInRole(userAccessTokenHeader, permission);
|
||||
|
||||
//IAM Access Token timeout 30min (1800 seconds)
|
||||
int cacheClearWaitTimeInSeconds = (int)Math.Round(1800 - (1800 * (Convert.ToDouble(pipelineConfigs.AuthenticatorSessionExpireOffsetInPercent) / 100)));
|
||||
cacheClearWaitTimeInSeconds += 10; //(10 seconds buffer)
|
||||
Report.Step($"Wait for { cacheClearWaitTimeInSeconds} seconds to get Redis cache clear", "");
|
||||
Sleep.Seconds(cacheClearWaitTimeInSeconds);
|
||||
|
||||
var permissionsFromIntrospectValue = APICallAndGetPermissionsFromIntrospectValue(userAccessTokenHeader);
|
||||
Report.Step(@"Access token permissions should change after redis cache timeout",
|
||||
@"The permissions should be changed");
|
||||
AssertTest.IsTrue(!permissionsFromIntrospectValue.Contains(permission), failMsg: $"Permission: {permission} removed, is not updated in redis cache", passMsg: $"Permission: { permission} removed, is updated in redis cache");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Report.Step("Executing the Finally Block", "Finally Block should get executed");
|
||||
AddPermissionInRole(userAccessTokenHeader, permission);
|
||||
_cfUtility.UpdateEnvironmentVariablesToCFApp(pipelineConfigs.CFOrgName, pipelineConfigs.CFSpaceName, pipelineConfigs.CFAuthenticatorAppName,
|
||||
new Dictionary<string, string> { { Constants.AuthenticatorSessionExpireOffsetInPercent, "10" } });
|
||||
}
|
||||
}
|
||||
|
||||
private void StopAccessTokenAuthenticatorAppAndMakeAPICallWithAccessTokenTest(Dictionary<string, string> userAccessTokenHeader)
|
||||
{
|
||||
Report.Step(@"Stop the access token authenticator application", @"Access token authenticator application should be stopped");
|
||||
AssertTest.IsTrue(_cfUtility.ChangingCFAppState(pipelineConfigs.CFOrgName, pipelineConfigs.CFSpaceName, pipelineConfigs.CFAuthenticatorAppName, AppState.stop), failMsg: "Failed to stop application", passMsg: "Application stopped successfully");
|
||||
|
||||
try
|
||||
{
|
||||
Report.Step(@"API call with access token", @"Should get the 403 forbidden response");
|
||||
var response = HttpClientUtility.ExecuteAsync(HttpMethod.Get, defaultEndpointUrl, userAccessTokenHeader, null).Result;
|
||||
AssertTest.IsTrue(response.StatusCode == HttpStatusCode.Forbidden, failMsg: $"Failed to get 403 Forbidden status code, Actual: {response.StatusCode}", passMsg: "Recieved 403 Forbidden status code");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Report.Step(@"Start the access token authenticator application", @"Access token authenticator application should be started");
|
||||
AssertTest.IsTrue(_cfUtility.ChangingCFAppState(pipelineConfigs.CFOrgName, pipelineConfigs.CFSpaceName, pipelineConfigs.CFAuthenticatorAppName, AppState.start), failMsg: "Failed to start application", passMsg: "Application started successfully");
|
||||
}
|
||||
}
|
||||
|
||||
private List<JToken> APICallAndGetPermissionsFromIntrospectValue(Dictionary<string, string> userAccessTokenHeader)
|
||||
{
|
||||
Report.Step(@"Another API call with the same access token", @"Should get the valid upstream response");
|
||||
string customUniqueRequestHeaderValue = Guid.NewGuid().ToString();
|
||||
userAccessTokenHeader.Add(Constants.CustomUniqueRequestHeaderName, customUniqueRequestHeaderValue);
|
||||
var responseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, defaultEndpointUrl, userAccessTokenHeader, null);
|
||||
AssertTest.IsTrue(responseBody != null && responseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received success response");
|
||||
|
||||
|
||||
Report.Step(@"Get the recorded upstream call request from mountebank mockservice",
|
||||
@"edisp-introspect-value should be available in the upstream request headers");
|
||||
CommonBL commonBL = new CommonBL();
|
||||
var getResponseBody = commonBL.GetImposterRecordedRequests(pipelineConfigs.APIGatewayBaseUrl, userAccessTokenHeader, "LessPayloadMockservice.json");
|
||||
var headers = getResponseBody["requests"].Where(x => x["headers"][Constants.CustomUniqueRequestHeaderName] != null && x["headers"][Constants.CustomUniqueRequestHeaderName].ToString() == customUniqueRequestHeaderValue).FirstOrDefault();
|
||||
var introspectEncodedValue = headers["headers"]["edisp-introspect-value"].ToString();
|
||||
AssertTest.IsTrue(!string.IsNullOrWhiteSpace(introspectEncodedValue), failMsg: "edisp-introspect-value is not found in upstream request headers", passMsg: "edisp-introspect-value is available in upstream request headers");
|
||||
|
||||
|
||||
byte[] data = Convert.FromBase64String(introspectEncodedValue);
|
||||
string decodedString = Encoding.UTF8.GetString(data);
|
||||
var permissionsFromIntrospectValue = JObject.Parse(decodedString)["organizations"]["organizationList"].Where(x => x["organizationId"].ToString() == tenantDetails[Constants.AccessTokenTenantKey].IamOrganizationId).FirstOrDefault()["permissions"].ToList();
|
||||
return permissionsFromIntrospectValue;
|
||||
}
|
||||
|
||||
private void APIGetCallAndRemoveAccessTokenPermissionInRole(Dictionary<string, string> accessTokenHeader, string permission)
|
||||
{
|
||||
Report.Step(@"API call with access token", @"Should get the valid upstream response");
|
||||
if (accessTokenHeader.ContainsKey("api-version"))
|
||||
accessTokenHeader.Remove("api-version");
|
||||
var responseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, defaultEndpointUrl, accessTokenHeader, null);
|
||||
AssertTest.IsTrue(responseBody != null && responseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: $"No Success response received, Response Body: '{responseBody}'", passMsg: "Received success response");
|
||||
|
||||
RemovePermissionInRole(accessTokenHeader, permission);
|
||||
}
|
||||
|
||||
private bool RemovePermissionInRole(Dictionary<string, string> accessTokenHeader, string permission)
|
||||
{
|
||||
Report.Step(@"Capture persmissions from Role in IAM for the access token", @"Should get all the permissions captured from Role in IAM");
|
||||
string roleId = _iamBL.GetRoleId(pipelineConfigs.IDMClientBaseUrl, accessTokenHeader, tenantDetails[Constants.AccessTokenTenantKey].IamOrganizationId, pipelineConfigs.AccessTokenTestRoleName);
|
||||
List<string> capturedAllPermissions = _iamBL.GetAllPersmissionsFromRole(pipelineConfigs.IDMClientBaseUrl, accessTokenHeader, roleId);
|
||||
AssertTest.IsTrue(capturedAllPermissions.Count > 0, failMsg: "No permission catpured from role", passMsg: "Captured all persmission from role");
|
||||
|
||||
|
||||
if (capturedAllPermissions.Contains(permission))
|
||||
{
|
||||
Report.Step(@"Remove permissions in Role", @"Permissions should be removed in the Role");
|
||||
_iamBL.RemovePermissionFromRole(pipelineConfigs.IDMClientBaseUrl, accessTokenHeader, roleId, _permissionsJson);
|
||||
Logger.Info($"Remove Permission: {permission}");
|
||||
bool isPermissionRemoved = !_iamBL.GetAllPersmissionsFromRole(pipelineConfigs.IDMClientBaseUrl, accessTokenHeader, roleId).Contains(permission);
|
||||
AssertTest.IsTrue(isPermissionRemoved, failMsg: $"Permission: {permission} not removed", passMsg: $"Permission: {permission} removed successfully");
|
||||
return isPermissionRemoved;
|
||||
}
|
||||
else
|
||||
{
|
||||
AssertTest.IsTrue(!capturedAllPermissions.Contains(permission), failMsg: $"Permission: {permission} exist ", passMsg: $"Permission: {permission} already not exists");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool AddPermissionInRole(Dictionary<string, string> accessTokenHeader, string permission)
|
||||
{
|
||||
Report.Step(@"Capture persmissions from Role in IAM for the access token", @"Should get all the permissions captured from Role in IAM");
|
||||
|
||||
string roleId = _iamBL.GetRoleId(pipelineConfigs.IDMClientBaseUrl, accessTokenHeader, tenantDetails[Constants.AccessTokenTenantKey].IamOrganizationId, pipelineConfigs.AccessTokenTestRoleName);
|
||||
List<string> capturedAllPermissions = _iamBL.GetAllPersmissionsFromRole(pipelineConfigs.IDMClientBaseUrl, accessTokenHeader, roleId);
|
||||
AssertTest.IsTrue(capturedAllPermissions.Count > 0, failMsg: "No permission catpured from role", passMsg: "Captured all persmission from role");
|
||||
|
||||
|
||||
Report.Step(@"Add permissions in Role", @"Permissions should be added in the Role");
|
||||
if (!capturedAllPermissions.Contains(permission))
|
||||
{
|
||||
_iamBL.AssignPermissionToRole(pipelineConfigs.IDMClientBaseUrl, accessTokenHeader, roleId, _permissionsJson);
|
||||
Logger.Info($"Assigned Permission: {permission}");
|
||||
bool isPermssionAdded = _iamBL.GetAllPersmissionsFromRole(pipelineConfigs.IDMClientBaseUrl, accessTokenHeader, roleId).Contains(permission);
|
||||
AssertTest.IsTrue(isPermssionAdded, failMsg: $"Permission: {permission} not added", passMsg: $"Permission: {permission} added successfully");
|
||||
return isPermssionAdded;
|
||||
}
|
||||
else
|
||||
{
|
||||
AssertTest.IsTrue(capturedAllPermissions.Contains(permission), failMsg: $"Permission: {permission} not exist", passMsg: $"Permission: {permission} already exists");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, string> CreateUserAccessTokenHeader(string tokenType = "access_token")
|
||||
{
|
||||
var userAccessTokenHeader = HttpClientUtility.CreateUserAccessTokenHeader(pipelineConfigs,tokenType);
|
||||
AssertTest.IsTrue(userAccessTokenHeader != null, failMsg: "User Access Token header is null", passMsg: $"User Access Token header is not null");
|
||||
return userAccessTokenHeader;
|
||||
}
|
||||
|
||||
private Dictionary<string, string> CreateServiceIDAccessTokenHeader()
|
||||
{
|
||||
var serviceIDAccessTokenHeader = HttpClientUtility.CreateServiceIdAccessTokenHeader(pipelineConfigs);
|
||||
AssertTest.IsTrue(serviceIDAccessTokenHeader != null, failMsg: "ServiceID Access Token header is null", passMsg: $"ServiceID Access Token header is not null:{serviceIDAccessTokenHeader}");
|
||||
return serviceIDAccessTokenHeader;
|
||||
}
|
||||
|
||||
private void APIGetCallWithAccessTokenWithNoPermission(Dictionary<string, string> accessTokenHeader)
|
||||
{
|
||||
Report.Step(@"Check and remove permissions in Role if exists", @"Permissions should be remove if exist in the Role");
|
||||
HSPIAMBusinessLayer iamBL = new HSPIAMBusinessLayer();
|
||||
string roleId = iamBL.GetRoleId(pipelineConfigs.IDMClientBaseUrl, accessTokenHeader, tenantDetails[Constants.AccessTokenTenantKey].IamOrganizationId, pipelineConfigs.AccessTokenTestRoleName);
|
||||
var allPermissions = iamBL.GetAllPersmissionsFromRole(pipelineConfigs.IDMClientBaseUrl, accessTokenHeader, roleId);
|
||||
if (allPermissions.Contains(_permission))
|
||||
{
|
||||
bool permissionRemovedStatus = iamBL.RemovePermissionFromRole(pipelineConfigs.IDMClientBaseUrl, accessTokenHeader, roleId, _permissionsJson);
|
||||
AssertTest.IsTrue(permissionRemovedStatus, failMsg: "Failed to removed the permission {_permission} in role", passMsg: $"Removed permission {_permission} in role");
|
||||
}
|
||||
|
||||
|
||||
Report.Step(@"API call with access token", @"Should get the 403 Forbidden response");
|
||||
string checkPermissionMockserviceUrl = $"{defaultEndpointUrl}/checkpermission";
|
||||
accessTokenHeader.Add("edisp-org-id", tenantDetails[Constants.AccessTokenTenantKey].IamOrganizationId);
|
||||
accessTokenHeader.Add("permission-name", _permission);
|
||||
var response = HttpClientUtility.ExecuteAsync(HttpMethod.Get, checkPermissionMockserviceUrl, accessTokenHeader, null).Result;
|
||||
AssertTest.IsTrue(response.StatusCode == HttpStatusCode.Forbidden, failMsg: $"Did not receive 403 Forbidden response, Actual: {response.StatusCode}", passMsg: "Received 403 Forbidden response");
|
||||
}
|
||||
|
||||
private void APICallsWithMultipleAccessTokenAndVerifySpecificAccessTokenIntrospectValue(Dictionary<string, string> accessTokenHeader1, Dictionary<string, string> accessTokenHeader2, Dictionary<string, string> accessTokenHeader3, Dictionary<string, string> userAccessTokenHeader4, Dictionary<string, string> userAccessTokenHeader5)
|
||||
{
|
||||
AddPermissionInRole(accessTokenHeader1, _permission);
|
||||
|
||||
Report.Step(@"2 API calls with first 2 different access token", @"Should get the valid upstream response for all 2 api calls");
|
||||
APIGetCallWithAccessToken(accessTokenHeader1);
|
||||
APIGetCallWithAccessToken(accessTokenHeader2);
|
||||
|
||||
|
||||
Report.Step(@"Remove permission with the access token", @"Permissions should be removed in Role");
|
||||
RemovePermissionInRole(accessTokenHeader3, _permission);
|
||||
|
||||
Sleep.Seconds(3);
|
||||
Report.Step(@"API call with 3rd access token", @"Should get the valid upstream response for the 3rd api call");
|
||||
APIGetCallWithAccessToken(accessTokenHeader3);
|
||||
|
||||
|
||||
Report.Step(@"Revert the permission which earlier did with access token", @"Permissions should be reverted in Role");
|
||||
RemovePermissionInRole(accessTokenHeader3, _permission);
|
||||
|
||||
|
||||
Report.Step(@"API calls with last 2 access token", @"Should get the valid upstream response for the last 2 api calls");
|
||||
APIGetCallWithAccessToken(userAccessTokenHeader4);
|
||||
APIGetCallWithAccessToken(userAccessTokenHeader5);
|
||||
|
||||
var introspectValuePermissions = APICallAndGetPermissionsFromIntrospectValue(accessTokenHeader3);
|
||||
|
||||
Report.Step(@"Should get the correct introspect value from Redis cache for the given access token",
|
||||
@"Should get the permission removed introspect value from Redis");
|
||||
AssertTest.IsTrue(!introspectValuePermissions.Contains(_permission), failMsg: "Failed to get the correct introspect value from Reids", passMsg: "Got the correct introspect value from Reids");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Collections.Generic;
|
||||
using Driver.UI.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Reporters;
|
||||
using Utilities;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.APITests.IntrospectionTests
|
||||
{
|
||||
[TestClass]
|
||||
public class IntrospectionTests : BaseTest
|
||||
{
|
||||
private Cookies _cookie;
|
||||
private Dictionary<string, string> _headers;
|
||||
|
||||
[TestInitialize]
|
||||
public void BeforeTest()
|
||||
{
|
||||
Logger.Info("Before test");
|
||||
CommonSteps commonSteps = new CommonSteps();
|
||||
commonSteps.BrowseEndpointAndVerifyLogin(defaultEndpointUrl, pipelineConfigs.AuthUserName, pipelineConfigs.AuthPassword);
|
||||
|
||||
Report.Step(@"Get the cookie from browser", @"Should get the valid cookie");
|
||||
AuthenticationBL authenticationBL = new AuthenticationBL(WebDriver);
|
||||
_cookie = authenticationBL.GetCookie(pipelineConfigs.CookieName);
|
||||
_headers = HttpClientUtility.CreateCookieHeader(pipelineConfigs.CookieName, _cookie.CookieValue); ;
|
||||
AssertTest.IsTrue(_cookie != null, failMsg: "Cookie is not available", passMsg: $"Cookie is available, Cookie value: {_cookie.CookieValue}");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void IntrospectValueToUpstreamRequestHeaderTest()
|
||||
{
|
||||
Report.Step(@"API call to Less payload mockservice and make an imposters api call with mockservice port number to get the recorded upstream request headers from API Gateway",
|
||||
@"edisp-introspect-value should be available in the upstream request headers");
|
||||
string customUniqueRequestHeaderValue = Guid.NewGuid().ToString();
|
||||
_headers.Add(Constants.CustomUniqueRequestHeaderName, customUniqueRequestHeaderValue);
|
||||
Logger.Info($"Mockservice Url: { defaultEndpointUrl}");
|
||||
_ = HttpClientUtility.ExecuteAsync(HttpMethod.Get, defaultEndpointUrl, _headers, null);
|
||||
CommonBL commonBL = new CommonBL();
|
||||
var getResponseBody = commonBL.GetImposterRecordedRequests(pipelineConfigs.APIGatewayBaseUrl, _headers, "LessPayloadMockservice.json");
|
||||
var isRecordRequest = (bool)getResponseBody["recordRequests"];
|
||||
AssertTest.IsTrue(isRecordRequest, failMsg: "Record requests is not enabled in Less payload mockservice imposter", passMsg: "Record request is enabled in Less payload mockservice imposter");
|
||||
var testHeaderRequest = getResponseBody["requests"].Where(x => x["headers"][Constants.CustomUniqueRequestHeaderName] != null && x["headers"][Constants.CustomUniqueRequestHeaderName].ToString() == customUniqueRequestHeaderValue).FirstOrDefault();
|
||||
var testHeaderValue = testHeaderRequest["headers"][Constants.CustomUniqueRequestHeaderName].ToString();
|
||||
var introspectValue = testHeaderRequest["headers"]["edisp-introspect-value"].ToString();
|
||||
AssertTest.IsTrue(!string.IsNullOrWhiteSpace(testHeaderValue) && !string.IsNullOrWhiteSpace(introspectValue), failMsg: "edisp-introspect-value is not found in upstream request headers", passMsg: "edisp-introspect-value is available in upstream request headers");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void IntrospectValueFromUpstreamResponseHeaderTest()
|
||||
{
|
||||
Report.Step(@"GET API call to the CDR service with cookie",
|
||||
@"edisp-introspect-value should be available in the upstream response headers and Authorization should not be available in the upstream response header");
|
||||
string cdrServiceUrl = $"{pipelineConfigs.APIGatewayBaseUrl}{appConfigs.CDRSubscriptionUrlPath.Replace("OrgId", tenantDetails[Constants.ValidTenantKey].TenantName)}";
|
||||
Logger.Info($"CDR service Url: {cdrServiceUrl}");
|
||||
var response = HttpClientUtility.ExecuteAsync(HttpMethod.Get, cdrServiceUrl, _headers, null).Result;
|
||||
AssertTest.IsTrue(response != null && response.Headers.Contains("edisp-introspect-value") && !string.IsNullOrWhiteSpace(response.Headers.GetValues("edisp-introspect-value").FirstOrDefault()),
|
||||
failMsg: "edisp-introspect-value is not found in upstream response headers", passMsg: "edisp-introspect-value is available in upstream request headers");
|
||||
AssertTest.IsTrue(response != null && !response.Headers.Contains("Authorization"),
|
||||
failMsg: "'Authorization' header found in upstream response headers", passMsg: "Authorization header is not available in upstream response headers");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
using Driver.UI.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Reporters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Utilities;
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.APITests.MultitenancyStaticConfiguration
|
||||
{
|
||||
[TestClass]
|
||||
public class MultitenancyStaticConfigurationTests : BaseTest
|
||||
{
|
||||
|
||||
private string placeHolderForOrgReplacement;
|
||||
|
||||
private Cookies _cookie;
|
||||
private Dictionary<string, string> _headers;
|
||||
private static string _apiGatewayBaseUrlWithOrgNamePlaceholder;
|
||||
private static string _cdrServiceUrlBasePathWithoutOrgId;
|
||||
private string _cdrSubscriptionUrlWithOrg1;
|
||||
private string _cdrSubscriptionUrlWithInvalidOrgName;
|
||||
private string _qidoStudyLevelUrlWithInvalidOrgName;
|
||||
|
||||
|
||||
[TestInitialize]
|
||||
public void BeforeTest()
|
||||
{
|
||||
Logger.Info("Before test");
|
||||
UriBuilder uriBuilder = new UriBuilder(pipelineConfigs.APIGatewayBaseUrl);
|
||||
placeHolderForOrgReplacement = $"OrgName-{uriBuilder.Host.Split('.')[0]}";
|
||||
uriBuilder.Host = $"OrgName-{uriBuilder.Host}";
|
||||
_apiGatewayBaseUrlWithOrgNamePlaceholder = uriBuilder.Uri.AbsoluteUri;
|
||||
_cdrServiceUrlBasePathWithoutOrgId = appConfigs.CDRImagingStudyUrlPath.Replace("/OrgId", string.Empty);
|
||||
_cdrSubscriptionUrlWithOrg1 = $"{_apiGatewayBaseUrlWithOrgNamePlaceholder.Replace(placeHolderForOrgReplacement, tenantDetails[Constants.ValidTenantKey].TenantName, StringComparison.InvariantCultureIgnoreCase)}{_cdrServiceUrlBasePathWithoutOrgId}";
|
||||
_cdrSubscriptionUrlWithInvalidOrgName = $"{_apiGatewayBaseUrlWithOrgNamePlaceholder.Replace(placeHolderForOrgReplacement, tenantDetails[Constants.InvalidTenantKey].TenantName, StringComparison.InvariantCultureIgnoreCase)}{_cdrServiceUrlBasePathWithoutOrgId}";
|
||||
_qidoStudyLevelUrlWithInvalidOrgName = $"{_apiGatewayBaseUrlWithOrgNamePlaceholder.Replace(placeHolderForOrgReplacement, tenantDetails[Constants.InvalidTenantKey].TenantName, StringComparison.InvariantCultureIgnoreCase)}{appConfigs.QidoStudyLevelUrlPathWithoutOrgId}";
|
||||
|
||||
Report.Step(@"Browse endpoint url and get the cookie from browser", @"Should get the valid cookie");
|
||||
LoginToEndpoint(_apiGatewayBaseUrlWithOrgNamePlaceholder.Replace(placeHolderForOrgReplacement, tenantDetails[Constants.ValidTenantKey].TenantName, StringComparison.InvariantCultureIgnoreCase), pipelineConfigs.AuthUserName, pipelineConfigs.AuthPassword);
|
||||
AuthenticationBL authenticationBL = new AuthenticationBL(WebDriver);
|
||||
_cookie = authenticationBL.GetCookie(pipelineConfigs.CookieName);
|
||||
_headers = HttpClientUtility.CreateCookieHeader(pipelineConfigs.CookieName, _cookie.CookieValue);
|
||||
AssertTest.IsTrue(_cookie != null, failMsg: "Cookie is not available", passMsg: $"Cookie is available, Cookie value: {_cookie.CookieValue}");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.OrgNameInUrl))]
|
||||
[TestMethod]
|
||||
public void APICallWithValidTenantAsSubDomainTest()
|
||||
{
|
||||
Report.Step(@"GET API call to the CDR service with Org Name(org1) as sub domain in Url", @"Should get the valid CDR service response");
|
||||
CDRGetCallAndAssert(_cdrSubscriptionUrlWithOrg1);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.OrgNameInUrl))]
|
||||
[TestMethod]
|
||||
public void APICallWithValidTenantAsSubDomainAndVerifyOrgIdInUpstreamUrlTest()
|
||||
{
|
||||
//pathMap= {["/mockserviceA/multitenancy"] = "/mockserviceA/multitenancy/orgId"} should be added in of global lua filter in envoy conifg
|
||||
|
||||
Report.Step(@"API call to Less payload mockservice with Org Name (org1) and verify the OrgId in upstream url", @"The upstream url should have org1 orgId");
|
||||
var customUniqueRequestHeaderValue = Guid.NewGuid().ToString();
|
||||
_headers.Add(Constants.CustomUniqueRequestHeaderName, customUniqueRequestHeaderValue);
|
||||
string baseUrl = _apiGatewayBaseUrlWithOrgNamePlaceholder.Replace(placeHolderForOrgReplacement, tenantDetails[Constants.ValidTenantKey].TenantName, StringComparison.InvariantCultureIgnoreCase);
|
||||
string multitenancyMockserviceUrl = $"{ baseUrl }{ appConfigs.MultitenancyMockservice}";
|
||||
Logger.Info($"Mockservice Url: {multitenancyMockserviceUrl}");
|
||||
_ = HttpClientUtility.ExecuteAsync(HttpMethod.Get, multitenancyMockserviceUrl, _headers, null);
|
||||
CommonBL commonBL = new CommonBL();
|
||||
_headers.Remove(Constants.CustomUniqueRequestHeaderName);
|
||||
var upstreamRequestUrl = commonBL.GetUpstreamRecordedRequest(baseUrl, _headers, Constants.CustomUniqueRequestHeaderName, customUniqueRequestHeaderValue, "LessPayloadMockservice.json");
|
||||
string reqUrl = upstreamRequestUrl["path"].ToString();
|
||||
Logger.Info($"Upstream request url: { reqUrl}");
|
||||
AssertTest.IsTrue(upstreamRequestUrl != null && reqUrl.EndsWith(tenantDetails[Constants.ValidTenantKey].IamOrganizationId, StringComparison.InvariantCultureIgnoreCase),
|
||||
failMsg: $"OrgId is not found in upstream request headers for OrgName: {tenantDetails[Constants.ValidTenantKey].TenantName}", passMsg: $"OrgId is available in upstream request headers for the OrgName: {tenantDetails[Constants.ValidTenantKey].TenantName}");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.OrgNameInUrl))]
|
||||
[TestMethod]
|
||||
public void APICallWithInValidTenantAsSubDomainAndOrgNameNotInStaticConfigurationTest()
|
||||
{
|
||||
Report.Step(@"GET API call to the CDR service with invalid Org Name as sub domain which is not in static configuration", @"Should get the 404 error response");
|
||||
Logger.Info($"CDR service invalid org name Url: {_cdrSubscriptionUrlWithInvalidOrgName}");
|
||||
var response = HttpClientUtility.ExecuteAsync(HttpMethod.Get, _cdrSubscriptionUrlWithInvalidOrgName, _headers, null).Result;
|
||||
AssertTest.IsTrue(!response.IsSuccessStatusCode && response.StatusCode == HttpStatusCode.NotFound,
|
||||
failMsg: "Failed to get 404 status code for the CDR service response", passMsg: "Received the 404 status code for the CDR service response");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.OrgNameInUrl))]
|
||||
[TestMethod]
|
||||
public void APICallWithInvalidTenantAsSubDomainAndInvalidOrgIdInHeaderTest()
|
||||
{
|
||||
Report.Step(@"GET API call to the CDR service with Org Name(org1) as sub domain in Url and invalid OrgId in headers", @"Should get the valid CDR service response");
|
||||
_headers.Add("edisp-org-id", tenantDetails[Constants.InvalidTenantKey].IamOrganizationId);
|
||||
Logger.Info($"Invalid OrgId: {tenantDetails[Constants.InvalidTenantKey].IamOrganizationId}");
|
||||
CDRGetCallAndAssert(_cdrSubscriptionUrlWithOrg1);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.OrgIdInHeader))]
|
||||
[TestMethod]
|
||||
public void APICallWithValidOrgIdInHeadersTest()
|
||||
{
|
||||
Report.Step(@"GET API call to the CDR service with valid OrgId in header", @"Should get the valid CDR service response");
|
||||
_headers.Add("edisp-org-id", tenantDetails[Constants.ValidTenantKey].IamOrganizationId);
|
||||
Logger.Info($"Valid OrgId: {tenantDetails[Constants.ValidTenantKey].TenantName}");
|
||||
CDRGetCallAndAssert(_cdrSubscriptionUrlWithOrg1);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.OrgIdInHeader))]
|
||||
[TestMethod]
|
||||
public void APICallWithInValidOrgIdInHeaderTest()
|
||||
{
|
||||
Report.Step(@"GET API call to the dicom service with invalid OrgId in header", @"Should get the 403 error response");
|
||||
_headers.Add("edisp-org-id", tenantDetails[Constants.InvalidTenantKey].IamOrganizationId);
|
||||
Logger.Info($"Qido study level Url: {_qidoStudyLevelUrlWithInvalidOrgName}");
|
||||
var response = HttpClientUtility.ExecuteAsync(HttpMethod.Get, _qidoStudyLevelUrlWithInvalidOrgName, _headers, null).Result;
|
||||
AssertTest.IsTrue(!response.IsSuccessStatusCode && response.StatusCode == HttpStatusCode.Forbidden,
|
||||
failMsg: "Failed to get 403 status code in response for the Qido call with invalid OrgId in header", passMsg: "Received the 403 status code response for the qido call with invalid Orgid in header ");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.OrgIdInHeader))]
|
||||
[TestMethod]
|
||||
public void APICallWithoutOrgIdInHeaderTest()
|
||||
{
|
||||
Report.Step(@"GET API call to the dicom service without OrgId in header", @"Should get the 404 error response");
|
||||
Logger.Info($"Qido study level Url: {_qidoStudyLevelUrlWithInvalidOrgName}");
|
||||
var response = HttpClientUtility.ExecuteAsync(HttpMethod.Get, _qidoStudyLevelUrlWithInvalidOrgName, _headers, null).Result;
|
||||
AssertTest.IsTrue(!response.IsSuccessStatusCode && response.StatusCode == HttpStatusCode.NotFound,
|
||||
failMsg: "Failed to get 404 status code in response for the Qido call without OrgId in header", passMsg: "Received the 404 status code response for the qido call without Orgid in header ");
|
||||
}
|
||||
|
||||
private void CDRGetCallAndAssert(string _crdSubscriptionUrl)
|
||||
{
|
||||
Logger.Info($"CDR subscription Url: {_crdSubscriptionUrl}");
|
||||
var responseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, _crdSubscriptionUrl, _headers, null);
|
||||
AssertTest.IsTrue(responseBody != null && responseBody.ContainsKey("resourceType") && responseBody["resourceType"].ToString().EqualsWithIgnoreCase("Bundle"),
|
||||
failMsg: "Failed to get the CDR service success response", passMsg: "Received the CDR service success response");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using Driver.UI.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Reporters;
|
||||
using Utilities;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.APITests.RequestTransformationHeadersTests
|
||||
{
|
||||
[TestClass]
|
||||
public class RequestTransformationHeadersTests : BaseTest
|
||||
{
|
||||
private Cookies _cookie;
|
||||
private Dictionary<string, string> _headers;
|
||||
|
||||
|
||||
[TestInitialize]
|
||||
public void BeforeTest()
|
||||
{
|
||||
Logger.Info("Before test");
|
||||
CommonSteps _commonSteps = new CommonSteps();
|
||||
_commonSteps.BrowseEndpointAndVerifyLogin(defaultEndpointUrl, pipelineConfigs.AuthUserName, pipelineConfigs.AuthPassword);
|
||||
|
||||
Report.Step(@"Get the cookie from browser", @"Should get the valid cookie");
|
||||
AuthenticationBL authenticationBL = new AuthenticationBL(WebDriver);
|
||||
_cookie = authenticationBL.GetCookie(pipelineConfigs.CookieName);
|
||||
_headers = HttpClientUtility.CreateCookieHeader(pipelineConfigs.CookieName, _cookie.CookieValue);
|
||||
AssertTest.IsTrue(_cookie != null, failMsg: "Cookie is not available", passMsg: $"Cookie is available, Cookie value: {_cookie.CookieValue}");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void CustomHeaderAddedToUpstreamRequestByAPIGatewayTest()
|
||||
{
|
||||
//custom-header:"100" should be added to less payload mockserviceA in envoy config
|
||||
|
||||
Report.Step(@"API call to Less payload mockservice and make an imposters api call with mockservice port number to get the recorded upstream request from API Gateway",
|
||||
@"custom-header should be available in the upstream request headers");
|
||||
Logger.Info($"Mockservice Url: {defaultEndpointUrl}");
|
||||
_ = HttpClientUtility.ExecuteAsync(HttpMethod.Get, defaultEndpointUrl, _headers, null);
|
||||
CommonBL commonBL = new CommonBL();
|
||||
var getResponseBody = commonBL.GetImposterRecordedRequests(pipelineConfigs.APIGatewayBaseUrl, _headers, "LessPayloadMockservice.json");
|
||||
var isRecordRequest = (bool)getResponseBody["recordRequests"];
|
||||
AssertTest.IsTrue(isRecordRequest, failMsg: "Record requests is not enabled in Less payload mockservice imposter", passMsg: "Record request is enabled in Less payload mockservice imposter");
|
||||
var customHeaderRequest = getResponseBody["requests"].Where(x => x["headers"]["custom-header"] != null && x["headers"]["custom-header"].ToString() == "100").FirstOrDefault();
|
||||
|
||||
AssertTest.IsTrue(customHeaderRequest != null, failMsg: "custom-header is not found in upstream request headers", passMsg: "custom-header is available in upstream request headers");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void PrefixReWriteTest()
|
||||
{
|
||||
//Make sure envoy config should have prefix:"/prefixrewritetest" and prefix_rewrite:"/mockserviceA"
|
||||
|
||||
Report.Step(@"API call with /prefixrewritetest/test url path", @"Url should be updated automatically to /mockserviceA/test and get the upstream response");
|
||||
var customUniqueRequestHeaderValue = Guid.NewGuid().ToString();
|
||||
_headers.Add(Constants.CustomUniqueRequestHeaderName, customUniqueRequestHeaderValue);
|
||||
string prefixReWriteMockserviceUrl = $"{ pipelineConfigs.APIGatewayBaseUrl}/prefixrewritetest/test";
|
||||
Logger.Info($"Mockservice Url: {prefixReWriteMockserviceUrl}");
|
||||
var upstreamResponse = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, prefixReWriteMockserviceUrl, _headers, null);
|
||||
CommonBL commonBL = new CommonBL();
|
||||
_headers.Remove(Constants.CustomUniqueRequestHeaderName);
|
||||
var upstreamRequestUrl = commonBL.GetUpstreamRecordedRequest(pipelineConfigs.APIGatewayBaseUrl, _headers, Constants.CustomUniqueRequestHeaderName, customUniqueRequestHeaderValue, "LessPayloadMockservice.json");
|
||||
string reqUrl = upstreamRequestUrl["path"].ToString();
|
||||
Logger.Info($"Upstream request url: { reqUrl}");
|
||||
AssertTest.IsTrue(upstreamRequestUrl != null && reqUrl.EndsWith(appConfigs.LessPayloadMockservice, StringComparison.InvariantCultureIgnoreCase), failMsg: "custom-header is not found in upstream request headers", passMsg: "custom-header is available in upstream request headers");
|
||||
AssertTest.IsTrue(upstreamResponse != null && upstreamResponse["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received Success response");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Driver.UI.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Reporters;
|
||||
using Utilities;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.APITest
|
||||
{
|
||||
[TestClass]
|
||||
public class ReverseProxyTests : BaseTest
|
||||
{
|
||||
private Cookies _cookie;
|
||||
private readonly CommonSteps _commonSteps = new CommonSteps();
|
||||
private readonly string _heavyPayloadMockServiceUrl = $"{pipelineConfigs.APIGatewayBaseUrl}/{ appConfigs.HeavyPayloadMockservice}";
|
||||
private readonly string _serviceUnavailableMockServiceUrl = $"{pipelineConfigs.APIGatewayBaseUrl}/{ appConfigs.ServiceUnavailableMockservice}";
|
||||
|
||||
[TestInitialize]
|
||||
public void BeforeTest()
|
||||
{
|
||||
Logger.Info("Before test");
|
||||
_commonSteps.BrowseEndpointAndVerifyLogin(defaultEndpointUrl, pipelineConfigs.AuthUserName, pipelineConfigs.AuthPassword);
|
||||
|
||||
Report.Step(@"Get the cookie from browser", @"Should get the valid cookie");
|
||||
AuthenticationBL authenticationBL = new AuthenticationBL(WebDriver);
|
||||
_cookie = authenticationBL.GetCookie(pipelineConfigs.CookieName);
|
||||
AssertTest.IsTrue(_cookie != null, failMsg: "Cookie is not available", passMsg: $"Cookie is available, Cookie value: {_cookie.CookieValue}");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void PostCallWithLessPayloadTest()
|
||||
{
|
||||
Report.Step(@"POST API call to the less payload mockservice with the cookie", @"Should get the valid upstream response with Status: Success");
|
||||
var (headers, requestBody) = GetRequestBody(defaultEndpointUrl);
|
||||
var postResponseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Post, defaultEndpointUrl, headers, requestBody);
|
||||
AssertTest.IsTrue(postResponseBody != null && postResponseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received Success response");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void PostCallWithHeavyPayloadTest()
|
||||
{
|
||||
Report.Step(@"POST API call to the Heavy payload mockservice with the cookie", @"Should get the valid upstream response with Status: Success");
|
||||
var (headers, requestBody) = GetRequestBody(_heavyPayloadMockServiceUrl);
|
||||
var postResponseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Post, _heavyPayloadMockServiceUrl, headers, requestBody);
|
||||
AssertTest.IsTrue(postResponseBody != null && postResponseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received Success response");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void PostCallWhenUpstreamServiceDownTest()
|
||||
{
|
||||
Report.Step(@"POST API call to the Service unavailable mockservice with the cookie", @"Should get 503 Service Unavailable status");
|
||||
var (headers, requestBody) = GetRequestBody(defaultEndpointUrl);
|
||||
var postResponseBody = HttpClientUtility.ExecuteAsync(HttpMethod.Post, _serviceUnavailableMockServiceUrl, headers, requestBody);
|
||||
AssertTest.IsTrue(postResponseBody.Result.StatusCode == HttpStatusCode.ServiceUnavailable, failMsg: "No StatusCode:503 Service Unavailable status received", passMsg: "Received StatusCode:503 Service Unavailable status");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void GetCallWithLessPayloadTest()
|
||||
{
|
||||
Report.Step(@"GET API call to the less payload mockservice with the cookie", @"Should get the valid upstream response with Status: Success");
|
||||
var headers = HttpClientUtility.CreateCookieHeader(pipelineConfigs.CookieName, _cookie.CookieValue);
|
||||
Logger.Info($"GET endpoint Url: {defaultEndpointUrl}");
|
||||
var getResponseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, defaultEndpointUrl, headers, null);
|
||||
AssertTest.IsTrue(getResponseBody != null && getResponseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received Success response");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void GetCallWithHeavyPayloadTest()
|
||||
{
|
||||
Report.Step(@"GET API call to the Heavy payload mockservice with the cookie", @"Should get the valid upstream response with Status: Success");
|
||||
var headers = HttpClientUtility.CreateCookieHeader(pipelineConfigs.CookieName, _cookie.CookieValue);
|
||||
Logger.Info($"GET endpoint Url: {_heavyPayloadMockServiceUrl}");
|
||||
var getResponseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, _heavyPayloadMockServiceUrl, headers, null);
|
||||
AssertTest.IsTrue(getResponseBody != null && getResponseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received Success response");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void GetCallWhenUpstreamServiceDownTest()
|
||||
{
|
||||
Report.Step(@"GET API call to the Service unavailable mockservice with the cookie", @"Should get 503 Service Unavailable status");
|
||||
var headers = HttpClientUtility.CreateCookieHeader(pipelineConfigs.CookieName, _cookie.CookieValue);
|
||||
Logger.Info($"GET endpoint Url: {_serviceUnavailableMockServiceUrl}");
|
||||
var getResponseBody = HttpClientUtility.ExecuteAsync(HttpMethod.Get, _serviceUnavailableMockServiceUrl, headers, null);
|
||||
AssertTest.IsTrue(getResponseBody.Result.StatusCode == HttpStatusCode.ServiceUnavailable, failMsg: "No StatusCode:503 Service Unavailable status received", passMsg: "Received StatusCode:503 Service Unavailable status");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void PutCallWithHeavyPayloadTest()
|
||||
{
|
||||
Report.Step(@"PUT API call to the Heavy payload mockservice with the cookie", @"Should get the valid upstream response with Status: Success");
|
||||
var (headers, requestBody) = GetRequestBody(defaultEndpointUrl);
|
||||
Logger.Info($"PUT call endpoint Url: {_heavyPayloadMockServiceUrl}");
|
||||
var putResponseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Put, _heavyPayloadMockServiceUrl, headers, requestBody);
|
||||
AssertTest.IsTrue(putResponseBody != null && putResponseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received Success response");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void PutCallWhenUpstreamServiceDownTest()
|
||||
{
|
||||
Report.Step(@"PUT API call to the Service unavailable mockservice with the cookie", @"Should get 503 Service Unavailable status");
|
||||
var (headers, requestBody) = GetRequestBody(defaultEndpointUrl);
|
||||
Logger.Info($"PUT call endpoint Url: {_serviceUnavailableMockServiceUrl}");
|
||||
var putResponseBody = HttpClientUtility.ExecuteAsync(HttpMethod.Put, _serviceUnavailableMockServiceUrl, headers, requestBody);
|
||||
AssertTest.IsTrue(putResponseBody.Result.StatusCode == HttpStatusCode.ServiceUnavailable, failMsg: "No StatusCode:503 Service Unavailable status received", passMsg: "Received StatusCode:503 Service Unavailable status");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void DeleteCallTest()
|
||||
{
|
||||
Report.Step(@"DELETE API call to the Heavy payload mockservice with cookie", @"Should get the valid upstream response with Status: Success");
|
||||
var headers = HttpClientUtility.CreateCookieHeader(pipelineConfigs.CookieName, _cookie.CookieValue);
|
||||
Logger.Info($"DELETE call endpoint Url: {_heavyPayloadMockServiceUrl}");
|
||||
var responseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Delete, _heavyPayloadMockServiceUrl, headers, null);
|
||||
AssertTest.IsTrue(responseBody != null && responseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received Success response");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void DeleteCallWhenUpstreamServiceDownTest()
|
||||
{
|
||||
Report.Step(@"DELETE API call to the Service unavailable mockservice with cookie", @"Should get 503 Service Unavailable status");
|
||||
var headers = HttpClientUtility.CreateCookieHeader(pipelineConfigs.CookieName, _cookie.CookieValue);
|
||||
Logger.Info($"DELETE call endpoint Url: {_serviceUnavailableMockServiceUrl}");
|
||||
var responseBody = HttpClientUtility.ExecuteAsync(HttpMethod.Delete, _serviceUnavailableMockServiceUrl, headers, null);
|
||||
AssertTest.IsTrue(responseBody.Result.StatusCode == HttpStatusCode.ServiceUnavailable, failMsg: "No StatusCode:503 Service Unavailable status received", passMsg: "Received StatusCode:503 Service Unavailable status");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void CDRUpstreamServiceAPICallTest()
|
||||
{
|
||||
Report.Step(@"GET API call to the CDR service with cookie", @"Should get the valid CDR service response");
|
||||
var headers = HttpClientUtility.CreateCookieHeader(pipelineConfigs.CookieName, _cookie.CookieValue);
|
||||
string cdrServiceUrl = $"{pipelineConfigs.APIGatewayBaseUrl}{appConfigs.CDRImagingStudyUrlPath.Replace("OrgId", tenantDetails[Constants.ValidTenantKey].IamOrganizationId)}";
|
||||
Logger.Info($"CDR service Url: {cdrServiceUrl}");
|
||||
var responseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, cdrServiceUrl, headers, null);
|
||||
AssertTest.IsTrue(responseBody != null && responseBody.ContainsKey("resourceType") && responseBody["resourceType"].ToString().EqualsWithIgnoreCase("Bundle"),
|
||||
failMsg: "Failed to get the CDR service success response", passMsg: "Received the CDR service success response");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void APICallsFromUIUpstreamInBrowserTest()
|
||||
{
|
||||
Report.Step(@"Browse the mountebank imposters endpoint url", @"Should get the mountebank imposters UI page in browser");
|
||||
var impostersUrl = $"{pipelineConfigs.APIGatewayBaseUrl}/imposters";
|
||||
Logger.Info($"Imposters page Url: {impostersUrl}");
|
||||
ReverseProxyBL reverseProxyBL = new ReverseProxyBL(WebDriver);
|
||||
AssertTest.IsTrue(reverseProxyBL.NavigateToImpostersPageAndGetIsMockServiceLinksDisplayed(impostersUrl), failMsg: "Imposters page is not displayed", passMsg: "Imposters page is displayed");
|
||||
|
||||
|
||||
Report.Step(@"Click on less payload mockservice link and verify", @"Should get the less payload mockservice contents");
|
||||
var isMockserviceADisplayed = reverseProxyBL.ClickOnImposterAndGetMockServiceContentIsDisplayed("ServiceA");
|
||||
AssertTest.IsTrue(isMockserviceADisplayed, failMsg: "Less payload mockservice content is not displayed", passMsg: "Less payload mockservice content is displayed");
|
||||
|
||||
|
||||
Report.Step(@"Click on Heavy payload mockservice link and verify", @"Should get the Heavy payload mockservice contents");
|
||||
WebDriver.ClickOnBrowserBackButton();
|
||||
var isMockserviceBDisplayed = reverseProxyBL.ClickOnImposterAndGetMockServiceContentIsDisplayed("ServiceB");
|
||||
AssertTest.IsTrue(isMockserviceBDisplayed, failMsg: "Heavy payload mockservice content is not displayed", passMsg: "Heavy payload mockservice content is displayed");
|
||||
}
|
||||
|
||||
private (Dictionary<string, string>, StringContent) GetRequestBody(string endpointUrl)
|
||||
{
|
||||
var headers = HttpClientUtility.CreateCookieHeader(pipelineConfigs.CookieName, _cookie.CookieValue);
|
||||
Logger.Info($"GET API call endpoint Url: {endpointUrl}");
|
||||
var getResponseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, defaultEndpointUrl, headers, null);
|
||||
var requestBody = HttpClientUtility.CreateHttpContent(getResponseBody.ToString());
|
||||
Logger.Info($"Request body: {requestBody}");
|
||||
return (headers, requestBody);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Reporters;
|
||||
using TimeZoneConverter;
|
||||
using Utilities;
|
||||
using Utilities.Wait;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.APITests
|
||||
{
|
||||
[TestClass]
|
||||
public class IAMBrokerConfigurationTests : BaseTest
|
||||
{
|
||||
private readonly string _setKeyUrl = $"{pipelineConfigs.APIGatewayBaseUrl}{appConfigs.IamBrokerConfigAPIRelativePath.Replace("OrgId", tenantDetails[Constants.ValidTenantKey].IamOrganizationId)}";
|
||||
private readonly VueSSOTokenBL _ssoTokenBL = new VueSSOTokenBL();
|
||||
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.IAMTokenExchangeBrokerPreCondition))]
|
||||
[TestMethod]
|
||||
public async Task SetSymmetricKeyWithValidAccessTokenTest()
|
||||
{
|
||||
Report.Step(@"Set symmetrickey with valid access token", @"Should get 204 NoContent response");
|
||||
var userAccessTokenHeader = HttpClientUtility.CreateUserAccessTokenHeader(pipelineConfigs);
|
||||
string url = $"{_setKeyUrl}{Constants.SymmetricKeyName}";
|
||||
Logger.Info($"Symmetrickey set url: {url}");
|
||||
var content = HttpClientUtility.CreateHttpContent($"\"{pipelineConfigs.OrgSymmetricKey}\"");
|
||||
var response = await HttpClientUtility.ExecuteAsync(HttpMethod.Post, url, userAccessTokenHeader, content);
|
||||
AssertTest.IsTrue(response != null && response.IsSuccessStatusCode && response.StatusCode == HttpStatusCode.NoContent, failMsg: $"Failed to set the symmetric key, StatusCode: {response.StatusCode}", passMsg: "Symmetrickey set successfully");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.IAMTokenExchangeBroker))]
|
||||
[TestMethod]
|
||||
public async Task SetSymmetricKeyWithInvalidAccessTokenTest()
|
||||
{
|
||||
Report.Step(@"Set symmetrickey with invalid access token", @"Should get 401 Unauthorized response");
|
||||
var invalidAccessTokenHeader = new Dictionary<string, string>();
|
||||
invalidAccessTokenHeader.Add("Authorization", $"Bearer {Guid.NewGuid()}");
|
||||
string url = $"{_setKeyUrl}{Constants.SymmetricKeyName}";
|
||||
Logger.Info($"Symmetrickey set url: {url}");
|
||||
var content = HttpClientUtility.CreateHttpContent($"\"{pipelineConfigs.OrgSymmetricKey}\"");
|
||||
var response = await HttpClientUtility.ExecuteAsync(HttpMethod.Post, _setKeyUrl, invalidAccessTokenHeader, content);
|
||||
AssertTest.IsTrue(response.StatusCode == HttpStatusCode.Unauthorized, failMsg: $"Not received HttpStatusCode 401 Unauthorized, Actual: {response.StatusCode}", passMsg: "Received HttpStatusCode.Unauthorized");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.IAMTokenExchangeBroker))]
|
||||
[TestMethod]
|
||||
public async Task SetTimeZoneWithTokyoStandardTimeTest()
|
||||
{
|
||||
try
|
||||
{
|
||||
await SetTimeZoneAndValidate(Constants.TokyoTimeZone);
|
||||
var response = await APICallWithSSOTokenAndGetResponse(Constants.TokyoTimeZone, defaultEndpointUrl);
|
||||
AssertTest.IsTrue(response != null && response.IsSuccessStatusCode, failMsg: $"TimeZone:{Constants.TokyoTimeZone}, Not received HttpStatusCode 200, Actual: {response.StatusCode}", passMsg: "Received HttpStatusCode 200");
|
||||
|
||||
response = await APICallWithSSOTokenAndGetResponse(Constants.UTCTimeZone, defaultEndpointUrl);
|
||||
AssertTest.IsTrue(response != null && response.StatusCode == HttpStatusCode.Unauthorized, failMsg: $"TimeZone:{Constants.UTCTimeZone}, Not received HttpStatusCode 401 Unauthorized, Actual: {response.StatusCode}", passMsg: "Received HttpStatusCode.Unauthorized");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
await SetTimeZoneAndValidate(Constants.UTCTimeZone);
|
||||
var response = await APICallWithSSOTokenAndGetResponse(Constants.UTCTimeZone, defaultEndpointUrl);
|
||||
AssertTest.IsTrue(response != null && response.IsSuccessStatusCode, failMsg: $"TimeZone:{Constants.UTCTimeZone}, Not received HttpStatusCode 200, Actual: {response.StatusCode}", passMsg: "Received HttpStatusCode 200");
|
||||
}
|
||||
}
|
||||
|
||||
#region private methods
|
||||
|
||||
private async Task SetTimeZoneAndValidate(string timeZoneName)
|
||||
{
|
||||
Report.Step($"Set {timeZoneName} timezone", @"Should get 204 NoContent response");
|
||||
var userAccessTokenHeader = HttpClientUtility.CreateUserAccessTokenHeader(pipelineConfigs);
|
||||
string url = $"{_setKeyUrl}{Constants.TimeZoneKeyName}";
|
||||
timeZoneName = $"\"{timeZoneName}\"";
|
||||
Logger.Info($"Set Timezone url: {url}");
|
||||
var content = HttpClientUtility.CreateHttpContent(timeZoneName);
|
||||
var response = await HttpClientUtility.ExecuteAsync(HttpMethod.Post, url, userAccessTokenHeader, content);
|
||||
AssertTest.IsTrue(response.IsSuccessStatusCode && response.StatusCode == HttpStatusCode.NoContent, failMsg: $"Failed to set the time zone- {timeZoneName}, StatusCode: {response.StatusCode}", passMsg: $"TimeZone was set successfully, StatusCode: {response.StatusCode}");
|
||||
}
|
||||
|
||||
private Task<HttpResponseMessage> APICallWithSSOTokenAndGetResponse(string timeZoneName, string url)
|
||||
{
|
||||
Report.Step($"API call with SSO token generated with {timeZoneName} timezone", @"Should get the upstream response");
|
||||
var tzi = TZConvert.GetTimeZoneInfo(timeZoneName);
|
||||
string ssoToken = _ssoTokenBL.GenerateSsoToken("user", TimeZoneInfo.ConvertTime(DateTimeOffset.UtcNow, tzi).DateTime.ToString(Constants.TimeStampFormat), pipelineConfigs.OrgSymmetricKey);
|
||||
Sleep.Seconds(appConfigs.MountibankTimeoutinSeconds);
|
||||
var headers = new Dictionary<string, string>();
|
||||
headers.TryAdd("EDISP-vuesso", ssoToken);
|
||||
headers.TryAdd("edisp-vuesso-orgid", tenantDetails[Constants.ValidTenantKey].IamOrganizationId);
|
||||
return HttpClientUtility.ExecuteAsync(HttpMethod.Get, url, headers, null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Reporters;
|
||||
using Utilities;
|
||||
using IdentityModel.Jwk;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.APITests
|
||||
{
|
||||
[TestClass]
|
||||
public class IDTokenValidatorTests : BaseTest
|
||||
{
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.IDTokenValidator))]
|
||||
[TestCategory(nameof(TestCategory.UpgradeSanity))]
|
||||
[TestCategory(nameof(TestCategory.IntegratedSanity))]
|
||||
[TestMethod]
|
||||
public void GetOpenIdConfigurationAndVerifyJWKSDataTest()
|
||||
{
|
||||
|
||||
var openIdConfigOrgs = JsonConvert.DeserializeObject<List<OpenIdConfigOrganizationCertificateMapping>>(pipelineConfigs.OpenIdConfigOrganizationCertificateMapping);
|
||||
|
||||
Report.Step(@"Get Jwks url from OpenId Configuration get call for multitenant ", @"Should get the respective tenant Jwks url");
|
||||
foreach (var org in openIdConfigOrgs)
|
||||
{
|
||||
string openIdConfigUrl = $"{pipelineConfigs.OpenIdConfigurationBaseUrl}{appConfigs.OpenIdConfigurationUrlPath.Replace("OrgId", org.OrganizationId)}";
|
||||
Logger.Info($"OpenId Configuration url: {openIdConfigUrl}");
|
||||
var openIdConfigResponse = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, openIdConfigUrl, new Dictionary<string, string>(), null);
|
||||
string jwksUrl = openIdConfigResponse["jwks_uri"]?.ToString();
|
||||
Logger.Info($"Jwks Url: {jwksUrl}");
|
||||
AssertTest.IsTrue(!string.IsNullOrWhiteSpace(jwksUrl) && jwksUrl.Contains($"/{org.OrganizationId}/"), failMsg: $"Failed to get Jwks url for the orgId: {org}", passMsg: "Jwks url is fetched successfully");
|
||||
|
||||
Report.Step(@"Get Jwks keys from the get call of jwks url", @"All the Jwks keys should not be null");
|
||||
var jwksResponse = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, jwksUrl, new Dictionary<string, string>(), null);
|
||||
var jwksData = JsonConvert.DeserializeObject<JsonWebKey>(jwksResponse["keys"]?.First.ToString());
|
||||
|
||||
string expectedCert = RemoveCertificateBoundaryAndLineBreaks(org.Certificate);
|
||||
AssertTest.IsTrue(jwksData.X5c != null && jwksData.X5c[0].Equals(expectedCert), failMsg: $"Property 'x5c' value is null ", passMsg: $"Property 'x5c(certificate)' value is matching with expected value");
|
||||
AssertTest.IsTrue(jwksData.Kid != null, failMsg: $"Property 'Kid' value is null ", passMsg: $"Property 'Kid' is not null ");
|
||||
AssertTest.IsTrue(jwksData.Kty != null, failMsg: $"Property 'Kty' value is null ", passMsg: $"Property 'Kty' is not null ");
|
||||
AssertTest.IsTrue(jwksData.Alg != null, failMsg: $"Property 'alg' value is null ", passMsg: $"Property 'alg' is not null ");
|
||||
AssertTest.IsTrue(jwksData.Use != null, failMsg: $"Property 'Use' value is null ", passMsg: $"Property 'Use' is not null ");
|
||||
AssertTest.IsTrue(jwksData.N != null, failMsg: $"Property 'N' value is null ", passMsg: $"Property 'N' is not null ");
|
||||
AssertTest.IsTrue(jwksData.E != null, failMsg: $"Property 'E' value is null ", passMsg: $"Property 'E' is not null ");
|
||||
}
|
||||
}
|
||||
|
||||
#region private methods
|
||||
private string RemoveCertificateBoundaryAndLineBreaks(string certData)
|
||||
{
|
||||
return certData.Replace("-----BEGIN CERTIFICATE-----", string.Empty)
|
||||
.Replace("-----END CERTIFICATE-----", string.Empty)
|
||||
.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", string.Empty);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,220 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using System.Net.Http;
|
||||
using Reporters;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Utilities.Wait;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.APITests.SSOTokenAuthenticatorTests
|
||||
{
|
||||
[TestClass]
|
||||
public class SSOTokenAuthenticatorTests : BaseTest
|
||||
{
|
||||
private readonly VueSSOTokenBL _ssoTokenBL = new VueSSOTokenBL();
|
||||
private readonly HSPIAMBusinessLayer _iamBL = new HSPIAMBusinessLayer();
|
||||
private string ssoToken;
|
||||
private string userName;
|
||||
string cdrServiceUrl = $"{pipelineConfigs.APIGatewayBaseUrl}{appConfigs.CDRImagingStudyUrlPath.Replace("OrgId", tenantDetails[Constants.ValidTenantKey].IamOrganizationId)}";
|
||||
string getStudyDetailsUrl = $"{pipelineConfigs.CDRBaseUrl}{appConfigs.CDRImagingStudyUrlPath.Replace("OrgId", tenantDetails[Constants.ValidTenantKey].IamOrganizationId)}?_count=1";
|
||||
|
||||
[TestCategory(nameof(TestCategory.SSOToken))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void UserwithPermissionsTest()
|
||||
{
|
||||
Report.Step(@"CDR Call with SSO token header of user having required permission", @"Should get the valid upstream response");
|
||||
var response = GetUpstreamResponseWithSSOToken(pipelineConfigs.SSOTokenUserName, pipelineConfigs.OrgSymmetricKey);
|
||||
AssertTest.IsTrue(response.ToString().Contains("StatusCode: 200"), failMsg: $"StatusCode was not 200, Resopnse Message: {response}", passMsg: "Received success response with statuscode as 200");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.SSOToken))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void CreateUserwithoutPermissionsTest()
|
||||
{
|
||||
try
|
||||
{
|
||||
Report.Step(@"CDR Call with SSO token header of a new user not having required permission", @"Should get 401 unauthorized upstream response");
|
||||
Random rand = new Random();
|
||||
userName = "autoTest"+ rand.Next(99, 9999);
|
||||
var response = GetUpstreamResponseWithSSOToken(userName, pipelineConfigs.OrgSymmetricKey);
|
||||
AssertTest.IsTrue(response.ToString().Contains("StatusCode: 401"), failMsg: "CDR call did not returned Unauthorized access",
|
||||
passMsg: "CDR call returned Status code of 401 Unauthorized access as expected");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Report.ReportError("Exception",e.ToString());
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
//Deleting the created automation user
|
||||
var userAccessTokenHeader = CreateUserAccessTokenHeader();
|
||||
_ = _iamBL.DeleteUser(pipelineConfigs.IAMGetUserUrl, pipelineConfigs.IDMClientBaseUrl, userName+ "_rubyhealthiamte@vue.com", userAccessTokenHeader);
|
||||
}
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.SSOToken))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void UserwithWrongSSOTokenHeaderTest()
|
||||
{
|
||||
Report.Step(@"CDR Call with with wrong SSO token header of a user", @"Should get invalid sso token upstream response");
|
||||
var headers = new Dictionary<string, string>();
|
||||
headers.TryAdd("EDISP-vuesso", "InvalidSSOToken");
|
||||
headers.TryAdd("edisp-vuesso-orgid", tenantDetails[Constants.ValidTenantKey].IamOrganizationId);
|
||||
var response = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, cdrServiceUrl, headers, null);
|
||||
AssertTest.IsTrue(response["Detail"].ToString().EqualsWithIgnoreCase("Please provide valid sso token and symmetric key"),
|
||||
failMsg: "CDR call did not returned 'Please provide valid sso token and symmetric key' error response",
|
||||
passMsg: "CDR call returned error message 'Please provide valid sso token and symmetric key' as expected");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.SSOToken))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void UserwithInvalidOrgIdHeaderTest()
|
||||
{
|
||||
Report.Step(@"CDR Call with with wrong orgId header", @"Should get the given key is not present in the dictionary upstream response");
|
||||
var headers = new Dictionary<string, string>();
|
||||
ssoToken = _ssoTokenBL.GenerateSsoToken(pipelineConfigs.SSOTokenUserName, DateTime.UtcNow.AddMinutes(0).ToString(Constants.TimeStampFormat), pipelineConfigs.OrgSymmetricKey);
|
||||
headers.TryAdd("EDISP-vuesso", ssoToken);
|
||||
headers.TryAdd("edisp-vuesso-orgid", string.Empty);
|
||||
var response = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, cdrServiceUrl, headers, null);
|
||||
var message = "orgId is empty, set it in edisp-vuesso-orgid header";
|
||||
AssertTest.IsTrue(response["Detail"].ToString().EqualsWithIgnoreCase(message),
|
||||
failMsg: $"CDR call did not returned '{message}' error response",
|
||||
passMsg: $"CDR call returned error message '{message}' as expected");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.SSOToken))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void UserwithExpiredSSOTokenTest()
|
||||
{
|
||||
Report.Step(@"CDR Call with with Expired SSO token header of a user with all required permission", @"Should get invalid sso token session timed out upstream response");
|
||||
ssoToken = _ssoTokenBL.GenerateSsoToken(pipelineConfigs.SSOTokenUserName, DateTime.UtcNow.AddMinutes(-31).ToString(Constants.TimeStampFormat), pipelineConfigs.OrgSymmetricKey);
|
||||
var headers = new Dictionary<string, string>();
|
||||
headers.TryAdd("EDISP-vuesso", ssoToken);
|
||||
headers.TryAdd("edisp-vuesso-orgid", tenantDetails[Constants.ValidTenantKey].IamOrganizationId);
|
||||
var response = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, cdrServiceUrl, headers, null);
|
||||
AssertTest.IsTrue(response["Detail"].ToString().EqualsWithIgnoreCase("SSO token session timed out"),
|
||||
failMsg: "CDR call did not returned 'SSO token session timed out' error response",
|
||||
passMsg: "CDR call returned error message 'SSO token session timed out' as expected");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.SSOToken))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public async Task AccessTokenValueisTakenFromCacheTest()
|
||||
{
|
||||
Report.Step(@"Verify that new session with same user uses same cached accesstoken",
|
||||
@"same cached access token should be used");
|
||||
List<string> accessTokenValues = new List<string>();
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
var headers = new Dictionary<string, string>();
|
||||
string customUniqueRequestHeaderValue = Guid.NewGuid().ToString();
|
||||
headers.Add(Constants.CustomUniqueRequestHeaderName, customUniqueRequestHeaderValue);
|
||||
ssoToken = _ssoTokenBL.GenerateSsoToken(pipelineConfigs.SSOTokenUserName, DateTime.UtcNow.ToString(Constants.TimeStampFormat), pipelineConfigs.OrgSymmetricKey);
|
||||
|
||||
headers.TryAdd("EDISP-vuesso", ssoToken);
|
||||
headers.TryAdd("edisp-vuesso-orgid", tenantDetails[Constants.ValidTenantKey].IamOrganizationId);
|
||||
Sleep.Seconds(appConfigs.MountibankTimeoutinSeconds);
|
||||
|
||||
_ = await HttpClientUtility.ExecuteAsync(HttpMethod.Get, defaultEndpointUrl, headers, null);
|
||||
CommonBL commonBL = new CommonBL();
|
||||
var testHeaderRequest = commonBL.GetUpstreamRecordedRequest(pipelineConfigs.APIGatewayBaseUrl, headers, Constants.CustomUniqueRequestHeaderName, customUniqueRequestHeaderValue, "LessPayloadMockservice.json");
|
||||
accessTokenValues.Add(testHeaderRequest["headers"]["authorization"].ToString());
|
||||
}
|
||||
AssertTest.IsTrue(accessTokenValues.First().Equals(accessTokenValues.Last()), failMsg: "New session with same user is not using same cached accesstoken",
|
||||
passMsg: "New session with same user is using cached accesstoken");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.SSOToken))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestMethod]
|
||||
public void InvalidSymmetricKeyTest()
|
||||
{
|
||||
Report.Step(@"CDR Call with SSO token header of Invalid Symmetric Key", @"Should get 401 unauthorized upstream response");
|
||||
var response = GetUpstreamResponseWithSSOToken(pipelineConfigs.SSOTokenUserName, "rpJupVvvHiX5kgrPllV8gWsurbzSu9D99kUwamFdL9I=");
|
||||
AssertTest.IsTrue(response.ToString().Contains("StatusCode: 401"), failMsg: "CDR call did not returned Unauthorized access",
|
||||
passMsg: "CDR call returned Status code of 401 Unauthorized access as expected");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get the Upstream response with SSO token
|
||||
/// </summary>
|
||||
/// <param name="userName">UserName to generate the SSO Token</param>
|
||||
/// <param name="addMin">addMinutes value</param>
|
||||
/// /// <param name="symmetricKey">SymmetricKey of org value</param>
|
||||
/// <returns>HttpResponseMessage</returns>
|
||||
private HttpResponseMessage GetUpstreamResponseWithSSOToken(String userName,string symmetricKey, int addMin = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
Report.Step(@"CDR Call with SSO token header of user having required permission", @"Should get the valid upstream response");
|
||||
ssoToken = _ssoTokenBL.GenerateSsoToken(userName, DateTime.UtcNow.AddMinutes(addMin).ToString(Constants.TimeStampFormat), symmetricKey);
|
||||
var headers = new Dictionary<string, string>();
|
||||
Sleep.Seconds(appConfigs.MountibankTimeoutinSeconds);
|
||||
headers.TryAdd("edisp-vuesso", ssoToken);
|
||||
headers.TryAdd("edisp-vuesso-orgid", tenantDetails[Constants.ValidTenantKey].IamOrganizationId);
|
||||
|
||||
return HttpClientUtility.ExecuteAsync(HttpMethod.Get, cdrServiceUrl + "/" + GetStudyUidDetails(), headers, null).Result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Report.ReportError("Exception", e.ToString());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to get the single studyuid details based on organization
|
||||
/// </summary>
|
||||
/// <returns>string of study id</returns>
|
||||
private string GetStudyUidDetails()
|
||||
{
|
||||
Report.Step(@"Get Study details for the Org", @"Should get the study details");
|
||||
var headers = CreateUserAccessTokenHeader();
|
||||
headers.TryAdd("api-version", "1");
|
||||
var responseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, getStudyDetailsUrl, headers, null);
|
||||
var studyDetails = responseBody["entry"]?.Where(x => x["resource"]["id"] != null).Select(x => x["resource"]?["id"]?.ToString()).ToList()[0];
|
||||
|
||||
if (string.IsNullOrEmpty((studyDetails)))
|
||||
{
|
||||
AssertTest.IsTrue(false, "Fetched Study details were empty", "", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AssertTest.IsTrue(true, "", "Study details were fetched", false);
|
||||
}
|
||||
|
||||
return studyDetails;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to created Access Token header
|
||||
/// </summary>
|
||||
/// <returns>Dictionary<Key, value></returns>
|
||||
private Dictionary<string, string> CreateUserAccessTokenHeader()
|
||||
{
|
||||
var userAccessTokenHeader = HttpClientUtility.CreateUserAccessTokenHeader(pipelineConfigs);
|
||||
AssertTest.IsTrue(userAccessTokenHeader != null, failMsg: "User Access Token header is null", passMsg: $"User Access Token header is not null");
|
||||
return userAccessTokenHeader;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Reporters;
|
||||
using Utilities;
|
||||
using Utilities.Enums;
|
||||
using Driver.UI.Interfaces;
|
||||
using Driver.UI.Selenium;
|
||||
using Utilities.Wait;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common
|
||||
{
|
||||
[TestClass]
|
||||
public abstract class BaseTest
|
||||
{
|
||||
|
||||
public static IWebDriverUi WebDriver
|
||||
{
|
||||
get => _WebDriver;
|
||||
}
|
||||
public static ReportManager Report
|
||||
{
|
||||
get => _report;
|
||||
}
|
||||
public TestContext TestContext
|
||||
{
|
||||
get => _testContext;
|
||||
set => _testContext = value;
|
||||
}
|
||||
|
||||
public static readonly AppConfiguration appConfigs = Settings.GetConfiguration<AppConfiguration>(typeof(AppConfiguration).Name);
|
||||
public static readonly PipelineConfiguration pipelineConfigs = Settings.GetConfiguration<PipelineConfiguration>(typeof(PipelineConfiguration).Name);
|
||||
public static readonly Dictionary<string, TenantMapping> tenantDetails = JsonConvert.DeserializeObject<Dictionary<string, TenantMapping>>(pipelineConfigs.TenantDetails);
|
||||
public readonly string defaultEndpointUrl = $"{pipelineConfigs.APIGatewayBaseUrl}{ appConfigs.LessPayloadMockservice}";
|
||||
private ReporterBase _ReporterBase;
|
||||
private static IWebDriverUi _WebDriver;
|
||||
private static ReportManager _report;
|
||||
private TestContext _testContext;
|
||||
private readonly string _outputFolder = Path.Combine(appConfigs.RootFolder, "Logs");
|
||||
private readonly ReporterTestInfo _testInfo = new ReporterTestInfo();
|
||||
|
||||
[TestInitialize]
|
||||
public void Before()
|
||||
{
|
||||
Logger.Info("######### Start Test ######### Test Name: " + _testContext.TestName + "\r\n");
|
||||
_ReporterBase = new ReporterBase(_outputFolder, appConfigs.ReporterList, appConfigs.RootFolder,
|
||||
appConfigs.RootEvidencePath, appConfigs.DifidoFolderLocation, appConfigs.ProductName);
|
||||
_report = _ReporterBase.GetReportMngInstance(_testContext.TestName, _testContext.FullyQualifiedTestClassName, _testInfo);
|
||||
AssertTest.ConfigureServices(TestProjectType.MsTest);
|
||||
AssertTest.InitAssertService();
|
||||
ProcessUtilities.KillChromeDriver();
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
public void After()
|
||||
{
|
||||
if (!TestContext.CurrentTestOutcome.Equals(UnitTestOutcome.Passed) &&
|
||||
Report.CurrentStepStatus == Reporters.BaseReport.Enums.Enum.StepStatus.Passed)
|
||||
Report.ReportError("The test has failed by throw an exception (not by any assert validation)");
|
||||
|
||||
_ReporterBase.CloseReports(_testInfo);
|
||||
|
||||
if (Report != null && WebDriver != null)
|
||||
{
|
||||
_ = WebDriver.Quit();
|
||||
}
|
||||
ProcessUtilities.KillChromeDriver();
|
||||
Logger.Info("######### End Test ######### Test Name: " + _testContext.TestName + "\r\n");
|
||||
}
|
||||
|
||||
protected bool LoginToEndpoint(string endpointUrl, string userName, string password)
|
||||
{
|
||||
Logger.InfoStartMethod();
|
||||
try
|
||||
{
|
||||
Logger.Info($"Endpoint url: {endpointUrl}");
|
||||
_WebDriver = new SeleniumDriver(Driver.Enums.BrowserType.Chrome, endpointUrl, null);
|
||||
|
||||
object userNameElement = null;
|
||||
WaitUtils.WaitUntil(() =>
|
||||
{
|
||||
userNameElement = WebDriver.FindElementById("idToken1");
|
||||
return WebDriver.IsExist(userNameElement);
|
||||
}, 60);
|
||||
|
||||
_ = WebDriver.TypeText(userNameElement, userName);
|
||||
|
||||
_ = WebDriver.TypeText(WebDriver.FindElementById("idToken2"), password);
|
||||
|
||||
_ = WebDriver.Click(WebDriver.FindElementById("loginButton_0"));
|
||||
|
||||
var saveConsentCheckBox = WebDriver.FindElementById("saveConsent");
|
||||
|
||||
if (WebDriver.IsExist(saveConsentCheckBox))
|
||||
{
|
||||
Logger.Info($"Save Consent exists");
|
||||
|
||||
_ = WebDriver.Click(saveConsentCheckBox);
|
||||
|
||||
_ = WebDriver.Click(WebDriver.FindElementByXPath("//button[@value='allow']"));
|
||||
}
|
||||
|
||||
var bodyElement = WebDriver.FindElementByXPath("//body/pre | //a[text()='home']");
|
||||
|
||||
return WebDriver.IsExist(bodyElement);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
WebDriver.TakeScreenshot();
|
||||
}
|
||||
}
|
||||
|
||||
protected JObject GetResponseFromUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
var bodyElement = WebDriver.FindElementByXPath("//body/pre");
|
||||
if (WebDriver.IsExist(bodyElement))
|
||||
{
|
||||
string responseJson = WebDriver.GetText(bodyElement);
|
||||
return JObject.Parse(responseJson);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected bool IsLoginPageDisplayed()
|
||||
{
|
||||
var userNameElement = WebDriver.FindElementById("idToken1");
|
||||
var passwordElement = WebDriver.FindElementById("idToken2");
|
||||
return WebDriver.IsExist(userNameElement) && WebDriver.IsExist(passwordElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Chrome;
|
||||
using OpenQA.Selenium.Support.UI;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Reporters;
|
||||
using Utilities.Wait;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common
|
||||
{
|
||||
public class CommonSteps : BaseTest
|
||||
{
|
||||
public void BrowseEndpointAndVerifyLogin(string endpoint, string userName, string password)
|
||||
{
|
||||
Report.Step(@"Browse the endpoint url and login", @"Should successfully login and get the upstream response");
|
||||
var isLoginSuccessful = LoginToEndpoint(endpoint, userName, password);
|
||||
AssertTest.IsTrue(isLoginSuccessful, failMsg: "Login Unsuccessful", passMsg: "Login Successful");
|
||||
var responseBody = GetResponseFromUI();
|
||||
AssertTest.IsTrue(responseBody != null && responseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response", passMsg: "Received success response");
|
||||
}
|
||||
|
||||
public bool LogoutWithPOST(string endpointUrl, string userName, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
IWebDriver _localWebDriver = new ChromeDriver();
|
||||
_localWebDriver.Url = defaultEndpointUrl;
|
||||
_localWebDriver.Navigate();
|
||||
|
||||
WebDriverWait wait = new WebDriverWait(_localWebDriver,TimeSpan.FromSeconds(20));
|
||||
|
||||
wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("idToken1")));
|
||||
|
||||
IWebElement userNameElement = null;
|
||||
WaitUtils.WaitUntil(() =>
|
||||
{
|
||||
userNameElement = _localWebDriver.FindElement(By.Id("idToken1"));
|
||||
return userNameElement.Displayed;
|
||||
}, 60);
|
||||
|
||||
userNameElement.SendKeys(userName);
|
||||
_localWebDriver.FindElement(By.Id("idToken2")).SendKeys(password); ;
|
||||
|
||||
_localWebDriver.FindElement(By.Id("loginButton_0")).Click();
|
||||
|
||||
wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.XPath("//body/pre | //a[text()='home']")));
|
||||
IWebElement bodyElement = _localWebDriver.FindElement(By.XPath("//body/pre | //a[text()='home']"));
|
||||
|
||||
if(bodyElement.Displayed)
|
||||
{
|
||||
IJavaScriptExecutor js = (IJavaScriptExecutor)_localWebDriver;
|
||||
string title = (string)js.ExecuteScript("navigator.sendBeacon('/logout');");
|
||||
}
|
||||
|
||||
_localWebDriver.Navigate().Refresh();
|
||||
wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.Id("idToken1")));
|
||||
userNameElement = _localWebDriver.FindElement(By.Id("idToken1"));
|
||||
bool isLoginPage = userNameElement.Enabled;
|
||||
_localWebDriver.Quit();
|
||||
return isLoginPage;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Report.ReportError(ex.ToString(), "LogoutWithPOST");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,285 @@
|
|||
{
|
||||
"protocol": "http",
|
||||
"port": 4546,
|
||||
"name": "ServiceB",
|
||||
"recordRequests": false,
|
||||
"defaultResponse": {
|
||||
"statusCode": 404
|
||||
},
|
||||
"stubs": [
|
||||
{
|
||||
"predicates": [
|
||||
{
|
||||
"endsWith": {
|
||||
"path": "/test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"equals": {
|
||||
"method": "POST"
|
||||
}
|
||||
},
|
||||
{
|
||||
"or": [
|
||||
{
|
||||
"contains": {
|
||||
"headers": {
|
||||
"cookie": "edi_session"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"startsWith": {
|
||||
"headers": {
|
||||
"authorization": "bearer"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matches": {
|
||||
"body": ".*"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
"is": {
|
||||
"statusCode": 201,
|
||||
"body": {
|
||||
"status": "Success",
|
||||
"message": "POST request received for sample payload"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"predicates": [
|
||||
{
|
||||
"endsWith": {
|
||||
"path": "/test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"equals": {
|
||||
"method": "GET"
|
||||
}
|
||||
},
|
||||
{
|
||||
"or": [
|
||||
{
|
||||
"contains": {
|
||||
"headers": {
|
||||
"cookie": "edi_session"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"startsWith": {
|
||||
"headers": {
|
||||
"authorization": "bearer"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
"is": {
|
||||
"statusCode": 200,
|
||||
"body": {
|
||||
"status": "Success",
|
||||
"SamplePayload": {
|
||||
"PickupTruckA": {
|
||||
"options": [
|
||||
"manual transmission",
|
||||
"sunroof",
|
||||
"premium stereo"
|
||||
],
|
||||
"manufactureDate": "2019-01-15",
|
||||
"current_location": {
|
||||
"lat": 37.773972,
|
||||
"lon": -122.431297
|
||||
},
|
||||
"fullLength": 230.25,
|
||||
"used": true,
|
||||
"price": 35000,
|
||||
"previousOwner": {
|
||||
"firstName": "John",
|
||||
"lastName": "Smith"
|
||||
}
|
||||
},
|
||||
"PickupTruckB": {
|
||||
"options": [
|
||||
"automatic transmission",
|
||||
"keyless entry"
|
||||
],
|
||||
"manufactureDate": "2018-06-12",
|
||||
"current_location": {
|
||||
"lat": 39.742043,
|
||||
"lon": -104.991531
|
||||
},
|
||||
"fullLength": 215.75,
|
||||
"used": true,
|
||||
"price": 29500,
|
||||
"previousOwner": {
|
||||
"firstName": "Jane",
|
||||
"lastName": "Jones"
|
||||
}
|
||||
},
|
||||
"PickupTruckC": {
|
||||
"options": [
|
||||
"automatic transmission",
|
||||
"keyless entry"
|
||||
],
|
||||
"manufactureDate": "2018-06-12",
|
||||
"current_location": {
|
||||
"lat": 39.742043,
|
||||
"lon": -104.991531
|
||||
},
|
||||
"fullLength": 215.75,
|
||||
"used": true,
|
||||
"price": 29500,
|
||||
"previousOwner": {
|
||||
"firstName": "Jane",
|
||||
"lastName": "Jones"
|
||||
}
|
||||
},
|
||||
"PickupTruckD": {
|
||||
"options": [
|
||||
"automatic transmission",
|
||||
"keyless entry"
|
||||
],
|
||||
"manufactureDate": "2018-06-12",
|
||||
"current_location": {
|
||||
"lat": 39.742043,
|
||||
"lon": -104.991531
|
||||
},
|
||||
"fullLength": 215.75,
|
||||
"used": true,
|
||||
"price": 29500,
|
||||
"previousOwner": {
|
||||
"firstName": "Jane",
|
||||
"lastName": "Jones"
|
||||
}
|
||||
},
|
||||
"PickupTruckE": {
|
||||
"options": [
|
||||
"automatic transmission",
|
||||
"keyless entry"
|
||||
],
|
||||
"manufactureDate": "2018-06-12",
|
||||
"current_location": {
|
||||
"lat": 39.742043,
|
||||
"lon": -104.991531
|
||||
},
|
||||
"fullLength": 215.75,
|
||||
"used": true,
|
||||
"price": 29500,
|
||||
"previousOwner": {
|
||||
"firstName": "Jane",
|
||||
"lastName": "Jones"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"predicates": [
|
||||
{
|
||||
"endsWith": {
|
||||
"path": "/test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"equals": {
|
||||
"method": "PUT"
|
||||
}
|
||||
},
|
||||
{
|
||||
"or": [
|
||||
{
|
||||
"contains": {
|
||||
"headers": {
|
||||
"cookie": "edi_session"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"startsWith": {
|
||||
"headers": {
|
||||
"authorization": "bearer"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matches": {
|
||||
"body": ".*"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
"is": {
|
||||
"statusCode": 201,
|
||||
"body": {
|
||||
"status": "Success",
|
||||
"message": "PUT request received for sample payload"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"predicates": [
|
||||
{
|
||||
"endsWith": {
|
||||
"path": "/test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"equals": {
|
||||
"method": "DELETE"
|
||||
}
|
||||
},
|
||||
{
|
||||
"or": [
|
||||
{
|
||||
"contains": {
|
||||
"headers": {
|
||||
"cookie": "edi_session"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"startsWith": {
|
||||
"headers": {
|
||||
"authorization": "bearer"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
"is": {
|
||||
"statusCode": 201,
|
||||
"body": {
|
||||
"status": "Success",
|
||||
"message": "DELETE request received"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,284 @@
|
|||
{
|
||||
"protocol": "http",
|
||||
"port": 4545,
|
||||
"name": "ServiceA",
|
||||
"numberOfRequests": 0,
|
||||
"recordRequests": true,
|
||||
"requests": [
|
||||
|
||||
],
|
||||
"defaultResponse": {
|
||||
"statusCode": 404
|
||||
},
|
||||
"stubs": [
|
||||
{
|
||||
"predicates": [
|
||||
{
|
||||
"endsWith": {
|
||||
"path": "/test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"equals": {
|
||||
"method": "POST"
|
||||
}
|
||||
},
|
||||
{
|
||||
"or": [
|
||||
{
|
||||
"contains": {
|
||||
"headers": {
|
||||
"cookie": "edi_session"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"startsWith": {
|
||||
"headers": {
|
||||
"authorization": "bearer"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matches": {
|
||||
"body": ".*"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
"is": {
|
||||
"statusCode": 201,
|
||||
"body": {
|
||||
"status": "Success",
|
||||
"message": "POST request received for sample payload"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"predicates": [
|
||||
{
|
||||
"endsWith": {
|
||||
"path": "/test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"equals": {
|
||||
"method": "GET"
|
||||
}
|
||||
},
|
||||
{
|
||||
"or": [
|
||||
{
|
||||
"contains": {
|
||||
"headers": {
|
||||
"cookie": "edi_session"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"startsWith": {
|
||||
"headers": {
|
||||
"authorization": "bearer"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
"is": {
|
||||
"statusCode": 200,
|
||||
"body": {
|
||||
"status": "Success"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"predicates": [
|
||||
{
|
||||
"contains": {
|
||||
"path": "/multitenancy"
|
||||
}
|
||||
},
|
||||
{
|
||||
"equals": {
|
||||
"method": "GET"
|
||||
}
|
||||
},
|
||||
{
|
||||
"or": [
|
||||
{
|
||||
"contains": {
|
||||
"headers": {
|
||||
"cookie": "edi_session"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"startsWith": {
|
||||
"headers": {
|
||||
"authorization": "bearer"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
"is": {
|
||||
"statusCode": 200,
|
||||
"body": {
|
||||
"status": "Success"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"predicates": [
|
||||
{
|
||||
"endsWith": {
|
||||
"path": "/test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"equals": {
|
||||
"method": "PUT"
|
||||
}
|
||||
},
|
||||
{
|
||||
"or": [
|
||||
{
|
||||
"contains": {
|
||||
"headers": {
|
||||
"cookie": "edi_session"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"startsWith": {
|
||||
"headers": {
|
||||
"authorization": "bearer"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matches": {
|
||||
"body": ".*"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
"is": {
|
||||
"statusCode": 201,
|
||||
"body": {
|
||||
"status": "Success",
|
||||
"message": "PUT request received for sample payload"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"predicates": [
|
||||
{
|
||||
"endsWith": {
|
||||
"path": "/test"
|
||||
}
|
||||
},
|
||||
{
|
||||
"equals": {
|
||||
"method": "DELETE"
|
||||
}
|
||||
},
|
||||
{
|
||||
"or": [
|
||||
{
|
||||
"contains": {
|
||||
"headers": {
|
||||
"cookie": "edi_session"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"startsWith": {
|
||||
"headers": {
|
||||
"authorization": "bearer"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
"is": {
|
||||
"statusCode": 204,
|
||||
"body": {
|
||||
"status": "Success",
|
||||
"message": "DELETE request received"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"predicates": [
|
||||
{
|
||||
"endsWith": {
|
||||
"path": "/test/checkpermission"
|
||||
}
|
||||
},
|
||||
{
|
||||
"equals": {
|
||||
"method": "GET"
|
||||
}
|
||||
},
|
||||
{
|
||||
"or": [
|
||||
{
|
||||
"contains": {
|
||||
"headers": {
|
||||
"cookie": "edi_session"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"startsWith": {
|
||||
"headers": {
|
||||
"authorization": "bearer"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"inject": "function (config) {\r\n\r\n var base64DecodedIntrospectValue = Buffer.from(config.request.headers[\"edisp-introspect-value\"], \"base64\").toString();\r\n\tvar orgList = JSON.parse(base64DecodedIntrospectValue )[\"organizations\"][\"organizationList\"];\r\n\r\n\tfor (let i in orgList) { \r\n\t\tif(orgList[i][\"organizationId\"] === config.request.headers[\"edisp-org-id\"])\r\n\t\t{\r\n\t\t\treturn !orgList[i][\"permissions\"].includes(config.request.headers[\"permission-name\"]); \r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}"
|
||||
}
|
||||
],
|
||||
"responses": [
|
||||
{
|
||||
"is": {
|
||||
"statusCode": 403,
|
||||
"body": {
|
||||
"status": "Forbidden",
|
||||
"message": "Access Forbidden"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Reporters;
|
||||
using Utilities;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.APITest
|
||||
{
|
||||
[TestClass]
|
||||
public class PostDeploymentTests : BaseTest
|
||||
{
|
||||
[TestCategory(nameof(TestCategory.PostDeployment))]
|
||||
[TestMethod]
|
||||
public void PostDeploymentTest()
|
||||
{
|
||||
Report.Step(@"Create the mockservices with mountebank", @"Should create the new mockservices");
|
||||
bool isLoginSuccessful = LoginToEndpoint(pipelineConfigs.APIGatewayBaseUrl, pipelineConfigs.AuthUserName, pipelineConfigs.AuthPassword);
|
||||
AssertTest.IsTrue(isLoginSuccessful, failMsg: "Login Unsuccessful", passMsg: "Login Successful");
|
||||
AuthenticationBL authenticationBL = new AuthenticationBL(WebDriver);
|
||||
var cookie = authenticationBL.GetCookie(pipelineConfigs.CookieName);
|
||||
string[] mockJsonFiles = Directory.GetFiles(Path.Join(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Tests", "Data", "MockServiceConfigs"), "*.json");
|
||||
|
||||
if (mockJsonFiles == null || mockJsonFiles.Length <= 0)
|
||||
{
|
||||
AssertTest.IsTrue(false, "No mock json files available");
|
||||
}
|
||||
|
||||
foreach (var mockJsonFile in mockJsonFiles)
|
||||
{
|
||||
string mockJsonString = File.ReadAllText(mockJsonFile);
|
||||
var impostersUrl = $"{pipelineConfigs.APIGatewayBaseUrl}/imposters";
|
||||
string port = JObject.Parse(mockJsonString)["port"].ToString();
|
||||
Logger.Info($"Mockservice File: {mockJsonFile}, Port: {port}");
|
||||
|
||||
var httpContent = HttpClientUtility.CreateHttpContent(mockJsonString);
|
||||
var headers = HttpClientUtility.CreateCookieHeader(pipelineConfigs.CookieName, cookie.CookieValue);
|
||||
string deleteMockServiceApiUrl = $"{ impostersUrl }/{ port}";
|
||||
Logger.Info($"Delete mockservice Url: {deleteMockServiceApiUrl}");
|
||||
var deleteResponse = HttpClientUtility.ExecuteAsync(HttpMethod.Delete, deleteMockServiceApiUrl, headers, httpContent).Result;
|
||||
AssertTest.IsTrue(deleteResponse.IsSuccessStatusCode || deleteResponse.StatusCode == HttpStatusCode.NotFound, failMsg: "Failed to delete the mockservice imposter", passMsg: "Deleted the mockservice imposter");
|
||||
Logger.Info($"Create mockservice url: {impostersUrl}");
|
||||
var postCallResponse = HttpClientUtility.ExecuteAsync(HttpMethod.Post, impostersUrl, headers, httpContent).Result;
|
||||
AssertTest.IsTrue(postCallResponse.IsSuccessStatusCode, failMsg: "Failed to create mockservice", passMsg: "Created mockservice successfully");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
using System.Net.Http;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Reporters;
|
||||
using Utilities.Wait;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.UITests.AuthenticationTests
|
||||
{
|
||||
[TestClass]
|
||||
public class AuthenticationTests : BaseTest
|
||||
{
|
||||
private readonly CommonSteps _commonSteps = new CommonSteps();
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void BrowseEndpointAndLoginWithValidCredentialsTest()
|
||||
{
|
||||
_commonSteps.BrowseEndpointAndVerifyLogin(defaultEndpointUrl, pipelineConfigs.AuthUserName, pipelineConfigs.AuthPassword);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void BrowseEndpointAndLoginWithInvalidCredentialsTest()
|
||||
{
|
||||
Report.Step(@"Browse the endpoint url and login with invalid UserName", @"Login should be unsuccessfull");
|
||||
var isLoginSuccessful = LoginToEndpoint(defaultEndpointUrl, userName: "abc@philips.com", "abc123");
|
||||
AssertTest.IsFalse(isLoginSuccessful, failMsg: "Login successful with invalid credentials", passMsg: "Unsuccessful Login");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void APICallWithValidCookieTest()
|
||||
{
|
||||
_commonSteps.BrowseEndpointAndVerifyLogin(defaultEndpointUrl, pipelineConfigs.AuthUserName, pipelineConfigs.AuthPassword);
|
||||
|
||||
|
||||
Report.Step(@"API call with cookie taken from browser", @"Should get the valid upstream response");
|
||||
AuthenticationBL authenticationBL = new AuthenticationBL(WebDriver);
|
||||
var cookie = authenticationBL.GetCookie(pipelineConfigs.CookieName);
|
||||
AssertTest.IsTrue(cookie != null, failMsg: "Cookie is not available", passMsg: $"Cookie is available, Cookie value: {cookie.CookieValue}");
|
||||
var headers = HttpClientUtility.CreateCookieHeader(pipelineConfigs.CookieName, cookie.CookieValue);
|
||||
var responseBody = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, defaultEndpointUrl, headers, null);
|
||||
AssertTest.IsTrue(responseBody != null && responseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received Success response");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void APICallInBrowserWithInValidCookieTest()
|
||||
{
|
||||
_commonSteps.BrowseEndpointAndVerifyLogin(defaultEndpointUrl, pipelineConfigs.AuthUserName, pipelineConfigs.AuthPassword);
|
||||
|
||||
|
||||
Report.Step(@"Delete/Modify the cookie in browser and browse again the same endpoint url", @"Should get a new cookie and that passes to upstream and get the valid upstream response");
|
||||
AuthenticationBL authenticationBL = new AuthenticationBL(WebDriver);
|
||||
var beforeCookie = authenticationBL.GetCookie(pipelineConfigs.CookieName);
|
||||
beforeCookie.CookieValue = $"abc123{beforeCookie.CookieValue}";
|
||||
authenticationBL.SetCookie(beforeCookie);
|
||||
WebDriver.Goto(defaultEndpointUrl);
|
||||
var afterCookie = authenticationBL.GetCookie(pipelineConfigs.CookieName);
|
||||
var responseBody = GetResponseFromUI();
|
||||
AssertTest.AreNotEqual(beforeCookie.CookieValue, afterCookie.CookieValue);
|
||||
AssertTest.IsTrue(responseBody != null && responseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received after cookie deleted/modified", passMsg: "Received Success response after cookie deleted/modified");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void AccessUpstreamJustBeforeSessionTimeoutTest()
|
||||
{
|
||||
//Make sure to set "OAUTH2_PROXY_COOKIE_REFRESH" = "0h0m15s" (15 seconds) in Oauth proxy service for automaiton
|
||||
|
||||
_commonSteps.BrowseEndpointAndVerifyLogin(defaultEndpointUrl, pipelineConfigs.AuthUserName, pipelineConfigs.AuthPassword);
|
||||
|
||||
|
||||
Report.Step($"Wait till before session timeout ({pipelineConfigs.OauthProxyCookieTimeoutInSeconds} seconds)", @"Cookie should not change before the session timeout");
|
||||
int waitTimeInSeconds = -18;
|
||||
AssertTest.IsFalse(WaitForGivenTimeAndGetIsCookieChanged(waitTimeInSeconds), failMsg: $"Cookie has changed before the session timeout: {pipelineConfigs.OauthProxyCookieTimeoutInSeconds} and wait time: {pipelineConfigs.OauthProxyCookieTimeoutInSeconds + waitTimeInSeconds}",
|
||||
passMsg: $"Cookie has not changed before the session timeout: {pipelineConfigs.OauthProxyCookieTimeoutInSeconds} and wait time: {pipelineConfigs.OauthProxyCookieTimeoutInSeconds + waitTimeInSeconds}");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void AccessUpstreamAfterSessionTimeoutTest()
|
||||
{
|
||||
_commonSteps.BrowseEndpointAndVerifyLogin(defaultEndpointUrl, pipelineConfigs.AuthUserName, pipelineConfigs.AuthPassword);
|
||||
|
||||
|
||||
Report.Step($"Wait till after session timeout ({pipelineConfigs.OauthProxyCookieTimeoutInSeconds} seconds)", @"Cookie should change after the session timeout");
|
||||
int waitTimeInSeconds = 2;
|
||||
AssertTest.IsTrue(WaitForGivenTimeAndGetIsCookieChanged(waitTimeInSeconds), failMsg: $"Cookie has not changed after the session timeout: {pipelineConfigs.OauthProxyCookieTimeoutInSeconds} and wait time: {pipelineConfigs.OauthProxyCookieTimeoutInSeconds + waitTimeInSeconds}",
|
||||
passMsg: $"Cookie has changed after the session timeout: {pipelineConfigs.OauthProxyCookieTimeoutInSeconds} and wait time: {pipelineConfigs.OauthProxyCookieTimeoutInSeconds + waitTimeInSeconds}");
|
||||
}
|
||||
|
||||
private bool WaitForGivenTimeAndGetIsCookieChanged(int waitTimeInSeconds)
|
||||
{
|
||||
AuthenticationBL authenticationBL = new AuthenticationBL(WebDriver);
|
||||
var beforeCookie = authenticationBL.GetCookie(pipelineConfigs.CookieName);
|
||||
int totalWaitTime = pipelineConfigs.OauthProxyCookieTimeoutInSeconds + waitTimeInSeconds;
|
||||
if (totalWaitTime > 0)
|
||||
{
|
||||
Sleep.Seconds(totalWaitTime);
|
||||
}
|
||||
WebDriver.Goto(defaultEndpointUrl);
|
||||
var afterCookie = authenticationBL.GetCookie(pipelineConfigs.CookieName);
|
||||
AssertTest.IsTrue(true,failMsg:"",passMsg:$"Before cookie:{beforeCookie.CookieValue}\nAfterCookie:{afterCookie.CookieValue}");
|
||||
return !beforeCookie.CookieValue.Equals(afterCookie.CookieValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
using Driver.UI.Common;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.BusinessLayer;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Reporters;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.UITests.LogoutTests
|
||||
{
|
||||
[TestClass]
|
||||
public class BrowserLogoutTests : BaseTest
|
||||
{
|
||||
#region Tests
|
||||
CommonSteps _commonSteps = new CommonSteps();
|
||||
[TestInitialize]
|
||||
public void BeforeTest()
|
||||
{
|
||||
Report.Step(@"Login and open default endpoint url", @"should open the default mockservice page");
|
||||
|
||||
_commonSteps.BrowseEndpointAndVerifyLogin(defaultEndpointUrl, pipelineConfigs.AuthUserName, pipelineConfigs.AuthPassword);
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.GatedSanity))]
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.BrowserLogout))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void LogoutSuccessTest()
|
||||
{
|
||||
Report.Step(@"Call Logout api", @"should be redirected to the login page");
|
||||
AssertLogoutSuccess();
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.BrowserLogout))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public async Task ApiRequestBeforeAndAfterLogoutTest()
|
||||
{
|
||||
var cookie = FetchAndAssertCookieFromBrowser();
|
||||
var headers = HttpClientUtility.CreateCookieHeader(pipelineConfigs.CookieName, cookie.CookieValue);
|
||||
|
||||
Report.Step(@"API call with cookie taken from browser", @"Should get the valid upstream response");
|
||||
var responseBeforeLogout = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, defaultEndpointUrl, headers, null);
|
||||
AssertTest.IsTrue(responseBeforeLogout != null && responseBeforeLogout["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received Success response");
|
||||
|
||||
Report.Step(@"Call Logout api", @"should be redirected to the login page");
|
||||
AssertLogoutSuccess();
|
||||
|
||||
Report.Step(@"API call with older cookie taken from browser before logout", @"Should receive the HTML response of the IAM Login page");
|
||||
var responseAfterLogout = await HttpClientUtility.ExecuteAsync(HttpMethod.Get, defaultEndpointUrl, headers, null);
|
||||
var body = await responseAfterLogout?.Content?.ReadAsStringAsync();
|
||||
//Assuming login page is HSDP IAM's Login page
|
||||
AssertTest.IsTrue(responseAfterLogout != null && responseAfterLogout.IsSuccessStatusCode && body != null && body.Contains("<title>Philips</title>"), failMsg: "IAM login page's title is not displayed", passMsg: "IAM login page's title is displayed");
|
||||
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.BrowserLogout))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void BrowserRequestBeforeandAfterLogoutTest()
|
||||
{
|
||||
Report.Step(@"Browser request to the same endpoint", @"Should get the upstream response and login page should not be displayed");
|
||||
WebDriver.Goto(defaultEndpointUrl);
|
||||
Assert.IsFalse(IsLoginPageDisplayed());
|
||||
var responseBody = GetResponseFromUI();
|
||||
AssertTest.IsTrue(responseBody != null && responseBody["status"].ToString().EqualsWithIgnoreCase("success"), failMsg: "No Success response received", passMsg: "Received Success response");
|
||||
|
||||
|
||||
Report.Step(@"Call Logout api", @"should be redirected to the login page");
|
||||
AssertLogoutSuccess();
|
||||
|
||||
Report.Step(@"Browser request to the default endpoint url", @"Should receive IAM Login page");
|
||||
WebDriver.Goto(defaultEndpointUrl);
|
||||
//Assuming login page is HSDP IAM's Login page
|
||||
AssertTest.IsTrue(IsLoginPageDisplayed(),
|
||||
failMsg: "Not redirected back to login page", passMsg: "Redirected to login page");
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.BrowserLogout))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void LogoutAfterTheSessionTerminatedTest()
|
||||
{
|
||||
Report.Step(@"Call Logout api", @"should be redirected to the login page");
|
||||
AssertLogoutSuccess();
|
||||
Report.Step(@"Calling Logout api again", @"should be redirected to the login page");
|
||||
//If we don't specify any redirect-uri it will give 422 Http response code
|
||||
AssertLogoutSuccess();
|
||||
}
|
||||
|
||||
[TestCategory(nameof(TestCategory.Nightly))]
|
||||
[TestCategory(nameof(TestCategory.WithoutMultitenancy))]
|
||||
[TestCategory(nameof(TestCategory.BrowserLogout))]
|
||||
[TestCategory(nameof(TestCategory.OnPrem))]
|
||||
[TestMethod]
|
||||
public void POST_HTTP_CallforLogoutAPITest()
|
||||
{
|
||||
Report.Step(@"Perform a POST Http call for Logout API", @"should be redirected to the login page");
|
||||
AssertTest.IsTrue(_commonSteps.LogoutWithPOST(defaultEndpointUrl, pipelineConfigs.AuthUserName, pipelineConfigs.AuthPassword),"Failed to Logout using PostCall",
|
||||
"Successfully logged out and redirected to login page with POST call");
|
||||
}
|
||||
|
||||
|
||||
#endregion Tests
|
||||
|
||||
#region Private Methods
|
||||
private static Cookies FetchAndAssertCookieFromBrowser()
|
||||
{
|
||||
Report.Step(@"Get cookie from browser", @"Should get cookie from the current page");
|
||||
var authenticationBL = new AuthenticationBL(WebDriver);
|
||||
var cookie = authenticationBL.GetCookie(pipelineConfigs.CookieName);
|
||||
AssertTest.IsTrue(cookie != null, failMsg: "Cookie is not available", passMsg: $"Cookie is available, Cookie value: {cookie.CookieValue}");
|
||||
return cookie;
|
||||
}
|
||||
|
||||
private void AssertLogoutSuccess()
|
||||
{
|
||||
string GatewayLogoutEndpoint = $"{pipelineConfigs.APIGatewayBaseUrl}{appConfigs.LogoutPath}";
|
||||
WebDriver.Goto(GatewayLogoutEndpoint);
|
||||
AssertTest.IsTrue(IsLoginPageDisplayed(),
|
||||
failMsg: "Logout unsuccessful, not redirected back to login page", passMsg: "Successfully logged out and redirected to login page");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,232 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.CFUtilites.Models;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities;
|
||||
using Utilities;
|
||||
using Utilities.Wait;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.CFUtilites
|
||||
{
|
||||
public class CFUtility
|
||||
{
|
||||
private readonly string _cfBaseUrl;
|
||||
private readonly string _cfUserName;
|
||||
private readonly string _cfPassword;
|
||||
private readonly string _cfAccessTokenUrl;
|
||||
|
||||
|
||||
public CFUtility(string cfBaseUrl, string cfUserName, string cfPassword, string cfAccessTokenUrl)
|
||||
{
|
||||
_cfBaseUrl = cfBaseUrl;
|
||||
_cfUserName = cfUserName;
|
||||
_cfPassword = cfPassword;
|
||||
_cfAccessTokenUrl = cfAccessTokenUrl;
|
||||
}
|
||||
|
||||
public bool ChangingCFAppState(string orgName, string spaceName, string appName, AppState appState)
|
||||
{
|
||||
try
|
||||
{
|
||||
string appGuid = GetCFAppGuid(orgName, spaceName, appName);
|
||||
string postUrl = $"{_cfBaseUrl}/apps/{appGuid }/actions/{appState.ToString()}";
|
||||
Logger.Info($"CF app state Url: { postUrl}");
|
||||
using (var apiResponse = HttpClientUtility.ExecuteAsync(HttpMethod.Post, postUrl, CFRequestHeadersWithAuth(), null).Result)
|
||||
{
|
||||
if (!apiResponse.IsSuccessStatusCode || apiResponse.Content == null)
|
||||
{
|
||||
Logger.Error("Response Code :" + apiResponse.StatusCode.ToString());
|
||||
Logger.Error($"Failed to change the state of the service to {appState.ToString()} response for : {postUrl}");
|
||||
return false;
|
||||
}
|
||||
bool appCurrentStatus = false;
|
||||
if (appState == AppState.start || appState == AppState.restart)
|
||||
{
|
||||
appCurrentStatus = WaitUtils.WaitUntil(() => GetCFAppStatus(appGuid).EqualsWithIgnoreCase("STARTED"), CFConstants.AppStateChangeTimeoutInSeconds, CFConstants.AppStateChangeCheckFequencyInMilliSeconds);
|
||||
}
|
||||
else if (appState == AppState.stop)
|
||||
{
|
||||
appCurrentStatus = WaitUtils.WaitUntil(() => GetCFAppStatus(appGuid).EqualsWithIgnoreCase("STOPPED"), CFConstants.AppStateChangeTimeoutInSeconds, CFConstants.AppStateChangeCheckFequencyInMilliSeconds);
|
||||
}
|
||||
Sleep.Seconds(10);
|
||||
return appCurrentStatus;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<string, string> GetEnvironmentVariablesFromCFApp(string orgName, string spaceName, string appName)
|
||||
{
|
||||
try
|
||||
{
|
||||
string appGuid = GetCFAppGuid(orgName, spaceName, appName);
|
||||
string getUrl = $"{_cfBaseUrl}/apps/{appGuid}/environment_variables";
|
||||
Logger.Info($"CF Get env url: {getUrl}");
|
||||
using (HttpResponseMessage apiResponse = HttpClientUtility.ExecuteAsync(HttpMethod.Get, getUrl, CFRequestHeadersWithAuth(), null).Result)
|
||||
{
|
||||
if (!apiResponse.IsSuccessStatusCode || apiResponse.Content == null)
|
||||
{
|
||||
Logger.Error("Response Code :" + apiResponse.StatusCode.ToString());
|
||||
Logger.Error($"Failed toget env variables of the application: {appName}");
|
||||
|
||||
return null;
|
||||
}
|
||||
return GetEnvironmentVariablesFromResponse(apiResponse);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public Dictionary<string, string> UpdateEnvironmentVariablesToCFApp(string orgName, string spaceName, string appName, Dictionary<string, string> envVariables)
|
||||
{
|
||||
try
|
||||
{
|
||||
string appGuid = GetCFAppGuid(orgName, spaceName, appName);
|
||||
string updateUrl = $"{_cfBaseUrl}/apps/{appGuid}/environment_variables";
|
||||
Logger.Info($"CF update env url: {updateUrl}");
|
||||
var envVariablesContent = new CFEnvironmentVariable()
|
||||
{
|
||||
EnvironmentVariables = envVariables
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(envVariablesContent);
|
||||
|
||||
using (HttpResponseMessage apiResponse = PatchEnvironmentVariablesToApp(updateUrl, json))
|
||||
{
|
||||
if (!apiResponse.IsSuccessStatusCode || apiResponse.Content == null)
|
||||
{
|
||||
Logger.Error("Response Code :" + apiResponse.StatusCode.ToString());
|
||||
Logger.Error($"Failed to update env variables for the application: {appName}");
|
||||
return null;
|
||||
}
|
||||
ChangingCFAppState(orgName, spaceName, appName, AppState.restart);
|
||||
return GetEnvironmentVariablesFromResponse(apiResponse);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#region private methods
|
||||
private string GetOrganizationGuid(string orgName)
|
||||
{
|
||||
string getOrgsUrl = $"{_cfBaseUrl}/organizations";
|
||||
Logger.Info($"Get Orgs url: {getOrgsUrl}");
|
||||
return GetResourceGuid(getOrgsUrl, orgName); ;
|
||||
}
|
||||
|
||||
private string GetSpaceGuid(string orgGuid, string spaceName)
|
||||
{
|
||||
string getSpacesUrl = $"{_cfBaseUrl}/spaces?organization_guids={orgGuid}&page=2&per_page=50";
|
||||
Logger.Info($"Get spaces url: {getSpacesUrl}");
|
||||
return GetResourceGuid(getSpacesUrl, spaceName);
|
||||
}
|
||||
|
||||
private string GetResourceGuid(string getUrl, string name)
|
||||
{
|
||||
var spacesList = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, getUrl, CFRequestHeadersWithAuth(), null)["resources"];
|
||||
var spaceGuid = spacesList.Where(x => x["name"].ToString().Equals(name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault()["guid"].ToString();
|
||||
return spaceGuid;
|
||||
}
|
||||
|
||||
private string GetCFAppGuid(string orgName, string spaceName, string appName)
|
||||
{
|
||||
string orgGuid = GetOrganizationGuid(orgName);
|
||||
string spaceGuid = GetSpaceGuid(orgGuid, spaceName);
|
||||
|
||||
string getAppsUrl = $"{_cfBaseUrl}/apps?organization_guids={orgGuid}&space_guids={spaceGuid}&names={appName}";
|
||||
Logger.Info($"Get apps url: {getAppsUrl}");
|
||||
return GetResourceGuid(getAppsUrl, appName);
|
||||
}
|
||||
|
||||
private string GetCFAppStatus(string cfAppGuid)
|
||||
{
|
||||
string postUrl = _cfBaseUrl + "/apps/" + cfAppGuid;
|
||||
var apiResponse = HttpClientUtility.ExecuteAndGetResponse(HttpMethod.Get, postUrl, CFRequestHeadersWithAuth(), null);
|
||||
return apiResponse["state"].ToString();
|
||||
}
|
||||
|
||||
private CFTokenResponse GetCFOauthToken()
|
||||
{
|
||||
var postData = new[]
|
||||
{
|
||||
new KeyValuePair<string, string>("grant_type","password"),
|
||||
new KeyValuePair<string, string>("username",_cfUserName),
|
||||
new KeyValuePair<string, string>("password",_cfPassword)
|
||||
};
|
||||
Logger.Info($"CF access token Url: {_cfAccessTokenUrl}");
|
||||
var token = PostFormUrlEncoded<CFTokenResponse>(_cfAccessTokenUrl, postData).Result;
|
||||
return token;
|
||||
}
|
||||
|
||||
private async Task<T> PostFormUrlEncoded<T>(string url, IEnumerable<KeyValuePair<string, string>> postData) where T : class
|
||||
{
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
string authInfo = "cf" + ":" + "";
|
||||
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
|
||||
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authInfo);
|
||||
|
||||
using (var content = new FormUrlEncodedContent(postData))
|
||||
{
|
||||
HttpResponseMessage response = await httpClient.PostAsync(url, content);
|
||||
string apiResponseString = response.Content.ReadAsStringAsync().Result;
|
||||
var tokenResponse = JsonConvert.DeserializeObject<T>(apiResponseString);
|
||||
return tokenResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
private Dictionary<string, string> CFRequestHeadersWithAuth()
|
||||
{
|
||||
Dictionary<string, string> headers = new Dictionary<string, string>();
|
||||
var authToken = GetCFOauthToken();
|
||||
if (!string.IsNullOrEmpty(authToken.AccessToken.ToString()))
|
||||
{
|
||||
headers.Add("Authorization", "Bearer " + authToken.AccessToken);
|
||||
}
|
||||
headers.Add("Content-Type", "application/json");
|
||||
headers.Add("Accept", "application/json");
|
||||
headers.Add("api-version", "1");
|
||||
return headers;
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> GetEnvironmentVariablesFromResponse(HttpResponseMessage apiResponse)
|
||||
{
|
||||
var envVariables = JObject.Parse(apiResponse.Content.ReadAsStringAsync().Result)["var"].ToString();
|
||||
return JsonConvert.DeserializeObject<Dictionary<string, string>>(envVariables);
|
||||
}
|
||||
|
||||
private HttpResponseMessage PatchEnvironmentVariablesToApp(string url, string content)
|
||||
{
|
||||
var httpClient = new HttpClient();
|
||||
var request = new HttpRequestMessage(HttpMethod.Patch, url);
|
||||
request.Content = new StringContent(content, Encoding.UTF8, "application/json");
|
||||
var authToken = GetCFOauthToken();
|
||||
if (!string.IsNullOrEmpty(authToken.AccessToken.ToString()))
|
||||
{
|
||||
request.Headers.Add("Authorization", "Bearer " + authToken.AccessToken);
|
||||
}
|
||||
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
request.Headers.Add("api-version", "1");
|
||||
return httpClient.SendAsync(request).Result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.CFUtilites.Models
|
||||
{
|
||||
public enum AppState
|
||||
{
|
||||
start,
|
||||
stop,
|
||||
restart
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.CFUtilites
|
||||
{
|
||||
public class CFConstants
|
||||
{
|
||||
public const int AppStateChangeTimeoutInSeconds = 30;
|
||||
public const int AppStateChangeCheckFequencyInMilliSeconds = 500;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.CFUtilites.Models
|
||||
{
|
||||
public class CFEnvironmentVariable
|
||||
{
|
||||
[JsonProperty("var")]
|
||||
public Dictionary<string, string> EnvironmentVariables { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
using Newtonsoft.Json;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.CFUtilites.Models
|
||||
{
|
||||
|
||||
public class CFTokenResponse
|
||||
{
|
||||
[JsonProperty("access_token")]
|
||||
public string AccessToken { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities
|
||||
{
|
||||
public class ConfigurationReader
|
||||
{
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public ConfigurationReader(string jsonFilePath)
|
||||
{
|
||||
var builder = new ConfigurationBuilder();
|
||||
builder.AddJsonFile(jsonFilePath);
|
||||
Configuration = builder.Build();
|
||||
}
|
||||
|
||||
public ConfigurationReader()
|
||||
{
|
||||
var builder = new ConfigurationBuilder();
|
||||
builder.AddEnvironmentVariables();
|
||||
Configuration = builder.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
using Driver.UI.Interfaces;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Tests.Common;
|
||||
using System;
|
||||
using Utilities;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static bool EqualsWithIgnoreCase(this string actual, string expected, StringComparison stringComparison = StringComparison.InvariantCultureIgnoreCase)
|
||||
{
|
||||
Logger.InfoStartMethod();
|
||||
try
|
||||
{
|
||||
return actual.Equals(expected, stringComparison);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool StartsWithIgnoreCase(this string actual, string expected, StringComparison stringComparison = StringComparison.InvariantCultureIgnoreCase)
|
||||
{
|
||||
Logger.InfoStartMethod();
|
||||
try
|
||||
{
|
||||
return actual.StartsWith(expected, stringComparison);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static string TakeScreenshot(this IWebDriverUi webDriver)
|
||||
{
|
||||
try
|
||||
{
|
||||
string evidenceFolderPath = BaseTest.Report.GetEvidencePath();
|
||||
string newEvidenceFolderName = BaseTest.Report.GetNewEvidenceFolderName();
|
||||
string newEvidenceFilePath = string.Format("{0}/{1}.png", evidenceFolderPath, newEvidenceFolderName);
|
||||
webDriver.TakesScreenShot(newEvidenceFilePath);
|
||||
return newEvidenceFilePath;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Driver.Api.HttpClientApi;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using Utilities;
|
||||
using Utilities.Common;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities
|
||||
{
|
||||
public class HttpClientUtility
|
||||
{
|
||||
private static readonly HttpClient _httpClient = new HttpClient();
|
||||
private static readonly HttpClient _httpClientWithoutRedirection = new HttpClient( new HttpClientHandler { AllowAutoRedirect = false });
|
||||
private static readonly HttpClientUtilities _httpClientUtility = new HttpClientUtilities();
|
||||
|
||||
public static async Task<HttpResponseMessage> ExecuteAsync(HttpMethod httpMethod, string url, Dictionary<string, string> headers, HttpContent content)
|
||||
{
|
||||
return await ExecuteAsync(_httpClient, httpMethod, url, headers, content);
|
||||
}
|
||||
|
||||
public static async Task<HttpResponseMessage> ExecuteAsyncWithoutHttpRedirection(HttpMethod httpMethod, string url, Dictionary<string, string> headers, HttpContent content)
|
||||
{
|
||||
return await ExecuteAsync(_httpClientWithoutRedirection, httpMethod, url, headers, content);
|
||||
}
|
||||
|
||||
private static async Task<HttpResponseMessage> ExecuteAsync(HttpClient client,HttpMethod httpMethod, string url, Dictionary<string, string> headers, HttpContent content)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (httpMethod.ToString()) switch
|
||||
{
|
||||
"POST" => await _httpClientUtility.HttpPostAsync(client, url, headers, content),
|
||||
"PUT" => await _httpClientUtility.HttpPutAsync(client, url, headers, content),
|
||||
"DELETE" => await _httpClientUtility.HttpDeleteAsync(client, url, headers),
|
||||
_ => await _httpClientUtility.HttpGetAsyncResp(client, url, headers),//GET
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static StringContent CreateHttpContent(string content, string MediaType = "application/json")
|
||||
{
|
||||
Logger.InfoStartMethod();
|
||||
try
|
||||
{
|
||||
return new StringContent(content, Encoding.UTF8, MediaType);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static Dictionary<string, string> CreateCookieHeader(string cookieName, string cookieValue)
|
||||
{
|
||||
Logger.InfoStartMethod();
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> cookieHeader = new Dictionary<string, string>
|
||||
{
|
||||
{ "Cookie", $"{cookieName}={cookieValue}" }
|
||||
};
|
||||
return cookieHeader;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static Dictionary<string, string> CreateUserAccessTokenHeader(PipelineConfiguration pipelineConfiguration, string tokenType = "access_token")
|
||||
{
|
||||
Logger.InfoStartMethod();
|
||||
try
|
||||
{
|
||||
Logger.Info($"Access token url: {pipelineConfiguration.IAMAuthorizationUrl}");
|
||||
var headers = new Dictionary<string, string>();
|
||||
headers.Add("Authorization", $"Basic {Convert.ToBase64String(Encoding.ASCII.GetBytes($"{pipelineConfiguration.OauthClientID}:{pipelineConfiguration.OauthClientSecret}"))}");
|
||||
string content = $"grant_type=password&username={pipelineConfiguration.AuthUserName}&password={pipelineConfiguration.AuthPassword}";
|
||||
var httpContent = CreateHttpContent(content, "application/x-www-form-urlencoded");
|
||||
var responseBody = ExecuteAndGetResponse(HttpMethod.Post, pipelineConfiguration.IAMAuthorizationUrl, headers, httpContent);
|
||||
string authToken = responseBody[tokenType]?.ToString();
|
||||
if(authToken == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var userAccessTokenHeader = new Dictionary<string, string>();
|
||||
userAccessTokenHeader.Add("Authorization", $"Bearer {authToken}");
|
||||
return userAccessTokenHeader;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static Dictionary<string, string> CreateServiceIdAccessTokenHeader(PipelineConfiguration pipelineConfig)
|
||||
{
|
||||
Logger.InfoStartMethod();
|
||||
try
|
||||
{
|
||||
string serviceIDAccessToken = CommonFunctionality.GetAccessToken(pipelineConfig.ServiceID, pipelineConfig.ServiceIDPrivateKey, pipelineConfig.IAMAccessTokenUrl, pipelineConfig.IAMAuthorizationUrl);
|
||||
var serviceIDAccessTokenHeader = new Dictionary<string, string>();
|
||||
serviceIDAccessTokenHeader.Add("Authorization", $"Bearer {serviceIDAccessToken}");
|
||||
return serviceIDAccessTokenHeader;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static JObject ExecuteAndGetResponse(HttpMethod httpMethod, string url, Dictionary<string, string> headers, HttpContent content)
|
||||
{
|
||||
Logger.InfoStartMethod();
|
||||
try
|
||||
{
|
||||
var response = ExecuteAsync(httpMethod, url, headers, content).Result.Content.ReadAsStringAsync().Result;
|
||||
if (string.IsNullOrEmpty(response))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return JObject.Parse(response);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Philips.EDI.Foundation.APIGateway.AutomationTest.Models;
|
||||
using Utilities;
|
||||
|
||||
namespace Philips.EDI.Foundation.APIGateway.AutomationTest.Utilities
|
||||
{
|
||||
public class Settings
|
||||
{
|
||||
private const string _envConfigFile = "Env.json";
|
||||
|
||||
private static readonly ConfigurationReader _envConfigReader = new ConfigurationReader(
|
||||
Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), _envConfigFile));
|
||||
|
||||
private static readonly string _executionEnvironment = _envConfigReader.Configuration.GetSection("ExecutionEnvironment").Value;
|
||||
private static ConfigurationReader _environmentVairableConfigReader;
|
||||
|
||||
public static T GetConfiguration<T>(string configSectionName) where T : new()
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.Info($"Config section name: {configSectionName}");
|
||||
T config = new T();
|
||||
|
||||
if (configSectionName.StartsWith("AppConfiguration", StringComparison.InvariantCultureIgnoreCase) || _executionEnvironment.Equals(nameof(ExecutionEnvironment.Local), StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
_envConfigReader.Configuration.GetSection(configSectionName).Bind(config);
|
||||
}
|
||||
else if (_executionEnvironment.Equals(nameof(ExecutionEnvironment.Production), StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
_environmentVairableConfigReader = new ConfigurationReader();
|
||||
_environmentVairableConfigReader.Configuration.Bind(config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.InfoFailedWithException(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Philips.EDI.Foundation.APIGateway.AutomationTest" Version="1.*" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
|
||||
<log4net>
|
||||
<root>
|
||||
<level value="ALL" />
|
||||
<appender-ref ref="file" />
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
<appender name="console" type="log4net.Appender.ConsoleAppender">
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date %level - %message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
<appender name="file" type="log4net.Appender.RollingFileAppender">
|
||||
<file value="AutomationLog.log" />
|
||||
<appendToFile value="true" />
|
||||
<rollingStyle value="Size" />
|
||||
<maxSizeRollBackups value="5" />
|
||||
<maximumFileSize value="10MB" />
|
||||
<staticLogFileName value="true" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date %level - %message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
</log4net>
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
include {
|
||||
path = find_in_parent_folders()
|
||||
}
|
||||
|
||||
terraform {
|
||||
source = "../../dependent_modules//api-gateway"
|
||||
}
|
||||
|
||||
inputs = {
|
||||
|
||||
proposition_id = dependency.core.outputs.foundation_envoy_proposition_id
|
||||
cf_org = "client-EDI-SolutionAccelerator"
|
||||
cf_space = "envoyci"
|
||||
cf_deploy_user = dependency.core.outputs.cf_deploy_user
|
||||
cf_deploy_password = dependency.core.outputs.cf_deploy_password
|
||||
cf_domain = "us-east.philips-healthsuite.com"
|
||||
redis_credentials = dependency.cloudfoundry.outputs.redis_credentials
|
||||
logdrainer = dependency.cloudfoundry.outputs.logdrainer_service_id
|
||||
oauth_proxy_redis = dependency.cloudfoundry.outputs.redis_service_id
|
||||
org_id_source = get_env("SOURCE", "url")
|
||||
config_file_location = get_env("CONFIG", "./envoyconfig_without_multitenancy.yml")
|
||||
envoy_tag = dependency.core.outputs.envoy_tag
|
||||
oauth_tag = dependency.core.outputs.oauth_tag
|
||||
authenticator_tag = dependency.core.outputs.authenticator_tag
|
||||
tokenexchange_tag = dependency.core.outputs.tokenexchange_tag
|
||||
}
|
||||
|
||||
dependency "core" {
|
||||
config_path = "../core/"
|
||||
}
|
||||
|
||||
dependency "cloudfoundry" {
|
||||
config_path = "../cloudfoundry/"
|
||||
}
|
||||
|
||||
generate "provider" {
|
||||
path = "provider.tf"
|
||||
if_exists = "overwrite_terragrunt"
|
||||
contents = <<EOF
|
||||
provider "cloudfoundry" {
|
||||
api_url = "${dependency.core.outputs.cf_api_url}"
|
||||
user = "${dependency.core.outputs.cf_deploy_user}"
|
||||
password = "${dependency.core.outputs.cf_deploy_password}"
|
||||
}
|
||||
provider "hsdp" {
|
||||
region = "us-east"
|
||||
environment = "client-test"
|
||||
service_id = "${dependency.core.outputs.automation_service_id}"
|
||||
service_private_key = "${replace(dependency.core.outputs.automation_service_private_key, "\n", "")}"
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
include {
|
||||
path = find_in_parent_folders()
|
||||
}
|
||||
|
||||
terraform {
|
||||
source = "../../dependent_modules//cloudfoundry"
|
||||
}
|
||||
|
||||
inputs = {
|
||||
cf_org = "client-EDI-SolutionAccelerator"
|
||||
cf_space_name = "envoyci"
|
||||
logdrainer_uri = "${dependency.core.outputs.logdrainer_base_uri}${dependency.core.outputs.logdrainer_uri}"
|
||||
redis_plan_name = "redis-development-standalone"
|
||||
cf_deploy_user = dependency.core.outputs.cf_deploy_user
|
||||
}
|
||||
|
||||
dependency "core" {
|
||||
config_path = "../core"
|
||||
}
|
||||
|
||||
generate "provider" {
|
||||
path = "provider.tf"
|
||||
if_exists = "overwrite_terragrunt"
|
||||
contents = <<EOF
|
||||
provider "cloudfoundry" {
|
||||
api_url = "${dependency.core.outputs.cf_api_url}"
|
||||
user = "${dependency.core.outputs.cf_deploy_user}"
|
||||
password = "${dependency.core.outputs.cf_deploy_password}"
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
include {
|
||||
path = find_in_parent_folders()
|
||||
}
|
||||
|
||||
terraform {
|
||||
source = "../../dependent_modules//core"
|
||||
}
|
||||
|
||||
inputs = {
|
||||
edisp_azure_vault_name = "edisp-UB5gKdbmC3"
|
||||
edisp_azure_automation_account_name = "edisp-HPTWRpsLcl"
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
skip = true
|
||||
|
||||
locals {
|
||||
path_segments = split("/", path_relative_to_include())
|
||||
environment = "client-test"
|
||||
region = "us-east"
|
||||
azure_subscription_id = "74d03f75-4bdb-4666-8095-500178a40764"
|
||||
}
|
||||
|
||||
remote_state {
|
||||
backend = "azurerm"
|
||||
generate = {
|
||||
path = "backend.tf"
|
||||
if_exists = "overwrite_terragrunt"
|
||||
}
|
||||
config = {
|
||||
storage_account_name = "foundationcicd"
|
||||
container_name = "envoyci"
|
||||
key = "${path_relative_to_include()}/terraform.tfstate"
|
||||
resource_group_name = "edi-platform-foundation-cicd"
|
||||
subscription_id = "${local.azure_subscription_id}"
|
||||
use_azuread_auth = true
|
||||
}
|
||||
}
|
||||
|
||||
// Setup the region and environment based on the folder name
|
||||
|
||||
generate "auto_vars" {
|
||||
path = "terragrunt.auto.tfvars"
|
||||
if_exists = "overwrite_terragrunt"
|
||||
contents = <<EOF
|
||||
region = "${local.region}"
|
||||
environment = "${local.environment}"
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
terraform {
|
||||
extra_arguments "azure_config" {
|
||||
commands = get_terraform_commands_that_need_vars()
|
||||
|
||||
env_vars = {
|
||||
# other credentials are secrets and are passed as env vars in the pipeline
|
||||
# or local credentails are used when logging in as a user
|
||||
ARM_SUBSCRIPTION_ID = local.azure_subscription_id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
|
||||
data "cloudfoundry_org" "org" {
|
||||
name = var.cf_org
|
||||
}
|
||||
|
||||
data "cloudfoundry_space" "cf_space" {
|
||||
name = var.cf_space
|
||||
org = data.cloudfoundry_org.org.id
|
||||
}
|
||||
|
||||
data "cloudfoundry_domain" "internal" {
|
||||
name = "apps.internal"
|
||||
}
|
||||
|
||||
|
||||
data "cloudfoundry_service" "data_redis_service" {
|
||||
name = "hsdp-redis-db"
|
||||
}
|
||||
|
||||
|
||||
data "cloudfoundry_service" "vault" {
|
||||
name = "hsdp-vault"
|
||||
}
|
||||
|
||||
data "cloudfoundry_app" "Prometheus" {
|
||||
name_or_id = "3ad08628-ae45-40b5-8ae7-f039b5f82b8f"
|
||||
space = var.cf_space
|
||||
}
|
||||
|
|
@ -0,0 +1,293 @@
|
|||
static_resources:
|
||||
listeners:
|
||||
- address:
|
||||
socket_address:
|
||||
address: 0.0.0.0
|
||||
port_value: ${ENVOY_PORT}
|
||||
filter_chains:
|
||||
- filters:
|
||||
- name: envoy.filters.network.http_connection_manager
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
|
||||
codec_type: AUTO
|
||||
stat_prefix: ingress_http
|
||||
access_log:
|
||||
- name: envoy.access_loggers.stdout
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
|
||||
route_config:
|
||||
name: local_route
|
||||
virtual_hosts:
|
||||
- name: upstream
|
||||
require_tls: EXTERNAL_ONLY
|
||||
request_headers_to_remove:
|
||||
- x-auth-introspect-value
|
||||
- x-auth-request-access-token
|
||||
domains:
|
||||
- "*"
|
||||
routes:
|
||||
- match:
|
||||
prefix: "/oauth2/callback"
|
||||
route:
|
||||
cluster: oauth-proxy-service
|
||||
- match:
|
||||
prefix: "/mockserviceA"
|
||||
route:
|
||||
cluster: mockserviceA
|
||||
- match:
|
||||
prefix: "/FilterService"
|
||||
route:
|
||||
cluster: FilterService
|
||||
- match:
|
||||
prefix: "/dicom/qido"
|
||||
request_headers_to_remove:
|
||||
- edisp-introspect-value
|
||||
route:
|
||||
cluster: qido-service
|
||||
host_rewrite_literal: dss-qido-edisa-tst.us-east.philips-healthsuite.com
|
||||
- match:
|
||||
prefix: "/store/dicom/qidors"
|
||||
route:
|
||||
cluster: qido-service
|
||||
host_rewrite_literal: dss-qido-edisa-tst.us-east.philips-healthsuite.com
|
||||
- match:
|
||||
prefix: "/store/fhir"
|
||||
request_headers_to_add:
|
||||
- header:
|
||||
key: "api-version"
|
||||
value: "1"
|
||||
- header:
|
||||
key: "Accept"
|
||||
value: "application/json"
|
||||
request_headers_to_remove:
|
||||
- edisp-introspect-value
|
||||
route:
|
||||
cluster: cdr-service
|
||||
host_rewrite_literal: cdr-edisa-test.us-east.philips-healthsuite.com
|
||||
- match:
|
||||
prefix: "/IamTokenExchangeBroker"
|
||||
route:
|
||||
cluster: sso_authenticator
|
||||
- match:
|
||||
prefix: "/"
|
||||
route:
|
||||
cluster: mountebank
|
||||
http_filters:
|
||||
- name: envoy.filters.http.lua
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
|
||||
inline_code: |
|
||||
function envoy_on_request(request_handle)
|
||||
local library = require("lib.envoyLibrary")
|
||||
library.SelectAuthenticationFlow(request_handle)
|
||||
end
|
||||
function envoy_on_response(response_handle)
|
||||
local library = require("lib.envoyLibrary")
|
||||
library.setIntrospectionValue(response_handle)
|
||||
response_handle:headers():remove("x-auth-introspect-value")
|
||||
end
|
||||
- name: envoy.filters.http.ext_authz
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz
|
||||
transport_api_version: V3
|
||||
http_service:
|
||||
server_uri:
|
||||
uri: ${OAUTH_PROXY_ENDPOINT}:${OAUTH_PROXY_PORT}
|
||||
cluster: oauth-proxy-service
|
||||
timeout: ${TimeoutInSeconds}
|
||||
authorization_request:
|
||||
allowed_headers:
|
||||
patterns:
|
||||
- exact: cookie
|
||||
- prefix: x-
|
||||
authorization_response:
|
||||
allowed_client_headers_on_success:
|
||||
patterns:
|
||||
- exact: set-cookie
|
||||
- prefix: x-auth-introspect
|
||||
allowed_upstream_headers:
|
||||
patterns:
|
||||
- exact: set-cookie
|
||||
- prefix: x-auth-request-access
|
||||
- prefix: x-auth-introspect
|
||||
filter_enabled_metadata:
|
||||
filter: envoy.filters.http.ext_authz
|
||||
path:
|
||||
- key: login_flow
|
||||
value:
|
||||
bool_match: true
|
||||
- name: envoy.filters.http.ext_authz
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz
|
||||
transport_api_version: V3
|
||||
http_service:
|
||||
server_uri:
|
||||
uri: ${SSO_AUTHENTICATOR_ENDPOINT}:${SSO_AUTHENTICATOR_PORT}
|
||||
cluster: sso_authenticator
|
||||
timeout: ${TimeoutInSeconds}
|
||||
authorization_request:
|
||||
allowed_headers:
|
||||
patterns:
|
||||
- prefix: edisp-
|
||||
authorization_response:
|
||||
allowed_upstream_headers:
|
||||
patterns:
|
||||
- prefix: auth
|
||||
filter_enabled_metadata:
|
||||
filter: envoy.filters.http.ext_authz
|
||||
path:
|
||||
- key: vuepacs_sso_token_flow
|
||||
value:
|
||||
bool_match: true
|
||||
- name: envoy.filters.http.ext_authz
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz
|
||||
transport_api_version: V3
|
||||
http_service:
|
||||
server_uri:
|
||||
uri: ${AUTHENTICATOR_ENDPOINT}:${AUTHENTICATOR_PORT}
|
||||
cluster: authenticator
|
||||
timeout: ${TimeoutInSeconds}
|
||||
authorization_request:
|
||||
allowed_headers:
|
||||
patterns:
|
||||
- exact: cookie
|
||||
- prefix: x-
|
||||
authorization_response:
|
||||
allowed_upstream_headers:
|
||||
patterns:
|
||||
- prefix: x-auth-introspect
|
||||
filter_enabled_metadata:
|
||||
filter: envoy.filters.http.ext_authz
|
||||
path:
|
||||
- key: access_token_flow
|
||||
value:
|
||||
bool_match: true
|
||||
- name: envoy.filters.http.lua
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
|
||||
inline_code: |
|
||||
pathMap = {["/store/fhir"] = "/store/fhir/orgId",["/dicom/qido"] = "/store/dicom/qidors/orgId",["/mockserviceA/multitenancy"] = "/mockserviceA/multitenancy/orgId"}
|
||||
function envoy_on_request(request_handle)
|
||||
local library = require("lib.envoyLibrary")
|
||||
library.setAccessToken(request_handle)
|
||||
if string.lower("${ORG_ID_SOURCE}")=="url" then
|
||||
library.setOrgIdInHeader(request_handle, ${ORG_ID_MAPPING}, pathMap)
|
||||
end
|
||||
if string.lower("${ORG_ID_SOURCE}")=="header" then
|
||||
library.modifyPath(request_handle, pathMap)
|
||||
end
|
||||
library.setIntrospectionValue(request_handle)
|
||||
end
|
||||
- name: envoy.filters.http.router
|
||||
typed_config: {}
|
||||
clusters:
|
||||
- name: oauth-proxy-service
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
load_assignment:
|
||||
cluster_name: oauth-proxy-service
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${OAUTH_PROXY_ENDPOINT}
|
||||
port_value: ${OAUTH_PROXY_PORT}
|
||||
- name: sso_authenticator
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
lb_policy: ROUND_ROBIN
|
||||
load_assignment:
|
||||
cluster_name: sso_authenticator
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${SSO_AUTHENTICATOR_ENDPOINT}
|
||||
port_value: ${SSO_AUTHENTICATOR_PORT}
|
||||
- name: authenticator
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
lb_policy: ROUND_ROBIN
|
||||
load_assignment:
|
||||
cluster_name: authenticator
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${AUTHENTICATOR_ENDPOINT}
|
||||
port_value: ${AUTHENTICATOR_PORT}
|
||||
- name: mountebank
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
lb_policy: ROUND_ROBIN
|
||||
load_assignment:
|
||||
cluster_name: mountebank
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${MOUNTEBANK_ENDPOINT}
|
||||
port_value: ${MOUNTEBANK_PORT}
|
||||
- name: mockserviceA
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
lb_policy: ROUND_ROBIN
|
||||
load_assignment:
|
||||
cluster_name: mockserviceA
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${MOUNTEBANK_ENDPOINT}
|
||||
port_value: 4545
|
||||
- name: FilterService
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
lb_policy: ROUND_ROBIN
|
||||
load_assignment:
|
||||
cluster_name: FilterService
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${MOUNTEBANK_ENDPOINT}
|
||||
port_value: 4547
|
||||
- name: qido-service
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
load_assignment:
|
||||
cluster_name: qido-service
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: dss-qido-edisa-tst.us-east.philips-healthsuite.com
|
||||
port_value: 443
|
||||
transport_socket:
|
||||
name: envoy.transport_sockets.tls
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
|
||||
- name: cdr-service
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
load_assignment:
|
||||
cluster_name: cdr-service
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: cdr-edisa-test.us-east.philips-healthsuite.com
|
||||
port_value: 443
|
||||
transport_socket:
|
||||
name: envoy.transport_sockets.tls
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
|
||||
|
|
@ -0,0 +1,323 @@
|
|||
static_resources:
|
||||
listeners:
|
||||
- address:
|
||||
socket_address:
|
||||
address: 0.0.0.0
|
||||
port_value: ${ENVOY_PORT}
|
||||
filter_chains:
|
||||
- filters:
|
||||
- name: envoy.filters.network.http_connection_manager
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
|
||||
codec_type: AUTO
|
||||
stat_prefix: ingress_http
|
||||
access_log:
|
||||
- name: envoy.access_loggers.stdout
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
|
||||
route_config:
|
||||
name: local_route
|
||||
virtual_hosts:
|
||||
- name: upstream
|
||||
require_tls: EXTERNAL_ONLY
|
||||
request_headers_to_remove:
|
||||
- x-auth-introspect-value
|
||||
- x-auth-request-access-token
|
||||
domains:
|
||||
- "*"
|
||||
routes:
|
||||
- match:
|
||||
prefix: "/logout"
|
||||
request_headers_to_add:
|
||||
- header:
|
||||
key: "X-Auth-Request-Redirect"
|
||||
value: ${IAM_TERMINATE_SESSION_URL}
|
||||
typed_per_filter_config:
|
||||
envoy.filters.http.ext_authz:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute
|
||||
disabled: true
|
||||
route:
|
||||
cluster: oauth-proxy-service
|
||||
prefix_rewrite: "/oauth2/sign_out"
|
||||
- match:
|
||||
prefix: "/IamTokenExchangeBroker"
|
||||
route:
|
||||
cluster: sso_authenticator
|
||||
- match:
|
||||
prefix: "/store/fhir"
|
||||
request_headers_to_add:
|
||||
- header:
|
||||
key: "api-version"
|
||||
value: "1"
|
||||
- header:
|
||||
key: "Accept"
|
||||
value: "application/json"
|
||||
request_headers_to_remove:
|
||||
- edisp-introspect-value
|
||||
route:
|
||||
cluster: cdr-service
|
||||
host_rewrite_literal: cdr-edisa-test.us-east.philips-healthsuite.com
|
||||
- match:
|
||||
prefix: "/mockserviceA"
|
||||
route:
|
||||
cluster: mockserviceA
|
||||
request_headers_to_add:
|
||||
- header:
|
||||
key: "custom-header"
|
||||
value: "100"
|
||||
- match:
|
||||
prefix: "/mockserviceB"
|
||||
route:
|
||||
cluster: mockserviceB
|
||||
- match:
|
||||
prefix: "/mockserviceX"
|
||||
route:
|
||||
cluster: mockserviceX
|
||||
- match:
|
||||
prefix: "/FilterService"
|
||||
route:
|
||||
cluster: FilterService
|
||||
- match:
|
||||
prefix: "/prefixrewritetest"
|
||||
route:
|
||||
cluster: mockserviceA
|
||||
prefix_rewrite: "/mockserviceA"
|
||||
- match:
|
||||
prefix: "/oauth2/callback"
|
||||
route:
|
||||
cluster: oauth-proxy-service
|
||||
- match:
|
||||
prefix: "/"
|
||||
route:
|
||||
cluster: mountebank
|
||||
http_filters:
|
||||
- name: envoy.filters.http.lua
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
|
||||
inline_code: |
|
||||
function envoy_on_request(request_handle)
|
||||
local library = require("lib.envoyLibrary")
|
||||
library.SelectAuthenticationFlow(request_handle)
|
||||
end
|
||||
function envoy_on_response(response_handle)
|
||||
local library = require("lib.envoyLibrary")
|
||||
library.setIntrospectionValue(response_handle)
|
||||
response_handle:headers():remove("x-auth-introspect-value")
|
||||
end
|
||||
- name: envoy.filters.http.ext_authz
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz
|
||||
transport_api_version: V3
|
||||
http_service:
|
||||
server_uri:
|
||||
uri: ${OAUTH_PROXY_ENDPOINT}:${OAUTH_PROXY_PORT}
|
||||
cluster: oauth-proxy-service
|
||||
timeout: ${TimeoutInSeconds}
|
||||
authorization_request:
|
||||
allowed_headers:
|
||||
patterns:
|
||||
- exact: cookie
|
||||
- prefix: x-
|
||||
authorization_response:
|
||||
allowed_client_headers:
|
||||
patterns:
|
||||
- exact: set-cookie
|
||||
allowed_client_headers_on_success:
|
||||
patterns:
|
||||
- exact: set-cookie
|
||||
- prefix: x-auth-introspect
|
||||
allowed_upstream_headers:
|
||||
patterns:
|
||||
- exact: set-cookie
|
||||
- prefix: x-auth-request-access
|
||||
- prefix: x-auth-introspect
|
||||
filter_enabled_metadata:
|
||||
filter: envoy.filters.http.ext_authz
|
||||
path:
|
||||
- key: login_flow
|
||||
value:
|
||||
bool_match: true
|
||||
- name: envoy.filters.http.ext_authz
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz
|
||||
transport_api_version: V3
|
||||
http_service:
|
||||
server_uri:
|
||||
uri: ${SSO_AUTHENTICATOR_ENDPOINT}:${SSO_AUTHENTICATOR_PORT}
|
||||
cluster: sso_authenticator
|
||||
timeout: ${TimeoutInSeconds}
|
||||
authorization_request:
|
||||
allowed_headers:
|
||||
patterns:
|
||||
- prefix: edisp-
|
||||
authorization_response:
|
||||
allowed_upstream_headers:
|
||||
patterns:
|
||||
- prefix: auth
|
||||
filter_enabled_metadata:
|
||||
filter: envoy.filters.http.ext_authz
|
||||
path:
|
||||
- key: vuepacs_sso_token_flow
|
||||
value:
|
||||
bool_match: true
|
||||
- name: envoy.filters.http.ext_authz
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz
|
||||
transport_api_version: V3
|
||||
http_service:
|
||||
server_uri:
|
||||
uri: ${AUTHENTICATOR_ENDPOINT}:${AUTHENTICATOR_PORT}
|
||||
cluster: authenticator
|
||||
timeout: ${TimeoutInSeconds}
|
||||
authorization_request:
|
||||
allowed_headers:
|
||||
patterns:
|
||||
- exact: cookie
|
||||
- prefix: x-
|
||||
authorization_response:
|
||||
allowed_upstream_headers:
|
||||
patterns:
|
||||
- prefix: x-auth-introspect
|
||||
filter_enabled_metadata:
|
||||
filter: envoy.filters.http.ext_authz
|
||||
path:
|
||||
- key: access_token_flow
|
||||
value:
|
||||
bool_match: true
|
||||
- name: envoy.filters.http.lua
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
|
||||
inline_code: |
|
||||
function envoy_on_request(request_handle)
|
||||
local library = require("lib.envoyLibrary")
|
||||
library.setAccessToken(request_handle)
|
||||
library.setIntrospectionValue(request_handle)
|
||||
end
|
||||
- name: envoy.filters.http.router
|
||||
typed_config: {}
|
||||
clusters:
|
||||
- name: mountebank
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
lb_policy: ROUND_ROBIN
|
||||
load_assignment:
|
||||
cluster_name: mountebank
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${MOUNTEBANK_ENDPOINT}
|
||||
port_value: ${MOUNTEBANK_PORT}
|
||||
- name: mockserviceA
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
lb_policy: ROUND_ROBIN
|
||||
load_assignment:
|
||||
cluster_name: mockserviceA
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${MOUNTEBANK_ENDPOINT}
|
||||
port_value: 4545
|
||||
- name: FilterService
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
lb_policy: ROUND_ROBIN
|
||||
load_assignment:
|
||||
cluster_name: FilterService
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${MOUNTEBANK_ENDPOINT}
|
||||
port_value: 4547
|
||||
- name: mockserviceB
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
lb_policy: ROUND_ROBIN
|
||||
load_assignment:
|
||||
cluster_name: mockserviceB
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${MOUNTEBANK_ENDPOINT}
|
||||
port_value: 4546
|
||||
- name: mockserviceX
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
lb_policy: ROUND_ROBIN
|
||||
load_assignment:
|
||||
cluster_name: mockserviceB
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${MONTEBANKSERVICEDOWNTEST}
|
||||
port_value: 4550
|
||||
- name: sso_authenticator
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
lb_policy: ROUND_ROBIN
|
||||
load_assignment:
|
||||
cluster_name: sso_authenticator
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${SSO_AUTHENTICATOR_ENDPOINT}
|
||||
port_value: ${SSO_AUTHENTICATOR_PORT}
|
||||
- name: oauth-proxy-service
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
load_assignment:
|
||||
cluster_name: oauth-proxy-service
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${OAUTH_PROXY_ENDPOINT}
|
||||
port_value: ${OAUTH_PROXY_PORT}
|
||||
- name: authenticator
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
lb_policy: ROUND_ROBIN
|
||||
load_assignment:
|
||||
cluster_name: authenticator
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: ${AUTHENTICATOR_ENDPOINT}
|
||||
port_value: ${AUTHENTICATOR_PORT}
|
||||
- name: cdr-service
|
||||
connect_timeout: ${TimeoutInSeconds}
|
||||
type: logical_dns
|
||||
load_assignment:
|
||||
cluster_name: cdr-service
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint:
|
||||
address:
|
||||
socket_address:
|
||||
address: cdr-edisa-test.us-east.philips-healthsuite.com
|
||||
port_value: 443
|
||||
transport_socket:
|
||||
name: envoy.transport_sockets.tls
|
||||
typed_config:
|
||||
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
|
||||
common_tls_context:
|
||||
validation_context:
|
||||
trusted_ca:
|
||||
filename: /etc/ssl/certs/ca-certificates.crt
|
||||
match_subject_alt_names:
|
||||
- exact: cdr-edisa-test.us-east.philips-healthsuite.com
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
locals {
|
||||
|
||||
monteback_routes = [{
|
||||
route = cloudfoundry_route.monteback.id
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
module "app_api_gateway" {
|
||||
source = "github.com/philips-internal/terraform-api-gateway?ref=v0.0.32"
|
||||
|
||||
api_gateway_image = { "image_name" : "edi-foundation-envoy-gateway", "registry" : "docker.na1.hsdp.io/edi", "image_tag" : "${var.envoy_tag}", "registry_username" : "${var.cf_deploy_user}", "registry_password" : "${var.cf_deploy_password}" }
|
||||
oauth2_proxy_image = { "image_name" : "edi-foundation-oauth2-proxy", "registry" : "docker.na1.hsdp.io/edi", "image_tag" : "${var.oauth_tag}", "registry_username" : "${var.cf_deploy_user}", "registry_password" : "${var.cf_deploy_password}" }
|
||||
authenticator_service_image = { "image_name" : "edi-foundation-apigateway-tokenauthenticator", "registry" : "docker.na1.hsdp.io/edi", "image_tag" : "${var.authenticator_tag}", "registry_username" : "${var.cf_deploy_user}", "registry_password" : "${var.cf_deploy_password}" }
|
||||
tokenexchange_broker_image = { "image_name" : "edi-foundation-iam-tokenexchange-broker", "registry" : "docker.na1.hsdp.io/edi", "image_tag" : "${var.tokenexchange_tag}", "registry_username" : "${var.cf_deploy_user}", "registry_password" : "${var.cf_deploy_password}" }
|
||||
api_gateway_routes = [
|
||||
{
|
||||
hostname = "${data.cloudfoundry_space.cf_space.name}-api-gateway"
|
||||
port = 8080
|
||||
},
|
||||
{
|
||||
hostname = "org1-${data.cloudfoundry_space.cf_space.name}-api-gateway"
|
||||
port = 8080
|
||||
},
|
||||
{
|
||||
hostname = "invalidorg-${data.cloudfoundry_space.cf_space.name}-api-gateway"
|
||||
port = 8080
|
||||
}
|
||||
]
|
||||
envoy_config = base64encode(file(var.config_file_location))
|
||||
space = var.cf_space
|
||||
proposition_id = var.proposition_id
|
||||
cf_org = var.cf_org
|
||||
domain = var.cf_domain
|
||||
api_gateway_environment = {
|
||||
"MOUNTEBANK_ENDPOINT" = "${cloudfoundry_route.monteback.endpoint}"
|
||||
"MOUNTEBANK_PORT" = 2525
|
||||
"MONTEBANKSERVICEDOWNTEST" = "${cloudfoundry_route.montebankservicedowntest.endpoint}"
|
||||
"ORG_ID_SOURCE" = var.org_id_source
|
||||
"ORG_ID_MAPPING" = "{[\"org1-${data.cloudfoundry_space.cf_space.name}-api-gateway\"] = \"51e2503f-c1df-430d-a1ce-2524fa796cda\"}"
|
||||
"TimeoutInSeconds" = "0.750s"
|
||||
"ENVOY_PORT" = 8080
|
||||
}
|
||||
oauth2_environment = {
|
||||
"OAUTH2_PROXY_COOKIE_REFRESH" = "0h0m25s"
|
||||
"OAUTH2_PROXY_SESSION_STORE_TYPE" = "redis"
|
||||
"OAUTH2_PROXY_REDIS_CONNECTION_URL" = "redis://:${var.redis_credentials["password"]}@${var.redis_credentials["hostname"]}:${var.redis_credentials["port"]}"
|
||||
}
|
||||
logout_redirect_url = "https://${data.cloudfoundry_space.cf_space.name}-api-gateway.${var.cf_domain}"
|
||||
log_service_id = var.logdrainer
|
||||
redis_service_id = var.oauth_proxy_redis
|
||||
vault_service_id = cloudfoundry_service_instance.gateway_vault.id
|
||||
use_authenticator = "true"
|
||||
use_tokenexchangebroker = "true"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
resource "cloudfoundry_network_policy" "monteback_a" {
|
||||
policy {
|
||||
source_app = module.app_api_gateway.api_gw_application_id
|
||||
destination_app = cloudfoundry_app.monteback.id
|
||||
port = 2525
|
||||
}
|
||||
}
|
||||
|
||||
resource "cloudfoundry_network_policy" "monteback_b" {
|
||||
policy {
|
||||
source_app = module.app_api_gateway.api_gw_application_id
|
||||
destination_app = cloudfoundry_app.monteback.id
|
||||
port = 4545
|
||||
}
|
||||
}
|
||||
|
||||
resource "cloudfoundry_network_policy" "monteback_c" {
|
||||
policy {
|
||||
source_app = module.app_api_gateway.api_gw_application_id
|
||||
destination_app = cloudfoundry_app.monteback.id
|
||||
port = 4546
|
||||
}
|
||||
}
|
||||
|
||||
resource "cloudfoundry_network_policy" "monteback_d" {
|
||||
policy {
|
||||
source_app = module.app_api_gateway.api_gw_application_id
|
||||
destination_app = cloudfoundry_app.monteback.id
|
||||
port = 4550
|
||||
}
|
||||
}
|
||||
|
||||
resource "cloudfoundry_network_policy" "monteback_FilterService" {
|
||||
policy {
|
||||
source_app = module.app_api_gateway.api_gw_application_id
|
||||
destination_app = cloudfoundry_app.monteback.id
|
||||
port = 4547
|
||||
}
|
||||
}
|
||||
|
||||
resource "cloudfoundry_app" "monteback" {
|
||||
space = data.cloudfoundry_space.cf_space.id
|
||||
name = "monteback"
|
||||
docker_image = "${var.DOCKER_REGISTRY}/mountebank:latest"
|
||||
instances = 1
|
||||
memory = 300
|
||||
disk_quota = 512
|
||||
command = "node bin/mb --allowInjection"
|
||||
docker_credentials = {
|
||||
username = var.cf_deploy_user
|
||||
password = var.cf_deploy_password
|
||||
}
|
||||
dynamic "routes" {
|
||||
for_each = local.monteback_routes
|
||||
|
||||
content {
|
||||
|
||||
route = routes.value.route
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
resource "cloudfoundry_route" "monteback" {
|
||||
domain = data.cloudfoundry_domain.internal.id
|
||||
space = data.cloudfoundry_space.cf_space.id
|
||||
hostname = "montebanktest-${data.cloudfoundry_space.cf_space.name}"
|
||||
|
||||
}
|
||||
|
||||
resource "cloudfoundry_route" "montebankservicedowntest" {
|
||||
domain = data.cloudfoundry_domain.internal.id
|
||||
space = data.cloudfoundry_space.cf_space.id
|
||||
hostname = "montebankservicedowntest-${data.cloudfoundry_space.cf_space.name}"
|
||||
|
||||
}
|
||||
resource "cloudfoundry_service_instance" "gateway_vault" {
|
||||
name = "gateway_vault"
|
||||
space = data.cloudfoundry_space.cf_space.id
|
||||
service_plan = data.cloudfoundry_service.vault.service_plans["vault-us-east-1"]
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
output "iam_url_us_east_prod1" {
|
||||
value = module.app_api_gateway.iam_url
|
||||
}
|
||||
|
||||
output "api_gw_endpoints" {
|
||||
value = module.app_api_gateway.api_gw_proposition_endpoints
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
terraform {
|
||||
experiments = [module_variable_optional_attrs]
|
||||
}
|
||||
|
||||
variable "CF_API_URL" {
|
||||
type = string
|
||||
description = "URL used to connect to CF environment API"
|
||||
default = "https://api.cloud.pcftest.com"
|
||||
}
|
||||
|
||||
variable "proposition_id" {
|
||||
type = string
|
||||
description = "foundation proposition id"
|
||||
}
|
||||
|
||||
variable "cf_space" {
|
||||
type = string
|
||||
description = "Cloud foundry space"
|
||||
}
|
||||
|
||||
variable "CF_USER" {
|
||||
type = string
|
||||
description = "Cloud foundry API username"
|
||||
default = "solutionaccelerator-cicd-svc"
|
||||
|
||||
}
|
||||
variable "cf_org" {
|
||||
type = string
|
||||
description = "Cloud foundry API ORG"
|
||||
|
||||
}
|
||||
|
||||
variable "cf_deploy_user" {
|
||||
type = string
|
||||
description = "Cloud foundry domain to deploy api gateway"
|
||||
}
|
||||
|
||||
variable "cf_deploy_password" {
|
||||
type = string
|
||||
description = "Cloud foundry domain to deploy api gateway"
|
||||
}
|
||||
|
||||
variable "cf_domain" {
|
||||
type = string
|
||||
description = "Cloud foundry domain to deploy api gateway"
|
||||
}
|
||||
|
||||
variable "DOCKER_REGISTRY" {
|
||||
type = string
|
||||
description = "Docker registry for all images"
|
||||
default = "docker.na1.hsdp.io/edi"
|
||||
}
|
||||
|
||||
|
||||
variable "api_gateway_appname" {
|
||||
type = string
|
||||
description = "space name"
|
||||
default = "api_gateway"
|
||||
}
|
||||
|
||||
|
||||
variable "oauth_proxy_appname" {
|
||||
type = string
|
||||
description = "Application name"
|
||||
default = "oauth_proxy"
|
||||
}
|
||||
|
||||
variable "envoy_tag" {
|
||||
type = string
|
||||
description = "Tag Value for Envoy Gateway"
|
||||
}
|
||||
|
||||
variable "oauth_tag" {
|
||||
type = string
|
||||
description = "Tag Value for OAuth Proxy"
|
||||
}
|
||||
|
||||
variable "authenticator_tag" {
|
||||
type = string
|
||||
description = "Tag Value for Token Authenticator"
|
||||
}
|
||||
|
||||
variable "tokenexchange_tag" {
|
||||
type = string
|
||||
description = "Tag Value for Token Exchange Broker"
|
||||
}
|
||||
|
||||
variable "hsdp_iam_url" {
|
||||
type = string
|
||||
description = "The IAM url for the region that the IAM ORG is in"
|
||||
default = "https://iam-client-test.us-east.philips-healthsuite.com"
|
||||
}
|
||||
|
||||
variable "hsdp_idm_url" {
|
||||
type = string
|
||||
description = "The IDM url for the region that the IAM ORG is in"
|
||||
default = "https://idm-client-test.us-east.philips-healthsuite.com"
|
||||
}
|
||||
|
||||
variable "client_id" {
|
||||
type = string
|
||||
description = "Client ID for terrafom iam"
|
||||
default = "sal_terraform"
|
||||
|
||||
}
|
||||
|
||||
variable "config_file_location" {
|
||||
type = string
|
||||
description = "Envoy Config File for routing"
|
||||
|
||||
}
|
||||
|
||||
variable "service_id" {
|
||||
type = string
|
||||
description = "iam service id - used to configure hsdp provider - service must have oauth2 client creation permission"
|
||||
default = "pf-automation-tf.pf-automation-tf.pf-automation-tf@edi-platform-service.ediplatform.philips-healthsuite.com"
|
||||
}
|
||||
|
||||
variable "syslog_url" {
|
||||
type = string
|
||||
default = "https://logdrainer-client-test.us-east.philips-healthsuite.com/core/log/Product/e66380ff07c42b67483a3eb14e49c8677d5785467f21ac2b1bdfdfa6d7bce9e6423ae79fe42d0456419653ee80222792"
|
||||
description = "The URL used for the syslog service created to send logs from each app"
|
||||
}
|
||||
|
||||
variable "org_id_source" {
|
||||
type = string
|
||||
description = "org_id source to read from"
|
||||
}
|
||||
|
||||
variable "logdrainer"{
|
||||
type = string
|
||||
description = "log drainer service id"
|
||||
}
|
||||
variable "oauth_proxy_redis"{
|
||||
type = string
|
||||
description = "oauth proxy redis id"
|
||||
}
|
||||
|
||||
|
||||
|
||||
variable "redis_credentials" {
|
||||
type = map(any)
|
||||
description = "cf redis credentials"
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
cloudfoundry = {
|
||||
source = "cloudfoundry-community/cloudfoundry"
|
||||
version = ">= 0.14.2"
|
||||
}
|
||||
hsdp = {
|
||||
source = "philips-software/hsdp"
|
||||
version = ">= 0.19.5"
|
||||
}
|
||||
}
|
||||
required_version = ">= 1.0"
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
data "cloudfoundry_space_quota" "cf_quota" {
|
||||
name = var.cf_quota_name
|
||||
}
|
||||
|
||||
data "cloudfoundry_org" "cf_org" {
|
||||
name = var.cf_org
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
resource "cloudfoundry_space" "envoy_gateway_cicd" {
|
||||
name = var.cf_space_name
|
||||
org = data.cloudfoundry_org.cf_org.id
|
||||
quota = data.cloudfoundry_space_quota.cf_quota.id
|
||||
allow_ssh = true
|
||||
}
|
||||
|
||||
resource "cloudfoundry_space_users" "envoy_gateway_cicd_users" {
|
||||
space = cloudfoundry_space.envoy_gateway_cicd.id
|
||||
managers = [
|
||||
var.cf_deploy_user
|
||||
]
|
||||
developers = [
|
||||
var.cf_deploy_user
|
||||
]
|
||||
}
|
||||
|
||||
resource "cloudfoundry_user_provided_service" "envoy_gateway_cicd_logdrainer" {
|
||||
name = "envoy-gateway-cicd-logdrainer"
|
||||
space = cloudfoundry_space.envoy_gateway_cicd.id
|
||||
syslog_drain_url = var.logdrainer_uri
|
||||
|
||||
depends_on = [
|
||||
cloudfoundry_space.envoy_gateway_cicd, # it tries to query the space resource inside this module before creating the space
|
||||
cloudfoundry_space_users.envoy_gateway_cicd_users
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
output "logdrainer_service_id" {
|
||||
value = cloudfoundry_user_provided_service.envoy_gateway_cicd_logdrainer.id
|
||||
}
|
||||
|
||||
output "redis_service_id" {
|
||||
value = cloudfoundry_service_instance.redis_cicd.id
|
||||
}
|
||||
|
||||
output "redis_credentials" {
|
||||
value = cloudfoundry_service_key.redis_key.credentials
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
data "cloudfoundry_service" "redis_service" {
|
||||
name = "hsdp-redis-db"
|
||||
}
|
||||
|
||||
resource "cloudfoundry_service_instance" "redis_cicd" {
|
||||
name = "redis-cicd"
|
||||
space = cloudfoundry_space.envoy_gateway_cicd.id
|
||||
service_plan = data.cloudfoundry_service.redis_service.service_plans["${var.redis_plan_name}"]
|
||||
|
||||
depends_on = [
|
||||
cloudfoundry_space.envoy_gateway_cicd, # it tries to query the space resource inside this module before creating the space
|
||||
cloudfoundry_space_users.envoy_gateway_cicd_users
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
resource "cloudfoundry_service_key" "redis_key" {
|
||||
name = "redis-key"
|
||||
service_instance = cloudfoundry_service_instance.redis_cicd.id
|
||||
|
||||
depends_on = [
|
||||
cloudfoundry_space.envoy_gateway_cicd, # it tries to query the space resource inside this module before creating the space
|
||||
cloudfoundry_space_users.envoy_gateway_cicd_users
|
||||
]
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
variable "cf_org" {
|
||||
type = string
|
||||
description = "Cloud foundry org"
|
||||
}
|
||||
|
||||
variable "cf_quota_name" {
|
||||
type = string
|
||||
description = "cloud foundry space quota.(Should be predefined for all the foundation cicd spaces)"
|
||||
default = "foundation-cicd-quota"
|
||||
}
|
||||
|
||||
variable "cf_space_name" {
|
||||
type = string
|
||||
description = "cloud foundry space name to be created"
|
||||
}
|
||||
|
||||
variable "cf_deploy_user" {
|
||||
type = string
|
||||
description = "cloudfoundry user to assign space permisions"
|
||||
}
|
||||
|
||||
variable "logdrainer_uri" {
|
||||
type = string
|
||||
description = "cloudfoundry user to assign space permisions"
|
||||
}
|
||||
|
||||
variable "redis_plan_name" {
|
||||
type = string
|
||||
description = "cloudfoundry redis plan name"
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
cloudfoundry = {
|
||||
source = "cloudfoundry-community/cloudfoundry"
|
||||
version = ">= 0.14.2"
|
||||
}
|
||||
}
|
||||
required_version = ">= 1.0"
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
data "hsdp_config" "iam_url" {
|
||||
service = "iam"
|
||||
region = var.region
|
||||
environment = var.environment
|
||||
}
|
||||
|
||||
data "hsdp_config" "idm_url" {
|
||||
service = "idm"
|
||||
region = var.region
|
||||
environment = var.environment
|
||||
}
|
||||
|
||||
data "hsdp_docker_namespace" "edi" {
|
||||
name = "edi"
|
||||
}
|
||||
|
||||
data "hsdp_docker_repository" "edi-foundation-envoy-gateway" {
|
||||
namespace_id = data.hsdp_docker_namespace.edi.id
|
||||
name = "edi-foundation-envoy-gateway"
|
||||
}
|
||||
|
||||
data "hsdp_docker_repository" "edi-foundation-oauth2-proxy" {
|
||||
namespace_id = data.hsdp_docker_namespace.edi.id
|
||||
name = "edi-foundation-oauth2-proxy"
|
||||
}
|
||||
|
||||
data "hsdp_docker_repository" "edi-foundation-apigateway-tokenauthenticator" {
|
||||
namespace_id = data.hsdp_docker_namespace.edi.id
|
||||
name = "edi-foundation-apigateway-tokenauthenticator"
|
||||
}
|
||||
|
||||
data "hsdp_docker_repository" "edi-foundation-iam-tokenexchange-broker" {
|
||||
namespace_id = data.hsdp_docker_namespace.edi.id
|
||||
name = "edi-foundation-iam-tokenexchange-broker"
|
||||
}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
module "edisp" {
|
||||
source = "github.com/philips-internal/terraform-edi-platform-secrets?ref=v0.1.2"
|
||||
|
||||
region = var.region
|
||||
environment = var.environment
|
||||
edisp_azure_vault_name = var.edisp_azure_vault_name
|
||||
edisp_resource_group_name = var.edisp_resource_group_name
|
||||
edisp_azure_automation_account_name = var.edisp_azure_automation_account_name
|
||||
variables = ["TENANTS", "ORG-ID", "EDI-ORG-ID", "EDIPLATFORM-LOGGING-LOGDRAINER-BASE-URI"]
|
||||
}
|
||||
|
||||
data "hsdp_iam_org" "proposition_org" {
|
||||
organization_id = module.edisp.variables["ORG-ID"]
|
||||
}
|
||||
|
||||
resource "hsdp_iam_proposition" "foundation_envoy_cicd_prop" {
|
||||
name = "FOUNDATION-OAUTH-CI-TF"
|
||||
description = "Proposition id Created for Envoy CD through terraform"
|
||||
organization_id = hsdp_iam_org.foundation_envoy_nightly_org.id
|
||||
}
|
||||
|
||||
resource "hsdp_iam_org" "foundation_envoy_nightly_org" {
|
||||
name = "Oauth-CI-Org-TF"
|
||||
description = "Envoy Nightly Organization to run envoy nightly tests, Do not modify manually"
|
||||
parent_org_id = data.hsdp_iam_org.proposition_org.id
|
||||
}
|
||||
|
||||
resource "hsdp_iam_application" "foundation_envoy_nightly_app" {
|
||||
name = "OAUTH-CI-APP-TF"
|
||||
description = "Envoy CI application for Automation Tests, Do not modify manually"
|
||||
proposition_id = hsdp_iam_proposition.foundation_envoy_cicd_prop.id
|
||||
}
|
||||
|
||||
resource "hsdp_iam_service" "envoy_ci_service" {
|
||||
name = "oauth-cicd-service"
|
||||
description = "Service Client for Envoy Nightly Tests, Do not modify manually"
|
||||
application_id = hsdp_iam_application.foundation_envoy_nightly_app.id
|
||||
|
||||
validity = 12
|
||||
|
||||
scopes = ["openid"]
|
||||
default_scopes = ["openid"]
|
||||
}
|
||||
|
||||
resource "hsdp_iam_role" "envoy_ci_service_role" {
|
||||
|
||||
managing_organization = hsdp_iam_org.foundation_envoy_nightly_org.id
|
||||
name = "OAUTH-CI-SERVICE-TF"
|
||||
description = "Permissions to create IAM resources below the provided proposition."
|
||||
permissions = [
|
||||
"GROUP.READ",
|
||||
"GROUP.WRITE",
|
||||
"USER.READ",
|
||||
"USER.WRITE",
|
||||
"BASIC.WRITE",
|
||||
"ROLE.READ",
|
||||
"ROLE.WRITE",
|
||||
"PERMISSION.READ",
|
||||
"BASICTEST.WRITE"
|
||||
]
|
||||
}
|
||||
|
||||
resource "hsdp_iam_group" "envoy_ci_service_group" {
|
||||
|
||||
managing_organization = hsdp_iam_org.foundation_envoy_nightly_org.id
|
||||
name = "OAUTH-CI-SERVICE-TF"
|
||||
description = "Group for envoy automation service identities, Do not modify manually"
|
||||
services = [hsdp_iam_service.envoy_ci_service.id]
|
||||
roles = [hsdp_iam_role.envoy_ci_service_role.id]
|
||||
}
|
||||
|
||||
module "hsdp_iam_foundation_auto_oauth2_client" {
|
||||
source = "github.com/philips-internal/terraform-module-iam-client?ref=v0.1.0"
|
||||
|
||||
client_name = "oauth_ci_client"
|
||||
client_id = "oauth-ci"
|
||||
scopes = ["mail", "sn", "profile", "auth_iam_organization", "auth_iam_introspect"]
|
||||
response_types = ["code"]
|
||||
redirection_uris = []
|
||||
application_id = hsdp_iam_application.foundation_envoy_nightly_app.id
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
output "automation_service_id" {
|
||||
value = module.edisp.secrets["SERVICE-ID"]
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "automation_service_private_key" {
|
||||
value = module.edisp.secrets["SERVICE-KEY"]
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "logdrainer_uri" {
|
||||
value = module.edisp.secrets["EDIPLATFORM-LOGGING-LOGDRAINER-URI"]
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "logdrainer_base_uri" {
|
||||
value = module.edisp.variables["EDIPLATFORM-LOGGING-LOGDRAINER-BASE-URI"]
|
||||
}
|
||||
|
||||
output "foundation_cicd_org_id" {
|
||||
value = module.edisp.variables["ORG-ID"]
|
||||
}
|
||||
|
||||
output "foundation_envoy_proposition_id" {
|
||||
value = hsdp_iam_proposition.foundation_envoy_cicd_prop.id
|
||||
}
|
||||
|
||||
output "ediplatform_org_id" {
|
||||
value = module.edisp.variables["EDI-ORG-ID"]
|
||||
}
|
||||
|
||||
output "cf_api_url" {
|
||||
value = data.azurerm_key_vault_secret.cf_secrets["HSDP-CF-API-URL"].value
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "cf_deploy_user" {
|
||||
value = data.azurerm_key_vault_secret.cf_secrets["HSDP-CF-DEPLOY-USER"].value
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "cf_deploy_password" {
|
||||
value = data.azurerm_key_vault_secret.cf_secrets["HSDP-CF-DEPLOY-PASSWORD"].value
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "foundation_envoy_nightly_org_id" {
|
||||
value = hsdp_iam_org.foundation_envoy_nightly_org.id
|
||||
}
|
||||
|
||||
output "foundation_envoy_nightly_service_id" {
|
||||
value = hsdp_iam_service.envoy_ci_service.service_id
|
||||
}
|
||||
|
||||
output "foundation_envoy_nightly_service_private_key" {
|
||||
value = replace(hsdp_iam_service.envoy_ci_service.private_key, "\n", "")
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "fdn_envoy_oauth_client_id" {
|
||||
value = module.hsdp_iam_foundation_auto_oauth2_client.client_id
|
||||
}
|
||||
|
||||
output "fdn_envoy_oauth_client_password" {
|
||||
value = module.hsdp_iam_foundation_auto_oauth2_client.secret
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
output "hsdp_iam_url" {
|
||||
value = data.hsdp_config.iam_url.url
|
||||
}
|
||||
|
||||
output "hsdp_idm_url" {
|
||||
value = data.hsdp_config.idm_url.url
|
||||
}
|
||||
|
||||
output "envoy_tag" {
|
||||
value = data.hsdp_docker_repository.edi-foundation-envoy-gateway.tags[0]
|
||||
}
|
||||
|
||||
output "oauth_tag" {
|
||||
value = data.hsdp_docker_repository.edi-foundation-oauth2-proxy.tags[0]
|
||||
}
|
||||
|
||||
output "authenticator_tag" {
|
||||
value = data.hsdp_docker_repository.edi-foundation-apigateway-tokenauthenticator.tags[0]
|
||||
}
|
||||
|
||||
output "tokenexchange_tag" {
|
||||
value = data.hsdp_docker_repository.edi-foundation-iam-tokenexchange-broker.tags[0]
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
provider "azurerm" {
|
||||
features {}
|
||||
# This provider is configuered by environment secrets managed by the calling configuration
|
||||
}
|
||||
|
||||
provider "hsdp" {
|
||||
region = var.region
|
||||
environment = var.environment
|
||||
service_id = module.edisp.secrets["SERVICE-ID"]
|
||||
service_private_key = module.edisp.secrets["SERVICE-KEY"]
|
||||
uaa_username = data.azurerm_key_vault_secret.cf_secrets["HSDP-CF-DEPLOY-USER"].value
|
||||
uaa_password = data.azurerm_key_vault_secret.cf_secrets["HSDP-CF-DEPLOY-PASSWORD"].value
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
data "azurerm_resource_group" "foundation_cicd" {
|
||||
name = var.foundation_cicd_resource_group_name
|
||||
}
|
||||
|
||||
data "azurerm_key_vault" "secrets" {
|
||||
name = var.foundation_cicd_vault_name
|
||||
resource_group_name = data.azurerm_resource_group.foundation_cicd.name
|
||||
}
|
||||
data "azurerm_key_vault_secret" "cf_secrets" {
|
||||
for_each = toset([
|
||||
"HSDP-CF-API-URL",
|
||||
"HSDP-CF-DEPLOY-USER",
|
||||
"HSDP-CF-DEPLOY-PASSWORD"
|
||||
])
|
||||
|
||||
name = upper("${var.region}-${each.key}")
|
||||
key_vault_id = data.azurerm_key_vault.secrets.id
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
variable "edisp_azure_vault_name" {
|
||||
type = string
|
||||
default = "The name of the vault created by the EDI Platform"
|
||||
}
|
||||
|
||||
variable "edisp_azure_automation_account_name" {
|
||||
type = string
|
||||
default = "The name of the vault created by the EDI Platform"
|
||||
}
|
||||
|
||||
variable "edisp_resource_group_name" {
|
||||
type = string
|
||||
description = "The name of the resoruce group in Azure that holds the resources for EDI Platform"
|
||||
default = "edi-platform"
|
||||
}
|
||||
|
||||
variable "foundation_cicd_resource_group_name" {
|
||||
type = string
|
||||
description = "The name of the resoruce group in Azure that holds the resources for EDI Platform foundation CICD"
|
||||
default = "edi-platform-foundation-cicd"
|
||||
}
|
||||
|
||||
variable "foundation_cicd_vault_name" {
|
||||
type = string
|
||||
description = "The name of the resoruce group in Azure that holds the resources for EDI Platform foundation CICD"
|
||||
default = "foundationcicd"
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
type = string
|
||||
description = "HSDP region that this will be deployed to"
|
||||
}
|
||||
|
||||
variable "environment" {
|
||||
type = string
|
||||
description = "HSDP environment that this will be deployed to (one of client-test or prod)"
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = ">= 2.67.0"
|
||||
}
|
||||
hsdp = {
|
||||
source = "philips-software/hsdp"
|
||||
version = ">= 0.19.5"
|
||||
}
|
||||
}
|
||||
required_version = ">= 1.0"
|
||||
}
|
||||
Loading…
Reference in New Issue