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

Function TestMasterKey_EncryptDecrypt_RoundTrip

pgp/keysource_test.go:513–531  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

511}
512
513func TestMasterKey_EncryptDecrypt_RoundTrip(t *testing.T) {
514 gnuPGHome, err := NewGnuPGHome()
515 assert.NoError(t, err)
516 t.Cleanup(func() {
517 _ = os.RemoveAll(gnuPGHome.String())
518 })
519 assert.NoError(t, gnuPGHome.ImportFile(mockPrivateKey))
520
521 key := NewMasterKeyFromFingerprint(mockFingerprint)
522 gnuPGHome.ApplyToMasterKey(key)
523
524 data := []byte("some secret data")
525 assert.NoError(t, key.Encrypt(data))
526 assert.NotEmpty(t, key.EncryptedKey)
527
528 decryptedData, err := key.Decrypt()
529 assert.NoError(t, err)
530 assert.Equal(t, data, decryptedData)
531}
532
533func TestMasterKey_NeedsRotation(t *testing.T) {
534 key := NewMasterKeyFromFingerprint("")

Callers

nothing calls this directly

Calls 8

StringMethod · 0.95
ImportFileMethod · 0.95
ApplyToMasterKeyMethod · 0.95
NewGnuPGHomeFunction · 0.85
CleanupMethod · 0.80
EncryptMethod · 0.65
DecryptMethod · 0.65

Tested by

no test coverage detected