Пример #1
0
 public async Task <SecretResponse> GetSecretAsync(string path, CancellationToken cancellationToken = default)
 {
     try
     {
         var slug = Normalize(path);
         return(await _secretsClient.GetSecretAsync(slug));
     }
     catch (ApiException ex)
     {
         throw ConvertException(ex);
     }
 }
        public async Task TestGetValue()
        {
            var secretPath = $"{_devOpsContext.BasePathPrefix}:{Guid.NewGuid().ToString()}";
            var value      = Guid.NewGuid().ToString();

            var tokenReturn = Task.FromResult(new AccessTokenResponse("access-token", 3600, tokenType: "bearer"));

            _tokensApi.TokenAsync("client_credentials", clientId: _devOpsContext.ClientId,
                                  clientSecret: _devOpsContext.ClientSecret)
            .Returns(tokenReturn);

            var secretReturn = Task.FromResult(new SecretResponse(path: secretPath,
                                                                  data: new Dictionary <string, object>()
            {
                { "password", value }
            }));

            _secretsApi.GetSecretAsync(secretPath)
            .Returns(secretReturn);

            var result = await _secureStore.GetValueAsync(_ctxString, secretPath);

            Assert.AreEqual(value, result);
        }