Skip to content

Commit

Permalink
some more changes
Browse files Browse the repository at this point in the history
Signed-off-by: Pritesh Bandi <[email protected]>
  • Loading branch information
Pritesh Bandi committed Jun 24, 2022
1 parent 8ee5013 commit 23d57cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions signer/jws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"testing"
)

// Tests various scenarios around newJWSEnvelopeFromBytes method
func TestNewJWSEnvelopeFromBytes(t *testing.T) {
t.Run("newJWSEnvelopeFromBytes", func(t *testing.T) {
if _, err := newJWSEnvelopeFromBytes([]byte(TestValidSig)); err != nil {
Expand All @@ -24,6 +25,7 @@ func TestNewJWSEnvelopeFromBytes(t *testing.T) {
})
}

// Tests various scenarios around validateIntegrity method
func TestValidateIntegrity(t *testing.T) {
t.Run("with newJWSEnvelope() returns error", func(t *testing.T) {
env := jwsEnvelope{}
Expand Down Expand Up @@ -76,6 +78,7 @@ func TestValidateIntegrity(t *testing.T) {
})
}

// Tests various scenarios around getSignerInfo method
func TestGetSignerInfo(t *testing.T) {
t.Run("with newJWSEnvelope before sign returns error", func(t *testing.T) {
env := jwsEnvelope{}
Expand Down Expand Up @@ -142,6 +145,7 @@ func TestGetSignerInfo(t *testing.T) {
})
}

// Tests various scenarios around signPayload method
func TestSignPayload(t *testing.T) {
env := jwsEnvelope{}
t.Run("using rsa key with newJWSEnvelope works", func(t *testing.T) {
Expand Down
6 changes: 6 additions & 0 deletions signer/signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func TestNewSignatureEnvelopeFromBytesError(t *testing.T) {
}
}

// Tests various scenarios around generating a signature envelope
func TestSign(t *testing.T) {
env, err := NewSignatureEnvelope(MediaTypeJWSJson)
if err != nil {
Expand Down Expand Up @@ -74,6 +75,7 @@ func TestSign(t *testing.T) {
})
}

// Tests various error scenarios around generating a signature envelope
func TestSignErrors(t *testing.T) {
env, _ := NewSignatureEnvelope(MediaTypeJWSJson)
req := getSignRequest()
Expand Down Expand Up @@ -114,6 +116,7 @@ func TestSignErrors(t *testing.T) {
})
}

// Tests various scenarios around signature envelope verification
func TestVerify(t *testing.T) {
certs := "MIIEfDCCAuSgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJVUzELMAkGA1UECBMCV0ExEDAOBgNVBAcTB1NlYXR0bGUxDzANBgNVBAoTBk5vdGFyeTEbMBkGA1UEAxMSTm90YXRpb24gVGVzdCBSb290MB4XDTIyMDYyMzA5MTkzOVoXDTIyMDYyNDA5MTkzOVowXzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZOb3RhcnkxIDAeBgNVBAMTF05vdGF0aW9uIFRlc3QgTGVhZiBDZXJ0MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA26n9XTnfViVMaPWJNe0YlYBfV80UB4ohpTTk/nAZX6IAYJemoN2MtUIgbdqxhKY1lvPnRh9RmzEwsk96auCKwTbqa7Z4FMtUg46GZqLWK5ioCg33hKRJnye/ENH2+iHy5MZUnXXfAZ89UG3Tq+LL8AJFykcw6XvslUUnw0m5aP+7fObF5SER5dpr7mMxArrVihvoDyjnfGRnDVljMwekrvKMzqCbg3qaCk6idETM7ylGZF9DzEk+mYxSnXUnGuxXTrc4bJYzx6Wb5Yio5srXWizOaTxtDZBWj0utdPxnJsQjVZzzhXQY7dbnO6ij8s6JYOl8fha+c/pUH47WSaXau7vSy1mwLhVZ6nTtNQ81H3/LStyZwpe49MgRHqcMmSXrxmXxnC1Ti5C1d+6GCvfLLtWJzy1mWNsLyrr5rVLbSS5yO67/fO+4zDdRp9hD7PlifAKUL4zHjY6fhFLwerDhnHKVw7iZStdpqgFYH3FPKQ9AV/ttVK7efclPDemy3DQ3AgMBAAGjSDBGMA4GA1UdDwEB/wQEAwIHgDATBgNVHSUEDDAKBggrBgEFBQcDA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b3EwWYXuCq8PjKjI0ZsCU2eGjasw=="
Expand Down Expand Up @@ -157,6 +160,7 @@ func TestVerify(t *testing.T) {
}
}

// Tests various error scenarios around signature envelope verification
func TestVerifyErrors(t *testing.T) {
t.Run("when trustedCerts is absent", func(t *testing.T) {
env, _ := NewSignatureEnvelopeFromBytes([]byte("{}"), MediaTypeJWSJson)
Expand All @@ -183,6 +187,7 @@ func TestVerifyErrors(t *testing.T) {
})
}

// Tests various scenarios around sign first and then verify envelope verification
func TestSignAndVerify(t *testing.T) {
t.Run("with RSA certificate", func(t *testing.T) {
// Sign
Expand Down Expand Up @@ -251,6 +256,7 @@ func TestSignAndVerify(t *testing.T) {
})
}

// Tests various error scenarios around GetSignerInfo method
func TestGetSignerInfoErrors(t *testing.T) {
env, _ := NewSignatureEnvelope(MediaTypeJWSJson)
t.Run("when called GetSignerInfo before sign or verify.", func(t *testing.T) {
Expand Down

0 comments on commit 23d57cd

Please sign in to comment.