mirror of
https://github.com/hashicorp/vault.git
synced 2025-12-26 20:01:12 +01:00
* convert file to typescript * remove unused util * add support for nested options * move automation snippets outside of builder component * update snippet utils * Revert "remove unused util" This reverts commit bcb53271e63dd1fc3d2f735d7f7fcc54e5e31988. * render automation snippets for only acl policy types * cleanup old args * add default arg for formatEot * make tfvp formatters easier to follow, maybe? Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
48 lines
1.7 KiB
JavaScript
48 lines
1.7 KiB
JavaScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupTest } from 'ember-qunit';
|
|
import { cliTemplate } from 'core/utils/code-generators/cli';
|
|
|
|
module('Integration | Util | code-generators/cli', function (hooks) {
|
|
setupTest(hooks);
|
|
|
|
test('cliTemplate: it formats CLI command with content', async function (assert) {
|
|
const content = `- <<EOT
|
|
path "secret/*" {
|
|
capabilities = ["read"]
|
|
}
|
|
EOT`;
|
|
const formatted = cliTemplate({ command: 'policy write my-policy', content });
|
|
const expected = `vault policy write my-policy ${content}`;
|
|
assert.strictEqual(formatted, expected, 'it formats CLI command with content');
|
|
});
|
|
|
|
test('cliTemplate: it handles empty content', async function (assert) {
|
|
const formatted = cliTemplate({ command: 'policy list', content: '' });
|
|
const expected = 'vault policy list';
|
|
assert.strictEqual(formatted, expected, 'it formats CLI command with empty content');
|
|
});
|
|
|
|
test('cliTemplate: it only supplies placeholder "[args]" when there is no command', async function (assert) {
|
|
let formatted = cliTemplate();
|
|
let expected = 'vault <command> [args]';
|
|
assert.strictEqual(formatted, expected, 'it formats CLI command with undefined args');
|
|
|
|
formatted = cliTemplate({ command: 'read my-secret' });
|
|
expected = 'vault read my-secret';
|
|
assert.strictEqual(formatted, expected, 'it formats CLI command without "[args]" placeholder');
|
|
|
|
formatted = cliTemplate({ command: '' });
|
|
expected = 'vault <command> [args]';
|
|
assert.strictEqual(
|
|
formatted,
|
|
expected,
|
|
'it formats CLI command with placeholders content is an empty string'
|
|
);
|
|
});
|
|
});
|