Exemple #1
0
        async void getSecretButton_Click(object sender, EventArgs e)
        {
            var   path = pathTextBox.Text;
            Lease lease;

            try
            {
                lease = await _client.LeaseAsync(path);
            }
            catch (Exception ex)
            {
                var type = ex.GetType();
                MessageBox.Show(ex.Message + "(" + type.Name + ")", "Error");
                return;
            }

            if (lease == null)
            {
                MessageBox.Show("Path not found: " + path);
                return;
            }

            var values = lease.Data
                         .Select(d => new Pair <string, object>(d.Key, d.Value))
                         .ToList();

            _secretValues = new BindingList <Pair <string, object> >(values);
            secretDataGridView.DataSource = _secretValues;
        }
        public async Task CanWriteAndReadSecrets()
        {
            var path          = "secret/foo";
            var expectedValue = Guid.NewGuid().ToString();
            var obj           = new Dictionary <string, object>()
            {
                { "Value", expectedValue }
            };
            var vault = new VaultClient(_uri, _token);
            await vault.WriteSecretAsync(path, obj);

            var result = await vault.LeaseAsync(path);

            Assert.NotNull(result);
            Assert.Equal(expectedValue, result.Data["Value"]);
        }
 public async Task CanWriteAndReadSecrets()
 {
     var path = "secret/foo";
     var expectedValue = Guid.NewGuid().ToString();
     var obj = new Dictionary<string, object>() { { "Value", expectedValue } };
     var vault = new VaultClient(_uri, _token);
     await vault.WriteSecretAsync(path, obj);
     var result = await vault.LeaseAsync(path);
     Assert.NotNull(result);
     Assert.Equal(expectedValue, result.Data["Value"]);
 }