-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "delete secret" command (so I can clean up mispelled keys)
- Loading branch information
1 parent
89e918f
commit 1c9a410
Showing
7 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { createInMemorySecretsVault } from '../lib'; | ||
import { getSecretKeyList } from './get-secret-key-list'; | ||
import { deleteSecret } from './delete-secret'; | ||
|
||
const getTestVault = (vaultData: any) => { | ||
const result = createInMemorySecretsVault(JSON.stringify(vaultData)); | ||
if (result.success) { | ||
return result.data; | ||
} else { | ||
throw new Error('Error creating in-memory test vault'); | ||
} | ||
}; | ||
|
||
describe('delete-secret command', () => { | ||
it('removes key', async () => { | ||
const vault = getTestVault({ | ||
'secret-key-1': 'value-1', | ||
}); | ||
await deleteSecret(vault, 'secret-key-1'); | ||
expect(await vault.getSecretKeys()).toEqual([]); | ||
}); | ||
|
||
it('silently handles non-existent keys', async () => { | ||
const vault = getTestVault({}); | ||
await deleteSecret(vault, 'secret-key-1'); | ||
expect(await vault.getSecretKeys()).toEqual([]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { SecretKey, SecretsVault } from '../lib/types'; | ||
|
||
export const deleteSecret = async (vault: SecretsVault, key: SecretKey) => { | ||
return await vault.deleteSecret(key); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters