Skip to content

Commit

Permalink
add test to ensure subject/issuer are set
Browse files Browse the repository at this point in the history
  • Loading branch information
peterargue committed Nov 30, 2021
1 parent 155ab63 commit 3d3b9c4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion utils/grpcutils/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ func TestCertificateGeneration(t *testing.T) {
// assert that the public key in the cert matches the test public key
require.True(t, expectedKey.Equals(pubKey))

// assert that the the cert is valid for at least an year starting from now
// assert that the cert is valid for at least an year starting from now
now := time.Now()
require.True(t, now.After(cert.NotBefore))
require.True(t, cert.NotAfter.After(now.Add(year)))

// assert that the cert's subject and issuer fields are set and match (self-signed)
require.NotEmpty(t, cert.Subject)
require.NotEmpty(t, cert.Issuer)
require.Equal(t, cert.Subject, cert.Issuer)
}

// TestPeerCertificateVerification tests that the verifyPeerCertificate function correctly verifies a server cert
Expand Down

0 comments on commit 3d3b9c4

Please sign in to comment.