(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestEncryptDecrypt(t *testing.T) { |
| 12 | s := "mysecret" |
| 13 | tr := secrettest.NewTestRegistry() |
| 14 | enc, err := tr.GetEncrypter(10*time.Minute, "TestEncryptDecrypt") |
| 15 | if err != nil { |
| 16 | t.Fatalf("Failed to create test Encrypter: %v", err) |
| 17 | } |
| 18 | |
| 19 | b := []byte(s) |
| 20 | encB, err := enc.Encrypt(b) |
| 21 | if err != nil { |
| 22 | t.Errorf("Failed to encrypt data: %v", err) |
| 23 | } |
| 24 | if reflect.DeepEqual(b, encB) { |
| 25 | t.Error("Encrypted data has the same byte sequence as the data itself") |
| 26 | } |
| 27 | |
| 28 | decB, err := enc.Decrypt(encB) |
| 29 | if err != nil { |
| 30 | t.Errorf("Failed to decrypt data: %v", err) |
| 31 | } |
| 32 | if !reflect.DeepEqual(b, decB) { |
| 33 | t.Error("Decrypted and encrypted data has to be the same byte sequence as the data itself") |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | func TestCreateNonce(t *testing.T) { |
| 38 | tr := secrettest.NewTestRegistry() |
nothing calls this directly
no test coverage detected
searching dependent graphs…