chore: Clarify GrantHash behavior when there are no GrantTuples (#5334)

* chore: Simplify appending

* test(grants): De-dupe hash comparison

* chore(grants): Remove TODO & add clarifying comment

* test(grants): Add test cases to enforce empty grants behavior
This commit is contained in:
David Kanney authored and GitHub committed 2024-12-06 16:45:38 -05:00
1 parent c32dcecb6e
commit f62e67584e
3 files changed
+25 -5

No files matched your search

+10 -1
View File
@@ -341,5 +341,14 @@ func TestGrantsHash(t *testing.T) {
hash3, err := res.GrantsHash(ctx)
require.NoError(t, err)
assert.False(t, bytes.Equal(hash1, hash3))
assert.False(t, bytes.Equal(hash1, hash3))
assert.False(t, bytes.Equal(hash2, hash3))
// Recreate auth result with no grants, should return a slice of empty bytes
res.grants = nil
hash4, err := res.GrantsHash(ctx)
require.NoError(t, err)
assert.False(t, bytes.Equal(hash1, hash4))
assert.False(t, bytes.Equal(hash2, hash4))
assert.False(t, bytes.Equal(hash3, hash4))
assert.True(t, bytes.Equal([]byte{0, 0, 0, 0, 0, 0, 0, 0}, hash4))
}