Skip to content

Commit

Permalink
update gwa gateway commands in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rustyjux committed Jul 8, 2024
1 parent 5f54739 commit 8a77dab
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Run this command to test logging in and creating a namespace:

```
gwa login
gwa namespace create --name gw-12345
gwa gateway create --gateway-id gw-12345
```

### Keycloak configuration
Expand Down
2 changes: 1 addition & 1 deletion e2e/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ COPY e2e/*.yml /e2e
COPY e2e/entrypoint.sh /tmp
ADD e2e/cypress /e2e/cypress

RUN curl -v -L -O https://github.com/bcgov/gwa-cli/releases/download/v2.0.15/gwa_Linux_x86_64.tgz \
RUN curl -v -L -O https://github.com/bcgov/gwa-cli/releases/download/v3.0.0/gwa_Linux_x86_64.tgz \
&& tar -xzf gwa_Linux_x86_64.tgz \
&& mv gwa /usr/local/bin/.

Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/support/auth-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ Cypress.Commands.add(
() => {
cy.wait(3000)
cy.get('@accessTokenResponse').then((res: any) => {
cy.executeCliCommand('gwa config set --namespace ' + namespace).then(
cy.executeCliCommand('gwa config set --gateway ' + namespace).then(
(response) => {
cy.executeCliCommand(
'gwa config set --token ' + res.body.access_token
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ describe('Grant appropriate permissions to team members for client credential fl

it('create namespace using gwa cli command', () => {
var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, "");
cy.exec('gwa namespace create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 5000, failOnNonZeroExit: false }).then((response) => {
cy.exec('gwa gateway create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 5000, failOnNonZeroExit: false }).then((response) => {
debugger
assert.isNotNaN(response.stdout)
namespace = response.stdout
cy.replaceWordInJsonObject('ccplatform', namespace, 'cc-service-gwa.yml')
cy.updateJsonValue('common-testdata.json', 'clientCredentials.namespace', namespace)
// cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace)
cy.executeCliCommand("gwa config set --namespace " + namespace)
cy.executeCliCommand("gwa config set --gateway " + namespace)
});
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Verify Two Tiered Hidden', () => {
it('create namespace with cli', () => {
cy.get('@common-testdata').then(({ twoTieredHidden }: any) => {
cy.executeCliCommand(
'gwa namespace create --name ' +
'gwa gateway create --gateway-id ' +
twoTieredHidden.namespace +
' --description="Two Tiered Hidden"'
).then((response) => {
Expand Down
4 changes: 2 additions & 2 deletions e2e/cypress/tests/10-clear-resources/01-create-api.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ describe('Create API Spec for Delete Resources', () => {

it('create namespace using gwa cli command', () => {
var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, "");
cy.exec('gwa namespace create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
cy.exec('gwa gateway create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
assert.isNotNaN(response.stdout)
namespace = response.stdout
cy.replaceWordInJsonObject('ns.deleteplatform', 'ns.' + namespace, 'service-clear-resources-gwa.yml')
cy.updateJsonValue('common-testdata.json', 'deleteResources.namespace', namespace)
// cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace)
cy.executeCliCommand("gwa config set --namespace " + namespace)
cy.executeCliCommand("gwa config set --gateway " + namespace)
});
})

Expand Down
4 changes: 2 additions & 2 deletions e2e/cypress/tests/12-access-permission/01-create-api.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ describe('Create API Spec', () => {

it('create namespace using gwa cli command', () => {
var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, "");
cy.exec('gwa namespace create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
cy.exec('gwa gateway create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
assert.isNotNaN(response.stdout)
namespace = response.stdout
cy.replaceWordInJsonObject('ns.permission', 'ns.' + namespace, 'service-permission-gwa.yml')
cy.updateJsonValue('common-testdata.json', 'checkPermission.namespace', namespace)
// cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace)
cy.executeCliCommand("gwa config set --namespace " + namespace)
cy.executeCliCommand("gwa config set --gateway " + namespace)
});
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ describe('Create API Spec', () => {

it('create namespace using gwa cli command', () => {
var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, "");
cy.exec('gwa namespace create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
cy.exec('gwa gateway create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
assert.isNotNaN(response.stdout)
namespace = response.stdout
cy.updateJsonValue('common-testdata.json', 'namespacePreview.namespace', namespace)
// cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace)
cy.executeCliCommand("gwa config set --namespace " + namespace)
cy.executeCliCommand("gwa config set --gateway " + namespace)
});
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ describe('Add Organization to publish API', () => {

it('create namespace using gwa cli command', () => {
var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, "");
cy.exec('gwa namespace create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
cy.exec('gwa gateway create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
assert.isNotNaN(response.stdout)
namespace = response.stdout
cy.updateJsonValue('common-testdata.json', 'orgAssignment.namespace', namespace)
// cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace)
cy.executeCliCommand("gwa config set --namespace " + namespace)
cy.executeCliCommand("gwa config set --gateway " + namespace)
});
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ describe('Multiple Org Adming for the organization', () => {

it('create namespace using gwa cli command', () => {
var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, "");
cy.exec('gwa namespace create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
cy.exec('gwa gateway create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
assert.isNotNaN(response.stdout)
namespace = response.stdout
cy.updateJsonValue('common-testdata.json', 'orgAssignment.namespace', namespace)
// cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace)
cy.executeCliCommand("gwa config set --namespace " + namespace)
cy.executeCliCommand("gwa config set --gateway " + namespace)
});
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ describe('Multiple Org Admin for the organization', () => {

it('create namespace using gwa cli command', () => {
var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, "");
cy.exec('gwa namespace create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
cy.exec('gwa gateway create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
assert.isNotNaN(response.stdout)
namespace = response.stdout
cy.updateJsonValue('common-testdata.json', 'orgAssignment.namespace', namespace)
// cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace)
cy.executeCliCommand("gwa config set --namespace " + namespace)
cy.executeCliCommand("gwa config set --gateway " + namespace)
});
})

Expand Down
4 changes: 2 additions & 2 deletions e2e/cypress/tests/15-aps-api/01-create-api.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ describe('Create API Spec', () => {

it('create namespace using gwa cli command', () => {
var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, "");
cy.exec('gwa namespace create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
cy.exec('gwa gateway create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
assert.isNotNaN(response.stdout)
namespace = response.stdout
cy.updateJsonValue('common-testdata.json', 'apiTest.namespace', namespace)
cy.updateJsonValue('api.json', 'organization.expectedNamespace.name', namespace)
// cy.updateJsonValue('apiowner.json', 'clientCredentials.clientIdSecret.product.environment.name.config.serviceName', 'cc-service-for-' + namespace)
cy.executeCliCommand("gwa config set --namespace " + namespace)
cy.executeCliCommand("gwa config set --gateway " + namespace)
});
})

Expand Down
6 changes: 3 additions & 3 deletions e2e/cypress/tests/16-gwa-cli/01-cli-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ describe('Verify CLI commands', () => {
})

it('Check gwa command to create namespace', () => {
cy.executeCliCommand('gwa namespace create --generate --host ' + cleanedUrl + ' --scheme http').then((response) => {
cy.executeCliCommand('gwa gateway create --generate --host ' + cleanedUrl + ' --scheme http').then((response) => {
assert.isNotNaN(response.stdout)
namespace = response.stdout
});
})


it('Check gwa namespace list command and verify the created namespace in the list', () => {
cy.executeCliCommand('gwa namespace list --host ' + cleanedUrl + ' --scheme http').then((response) => {
it('Check gwa gateway list command and verify the created namespace in the list', () => {
cy.executeCliCommand('gwa gatway list --host ' + cleanedUrl + ' --scheme http').then((response) => {
expect(response.stdout).to.contain(namespace);
});
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,38 @@ describe('Verify namespace delete using gwa command', () => {

it('Create namespace using gwa cli command', () => {
var cleanedUrl = Cypress.env('BASE_URL').replace(/^http?:\/\//i, "");
cy.exec('gwa namespace create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
cy.exec('gwa gateway create --generate --host ' + cleanedUrl + ' --scheme http', { timeout: 3000, failOnNonZeroExit: false }).then((response) => {
assert.isNotNaN(response.stdout)
_namespace = response.stdout
});
})

it('Check gwa namespace destroy command for soft deleting namespace', () => {
cy.executeCliCommand('gwa namespace destroy ' + _namespace).then((response) => {
it('Check gwa gateway destroy command for soft deleting namespace', () => {
cy.executeCliCommand('gwa gateway destroy ' + _namespace).then((response) => {
expect(response.stdout).to.contain('Namespace destroyed: ' + _namespace);
});
})

it('Check that deleted namespace does not display in gwa namespace list command', () => {
cy.executeCliCommand('gwa namespace list').then((response) => {
it('Check that deleted namespace does not display in gwa gateway list command', () => {
cy.executeCliCommand('gwa gateway list').then((response) => {
expect(response.stdout).not.to.contain(_namespace);
});
})

it('Check gwa namespace destroy command for the namespace associated with services', () => {
it('Check gwa gateway destroy command for the namespace associated with services', () => {
cy.get('@common-testdata').then(({ namespace }: any) => {
_namespace = namespace
cy.executeCliCommand('gwa config set --namespace ' + namespace).then((response) => {
cy.executeCliCommand('gwa config set --gateway ' + namespace).then((response) => {
expect(response.stdout).to.contain("Config settings saved")
cy.executeCliCommand('gwa namespace destroy').then((response) => {
cy.executeCliCommand('gwa gateway destroy').then((response) => {
expect(response.stderr).to.contain('Error: Validation Failed');
});
})
})
})

it('Check validation if any consumer is associated with namespace for hard deleting the namespace', () => {
cy.executeCliCommand('gwa namespace destroy --force').then((response) => {
cy.executeCliCommand('gwa gateway destroy --force').then((response) => {
expect(response.stderr).to.contain('Error: Validation Failed');
});
})
Expand Down

0 comments on commit 8a77dab

Please sign in to comment.