Skip to content

Commit 8952580

Browse files
authored
Merge pull request #293 from nodevault/copilot/add-support-for-kv-v2-destroy-command
Add KV v2 `destroySecretVersions` command
2 parents 7ad67a9 + a5b1efc commit 8952580

4 files changed

Lines changed: 51 additions & 0 deletions

File tree

features.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,3 +405,8 @@
405405
## vault.stepDown
406406

407407
`PUT /sys/step-down`
408+
409+
410+
## vault.destroySecretVersions
411+
412+
`POST /{{mount_point}}{{^mount_point}}secret{{/mount_point}}/destroy/{{path}}`

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ declare namespace NodeVault {
181181
transitListKeys(options?: Option): Promise<any>;
182182
transitDeleteKey(options?: Option): Promise<any>;
183183
generateDatabaseCredentials(options?: Option): Promise<any>;
184+
destroySecretVersions(options?: Option): Promise<any>;
184185
}
185186

186187
interface VaultOptions {

src/commands.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,4 +1374,23 @@ module.exports = {
13741374
method: 'PUT',
13751375
path: '/sys/step-down',
13761376
},
1377+
destroySecretVersions: {
1378+
method: 'POST',
1379+
path: '/{{mount_point}}{{^mount_point}}secret{{/mount_point}}/destroy/{{path}}',
1380+
schema: {
1381+
req: {
1382+
type: 'object',
1383+
properties: {
1384+
versions: {
1385+
type: 'array',
1386+
items: {
1387+
type: 'integer',
1388+
},
1389+
minItems: 1,
1390+
},
1391+
},
1392+
required: ['versions'],
1393+
},
1394+
},
1395+
},
13771396
}

test/unit.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,32 @@ describe('node-vault', () => {
868868
});
869869
});
870870

871+
describe('KV v2 commands', () => {
872+
it('should have destroySecretVersions function', () => {
873+
vault.destroySecretVersions.should.be.a('function');
874+
});
875+
876+
it('should call destroySecretVersions with correct path and method', (done) => {
877+
const params = {
878+
method: 'POST',
879+
path: '/secret/destroy/my-secret',
880+
};
881+
vault.destroySecretVersions({ path: 'my-secret', versions: [1, 2] })
882+
.then(assertRequest(request, params, done))
883+
.catch(done);
884+
});
885+
886+
it('should call destroySecretVersions with custom mount point', (done) => {
887+
const params = {
888+
method: 'POST',
889+
path: '/custom-kv/destroy/my-secret',
890+
};
891+
vault.destroySecretVersions({ mount_point: 'custom-kv', path: 'my-secret', versions: [1, 2] })
892+
.then(assertRequest(request, params, done))
893+
.catch(done);
894+
});
895+
});
896+
871897
describe('commands export', () => {
872898
it('should expose commands object on client', () => {
873899
vault.commands.should.be.an('object');

0 commit comments

Comments
 (0)