-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c7f886
commit 6a949ea
Showing
6 changed files
with
154 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
frontend/src/__tests__/cypress/cypress/utils/oc_commands/baseCommands.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Applies the given YAML content using the `oc apply` command. | ||
* | ||
* @param yamlContent YAML content to be applied | ||
* @returns Cypress Chainable | ||
*/ | ||
export const applyOpenShiftYaml = (yamlContent: string) => { | ||
const ocCommand = `oc apply -f - <<EOF\n${yamlContent}EOF`; | ||
return cy.exec(ocCommand, { failOnNonZeroExit: false }).then((result) => { | ||
if (result.code !== 0) { | ||
// If there is an error, log the error and fail the test | ||
cy.log(`ERROR applying YAML content | ||
stdout: ${result.stdout} | ||
stderr: ${result.stderr}`); | ||
throw new Error(`Command failed with code ${result.code}`); | ||
} | ||
return result; | ||
}); | ||
}; | ||
28 changes: 28 additions & 0 deletions
28
frontend/src/__tests__/cypress/cypress/utils/oc_commands/dataConnection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { replacePlaceholdersInYaml } from "../yaml_files"; | ||
Check warning on line 1 in frontend/src/__tests__/cypress/cypress/utils/oc_commands/dataConnection.ts GitHub Actions / Tests (18.x)
|
||
import { applyOpenShiftYaml } from "./baseCommands"; | ||
|
||
/** | ||
* Try to create a data connection based on the dataConnectionReplacements config | ||
* @param dataConnectionReplacements Dictionary with the config values | ||
* Dict Structure: | ||
* dataConnectionReplacements = { | ||
* NAMESPACE: <PROJECT NAME>, | ||
* AWS_ACCESS_KEY_ID: <AWS ACCESS KEY ID>, | ||
* AWS_DEFAULT_REGION: <AWS REGION>, | ||
* AWS_S3_BUCKET: <AWS BUCKET NAME>, | ||
* AWS_S3_ENDPOINT: <AWS ENDPOINT>, | ||
* AWS_SECRET_ACCESS_KEY: <AWS SECRET>, | ||
* } | ||
* @param yamlFilePath | ||
*/ | ||
export const createDataConnection = ( | ||
dataConnectionReplacements: { [key: string]: string }, | ||
yamlFilePath: string = 'resources/yaml/data_connection.yml' | ||
) => { | ||
cy.fixture(yamlFilePath).then((yamlContent) => { | ||
const modifiedYamlContent = replacePlaceholdersInYaml(yamlContent, dataConnectionReplacements); | ||
applyOpenShiftYaml(modifiedYamlContent).then((result) => { | ||
return result; | ||
}); | ||
}); | ||
}; |
49 changes: 49 additions & 0 deletions
49
frontend/src/__tests__/cypress/cypress/utils/oc_commands/dspa.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { replacePlaceholdersInYaml } from "../yaml_files"; | ||
import { applyOpenShiftYaml } from "./baseCommands"; | ||
|
||
/** | ||
* Try to create a DSPA Secret based on the dspaSecretReplacements config | ||
* @param dspaSecretReplacements Dictionary with the config values | ||
* Dict Structure: | ||
* dspaSecretReplacements = { | ||
* DSPA_SECRET_NAME: <DSPA SECRET NAME>, | ||
* NAMESPACE: <PROJECT NAME>, | ||
* AWS_ACCESS_KEY_ID: <AWS ACCESS KEY ID>, | ||
* AWS_SECRET_ACCESS_KEY: <AWS SECRET>, | ||
* } | ||
* @param yamlFilePath | ||
*/ | ||
export const createDSPASecret = ( | ||
dspaSecretReplacements: { [key: string]: string }, | ||
yamlFilePath: string = 'resources/yaml/dspa_secret.yml' | ||
) => { | ||
cy.fixture(yamlFilePath).then((yamlContent) => { | ||
const modifiedYamlContent = replacePlaceholdersInYaml(yamlContent, dspaSecretReplacements); | ||
applyOpenShiftYaml(modifiedYamlContent).then((result) => { | ||
return result; | ||
}); | ||
}); | ||
}; | ||
|
||
/** | ||
* Try to create a DSPA based on the dspaReplacements config | ||
* @param dspaReplacements Dictionary with the config values | ||
* Dict Structure: | ||
* dspaSecretReplacements = { | ||
* DSPA_SECRET_NAME: <DSPA SECRET NAME>, | ||
* NAMESPACE: <PROJECT NAME>, | ||
* AWS_S3_BUCKET: <AWS BUCKET NAME> | ||
* } | ||
* @param yamlFilePath | ||
*/ | ||
export const createDSPA = ( | ||
dspaReplacements: { [key: string]: string }, | ||
yamlFilePath: string = 'resources/yaml/dspa.yml' | ||
) => { | ||
cy.fixture(yamlFilePath).then((yamlContent) => { | ||
const modifiedYamlContent = replacePlaceholdersInYaml(yamlContent, dspaReplacements); | ||
applyOpenShiftYaml(modifiedYamlContent).then((result) => { | ||
return result; | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters