2018-09-25 16:28:26 +00:00
|
|
|
import { currentRouteName } from '@ember/test-helpers';
|
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupApplicationTest } from 'ember-qunit';
|
2018-04-03 14:16:57 +00:00
|
|
|
import page from 'vault/tests/pages/settings/mount-secret-backend';
|
2018-05-23 16:25:52 +00:00
|
|
|
import configPage from 'vault/tests/pages/secrets/backend/configuration';
|
2018-09-25 16:28:26 +00:00
|
|
|
import authPage from 'vault/tests/pages/auth';
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
module('Acceptance | settings/mount-secret-backend', function(hooks) {
|
|
|
|
setupApplicationTest(hooks);
|
|
|
|
|
|
|
|
hooks.beforeEach(function() {
|
|
|
|
return authPage.login();
|
|
|
|
});
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2020-04-20 15:17:50 +00:00
|
|
|
test('it sets the ttl correctly when mounting', async function(assert) {
|
2018-09-25 16:28:26 +00:00
|
|
|
// always force the new mount to the top of the list
|
|
|
|
const path = `kv-${new Date().getTime()}`;
|
|
|
|
const defaultTTLHours = 100;
|
|
|
|
const maxTTLHours = 300;
|
|
|
|
const defaultTTLSeconds = defaultTTLHours * 60 * 60;
|
|
|
|
const maxTTLSeconds = maxTTLHours * 60 * 60;
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
await page.visit();
|
2019-08-01 21:35:18 +00:00
|
|
|
|
2018-08-28 05:03:55 +00:00
|
|
|
assert.equal(currentRouteName(), 'vault.cluster.settings.mount-secret-backend');
|
2018-09-25 16:28:26 +00:00
|
|
|
await page.selectType('kv');
|
2019-04-10 14:36:32 +00:00
|
|
|
await page
|
|
|
|
.next()
|
|
|
|
.path(path)
|
|
|
|
.toggleOptions()
|
2020-04-20 15:17:50 +00:00
|
|
|
.enableDefaultTtl()
|
2019-04-10 14:36:32 +00:00
|
|
|
.defaultTTLUnit('h')
|
2020-04-20 15:17:50 +00:00
|
|
|
.defaultTTLVal(defaultTTLHours)
|
|
|
|
.enableMaxTtl()
|
2019-04-10 14:36:32 +00:00
|
|
|
.maxTTLUnit('h')
|
2020-04-20 15:17:50 +00:00
|
|
|
.maxTTLVal(maxTTLHours)
|
2019-04-10 14:36:32 +00:00
|
|
|
.submit();
|
2018-09-25 16:28:26 +00:00
|
|
|
await configPage.visit({ backend: path });
|
2018-05-23 16:25:52 +00:00
|
|
|
assert.equal(configPage.defaultTTL, defaultTTLSeconds, 'shows the proper TTL');
|
|
|
|
assert.equal(configPage.maxTTL, maxTTLSeconds, 'shows the proper max TTL');
|
2018-04-03 14:16:57 +00:00
|
|
|
});
|
2020-05-08 17:08:04 +00:00
|
|
|
|
|
|
|
test('it sets the ttl when enabled then disabled', async function(assert) {
|
|
|
|
// always force the new mount to the top of the list
|
|
|
|
const path = `kv-${new Date().getTime()}`;
|
|
|
|
const maxTTLHours = 300;
|
|
|
|
const maxTTLSeconds = maxTTLHours * 60 * 60;
|
|
|
|
|
|
|
|
await page.visit();
|
|
|
|
|
|
|
|
assert.equal(currentRouteName(), 'vault.cluster.settings.mount-secret-backend');
|
|
|
|
await page.selectType('kv');
|
|
|
|
await page
|
|
|
|
.next()
|
|
|
|
.path(path)
|
|
|
|
.toggleOptions()
|
|
|
|
.enableDefaultTtl()
|
|
|
|
.enableDefaultTtl()
|
|
|
|
.enableMaxTtl()
|
|
|
|
.maxTTLUnit('h')
|
|
|
|
.maxTTLVal(maxTTLHours)
|
|
|
|
.submit();
|
|
|
|
await configPage.visit({ backend: path });
|
|
|
|
assert.equal(configPage.defaultTTL, 0, 'shows the proper TTL');
|
|
|
|
assert.equal(configPage.maxTTL, maxTTLSeconds, 'shows the proper max TTL');
|
|
|
|
});
|
2018-04-03 14:16:57 +00:00
|
|
|
});
|