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

* test coverage for bug

* Add defaultValue to acmeAccountSafetyBuffer

* fix failing PKI tests

* Add changelog
This commit is contained in:
Chelsea Shaw
2024-07-10 13:50:59 -05:00
committed by GitHub
parent 5856ae4ef7
commit b0ee637829
4 changed files with 35 additions and 3 deletions

3
changelog/27742.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
ui: fix issue where enabling then disabling "Tidy ACME" in PKI results in failed API call.
```

View File

@@ -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.', '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', detailsLabel: 'ACME account safety buffer',
formatTtl: true, formatTtl: true,
defaultValue: '720h',
}) })
acmeAccountSafetyBuffer; acmeAccountSafetyBuffer;

View File

@@ -143,6 +143,33 @@ module('Acceptance | pki tidy', function (hooks) {
assert.strictEqual(currentRouteName(), 'vault.cluster.secrets.backend.pki.tidy.auto.index'); 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) { test('it opens a tidy modal when the user clicks on the tidy toolbar action', async function (assert) {
await authPage.login(this.pkiAdminToken); await authPage.login(this.pkiAdminToken);
await visit(`/vault/secrets/${this.mountPath}/pki/tidy`); await visit(`/vault/secrets/${this.mountPath}/pki/tidy`);

View File

@@ -180,7 +180,7 @@ module('Integration | Component | pki tidy form', function (hooks) {
assert.propEqual( assert.propEqual(
JSON.parse(req.requestBody), JSON.parse(req.requestBody),
{ {
acme_account_safety_buffer: '60s', acme_account_safety_buffer: '72h',
enabled: true, enabled: true,
interval_duration: '10s', interval_duration: '10s',
issuer_safety_buffer: '20s', issuer_safety_buffer: '20s',
@@ -230,7 +230,7 @@ module('Integration | Component | pki tidy form', function (hooks) {
assert.false(this.autoTidy.tidyAcme, 'tidyAcme is false on model'); assert.false(this.autoTidy.tidyAcme, 'tidyAcme is false on model');
await click(PKI_TIDY_FORM.toggleInput('acmeAccountSafetyBuffer')); 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'); assert.true(this.autoTidy.tidyAcme, 'tidyAcme toggles to true');
const fillInValues = { const fillInValues = {
@@ -262,6 +262,7 @@ module('Integration | Component | pki tidy form', function (hooks) {
assert.propEqual( assert.propEqual(
JSON.parse(req.requestBody), JSON.parse(req.requestBody),
{ {
acme_account_safety_buffer: '720h',
enabled: false, enabled: false,
tidy_acme: false, tidy_acme: false,
}, },
@@ -294,7 +295,7 @@ module('Integration | Component | pki tidy form', function (hooks) {
assert.ok(true, 'Request made to perform manual tidy'); assert.ok(true, 'Request made to perform manual tidy');
assert.propEqual( assert.propEqual(
JSON.parse(req.requestBody), JSON.parse(req.requestBody),
{ tidy_acme: false }, { acme_account_safety_buffer: '720h', tidy_acme: false },
'response contains manual tidy params' 'response contains manual tidy params'
); );
return { id: 'pki-manual-tidy' }; return { id: 'pki-manual-tidy' };