diff --git a/features.md b/features.md index 330b813..60c9013 100644 --- a/features.md +++ b/features.md @@ -405,3 +405,8 @@ ## vault.stepDown `PUT /sys/step-down` + + +## vault.destroySecretVersions + +`POST /{{mount_point}}{{^mount_point}}secret{{/mount_point}}/destroy/{{path}}` diff --git a/index.d.ts b/index.d.ts index 5a590f7..d9b197e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -181,6 +181,7 @@ declare namespace NodeVault { transitListKeys(options?: Option): Promise; transitDeleteKey(options?: Option): Promise; generateDatabaseCredentials(options?: Option): Promise; + destroySecretVersions(options?: Option): Promise; } interface VaultOptions { diff --git a/src/commands.js b/src/commands.js index 47bd49b..efffce7 100644 --- a/src/commands.js +++ b/src/commands.js @@ -1374,4 +1374,23 @@ module.exports = { method: 'PUT', path: '/sys/step-down', }, + destroySecretVersions: { + method: 'POST', + path: '/{{mount_point}}{{^mount_point}}secret{{/mount_point}}/destroy/{{path}}', + schema: { + req: { + type: 'object', + properties: { + versions: { + type: 'array', + items: { + type: 'integer', + }, + minItems: 1, + }, + }, + required: ['versions'], + }, + }, + }, } \ No newline at end of file diff --git a/test/unit.js b/test/unit.js index c951a7b..8ba39df 100644 --- a/test/unit.js +++ b/test/unit.js @@ -868,6 +868,32 @@ describe('node-vault', () => { }); }); + describe('KV v2 commands', () => { + it('should have destroySecretVersions function', () => { + vault.destroySecretVersions.should.be.a('function'); + }); + + it('should call destroySecretVersions with correct path and method', (done) => { + const params = { + method: 'POST', + path: '/secret/destroy/my-secret', + }; + vault.destroySecretVersions({ path: 'my-secret', versions: [1, 2] }) + .then(assertRequest(request, params, done)) + .catch(done); + }); + + it('should call destroySecretVersions with custom mount point', (done) => { + const params = { + method: 'POST', + path: '/custom-kv/destroy/my-secret', + }; + vault.destroySecretVersions({ mount_point: 'custom-kv', path: 'my-secret', versions: [1, 2] }) + .then(assertRequest(request, params, done)) + .catch(done); + }); + }); + describe('commands export', () => { it('should expose commands object on client', () => { vault.commands.should.be.an('object');