-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend certMatchesPolicy to support google_x509
Signed-off-by: linus-sun <[email protected]>
- Loading branch information
Showing
2 changed files
with
73 additions
and
2 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
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 |
---|---|---|
|
@@ -447,3 +447,24 @@ func TestCertMatches(t *testing.T) { | |
t.Errorf("expected subject %s and issuer %s, received subject %s and issuer %s", emailAddr, issuer, receivedSub, receivedIssuer) | ||
} | ||
} | ||
|
||
func TestGoogleCertMatches(t *testing.T) { | ||
emailAddr := "[email protected]" | ||
issuer := "test-issuer" | ||
cert := &google_x509.Certificate{ | ||
EmailAddresses: []string{emailAddr}, | ||
Extensions: []google_pkix.Extension{ | ||
{ | ||
Id: (google_asn1.ObjectIdentifier)(certExtensionOIDCIssuer), | ||
Value: []byte(issuer), | ||
}, | ||
}, | ||
} | ||
matches, receivedSub, receivedIssuer, err := CertMatchesPolicy(cert, emailAddr, []string{issuer}) | ||
if !matches || err != nil { | ||
t.Errorf("Expected true without error, got %v, error %v", matches, err) | ||
} | ||
if receivedSub != emailAddr || receivedIssuer != issuer { | ||
t.Errorf("expected subject %s and issuer %s, received subject %s and issuer %s", emailAddr, issuer, receivedSub, receivedIssuer) | ||
} | ||
} |