diff --git a/.github/workflows/BETA-xray-cucumber-integration.yaml b/.github/workflows/BETA-xray-cucumber-integration.yaml index c1ebea938e..5aa56f110f 100644 --- a/.github/workflows/BETA-xray-cucumber-integration.yaml +++ b/.github/workflows/BETA-xray-cucumber-integration.yaml @@ -38,7 +38,8 @@ jobs: - name: Build with Maven if: ${{ steps.download.outputs.http_response == '200' }} env: - OAUTH2_CLIENT_SECRET: ${{ secrets.OAUTH2_CLIENT_SECRET_BETA }} + REGULAR_USER_API_KEY: ${{ secrets.BETA_REGULAR_USER_API_KEY }} + ADMIN_USER_API_KEY: ${{ secrets.BETA_ADMIN_USER_API_KEY }} run: | unzip -o features.zip -d irs-cucumber-tests/src/test/resources/features mvn --batch-mode clean install -pl irs-cucumber-tests,irs-models -D"cucumber.filter.tags"="not @Ignore and @INTEGRATION_TEST" diff --git a/.github/workflows/integration-test-DEV.yaml b/.github/workflows/integration-test-DEV.yaml index 8fb3a551c2..11d76e3b5b 100644 --- a/.github/workflows/integration-test-DEV.yaml +++ b/.github/workflows/integration-test-DEV.yaml @@ -23,9 +23,8 @@ jobs: trigger-integration-test: uses: ./.github/workflows/xray-cucumber-integration.yaml secrets: - oauth2TokenUrl: ${{ secrets.OAUTH2_CLIENT_TOKEN_URI }} - clientId: ${{ secrets.OAUTH2_CLIENT_ID }} - clientSecret: ${{ secrets.OAUTH2_CLIENT_SECRET }} + regularUserApiKey: ${{ secrets.DEV_REGULAR_USER_API_KEY }} + adminUserApiKey: ${{ secrets.DEV_ADMIN_USER_API_KEY }} jiraUser: ${{ secrets.ORG_IRS_JIRA_USERNAME }} jiraPassword: ${{ secrets.ORG_IRS_JIRA_PASSWORD }} with: diff --git a/.github/workflows/integration-test-DIL.yaml b/.github/workflows/integration-test-DIL.yaml index 501a816659..d0e94291a3 100644 --- a/.github/workflows/integration-test-DIL.yaml +++ b/.github/workflows/integration-test-DIL.yaml @@ -12,9 +12,8 @@ jobs: trigger-integration-test: uses: ./.github/workflows/xray-cucumber-integration.yaml secrets: - oauth2TokenUrl: ${{ secrets.OAUTH2_CLIENT_TOKEN_URI }} - clientId: ${{ secrets.IRS_OAUTH2_CLIENT_ID_DIL }} - clientSecret: ${{ secrets.IRS_OAUTH2_CLIENT_SECRET_DIL }} + regularUserApiKey: ${{ secrets.DIL_REGULAR_USER_API_KEY }} + adminUserApiKey: ${{ secrets.DIL_ADMIN_USER_API_KEY }} jiraUser: ${{ secrets.ORG_IRS_JIRA_USERNAME }} jiraPassword: ${{ secrets.ORG_IRS_JIRA_PASSWORD }} with: diff --git a/.github/workflows/integration-test-INT.yaml b/.github/workflows/integration-test-INT.yaml index bbe00c2634..1f88d76e9a 100644 --- a/.github/workflows/integration-test-INT.yaml +++ b/.github/workflows/integration-test-INT.yaml @@ -7,9 +7,8 @@ jobs: trigger-integration-test: uses: ./.github/workflows/xray-cucumber-integration.yaml secrets: - oauth2TokenUrl: ${{ secrets.OAUTH2_CLIENT_TOKEN_URI }} - clientId: ${{ secrets.ORG_IRS_OAUTH2_CLIENT_ID_INT }} - clientSecret: ${{ secrets.ORG_IRS_OAUTH2_CLIENT_SECRET_INT }} + regularUserApiKey: ${{ secrets.INT_REGULAR_USER_API_KEY }} + adminUserApiKey: ${{ secrets.INT_ADMIN_USER_API_KEY }} jiraUser: ${{ secrets.ORG_IRS_JIRA_USERNAME }} jiraPassword: ${{ secrets.ORG_IRS_JIRA_PASSWORD }} with: diff --git a/.github/workflows/tavern-integration.yml b/.github/workflows/tavern-integration.yml index 268bad26f4..41b2be192a 100644 --- a/.github/workflows/tavern-integration.yml +++ b/.github/workflows/tavern-integration.yml @@ -61,9 +61,8 @@ jobs: env: IRS_HOST: ${{ 'https://irs.int.demo.catena-x.net' }} IRS_ESS_HOST: ${{ github.event.inputs.irs-ess-host || 'https://irs-ess.int.demo.catena-x.net' }} - OAUTH2_HOST: ${{ secrets.OAUTH2_CLIENT_TOKEN_URI }} - OAUTH2_CLIENT_ID: ${{ secrets.ORG_IRS_OAUTH2_CLIENT_ID_INT }} - OAUTH2_CLIENT_SECRET: ${{ secrets.ORG_IRS_OAUTH2_CLIENT_SECRET_INT }} + REGULAR_USER_API_KEY: ${{ secrets.INT_REGULAR_USER_API_KEY }} + ADMIN_USER_API_KEY: ${{ secrets.INT_ADMIN_USER_API_KEY }} GLOBAL_ASSET_ID_AS_PLANNED: ${{ github.event.inputs.global-asset-id-asPlanned || 'urn:uuid:0733946c-59c6-41ae-9570-cb43a6e4c79e' }} BPN_AS_PLANNED: ${{ github.event.inputs.bpn-asPlanned || 'BPNL00000003AYRE' }} GLOBAL_ASSET_ID_AS_BUILT: ${{ github.event.inputs.global-asset-id-asBuilt || 'urn:uuid:1b17682e-5e2a-4913-aa1b-7d59a072a3cb' }} diff --git a/.github/workflows/tavern.yml b/.github/workflows/tavern.yml index bd21b36033..7f165f966e 100644 --- a/.github/workflows/tavern.yml +++ b/.github/workflows/tavern.yml @@ -63,9 +63,8 @@ jobs: env: IRS_HOST: ${{ 'https://irs.dev.demo.catena-x.net' }} IRS_ESS_HOST: ${{ github.event.inputs.irs-ess-host || 'https://irs-ess.int.demo.catena-x.net' }} - OAUTH2_HOST: ${{ secrets.OAUTH2_CLIENT_TOKEN_URI }} - OAUTH2_CLIENT_ID: ${{ secrets.OAUTH2_CLIENT_ID }} - OAUTH2_CLIENT_SECRET: ${{ secrets.OAUTH2_CLIENT_SECRET }} + REGULAR_USER_API_KEY: ${{ secrets.DEV_REGULAR_USER_API_KEY }} + ADMIN_USER_API_KEY: ${{ secrets.DEV_ADMIN_USER_API_KEY }} GLOBAL_ASSET_ID_AS_PLANNED: ${{ github.event.inputs.global-asset-id-asPlanned || 'urn:uuid:0733946c-59c6-41ae-9570-cb43a6e4c79e' }} BPN_AS_PLANNED: ${{ github.event.inputs.bpn-asPlanned || 'BPNL00000003AYRE' }} GLOBAL_ASSET_ID_AS_BUILT: ${{ github.event.inputs.global-asset-id-asBuilt || 'urn:uuid:6d505432-8b31-4966-9514-4b753372683f' }} diff --git a/.github/workflows/xray-cucumber-integration.yaml b/.github/workflows/xray-cucumber-integration.yaml index b7700a1caf..70fee9367b 100644 --- a/.github/workflows/xray-cucumber-integration.yaml +++ b/.github/workflows/xray-cucumber-integration.yaml @@ -3,11 +3,9 @@ name: IRS Cucumber Integration test Xray execution on: workflow_call: # Trigger by another workflow secrets: - oauth2TokenUrl: + regularUserApiKey: required: true - clientId: - required: true - clientSecret: + adminUserApiKey: required: true jiraUser: required: true @@ -57,9 +55,8 @@ jobs: - name: Build with Maven if: ${{ steps.download.outputs.http_response == '200' }} env: - OAUTH2_HOST: ${{ secrets.oauth2TokenUrl }} - OAUTH2_CLIENT_ID: ${{ secrets.clientId }} - OAUTH2_CLIENT_SECRET: ${{ secrets.clientSecret }} + REGULAR_USER_API_KEY: ${{ secrets.regularUserApiKey }} + ADMIN_USER_API_KEY: ${{ secrets.adminUserApiKey }} ISSUE_FILTER: ${{ inputs.executionFilter }} run: | unzip -o features.zip -d irs-cucumber-tests/src/test/resources/features diff --git a/.github/workflows/xray-cucumber.yaml b/.github/workflows/xray-cucumber.yaml index 3b73158595..ce8a05cc5f 100644 --- a/.github/workflows/xray-cucumber.yaml +++ b/.github/workflows/xray-cucumber.yaml @@ -31,9 +31,8 @@ jobs: trigger-integration-test: uses: ./.github/workflows/xray-cucumber-integration.yaml secrets: - oauth2TokenUrl: ${{ secrets.OAUTH2_CLIENT_TOKEN_URI }} - clientId: ${{ secrets.OAUTH2_CLIENT_ID }} - clientSecret: ${{ secrets.OAUTH2_CLIENT_SECRET }} + regularUserApiKey: ${{ secrets.DEV_REGULAR_USER_API_KEY }} + adminUserApiKey: ${{ secrets.DEV_ADMIN_USER_API_KEY }} jiraUser: ${{ secrets.ORG_IRS_JIRA_USERNAME }} jiraPassword: ${{ secrets.ORG_IRS_JIRA_PASSWORD }} with: diff --git a/irs-cucumber-tests/src/test/java/org/eclipse/tractusx/irs/cucumber/AuthenticationProperties.java b/irs-cucumber-tests/src/test/java/org/eclipse/tractusx/irs/cucumber/AuthenticationProperties.java index 585a058012..b399155629 100644 --- a/irs-cucumber-tests/src/test/java/org/eclipse/tractusx/irs/cucumber/AuthenticationProperties.java +++ b/irs-cucumber-tests/src/test/java/org/eclipse/tractusx/irs/cucumber/AuthenticationProperties.java @@ -23,11 +23,6 @@ ********************************************************************************/ package org.eclipse.tractusx.irs.cucumber; -import static io.restassured.RestAssured.given; - -import java.util.HashMap; -import java.util.Map; - import io.restassured.builder.RequestSpecBuilder; import io.restassured.specification.RequestSpecification; import lombok.Builder; @@ -35,35 +30,16 @@ @Builder /* package */ class AuthenticationProperties { private final String uri; - private final String clientId; - private final String clientSecret; - private final String oauth2Url; - private final String grantType; - private final String tokenPath; + private final String apiKey; - /* package */ AuthenticationProperties(final String uri, final String clientId, final String clientSecret, - final String oauth2Url, final String grantType, final String tokenPath) { + /* package */ AuthenticationProperties(final String uri, final String apiKey) { this.uri = uri; - this.clientId = clientId; - this.clientSecret = clientSecret; - this.oauth2Url = oauth2Url; - this.grantType = grantType; - this.tokenPath = tokenPath; - } - - private String obtainAccessToken() { - final Map oauth2Payload = new HashMap<>(); - oauth2Payload.put("grant_type", grantType); - oauth2Payload.put("client_id", clientId); - oauth2Payload.put("client_secret", clientSecret); - - return given().params(oauth2Payload).post(oauth2Url).then().extract().jsonPath().getString(tokenPath); + this.apiKey = apiKey; } /* package */ RequestSpecification getNewAuthenticationRequestSpecification() { - final String accessToken = obtainAccessToken(); final RequestSpecBuilder builder = new RequestSpecBuilder(); - builder.addHeader("Authorization", "Bearer " + accessToken); + builder.addHeader("X-API-KEY", apiKey); builder.setBaseUri(uri); return builder.build(); diff --git a/irs-cucumber-tests/src/test/java/org/eclipse/tractusx/irs/cucumber/E2ETestStepDefinitions.java b/irs-cucumber-tests/src/test/java/org/eclipse/tractusx/irs/cucumber/E2ETestStepDefinitions.java index 9bb8adf948..99db6f13f7 100644 --- a/irs-cucumber-tests/src/test/java/org/eclipse/tractusx/irs/cucumber/E2ETestStepDefinitions.java +++ b/irs-cucumber-tests/src/test/java/org/eclipse/tractusx/irs/cucumber/E2ETestStepDefinitions.java @@ -88,7 +88,6 @@ public void setup() { registerJobBuilder = RegisterJob.builder(); registerBatchOrderBuilder = RegisterBatchOrder.builder(); authenticationPropertiesBuilder = AuthenticationProperties.builder(); - authenticationPropertiesBuilder.grantType("client_credentials").tokenPath("access_token"); objectMapper = new ObjectMapper(); objectMapper.registerModule(new JavaTimeModule()); @@ -105,21 +104,26 @@ public void theIRSURL(String irsUrl) { authenticationPropertiesBuilder.uri(irsUrl); } - @And("the user {string} with authentication") - public void theUser(String clientId) throws PropertyNotFoundException { - authenticationPropertiesBuilder.clientId(clientId); - final String oauth2UrlClientSecretKey = "OAUTH2_CLIENT_SECRET"; - String clientSecret = System.getenv(oauth2UrlClientSecretKey); - if (clientSecret != null) { - authenticationPropertiesBuilder.clientSecret(clientSecret); + @And("the regular user api key") + public void theRegularUser() throws PropertyNotFoundException { + final String regularUserApiKey = "REGULAR_USER_API_KEY"; + String apiKey = System.getenv(regularUserApiKey); + if (apiKey != null) { + authenticationPropertiesBuilder.apiKey(apiKey); } else { - throw new PropertyNotFoundException("Environment Variable missing: " + oauth2UrlClientSecretKey); + throw new PropertyNotFoundException("Environment Variable missing: " + regularUserApiKey); } } - @And("the OAuth2 token url {string}") - public void theOAuth2TokenUrl(String tokenUrl) { - authenticationPropertiesBuilder.oauth2Url(tokenUrl); + @And("the admin user api key") + public void theAdminUser() throws PropertyNotFoundException { + final String adminUserApiKey = "ADMIN_USER_API_KEY"; + String apiKey = System.getenv(adminUserApiKey); + if (apiKey != null) { + authenticationPropertiesBuilder.apiKey(apiKey); + } else { + throw new PropertyNotFoundException("Environment Variable missing: " + adminUserApiKey); + } } @Given("I register an IRS job for globalAssetId {string}")