MCPcopy
hub / github.com/dgraph-io/badger / TestEncryptionAndDecryption

Function TestEncryptionAndDecryption

key_registry_test.go:113–134  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

111}
112
113func TestEncryptionAndDecryption(t *testing.T) {
114 encryptionKey := make([]byte, 32)
115 dir, err := ioutil.TempDir("", "badger-test")
116 require.NoError(t, err)
117 defer removeDir(dir)
118 _, err = rand.Read(encryptionKey)
119 require.NoError(t, err)
120 opt := getRegistryTestOptions(dir, encryptionKey)
121 kr, err := OpenKeyRegistry(opt)
122 require.NoError(t, err)
123 dk, err := kr.latestDataKey()
124 require.NoError(t, err)
125 require.NoError(t, kr.Close())
126 // Checking the correctness of the datakey after closing and
127 // opening the key registry.
128 kr, err = OpenKeyRegistry(opt)
129 require.NoError(t, err)
130 dk1, err := kr.dataKey(dk.GetKeyId())
131 require.NoError(t, err)
132 require.Equal(t, dk.Data, dk1.Data)
133 require.NoError(t, kr.Close())
134}
135
136func TestKeyRegistryInMemory(t *testing.T) {
137 encryptionKey := make([]byte, 32)

Callers

nothing calls this directly

Calls 8

removeDirFunction · 0.85
getRegistryTestOptionsFunction · 0.85
OpenKeyRegistryFunction · 0.85
latestDataKeyMethod · 0.80
dataKeyMethod · 0.80
CloseMethod · 0.65
ReadMethod · 0.45
GetKeyIdMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…