public void ParameterizedTests( IEnvelopeEncryption <byte[]> envelopeEncryptionJson, Mock <IMetastore <JObject> > metastore, KeyState cacheIK, KeyState metaIK, KeyState cacheSK, KeyState metaSK, Partition partition) { using (Session <JObject, byte[]> sessionJsonImpl = new SessionJsonImpl <byte[]>(envelopeEncryptionJson)) { EncryptMetastoreInteractions encryptMetastoreInteractions = new EncryptMetastoreInteractions(cacheIK, metaIK, cacheSK, metaSK); DecryptMetastoreInteractions decryptMetastoreInteractions = new DecryptMetastoreInteractions(cacheIK, cacheSK); // encrypt with library object(sessionJsonImpl) byte[] encryptedPayload = sessionJsonImpl.Encrypt(payload); Assert.NotNull(encryptedPayload); VerifyEncryptFlow(metastore, encryptMetastoreInteractions, partition); metastore.Invocations.Clear(); JObject decryptedPayload = sessionJsonImpl.Decrypt(encryptedPayload); VerifyDecryptFlow(metastore, decryptMetastoreInteractions, partition); Assert.True(JToken.DeepEquals(payload, decryptedPayload)); } }
private void TestEncrypt() { const string expectedDataRowRecord = "some data row record"; const string json = @"{key:'some_key', value:123}"; JObject jObject = JObject.Parse(json); envelopeEncryptionMock.Setup(x => x.EncryptPayload(It.IsAny <byte[]>())).Returns(expectedDataRowRecord); string actualDataRowRecord = sessionJsonImpl.Encrypt(jObject); Assert.Equal(expectedDataRowRecord, actualDataRowRecord); }