public async Task UpsertAsync_UpdateVariableByExistingKey_SuccessfullyUpdated() { // Arrange VariableValue variableValue = new VariableValue( Guid.Parse("4674d60d-7f3e-4b54-8bfb-b484303f62b0"), new VariableKey( Guid.Parse("98047CEA-E467-4D7A-8EB1-73F617BDCF75"), null, null, null), "This is a insertion test.", null, 0); InsertVariableValues(variableValue); variableValue = variableValue with { Value = "Updated variable Value", Encryption = new VariableEncryptionInfo("AzureKeyVault", "xyz", "AES256") }; VariableValueStore variableValueStore = new VariableValueStore(_docuStoreDbContext); // Act await variableValueStore.SaveAsync(variableValue, default); // Assert Snapshot.Match(GetVariableValueDump()); }
public Task <string> DecryptAsync( string encryptedValue, VariableEncryptionInfo encryptionInfo, CancellationToken cancellationToken) { return(Task.FromResult(new string(encryptedValue.Reverse().ToArray()))); }
public async Task <string> DecryptAsync( string cipherValue, VariableEncryptionInfo encryptionInfo, CancellationToken cancellationToken) { EncryptionAlgorithm algorithm = new EncryptionAlgorithm(encryptionInfo.Algorithm); CryptographyClient cryptoClient = _clientFactory .CreateDecryptionClient(encryptionInfo.Key); DecryptResult result = await cryptoClient.DecryptAsync( algorithm, Convert.FromBase64String(cipherValue), cancellationToken); return(Encoding.UTF8.GetString(result.Plaintext)); }