public async Task <IHttpActionResult> Post(UpdateConfigurationRequest updateConfiguration)
        {
            var apiKey = updateConfiguration.ApiKey;

            var hostForwardSettings = await _apiSettingsData.GetByApiKeyAsync(apiKey);

            if (hostForwardSettings == null)
            {
                return(BadRequest(Constants.InvalidApiKey));
            }

            var chaosConfiguration = UpdateRequestToConfigurationConverter.ToChaosConfiguration(updateConfiguration);

            if (!chaosConfiguration.IsValid())
            {
                return(BadRequest(chaosConfiguration.ValidationErrors.AsFormattingString()));
            }

            await _chaosConfigurationSettings.CreateOrUpdateAsync(hostForwardSettings, apiKey, chaosConfiguration);

            _cacheInvalidator.Invalidate(apiKey);

            return(Created(hostForwardSettings.ForwardApiHostName, chaosConfiguration));
        }
Exemplo n.º 2
0
        public void Given_I_Have_Converted_A_Request_To_An_Api_Configueration()
        {
            var updateConfigurationRequest = BuildRequest();

            _apiConfiguration = UpdateRequestToConfigurationConverter.ToChaosConfiguration(updateConfigurationRequest);
        }