Skip to content

Commit

Permalink
feat(impl):[#259] update tavern and cucumber workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-ext-kmassalski committed Jan 2, 2024
1 parent 03c8623 commit 968e925
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 66 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/BETA-xray-cucumber-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/integration-test-DEV.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/integration-test-DIL.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/integration-test-INT.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/tavern-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/tavern.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/xray-cucumber-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/xray-cucumber.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,23 @@
********************************************************************************/
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;

@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<String, String> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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}")
Expand Down

0 comments on commit 968e925

Please sign in to comment.