Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prep work for creating one WIF configuration component #29345

Merged
merged 6 commits into from
Jan 10, 2025

Conversation

Monkeychip
Copy link
Contributor

@Monkeychip Monkeychip commented Jan 10, 2025

Description

Pulling out some changes from a larger PR #29323. These changes are more clean up 🧹 related and distract a little from the core changes to that pr.

Specifically:

  • Cleaned up AWS models to match the pattern of Azure and GCP. All the changes are naming changes. No functional changes.
  • Using my new helper string-array-to-camel I was able to greatly simplify the method expectedConfigKeys which I use heavily in testing WIF engines. Before, this method was handling all sorts of options ex: expectedConfigKeys("aws-root-create") or ``expectedConfigKeys("aws-root-create-wif"). To simplify this method and clarify the potential keys, I pulled all the key options out. Now each engine has three options: generic, account or wif. And these key selectors change depending on if I'm viewing details or create views, so I use my stringArrayToCamel()` helper to help here.

No user facing changes.

  • ent tests pass.

@Monkeychip Monkeychip added this to the 1.19.0-rc milestone Jan 10, 2025
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Jan 10, 2025
Copy link

github-actions bot commented Jan 10, 2025

CI Results:
All Go tests succeeded! ✅

@@ -45,23 +45,33 @@ export default class AwsRootConfig extends Model {
iamEndpoint;
@attr('string', { label: 'STS endpoint' }) stsEndpoint;
@attr('number', {
label: 'Maximum retries',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The api name for this is "Max retries". I'm going to opt out of overriding this because it makes it complicated for testing.

@@ -45,23 +45,33 @@ 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;

Copy link
Contributor Author

@Monkeychip Monkeychip Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no functional changes, just restructuring to match azure and gcp models—see here.

@@ -38,16 +38,15 @@ export default class SshCaConfig extends Model {
@attr('string') backend; // dynamic path of secret -- set on response from value passed to queryRecord
@attr('string', { sensitive: true }) privateKey; // obfuscated, never returned by API
@attr('string') publicKey;
Copy link
Contributor Author

@Monkeychip Monkeychip Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no functional changes, just restructuring to match azure and gcp models—see here.

@@ -219,7 +219,6 @@ module('Acceptance | aws | configuration', function (hooks) {
});

test('it shows AWS mount configuration details', async function (assert) {
assert.expect(12);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert.expect unnecessary because we'll get hit if one of the keys fails.

@@ -231,6 +230,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)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll see a couple of these exceptions added to these loops. This is because of a clean up work done on the secret-engine-helper.

In that helper, I changed the method expectedConfigKeys to create generic arrays of expected values. Before I had two arrays for each engine, one for details and one for create—I opted to remove the two arrays and just make one for each engine to clarify within the tests, as I do here, what key we should not see in this iteration because the value is not returned from the API.

@@ -368,7 +368,7 @@ module('Acceptance | aws | configuration', function (hooks) {
.doesNotExist('Access type section does not render for a community user');
// check all the form fields are present
await click(GENERAL.toggleGroup('Root config options'));
for (const key of expectedConfigKeys('aws-root-create')) {
Copy link
Contributor Author

@Monkeychip Monkeychip Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the value passed into expectedConfigKeys is changed here because of the above mentioned changed: I cleaned up this method to create generic arrays of keys that could come in camelized or not camelized.

true as a second param indicates "camelized"

@@ -68,6 +68,8 @@ module('Acceptance | GCP | configuration', function (hooks) {
service_account_email: 'service-email',
identity_token_audience: 'audience',
identity_token_ttl: 720000,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not originally tests these values on edit, but I am now.

await fillIn(GENERAL.ttl.input('Identity token TTL'), '7200');
}
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything above this line is just re-organization, no changes. Below is the clean up of the expectedConfigKeys using my new helper method and making the arrays more generic.

@@ -32,8 +32,15 @@ export default class AwsLeaseConfig extends Model {
})
lease;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no functional changes, just restructuring to match azure and gcp models—see here.

@@ -20,6 +21,32 @@ export const createSecretsEngine = (store, type, path) => {
});
return store.peekRecord('secret-engine', path);
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes until the next comment are just moving methods around to make it easier to read

@Monkeychip Monkeychip marked this pull request as ready for review January 10, 2025 20:21
@Monkeychip Monkeychip requested a review from a team as a code owner January 10, 2025 20:21
Copy link

Build Results:
All builds succeeded! ✅

@@ -231,6 +230,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') return; // secret-key is not returned by the API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think return will stop overall execution of the function.

Maybe continue?

Suggested change
if (key === 'Secret key') return; // secret-key is not returned by the API
if (key === 'Secret key') continue; // secret-key is not returned by the API

@@ -94,6 +94,7 @@ module('Acceptance | Azure | configuration', function (hooks) {
});
await enablePage.enable(this.type, path);
for (const key of expectedConfigKeys('azure')) {
if (key === 'Client secret') return; // client-secret is not returned by the API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (key === 'Client secret') return; // client-secret is not returned by the API
if (key === 'Client secret') continue; // client-secret is not returned by the API

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (key === 'Credentials') return; // not returned by the API
if (key === 'Credentials') continue; // not returned by the API

Copy link
Contributor

@emoncuso emoncuso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@Monkeychip Monkeychip enabled auto-merge (squash) January 10, 2025 21:37
@Monkeychip Monkeychip merged commit a73a698 into main Jan 10, 2025
32 of 33 checks passed
@Monkeychip Monkeychip deleted the ui/VAULT-33327/clean-up branch January 10, 2025 22:06
michael-diggin pushed a commit to michael-diggin/vault that referenced this pull request Jan 20, 2025
* initial things without helper changes

* adjust test for clean up of secret-engine-helper

* remove added line thats better in next pr

* remove extra check

* 🧹

* replace return with continue within loops
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed pr/no-changelog ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants