MCPcopy Create free account
hub / github.com/crewjam/saml / covTestKeyDocument

Function covTestKeyDocument

xmlenc/fuzz_coverage_test.go:32–52  ·  view source on GitHub ↗

covTestKeyDocument returns an EncryptedData document encrypted to covFuzzKey, the key the tests pass to Fuzz.

(t testing.TB, e RSA)

Source from the content-addressed store, hash-verified

30// covTestKeyDocument returns an EncryptedData document encrypted to covFuzzKey,
31// the key the tests pass to Fuzz.
32func covTestKeyDocument(t testing.TB, e RSA) []byte {
33 t.Helper()
34 template := &x509.Certificate{
35 SerialNumber: big.NewInt(3),
36 Subject: pkix.Name{CommonName: "fuzz.example.com"},
37 NotBefore: time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
38 NotAfter: time.Date(2100, 1, 1, 0, 0, 0, 0, time.UTC),
39 }
40 der, err := x509.CreateCertificate(rand.Reader, template, template, &covFuzzKey().PublicKey, covFuzzKey())
41 assert.NilError(t, err)
42 cert, err := x509.ParseCertificate(der)
43 assert.NilError(t, err)
44
45 el, err := e.Encrypt(cert, []byte("<Assertion>fuzz</Assertion>"), nil)
46 assert.NilError(t, err)
47 doc := etree.NewDocument()
48 doc.SetRoot(el)
49 buf, err := doc.WriteToBytes()
50 assert.NilError(t, err)
51 return buf
52}
53
54func TestCovFuzz(t *testing.T) {
55 assert.Check(t, decryptForFuzzing(covFuzzKey(), []byte("<unclosed")) != nil, "not XML")

Callers 2

TestCovFuzzFunction · 0.85
FuzzDecryptFunction · 0.85

Calls 1

EncryptMethod · 0.65

Tested by

no test coverage detected