-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented wildcard selector (based on #238) #488
Changes from all commits
cc9c383
f09a7fe
6c9a25f
a729d0a
755188e
8bf66ca
5ecd962
ef3b3cc
477b475
4c238e2
11c0abf
6966788
c557ed0
5dda2cf
9109e52
9f38d38
e716b61
8c2d8ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,6 +171,26 @@ describe('integration', () => { | |
expect(core.exportVariable).toBeCalledWith('OTHERSECRETDASH', 'OTHERSUPERSECRET'); | ||
}); | ||
|
||
it('get wildcard secrets', async () => { | ||
mockInput(`secret/data/test * ;`); | ||
|
||
await exportSecrets(); | ||
|
||
expect(core.exportVariable).toBeCalledTimes(1); | ||
|
||
expect(core.exportVariable).toBeCalledWith('SECRET', 'SUPERSECRET'); | ||
}); | ||
|
||
it('get wildcard secrets with name prefix', async () => { | ||
mockInput(`secret/data/test * | GROUP_ ;`); | ||
|
||
await exportSecrets(); | ||
|
||
expect(core.exportVariable).toBeCalledTimes(1); | ||
|
||
expect(core.exportVariable).toBeCalledWith('GROUP_SECRET', 'SUPERSECRET'); | ||
}); | ||
|
||
it('leading slash kvv2', async () => { | ||
mockInput('/secret/data/foobar fookv2'); | ||
|
||
|
@@ -195,6 +215,34 @@ describe('integration', () => { | |
expect(core.exportVariable).toBeCalledWith('OTHERSECRETDASH', 'OTHERCUSTOMSECRET'); | ||
}); | ||
|
||
it('get K/V v1 wildcard secrets', async () => { | ||
mockInput(`secret-kv1/test * ;`); | ||
|
||
await exportSecrets(); | ||
|
||
expect(core.exportVariable).toBeCalledTimes(1); | ||
|
||
expect(core.exportVariable).toBeCalledWith('SECRET', 'CUSTOMSECRET'); | ||
}); | ||
|
||
it('get K/V v1 wildcard secrets with name prefix', async () => { | ||
mockInput(`secret-kv1/test * | GROUP_ ;`); | ||
|
||
await exportSecrets(); | ||
|
||
expect(core.exportVariable).toBeCalledTimes(1); | ||
|
||
expect(core.exportVariable).toBeCalledWith('GROUP_SECRET', 'CUSTOMSECRET'); | ||
}); | ||
|
||
it('get wildcard nested secret from K/V v1', async () => { | ||
mockInput('secret-kv1/nested/test *'); | ||
|
||
await exportSecrets(); | ||
|
||
expect(core.exportVariable).toBeCalledWith('OTHERSECRETDASH', 'OTHERCUSTOMSECRET'); | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then you can modify the test to cover not only that the wildcard is valid & the prefix gets applied, but that multiple sub-keys get picked up as well as desired:
|
||
it('leading slash kvv1', async () => { | ||
mockInput('/secret-kv1/foobar fookv1'); | ||
|
||
|
@@ -225,6 +273,17 @@ describe('integration', () => { | |
expect(core.exportVariable).toBeCalledWith('FOO', 'bar'); | ||
}); | ||
|
||
it('wildcard supports cubbyhole', async () => { | ||
mockInput('/cubbyhole/test *'); | ||
|
||
await exportSecrets(); | ||
|
||
expect(core.exportVariable).toBeCalledTimes(2); | ||
|
||
expect(core.exportVariable).toBeCalledWith('FOO', 'bar'); | ||
expect(core.exportVariable).toBeCalledWith('ZIP', 'zap'); | ||
}); | ||
|
||
it('caches responses', async () => { | ||
mockInput(` | ||
/cubbyhole/test foo ; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,22 @@ describe('integration', () => { | |
expect(core.exportVariable).toBeCalledWith('TEST_KEY', 'SUPERSECRET_IN_NAMESPACE'); | ||
}); | ||
|
||
it('get wildcard secrets', async () => { | ||
mockInput('secret/data/test *'); | ||
|
||
await exportSecrets(); | ||
|
||
expect(core.exportVariable).toBeCalledWith('SECRET', 'SUPERSECRET_IN_NAMESPACE'); | ||
}); | ||
|
||
it('get wildcard secrets with name prefix', async () => { | ||
mockInput('secret/data/test * | GROUP_'); | ||
|
||
await exportSecrets(); | ||
|
||
expect(core.exportVariable).toBeCalledWith('GROUP_SECRET', 'SUPERSECRET_IN_NAMESPACE'); | ||
}); | ||
|
||
it('get nested secret', async () => { | ||
mockInput('secret/data/nested/test otherSecret'); | ||
|
||
|
@@ -103,6 +119,22 @@ describe('integration', () => { | |
expect(core.exportVariable).toBeCalledWith('SECRET', 'CUSTOMSECRET_IN_NAMESPACE'); | ||
}); | ||
|
||
it('get wildcard secrets from K/V v1', async () => { | ||
mockInput('my-secret/test *'); | ||
|
||
await exportSecrets(); | ||
|
||
expect(core.exportVariable).toBeCalledWith('SECRET', 'CUSTOMSECRET_IN_NAMESPACE'); | ||
}); | ||
|
||
it('get wildcard secrets from K/V v1 with name prefix', async () => { | ||
mockInput('my-secret/test * | GROUP_'); | ||
|
||
await exportSecrets(); | ||
|
||
expect(core.exportVariable).toBeCalledWith('GROUP_SECRET', 'CUSTOMSECRET_IN_NAMESPACE'); | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, would be great to have a multi-value secret as part of the tests. |
||
it('get nested secret from K/V v1', async () => { | ||
mockInput('my-secret/nested/test otherSecret'); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small suggestion would be to setup a secret with multiple keys to validate that the wildcard operator does indeed picks up all the sub-keys.
For example on l.22: