(t *testing.T)
| 307 | } |
| 308 | |
| 309 | func TestMasterKey_EncryptIfNeeded(t *testing.T) { |
| 310 | gnuPGHome, err := NewGnuPGHome() |
| 311 | assert.NoError(t, err) |
| 312 | t.Cleanup(func() { |
| 313 | _ = os.RemoveAll(gnuPGHome.String()) |
| 314 | }) |
| 315 | assert.NoError(t, gnuPGHome.ImportFile(mockPrivateKey)) |
| 316 | |
| 317 | key := NewMasterKeyFromFingerprint(mockFingerprint) |
| 318 | gnuPGHome.ApplyToMasterKey(key) |
| 319 | assert.NoError(t, key.EncryptIfNeeded([]byte("data"))) |
| 320 | |
| 321 | encryptedKey := key.EncryptedKey |
| 322 | assert.Contains(t, encryptedKey, "END PGP MESSAGE") |
| 323 | |
| 324 | assert.NoError(t, key.EncryptIfNeeded([]byte("some other data"))) |
| 325 | assert.Equal(t, encryptedKey, key.EncryptedKey) |
| 326 | } |
| 327 | |
| 328 | func TestMasterKey_EncryptedDataKey(t *testing.T) { |
| 329 | key := &MasterKey{EncryptedKey: "some key"} |
nothing calls this directly
no test coverage detected