Skip to content

Commit

Permalink
backport of UI: fix ACME account safety buffer ttl (#27751)
Browse files Browse the repository at this point in the history
Co-authored-by: Chelsea Shaw <[email protected]>
  • Loading branch information
1 parent e9e0bce commit 7245708
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog/27742.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: fix issue where enabling then disabling "Tidy ACME" in PKI results in failed API call.
```
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

0 comments on commit 7245708

Please sign in to comment.