Skip to content

Commit 7949ce5

Browse files
committed
policy: fix flaky HTTP PGP test
Ensure the negative checksum case always mutates the digest instead of sometimes reproducing the original value when it already starts with 0. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
1 parent 9ee3717 commit 7949ce5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

policy/funcs_http_pgp_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ func TestBuiltinVerifyHTTPPGPSignatureImpl(t *testing.T) {
6767
t.Run("verify-failure-returns-false", func(t *testing.T) {
6868
encoded := checksumDigest.Encoded()
6969
require.NotEmpty(t, encoded)
70-
flipped := "0" + encoded[1:]
70+
flippedFirst := byte('0')
71+
if encoded[0] == '0' {
72+
flippedFirst = '1'
73+
}
74+
flipped := string(flippedFirst) + encoded[1:]
7175
badDigest := digest.NewDigestFromEncoded(checksumDigest.Algorithm(), flipped)
7276

7377
st := &state{

0 commit comments

Comments
 (0)