Skip to content

Commit

Permalink
clean up acceptance tests for configurable engines
Browse files Browse the repository at this point in the history
  • Loading branch information
Monkeychip committed Jan 9, 2025
1 parent 5f054bf commit 2a454cd
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 19 deletions.
1 change: 0 additions & 1 deletion ui/app/models/aws/root-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export default class AwsRootConfig extends Model {
iamEndpoint;
@attr('string', { label: 'STS endpoint' }) stsEndpoint;
@attr('number', {
label: 'Maximum retries',
subText: 'Number of max retries the client should use for recoverable errors. Default is -1.',
})
maxRetries;
Expand Down
1 change: 1 addition & 0 deletions ui/app/models/gcp/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default class GcpConfig extends Model {
})
maxTtl;

/* GCP credential config field */
@attr('string', {
label: 'JSON credentials',
subText:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ module('Acceptance | aws | configuration', function (hooks) {
assert
.dom(GENERAL.infoRowValue('Identity token TTL'))
.doesNotExist('Identity token TTL does not show.');
assert.dom(GENERAL.infoRowValue('Maximum retries')).doesNotExist('Maximum retries does not show.');
assert.dom(GENERAL.infoRowValue('Max retries')).doesNotExist('Max retries does not show.');
// cleanup
await runCmd(`delete sys/mounts/${path}`);
});
Expand Down Expand Up @@ -233,7 +233,7 @@ module('Acceptance | aws | configuration', function (hooks) {
createConfig(this.store, path, type); // create the aws root config in the store
await click(SES.configTab);
for (const key of expectedConfigKeys(type)) {
if (key === 'Secret Key' || key === 'Client Secret') return; // these keys are not returned by the API so they will not show up on the details page
if (key === 'Secret key') return; // secret-key is not returned by the API
assert.dom(GENERAL.infoRowLabel(key)).exists(`${key} on the ${type} config details exists.`);
const responseKeyAndValue = expectedValueOfConfigKeys(type, key);
assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ module('Acceptance | Azure | configuration', function (hooks) {
return { data: { id: path, type: this.type, ...azureAccountAttrs } };
});
await enablePage.enable(this.type, path);
for (const key of expectedConfigKeys('azure-details')) {

for (const key of expectedConfigKeys('azure')) {
if (key === 'Client secret') return; // client-secret is not returned by the API
assert.dom(GENERAL.infoRowLabel(key)).exists(`${key} on the ${this.type} config details exists.`);
const responseKeyAndValue = expectedValueOfConfigKeys(this.type, key);
assert
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ module('Acceptance | GCP | configuration', function (hooks) {
service_account_email: 'service-email',
identity_token_audience: 'audience',
identity_token_ttl: 720000,
max_ttl: 14400,
ttl: 3600,
};
this.server.get(`${path}/config`, () => {
assert.ok(true, 'request made to config when navigating to the configuration page.');
Expand Down Expand Up @@ -102,6 +104,7 @@ module('Acceptance | GCP | configuration', function (hooks) {
});
await enablePage.enable(this.type, path);
for (const key of expectedConfigKeys(this.type)) {
if (key === 'Credentials') return; // not returned by the API
const responseKeyAndValue = expectedValueOfConfigKeys(this.type, key);
assert
.dom(GENERAL.infoRowValue(key))
Expand Down
16 changes: 12 additions & 4 deletions ui/tests/helpers/secret-engine/secret-engine-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,18 @@ export const fillInAzureConfig = async (situation = 'azure') => {
const genericWifKeys = ['Identity token audience', 'Identity token TTL'];
// AWS specific keys
const awsLeaseKeys = ['Default Lease TTL', 'Max Lease TTL'];
const awsKeys = ['Access key', 'Secret Key', 'Region', 'IAM Endpoint', 'STS Endpoint', 'Max Retries'];
const awsKeys = ['Access key', 'Secret key', 'Region', 'IAM endpoint', 'STS endpoint', 'Max retries'];
const awsWifKeys = ['Issuer', 'Role ARN', ...genericWifKeys];
// Azure specific keys
const genericAzureKeys = ['Subscription ID', 'Tenant ID', 'Client ID', 'Environment'];
const azureKeys = [...genericAzureKeys, 'Client Secret', 'Root password TTL'];
const azureKeys = [...genericAzureKeys, 'Client secret', 'Root password TTL'];
const azureWifKeys = [...genericAzureKeys, ...genericWifKeys];
// GCP specific keys
const genericGcpKeys = ['Config TTL', 'Max TTL'];
const gcpKeys = [...genericGcpKeys, 'Credentials'];
const gcpWifKeys = [...genericGcpKeys, ...genericWifKeys, 'Service account email'];
// SSH specific keys
const sshKeys = ['Private Key', 'Public Key', 'Generate Signing Key'];
const sshKeys = ['Private key', 'Public key', 'Generate signing key'];

export const expectedConfigKeys = (type, camelCase = false) => {
switch (type) {
Expand All @@ -295,6 +299,10 @@ export const expectedConfigKeys = (type, camelCase = false) => {
return camelCase ? stringToCamelCase(azureKeys) : azureKeys;
case 'azure-wif':
return camelCase ? stringToCamelCase(azureWifKeys) : azureWifKeys;
case 'gcp':
return camelCase ? stringToCamelCase(gcpKeys) : gcpKeys;
case 'gcp-wif':
return camelCase ? stringToCamelCase(gcpWifKeys) : gcpWifKeys;
case 'ssh':
return camelCase ? stringToCamelCase(sshKeys) : sshKeys;
}
Expand All @@ -310,7 +318,7 @@ const valueOfAwsKeys = (string) => {
return 'iam-endpoint';
case 'STS endpoint':
return 'sts-endpoint';
case 'Maximum retries':
case 'Max retries':
return '1';
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module('Integration | Component | SecretEngine/ConfigurationDetails', function (
});

for (const type of CONFIGURABLE_SECRET_ENGINES) {
test(`it shows config details if configModel(s) are passed in for type: ${type}`, async function (assert) {
test(`${type}: it shows config details if configModel(s) are passed in`, async function (assert) {
const backend = `test-${type}`;
this.configModels = createConfig(this.store, backend, type);
this.typeDisplay = allEnginesArray.find((engine) => engine.type === type).displayName;
Expand All @@ -48,16 +48,29 @@ module('Integration | Component | SecretEngine/ConfigurationDetails', function (
);

for (const key of expectedConfigKeys(type)) {
assert.dom(GENERAL.infoRowLabel(key)).exists(`${key} on the ${type} config details exists.`);
const responseKeyAndValue = expectedValueOfConfigKeys(type, key);
assert
.dom(GENERAL.infoRowValue(key))
.hasText(responseKeyAndValue, `${key} value for the ${type} config details exists.`);
// make sure the ones that should be masked are masked, and others are not.
if (key === 'private_key' || key === 'public_key') {
assert.dom(GENERAL.infoRowValue(key)).hasClass('masked-input', `${key} is masked`);
if (
key === 'Secret key' ||
key === 'Client secret' ||
key === 'Private key' ||
key === 'Credentials'
) {
// these keys are not returned by the API and should not show on the details page
assert
.dom(GENERAL.infoRowLabel(key))
.doesNotExist(`${key} on the ${type} config details does NOT exists.`);
} else {
assert.dom(GENERAL.infoRowValue(key)).doesNotHaveClass('masked-input', `${key} is not masked`);
assert.dom(GENERAL.infoRowLabel(key)).exists(`${key} on the ${type} config details exists.`);
const responseKeyAndValue = expectedValueOfConfigKeys(type, key);
assert
.dom(GENERAL.infoRowValue(key))
.hasText(responseKeyAndValue, `${key} value for the ${type} config details exists.`);
// make sure the ones that should be masked are masked, and others are not.

if (key === 'Public Key') {
assert.dom(GENERAL.infoRowValue(key)).hasClass('masked-input', `${key} is masked`);
} else {
assert.dom(GENERAL.infoRowValue(key)).doesNotHaveClass('masked-input', `${key} is not masked`);
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ module('Integration | Component | SecretEngine/ConfigureCreateEdit', function (h
.hasValue('**********', 'clientSecret is masked on edit the value');
});

test('it requires a double click to change the client secret meep', async function (assert) {
test('it requires a double click to change the client secret', async function (assert) {
this.id = `azure-${this.uid}`;
this.config = createConfig(this.store, this.id, 'azure');
await render(hbs`
Expand Down

0 comments on commit 2a454cd

Please sign in to comment.