diff --git a/.github/workflows/BETA-xray-cucumber-integration.yaml b/.github/workflows/BETA-xray-cucumber-integration.yaml index c3fdf388cd..0899d5abb5 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 88e24ed856..747691a14b 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 a48ee04fa7..fa8f519ba4 100644 --- a/.github/workflows/tavern.yml +++ b/.github/workflows/tavern.yml @@ -63,9 +63,10 @@ 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 }} + REGULAR_USER_API_KEY_ESS: ${{ secrets.INT_REGULAR_USER_API_KEY }} + ADMIN_USER_API_KEY_ESS: ${{ 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:6d505432-8b31-4966-9514-4b753372683f' }} diff --git a/.github/workflows/xray-cucumber-integration.yaml b/.github/workflows/xray-cucumber-integration.yaml index 970c596e54..9688fc25fd 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}") diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyCheckerService.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyCheckerService.java index 40caa45900..5f5e67fb68 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyCheckerService.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyCheckerService.java @@ -23,17 +23,14 @@ ********************************************************************************/ package org.eclipse.tractusx.irs.edc.client.policy; -import java.nio.charset.StandardCharsets; import java.time.OffsetDateTime; import java.util.List; -import java.util.stream.Stream; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.eclipse.edc.policy.model.Permission; import org.eclipse.edc.policy.model.Policy; import org.springframework.stereotype.Service; -import org.springframework.web.util.UriUtils; /** * Check and validate Policy in Catalog fetch from EDC providers. @@ -47,25 +44,13 @@ public class PolicyCheckerService { private final ConstraintCheckerService constraintCheckerService; public boolean isValid(final Policy policy) { - if (getValidStoredPolicyIds().contains("*")) { - return true; - } - return policy.getPermissions().stream().allMatch(permission -> isValid(permission, getValidStoredPolicies())); } private boolean isValid(final Permission permission, final List validStoredPolicies) { - return validStoredPolicies.stream().anyMatch(acceptedPolicy -> - constraintCheckerService.hasAllConstraint(acceptedPolicy.policy(), permission.getConstraints())); - } - - private List getValidStoredPolicyIds() { - return policyStore.getAcceptedPolicies() - .stream() - .filter(p -> p.validUntil().isAfter(OffsetDateTime.now())) - .map(acceptedPolicy -> acceptedPolicy.policy().getPolicyId()) - .flatMap(this::addEncodedVersion) - .toList(); + return validStoredPolicies.stream() + .anyMatch(acceptedPolicy -> constraintCheckerService.hasAllConstraint( + acceptedPolicy.policy(), permission.getConstraints())); } private List getValidStoredPolicies() { @@ -75,8 +60,4 @@ private List getValidStoredPolicies() { .toList(); } - private Stream addEncodedVersion(final String original) { - return Stream.of(original, UriUtils.encode(original, StandardCharsets.UTF_8)); - } - } diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyCheckerServiceTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyCheckerServiceTest.java index a06bc9fd43..cd39c4e503 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyCheckerServiceTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/PolicyCheckerServiceTest.java @@ -84,39 +84,6 @@ void shouldRejectWhenPolicyStoreIsEmpty() { assertThat(result).isFalse(); } - @Test - void shouldConfirmValidPolicyWhenWildcardIsSet() { - // given - final String wildcardPolicyId = "*"; - final var policyList = List.of( - new AcceptedPolicy(policy(TestConstants.ID_3_0_TRACE), OffsetDateTime.now().plusYears(1)), - new AcceptedPolicy(policy(wildcardPolicyId), OffsetDateTime.now().plusYears(1))); - when(policyStore.getAcceptedPolicies()).thenReturn(policyList); - Policy policy = createAtomicConstraintPolicy(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY, - TestConstants.STATUS_ACTIVE); - // when - boolean result = policyCheckerService.isValid(policy); - - // then - assertThat(result).isTrue(); - } - - @Test - void shouldRejectWhenWildcardIsPartOfPolicy() { - // given - final String invalidWildcardPolicy = "Policy*"; - final var policyList = List.of( - new AcceptedPolicy(policy(invalidWildcardPolicy), OffsetDateTime.now().plusYears(1))); - when(policyStore.getAcceptedPolicies()).thenReturn(policyList); - Policy policy = createAtomicConstraintPolicy(TestConstants.FRAMEWORK_AGREEMENT_TRACEABILITY, - TestConstants.STATUS_ACTIVE); - // when - boolean result = policyCheckerService.isValid(policy); - - // then - assertThat(result).isFalse(); - } - @Test void shouldRejectAndConstraintsWhenOnlyOneMatch() { // given diff --git a/local/testing/api-tests/irs-api-tests.tavern.yaml b/local/testing/api-tests/irs-api-tests.tavern.yaml index 02f896e5fa..c9de2ed681 100644 --- a/local/testing/api-tests/irs-api-tests.tavern.yaml +++ b/local/testing/api-tests/irs-api-tests.tavern.yaml @@ -18,7 +18,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 400 verify_response_with: @@ -56,7 +56,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -76,7 +76,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 json: @@ -93,7 +93,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -131,7 +131,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -151,7 +151,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -186,7 +186,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -206,7 +206,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -244,7 +244,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -264,7 +264,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -303,7 +303,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -323,7 +323,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -359,7 +359,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -379,7 +379,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -421,7 +421,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -441,7 +441,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -480,7 +480,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -500,7 +500,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -540,7 +540,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -560,7 +560,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -601,7 +601,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -621,7 +621,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -660,7 +660,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -680,7 +680,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -719,7 +719,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -739,7 +739,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -780,7 +780,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -800,7 +800,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -839,7 +839,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -859,7 +859,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -898,7 +898,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 201 headers: @@ -918,7 +918,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key_ess response: status_code: 200 verify_response_with: @@ -959,7 +959,7 @@ stages: # headers: # content-type: application/json # $ext: -# function: local.testing.api-tests.tavern_helpers:create_bearer_token +# function: local.testing.api-tests.tavern_helpers:create_api_key_ess # response: # status_code: 201 # headers: @@ -979,7 +979,7 @@ stages: # headers: # content-type: application/json # $ext: -# function: local.testing.api-tests.tavern_helpers:create_bearer_token +# function: local.testing.api-tests.tavern_helpers:create_api_key_ess # response: # status_code: 200 # verify_response_with: @@ -1014,7 +1014,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -1033,7 +1033,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 206 headers: @@ -1066,7 +1066,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -1084,7 +1084,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 206 json: @@ -1119,7 +1119,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -1139,7 +1139,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 json: @@ -1156,7 +1156,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -1195,7 +1195,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -1215,7 +1215,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -1249,7 +1249,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -1269,7 +1269,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -1306,7 +1306,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 400 verify_response_with: @@ -1342,7 +1342,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 json: @@ -1364,7 +1364,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -1401,7 +1401,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 json: @@ -1423,7 +1423,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -1461,7 +1461,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 json: @@ -1483,7 +1483,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -1520,7 +1520,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 json: @@ -1542,7 +1542,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -1580,7 +1580,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 json: @@ -1602,7 +1602,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -1640,7 +1640,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 json: @@ -1662,7 +1662,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -1698,7 +1698,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 400 json: @@ -1743,7 +1743,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 json: @@ -1764,7 +1764,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 206 json: @@ -1801,7 +1801,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 400 verify_response_with: @@ -1856,7 +1856,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 json: @@ -1879,7 +1879,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -1926,7 +1926,7 @@ stages: # headers: # content-type: application/json # $ext: - # function: local.testing.api-tests.tavern_helpers:create_bearer_token + # function: local.testing.api-tests.tavern_helpers:create_api_key # response: # status_code: 400 # json: @@ -1954,7 +1954,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -1982,7 +1982,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2010,7 +2010,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2045,7 +2045,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -2058,7 +2058,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2086,7 +2086,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2112,7 +2112,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 400 json: @@ -2139,7 +2139,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 404 json: @@ -2168,7 +2168,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2198,7 +2198,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -2214,7 +2214,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 headers: @@ -2229,7 +2229,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 json: @@ -2256,7 +2256,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2283,7 +2283,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2310,7 +2310,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2346,7 +2346,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 400 json: @@ -2381,7 +2381,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -2401,7 +2401,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2430,7 +2430,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2456,7 +2456,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2495,7 +2495,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -2514,7 +2514,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 206 verify_response_with: @@ -2547,7 +2547,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -2567,7 +2567,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2601,7 +2601,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -2621,7 +2621,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2655,7 +2655,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -2675,7 +2675,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2758,7 +2758,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -2776,7 +2776,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2818,7 +2818,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 400 verify_response_with: @@ -2870,7 +2870,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -2888,7 +2888,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -2910,7 +2910,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 headers: @@ -2925,7 +2925,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -3001,7 +3001,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -3019,7 +3019,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -3061,7 +3061,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 400 verify_response_with: @@ -3140,7 +3140,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 201 headers: @@ -3158,7 +3158,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: @@ -3180,7 +3180,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 headers: @@ -3195,7 +3195,7 @@ stages: headers: content-type: application/json $ext: - function: local.testing.api-tests.tavern_helpers:create_bearer_token + function: local.testing.api-tests.tavern_helpers:create_api_key response: status_code: 200 verify_response_with: diff --git a/local/testing/api-tests/tavern_helpers.py b/local/testing/api-tests/tavern_helpers.py index 1500d4d59e..22f7c934d2 100644 --- a/local/testing/api-tests/tavern_helpers.py +++ b/local/testing/api-tests/tavern_helpers.py @@ -1,7 +1,6 @@ # testing_utils.py from datetime import datetime -import requests import os from box import Box @@ -346,11 +345,13 @@ def job_parameter_are_as_requested(response): assert 'PartAsPlanned' in aspects_list -def create_bearer_token(): - url = os.getenv('OAUTH2_HOST') - client_id = os.getenv('OAUTH2_CLIENT_ID') - client_secret = os.getenv('OAUTH2_CLIENT_SECRET') +def create_api_key(): + api_key = os.getenv('ADMIN_USER_API_KEY') - data = {"grant_type": "client_credentials", "client_id": client_id, "client_secret": client_secret} - token = requests.post(url, data).json().get('access_token') - return {"Authorization": f"Bearer {token}"} \ No newline at end of file + return {"X-API-KEY": api_key} + + +def create_api_key_ess(): + api_key = os.getenv('ADMIN_USER_API_KEY_ESS') + + return {"X-API-KEY": api_key} \ No newline at end of file