Skip to content

Commit

Permalink
PMM-13132 Fix in test.
Browse files Browse the repository at this point in the history
  • Loading branch information
JiriCtvrtka committed Sep 19, 2024
1 parent be0c4b7 commit 7986a5b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions encryption-rotation/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ const (
encryptionKeyTestPath = "/srv/pmm-encryption-rotation-test.key"
originEncryptionKey = `CMatkOIIEmQKWAowdHlwZS5nb29nbGVhcGlzLmNvbS9nb29nbGUuY3J5cHRvLnRpbmsuQWVzR2NtS2V5EiIaIKDxOKZxwiJl5Hj6oPZ/unTzmAvfwHWzZ1Wli0vac15YGAEQARjGrZDiCCAB`
// pmm-managed-username encrypted with originEncryptionKey
originUsernameHash = `AYxEFsbCFxg31sCqO4KlCsqASFYNeHapjT+vf8seEhsQrN5hWOCuvCSxd/ZERv8RODu3oX4=`
originUsernameHash = `AYxEFsZsg7lp9+eSy6+wPFHlaNNy0ZpTbYN0NuCLPnQOZUYf2S6H9B+XJdF4+DscxC/pJwI=`
// pmm-managed-password encrypted with originEncryptionKey
originPasswordHash = `AYxEFsajO8X5rrXG4ocOEE4ltWuaNmy7Uz0GyDgZ/Q04O2biFah5IdkenQ9ehXwv+nyiwDw=` //nolint:gosec
originPasswordHash = `AYxEFsZuL5xZb5IxGGh8NI6GrjDxCzFGxIcHe94UXcg+dnZphu7GQSgmZm633XvZ8CBU2wo=` //nolint:gosec
)

func TestEncryptionRotation(t *testing.T) {
Expand All @@ -65,7 +65,12 @@ func TestEncryptionRotation(t *testing.T) {

func createOriginEncryptionKey() error {
encryption.DefaultEncryptionKeyPath = encryptionKeyTestPath
return os.WriteFile(encryptionKeyTestPath, []byte(originEncryptionKey), 0o644)
err := os.WriteFile(encryptionKeyTestPath, []byte(originEncryptionKey), 0o600)
if err != nil {
return err
}
encryption.DefaultEncryption = encryption.New()
return nil
}

func insertTestData(db *sql.DB) error {
Expand Down Expand Up @@ -120,15 +125,15 @@ func checkNewlyEncryptedData(db *sql.DB) error {
if err != nil {
return err
}
if username != "pmm-managed" {
if username != "pmm-managed-username" {
return errors.New("username not properly decrypted")
}

password, err := encryption.Decrypt(newlyEncryptedPassword)
if err != nil {
return err
}
if password != "pmm-managed" {
if password != "pmm-managed-password" {
return errors.New("password not properly decrypted")
}

Expand Down

0 comments on commit 7986a5b

Please sign in to comment.