MCPcopy
hub / github.com/getsops/sops / TestMasterKey_EncryptIfNeeded

Function TestMasterKey_EncryptIfNeeded

hcvault/keysource_test.go:220–236  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

218}
219
220func TestMasterKey_EncryptIfNeeded(t *testing.T) {
221 if testSkipDocker {
222 return
223 }
224
225 key := NewMasterKey(testVaultAddress, testEnginePath, "encrypt-if-needed")
226 (Token(testVaultToken)).ApplyToMasterKey(key)
227 assert.NoError(t, createVaultKey(key))
228
229 assert.NoError(t, key.EncryptIfNeeded([]byte("stingy string")))
230
231 encryptedKey := key.EncryptedKey
232 assert.NotEmpty(t, encryptedKey)
233
234 assert.NoError(t, key.EncryptIfNeeded([]byte("stringy sting")))
235 assert.Equal(t, encryptedKey, key.EncryptedKey)
236}
237
238func TestMasterKey_EncryptedDataKey(t *testing.T) {
239 key := &MasterKey{EncryptedKey: "some key"}

Callers

nothing calls this directly

Calls 5

EncryptIfNeededMethod · 0.95
TokenTypeAlias · 0.85
createVaultKeyFunction · 0.85
NewMasterKeyFunction · 0.70
ApplyToMasterKeyMethod · 0.45

Tested by

no test coverage detected