private async Task <DestinationInfo> GetDestinationInfo(CancellationToken cancellationToken)
        {
            SecretWrapper secret = await _secretStore.GetSecretAsync(_exportJobRecord.SecretName, cancellationToken);

            DestinationInfo destinationInfo = JsonConvert.DeserializeObject <DestinationInfo>(secret.SecretValue);

            return(destinationInfo);
        }
        // Get destination info from secret store, create appropriate export client and connect to destination.
        private async Task GetDestinationInfoAndConnectAsync(CancellationToken cancellationToken)
        {
            SecretWrapper secret = await _secretStore.GetSecretAsync(_exportJobRecord.SecretName, cancellationToken);

            DestinationInfo destinationInfo = JsonConvert.DeserializeObject <DestinationInfo>(secret.SecretValue);

            _exportDestinationClient = _exportDestinationClientFactory.Create(destinationInfo.DestinationType);

            await _exportDestinationClient.ConnectAsync(destinationInfo.DestinationConnectionString, cancellationToken, _exportJobRecord.Id);
        }
        public Task <SecretWrapper> GetSecretAsync(string secretName, CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNullOrWhiteSpace(secretName);

            SecretWrapper wrapper = null;

            if (_secrets.TryGetValue(secretName, out string secretValue))
            {
                wrapper = new SecretWrapper(secretName, secretValue);
            }

            return(Task.FromResult(wrapper));
        }
        public async Task GivenThereIsNoMatchingJob_WhenCreatingAnExportJob_ThenNewJobShouldBeCreated()
        {
            var request = new CreateExportRequest(RequestUrl, DestinationType, ConnectionString);

            CreateExportResponse response = await _createExportRequestHandler.Handle(request, _cancellationToken);

            Assert.NotNull(response);
            Assert.NotEmpty(response.JobId);

            SecretWrapper secret = await _secretStore.GetSecretAsync($"Export-Destination-{response.JobId}");

            Assert.NotNull(secret);
        }
Exemple #5
0
        public Task <SecretWrapper> DeleteSecretAsync(string secretName)
        {
            EnsureArg.IsNotNullOrWhiteSpace(secretName);

            SecretWrapper wrapper = null;

            if (_secrets.TryGetValue(secretName, out string secretValue))
            {
                wrapper = new SecretWrapper(secretName, secretValue);
                _secrets.Remove(secretName);
            }

            return(Task.FromResult(wrapper));
        }
        public Task <SecretWrapper> GetSecretAsync(string secretName, CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNullOrWhiteSpace(secretName);

            SecretWrapper wrapper = null;

            if (_secrets.TryGetValue(secretName, out string secretValue))
            {
                wrapper = new SecretWrapper(secretName, secretValue);
            }
            else
            {
                throw new SecretStoreException(SecretStoreErrors.GetSecretError, innerException: null, HttpStatusCode.InternalServerError);
            }

            return(Task.FromResult(wrapper));
        }