MCPcopy Create free account
hub / github.com/PerpetualSoftware/pad / TestEncryptDecryptEmpty

Function TestEncryptDecryptEmpty

internal/store/encryption_test.go:74–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestEncryptDecryptEmpty(t *testing.T) {
75 s := testStore(t)
76
77 key := make([]byte, 32)
78 rand.Read(key)
79 s.SetEncryptionKey(key)
80
81 // Empty strings should pass through
82 encrypted, err := s.encrypt("")
83 if err != nil {
84 t.Fatalf("encrypt empty: %v", err)
85 }
86 if encrypted != "" {
87 t.Errorf("expected empty, got %q", encrypted)
88 }
89
90 decrypted, err := s.decrypt("")
91 if err != nil {
92 t.Fatalf("decrypt empty: %v", err)
93 }
94 if decrypted != "" {
95 t.Errorf("expected empty, got %q", decrypted)
96 }
97}
98
99func TestTOTPEncryptionRoundTrip(t *testing.T) {
100 s := testStore(t)

Callers

nothing calls this directly

Calls 5

testStoreFunction · 0.85
ReadMethod · 0.80
SetEncryptionKeyMethod · 0.80
encryptMethod · 0.80
decryptMethod · 0.80

Tested by

no test coverage detected