-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add verification policy support to client package (#893)
Signed-off-by: Brian DeHamer <[email protected]>
- Loading branch information
Showing
13 changed files
with
124 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sigstore/verify': minor | ||
--- | ||
|
||
Export `VerificationPolicy` type |
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,2 @@ | ||
--- | ||
--- |
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 |
---|---|---|
|
@@ -18,7 +18,11 @@ import { | |
MessageSignatureBundleBuilder, | ||
} from '@sigstore/sign'; | ||
import { VerificationError } from '@sigstore/verify'; | ||
import { createBundleBuilder, createKeyFinder } from '../config'; | ||
import { | ||
createBundleBuilder, | ||
createKeyFinder, | ||
createVerificationPolicy, | ||
} from '../config'; | ||
import { publicKeys } from './__fixtures__/bundles/valid'; | ||
|
||
describe('createBundleBuilder', () => { | ||
|
@@ -91,3 +95,43 @@ describe('createKeyFinder', () => { | |
}); | ||
}); | ||
}); | ||
|
||
describe('createVerificationPolicy', () => { | ||
describe('when the options specify a certificateIdentityEmail', () => { | ||
const options = { certificateIdentityEmail: '[email protected]' }; | ||
|
||
it('returns a verification policy', () => { | ||
const policy = createVerificationPolicy(options); | ||
expect(policy).toBeDefined(); | ||
expect(policy.subjectAlternativeName).toEqual( | ||
options.certificateIdentityEmail | ||
); | ||
expect(policy.extensions).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe('when the options specify a certificateIdentityURI', () => { | ||
const options = { certificateIdentityURI: 'https://foo.bar.com' }; | ||
|
||
it('returns a verification policy', () => { | ||
const policy = createVerificationPolicy(options); | ||
expect(policy).toBeDefined(); | ||
expect(policy.subjectAlternativeName).toEqual( | ||
options.certificateIdentityURI | ||
); | ||
expect(policy.extensions).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe('when the options specify a certificateIssuer', () => { | ||
const options = { certificateIssuer: 'https://bar.foo.com' }; | ||
|
||
it('returns a verification policy', () => { | ||
const policy = createVerificationPolicy(options); | ||
expect(policy).toBeDefined(); | ||
expect(policy.extensions).toBeDefined(); | ||
expect(policy.extensions?.issuer).toEqual(options.certificateIssuer); | ||
expect(policy.subjectAlternativeName).toBeUndefined(); | ||
}); | ||
}); | ||
}); |
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
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
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