forked from jriou/coller
feat: Rename password by encryption key
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
634326190c
commit
8e1dd686d3
16 changed files with 118 additions and 117 deletions
|
@ -6,10 +6,10 @@ import (
|
|||
|
||||
func TestEncryptAndDecrypt(t *testing.T) {
|
||||
plaintext := "test"
|
||||
password := "test"
|
||||
wrongPassword := password + "wrong"
|
||||
encryptionKey := "test"
|
||||
wrongEncryptionKey := encryptionKey + "wrong"
|
||||
|
||||
ciphertext, err := Encrypt([]byte(plaintext), password)
|
||||
ciphertext, err := Encrypt([]byte(plaintext), encryptionKey)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error when encrypting: %v", err)
|
||||
return
|
||||
|
@ -20,7 +20,7 @@ func TestEncryptAndDecrypt(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
cleartext, err := Decrypt(ciphertext, password)
|
||||
cleartext, err := Decrypt(ciphertext, encryptionKey)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error when decrypting: %v", err)
|
||||
return
|
||||
|
@ -31,14 +31,14 @@ func TestEncryptAndDecrypt(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
if password == wrongPassword {
|
||||
t.Errorf("passwords must be different")
|
||||
if encryptionKey == wrongEncryptionKey {
|
||||
t.Errorf("encryption keys must be different")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = Decrypt(ciphertext, wrongPassword)
|
||||
_, err = Decrypt(ciphertext, wrongEncryptionKey)
|
||||
if err == nil {
|
||||
t.Errorf("expected error when decrypting with a wrong password, got none")
|
||||
t.Errorf("expected error when decrypting with a wrong encryption key, got none")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue