You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-12-01 22:51:45 +02:00
Ensure Cipher.Decrypt doesn't mangle input ciphertext []byte
This commit is contained in:
@@ -84,9 +84,17 @@ func TestEncryptAndDecrypt(t *testing.T) {
|
||||
assert.Equal(t, nil, err)
|
||||
assert.NotEqual(t, encrypted, data)
|
||||
|
||||
// Ensure our Decrypt function doesn't decrypt in place
|
||||
immutable := make([]byte, len(encrypted))
|
||||
copy(immutable, encrypted)
|
||||
|
||||
decrypted, err := c.Decrypt(encrypted)
|
||||
assert.Equal(t, nil, err)
|
||||
// Original data back
|
||||
assert.Equal(t, data, decrypted)
|
||||
// Decrypt didn't operate in-place on []byte
|
||||
assert.Equal(t, encrypted, immutable)
|
||||
// Encrypt/Decrypt actually did something
|
||||
assert.NotEqual(t, encrypted, decrypted)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user