Documentation
¶
Overview ¶
Package testutil holds test fixtures shared by the jws, identity and resolver packages: key generators, PEM and certificate helpers, a fake fetcher, key assertions, and the sign-resolve-verify claim flow. It imports jws and identity, so their tests must be external (package jws_test).
Index ¶
- Constants
- func CertificatePEM(der []byte) []byte
- func EdPublic(t *testing.T, key ed25519.PrivateKey) ed25519.PublicKey
- func JWKS(t *testing.T, keys ...crypto.PublicKey) []byte
- func NewECKey(t *testing.T, curve elliptic.Curve) *ecdsa.PrivateKey
- func NewEdKey(t *testing.T) ed25519.PrivateKey
- func NewKey(t *testing.T, kind string) crypto.Signer
- func NewRSAKey(t *testing.T) *rsa.PrivateKey
- func NewSmallRSAKey(t *testing.T) *rsa.PrivateKey
- func PKCS8PEM(t *testing.T, key crypto.PrivateKey) []byte
- func RequireSameKeys(t *testing.T, want, got []crypto.PublicKey)
- func SelfSignedCertPEM(t *testing.T, key crypto.Signer, uriSAN string) []byte
- func SignedCertClaim(t *testing.T, subject string, key crypto.PrivateKey, certPEM []byte) *identityv1.Claim
- func SignedClaim(t *testing.T, subject string, key crypto.PrivateKey) *identityv1.Claim
- func VerifyClaim(t *testing.T, r resolvers.Resolver, claim *identityv1.Claim) (bool, error)
- type FakeFetcher
Constants ¶
const ( // SVIDSubject is the SPIFFE ID the test certificates carry by default. SVIDSubject = "spiffe://acme.com/agents/finance" // RecordCID is the record every test claim is attached to. RecordCID = "bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi" )
Variables ¶
This section is empty.
Functions ¶
func CertificatePEM ¶
CertificatePEM encodes a DER certificate as a PEM block.
func NewRSAKey ¶
func NewRSAKey(t *testing.T) *rsa.PrivateKey
NewRSAKey generates a 2048-bit RSA key.
func NewSmallRSAKey ¶
func NewSmallRSAKey(t *testing.T) *rsa.PrivateKey
NewSmallRSAKey generates a 1024-bit RSA key, below the size jws accepts.
func PKCS8PEM ¶
func PKCS8PEM(t *testing.T, key crypto.PrivateKey) []byte
PKCS8PEM encodes key as an unencrypted PKCS#8 PEM block.
func RequireSameKeys ¶
RequireSameKeys asserts got holds exactly the wanted keys, in any order.
func SelfSignedCertPEM ¶
SelfSignedCertPEM returns a self-signed certificate for key carrying uriSAN as its only URI SAN.
func SignedCertClaim ¶
func SignedCertClaim(t *testing.T, subject string, key crypto.PrivateKey, certPEM []byte) *identityv1.Claim
SignedCertClaim signs a claim for subject that carries certPEM, the certificate of key.
func SignedClaim ¶
func SignedClaim(t *testing.T, subject string, key crypto.PrivateKey) *identityv1.Claim
SignedClaim signs a fresh identity claim for subject the way a publisher would.
func VerifyClaim ¶
VerifyClaim is the flow a real caller follows: resolve the subject's keys, then verify the claim against all of them.