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

UI: Fix ACME Account Safety Buffer not able to be turned off #27742

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/app/models/pki/tidy.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class PkiTidyModel extends Model {
'The amount of time that must pass after creation that an account with no orders is marked revoked, and the amount of time after being marked revoked or deactivated.',
detailsLabel: 'ACME account safety buffer',
formatTtl: true,
defaultValue: '720h',
})
acmeAccountSafetyBuffer;

Expand Down
27 changes: 27 additions & 0 deletions ui/tests/acceptance/pki/pki-tidy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,33 @@ module('Acceptance | pki tidy', function (hooks) {
assert.strictEqual(currentRouteName(), 'vault.cluster.secrets.backend.pki.tidy.auto.index');
});

// test coverage for a bug where toggling acme tidy on then off caused API failure
test('it configures a manual tidy operation', async function (assert) {
await authPage.login(this.pkiAdminToken);
await visit(`/vault/secrets/${this.mountPath}/pki/tidy`);
await click(PKI_TIDY.tidyEmptyStateConfigure);
assert.dom(PKI_TIDY.tidyConfigureModal.configureTidyModal).exists();
assert.dom(PKI_TIDY.tidyConfigureModal.tidyModalAutoButton).exists();
assert.dom(PKI_TIDY.tidyConfigureModal.tidyModalManualButton).exists();
await click(PKI_TIDY.tidyConfigureModal.tidyModalManualButton);

assert.dom(PKI_TIDY_FORM.tidyFormName('manual')).exists();
await click(PKI_TIDY_FORM.inputByAttr('tidyCertStore'));

await click(GENERAL.ttl.toggle('Tidy ACME disabled'));
assert
.dom(GENERAL.ttl.input('Tidy ACME enabled'))
.hasValue('30', 'acmeAccountSafetyBuffer defaults to 30 days');
await click('[data-test-toggle-input="Tidy ACME enabled"]');

await click(PKI_TIDY_FORM.tidySave);
assert.strictEqual(
currentRouteName(),
'vault.cluster.secrets.backend.pki.tidy.index',
'saves successfully and redirects to index'
);
});

test('it opens a tidy modal when the user clicks on the tidy toolbar action', async function (assert) {
await authPage.login(this.pkiAdminToken);
await visit(`/vault/secrets/${this.mountPath}/pki/tidy`);
Expand Down
7 changes: 4 additions & 3 deletions ui/tests/integration/components/pki/pki-tidy-form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ module('Integration | Component | pki tidy form', function (hooks) {
assert.propEqual(
JSON.parse(req.requestBody),
{
acme_account_safety_buffer: '60s',
acme_account_safety_buffer: '72h',
enabled: true,
interval_duration: '10s',
issuer_safety_buffer: '20s',
Expand Down Expand Up @@ -230,7 +230,7 @@ module('Integration | Component | pki tidy form', function (hooks) {
assert.false(this.autoTidy.tidyAcme, 'tidyAcme is false on model');

await click(PKI_TIDY_FORM.toggleInput('acmeAccountSafetyBuffer'));
await fillIn(PKI_TIDY_FORM.acmeAccountSafetyBuffer, 60);
await fillIn(PKI_TIDY_FORM.acmeAccountSafetyBuffer, 3); // units are days based on defaultValue
assert.true(this.autoTidy.tidyAcme, 'tidyAcme toggles to true');

const fillInValues = {
Expand Down Expand Up @@ -262,6 +262,7 @@ module('Integration | Component | pki tidy form', function (hooks) {
assert.propEqual(
JSON.parse(req.requestBody),
{
acme_account_safety_buffer: '720h',
enabled: false,
tidy_acme: false,
},
Expand Down Expand Up @@ -294,7 +295,7 @@ module('Integration | Component | pki tidy form', function (hooks) {
assert.ok(true, 'Request made to perform manual tidy');
assert.propEqual(
JSON.parse(req.requestBody),
{ tidy_acme: false },
{ acme_account_safety_buffer: '720h', tidy_acme: false },
'response contains manual tidy params'
);
return { id: 'pki-manual-tidy' };
Expand Down
Loading