Skip to content

Commit

Permalink
fix: integration
Browse files Browse the repository at this point in the history
  • Loading branch information
gak committed Aug 19, 2024
1 parent 42f8c0a commit fbaeb39
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/encryption/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,20 @@ func TestKMSEncryptorLocalstack(t *testing.T) {
Region: awsv1.String("us-west-2"),
})

encryptor, err := NewKMSEncryptorGenerateKey(uri, v1client)
key, err := newKey(uri, v1client)
assert.NoError(t, err)

encrypted, err := encryptor.Encrypt(TimelineSubkey, []byte("hunter2"))
encryptor, err := NewKMSEncryptorWithKMS(uri, v1client, key)
assert.NoError(t, err)

decrypted, err := encryptor.Decrypt(TimelineSubkey, encrypted)
encrypted, err := encryptor.Encrypt(TimelineSubkey{}, []byte("hunter2"))
assert.NoError(t, err)

decrypted, err := encryptor.Decrypt(TimelineSubkey{}, encrypted)
assert.NoError(t, err)
assert.Equal(t, "hunter2", string(decrypted))

// Should fail to decrypt with the wrong subkey
_, err = encryptor.Decrypt(AsyncSubkey, encrypted)
_, err = encryptor.Decrypt(AsyncSubkey{}, encrypted)
assert.Error(t, err)
}

0 comments on commit fbaeb39

Please sign in to comment.