MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestEncryptDecryptCases

Function TestEncryptDecryptCases

client/toolkit/e2ee_test.go:85–109  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

83}
84
85func TestEncryptDecryptCases(t *testing.T) {
86 defaultLevel := log.GetLevel()
87 log.SetLevel(log.DebugLevel)
88 defer log.SetLevel(defaultLevel)
89 Convey("encrypt & decrypt cases", t, func() {
90 for i, c := range testCases {
91 in, _ := hex.DecodeString(c.raw)
92 pass := []byte(c.pass)
93 out, _ := hex.DecodeString(c.possibleEncrypted)
94 log.Infof("TestEncryptDecryptCases: %d", i)
95 enc, err := Encrypt(in, pass)
96 log.Debugf("Enc: %x", enc)
97 So(err, ShouldBeNil)
98 dec1, err := Decrypt(enc, pass)
99 if !bytes.Equal(dec1, in) {
100 t.Errorf("\nExpected:\n%x\nActual:\n%x\n", in, dec1)
101 }
102 dec2, err := Decrypt(out, pass)
103 So(err, ShouldBeNil)
104 if !bytes.Equal(dec2, in) {
105 t.Errorf("\nExpected:\n%x\nActual:\n%x\n", in, dec2)
106 }
107 }
108 })
109}
110
111func TestEncryptDecrypt(t *testing.T) {
112 var password = "CovenantSQL.io"

Callers

nothing calls this directly

Calls 7

GetLevelFunction · 0.92
SetLevelFunction · 0.92
InfofFunction · 0.92
DebugfFunction · 0.92
EncryptFunction · 0.85
DecryptFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected