MCPcopy
hub / github.com/zalando/skipper / TestEncryptDecrypt

Function TestEncryptDecrypt

secrets/user_test.go:11–35  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func 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
37func TestCreateNonce(t *testing.T) {
38 tr := secrettest.NewTestRegistry()

Callers

nothing calls this directly

Calls 6

GetEncrypterMethod · 0.95
NewTestRegistryFunction · 0.92
EncryptMethod · 0.65
ErrorfMethod · 0.65
ErrorMethod · 0.65
DecryptMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…