Skip to content

Commit

Permalink
Add equivalent test for #681
Browse files Browse the repository at this point in the history
the v2 branch seems to have received fixes during the refactoring,
and symptoms described in #681 did not show up. However, out of
caution we will add this test that checks for #681 so that future
regressions may be prevented
  • Loading branch information
lestrrat committed Apr 8, 2022
1 parent be5de91 commit d1c3947
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions jws/jws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1814,3 +1814,22 @@ func TestAlgorithmsForKey(t *testing.T) {
})
}
}

func TestGH681(t *testing.T) {
privkey, err := jwxtest.GenerateRsaKey()
if !assert.NoError(t, err, "failed to create private key") {
return
}

buf, err := jws.Sign(nil, jws.WithKey(jwa.RS256, privkey), jws.WithDetachedPayload([]byte("Lorem ipsum")))
if !assert.NoError(t, err, "failed to sign payload") {
return
}

t.Logf("%s", buf)

_, err = jws.Verify(buf, jws.WithKey(jwa.RS256, &privkey.PublicKey), jws.WithDetachedPayload([]byte("Lorem ipsum")))
if !assert.NoError(t, err, "failed to verify JWS message") {
return
}
}

0 comments on commit d1c3947

Please sign in to comment.