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

Function TestMasterKey_EncryptIfNeeded

age/keysource_test.go:227–238  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

225}
226
227func TestMasterKey_EncryptIfNeeded(t *testing.T) {
228 key, err := MasterKeyFromRecipient(mockRecipient)
229 assert.NoError(t, err)
230
231 assert.NoError(t, key.EncryptIfNeeded([]byte(mockEncryptedKeyPlain)))
232
233 encryptedKey := key.EncryptedKey
234 assert.Contains(t, encryptedKey, "AGE ENCRYPTED FILE")
235
236 assert.NoError(t, key.EncryptIfNeeded([]byte("some other data")))
237 assert.Equal(t, encryptedKey, key.EncryptedKey)
238}
239
240func TestMasterKey_EncryptedDataKey(t *testing.T) {
241 key := &MasterKey{EncryptedKey: "some key"}

Callers

nothing calls this directly

Calls 2

MasterKeyFromRecipientFunction · 0.85
EncryptIfNeededMethod · 0.65

Tested by

no test coverage detected