MCPcopy Index your code
hub / github.com/getsops/sops / TestMasterKey_EncryptDecrypt_RoundTrip

Function TestMasterKey_EncryptDecrypt_RoundTrip

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

Source from the content-addressed store, hash-verified

322}
323
324func TestMasterKey_EncryptDecrypt_RoundTrip(t *testing.T) {
325 encryptKey, err := MasterKeyFromRecipient(mockRecipient)
326 assert.NoError(t, err)
327
328 data := []byte("some secret data")
329 assert.NoError(t, encryptKey.Encrypt(data))
330 assert.NotEmpty(t, encryptKey.EncryptedKey)
331
332 var ids ParsedIdentities
333 assert.NoError(t, ids.Import(mockIdentity))
334
335 decryptKey := &MasterKey{}
336 decryptKey.EncryptedKey = encryptKey.EncryptedKey
337 ids.ApplyToMasterKey(decryptKey)
338
339 decryptedData, err := decryptKey.Decrypt()
340 assert.NoError(t, err)
341 assert.Equal(t, data, decryptedData)
342}
343
344func TestMasterKey_NeedsRotation(t *testing.T) {
345 key := &MasterKey{Recipient: mockRecipient}

Callers

nothing calls this directly

Calls 5

ImportMethod · 0.95
ApplyToMasterKeyMethod · 0.95
DecryptMethod · 0.95
MasterKeyFromRecipientFunction · 0.85
EncryptMethod · 0.65

Tested by

no test coverage detected