示例#1
0
func TestCreateInvalidChain(t *testing.T) {
	test := marshalCertData("_fixtures/illegal_chain.yaml", t)
	test.setupKeys()
	test.setupTemplates()
	test.setupSigner()
	test.signAll()
	client, _ := test.findByid("client")
	ca, _ := test.findByid(client.Signers[0])
	result := certificate.CheckCertificate("", ca.CertBytes, nil, client.CertBytes)
	if result {
		t.Fatal("Failed to create certificate chanin vid invalid signer")
	}
}
示例#2
0
func TestSignAll(t *testing.T) {
	test := marshalCertData("_fixtures/data.yaml", t)
	test.setupKeys()
	test.setupTemplates()
	test.setupSigner()
	test.signAll()
	for _, cert := range test.Certificates {
		if !cert.signed {
			if cert.CertConfig.Id != "client3" {
				t.Fatalf("Failed to sign cert: %v", cert.CertConfig.Id)
			}
		}
	}
	client, _ := test.findByid("client")
	ca, _ := test.findByid(client.Signers[0])
	inca, _ := test.findByid(client.Signers[1])
	result := certificate.CheckCertificate("", ca.CertBytes, inca.CertBytes, client.CertBytes)
	if !result {
		t.Fatal("certificate with id: client did not have correct certificate chain")
	}
}