Skip to content

Commit

Permalink
fix: fix unit test error code
Browse files Browse the repository at this point in the history
Signed-off-by: Junjie Gao <junjiegao@microsoft.com>
  • Loading branch information
JeyJeyGao committed Sep 7, 2022
1 parent 25e1806 commit 7e3e5f8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions signature/jws/envelope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,12 @@ func TestSigningScheme(t *testing.T) {

func TestSignVerify(t *testing.T) {
for _, keyType := range signaturetest.KeyTypes {
keyName := map[signature.KeyType]string{
signature.KeyTypeEC: "ECDSA",
signature.KeyTypeRSA: "RSA",
}[keyType]
for _, size := range signaturetest.GetKeySizes(keyType) {
t.Run(fmt.Sprintf("%s %d", keyType, size), func(t *testing.T) {
t.Run(fmt.Sprintf("%s %d", keyName, size), func(t *testing.T) {
signer, err := signaturetest.GetTestLocalSigner(keyType, size)
checkNoError(t, err)

Expand Down Expand Up @@ -354,7 +358,7 @@ func TestVerify(t *testing.T) {
env.Protected = "$" + env.Protected

err = verifyEnvelope(env)
checkErrorEqual(t, "jws envelope protected header can't be decoded: illegal base64 data at input byte 0", err.Error())
checkErrorEqual(t, "signature is invalid. Error: illegal base64 data at input byte 0", err.Error())
})
t.Run("malformed protected header raw", func(t *testing.T) {
// get envelope
Expand All @@ -369,7 +373,7 @@ func TestVerify(t *testing.T) {
env.Protected = base64.RawURLEncoding.EncodeToString(rawProtected)

err = verifyEnvelope(env)
checkErrorEqual(t, "jws envelope protected header can't be decoded: invalid character '}' looking for beginning of value", err.Error())
checkErrorEqual(t, "signature is invalid. Error: invalid character '}' looking for beginning of value", err.Error())
})
}

Expand Down

0 comments on commit 7e3e5f8

Please sign in to comment.