public static KongRoute WithIdAndCreatedAtAndServiceReference(this KongRoute kongRoute, string serviceId) { kongRoute.WithIdAndCreatedAt(); kongRoute.Service = new KongRoute.ServiceReference { Id = serviceId }; return(kongRoute); }
public void Scenario6() { KongRoute route = null; this.Given(() => route = Fixture.Create <KongRoute>(), "A kong route") .And(s => s.KongRespondsCorrectly(HttpMethod.Delete, $"/routes/{route.Id}"), KongRespondsCorrectlyToMethodAtPathTextTemplate) .When(async() => await Subject.DeleteRoute(route.Id), Invoking(nameof(KongAdminWriter.DeleteRoute))) .Then("it succeeds") .BDDfy(); }
public static KongRoute AsTarget(this KongRoute kongRoute, bool modified = false) { var target = kongRoute.Clone(); if (modified) { target.Hosts = new [] { Guid.NewGuid().ToString() }; } return(target); }
public void Scenario5() { KongRoute route = null; this.Given(() => route = Fixture.Create <KongRoute>(), "A kong route") .And(s => s.KongRespondsCorrectly <KongRoute>(HttpMethod.Put, $"/routes/{route.Id}", route.ToJsonStringContent()), KongRespondsCorrectlyToMethodAtPathTextTemplate) .When(async() => await Subject.PutRoute(route), Invoking(nameof(KongAdminWriter.PutRoute))) .Then("it succeeds") .BDDfy(); }
public async Task AddRoute(string serviceId, KongRoute route) { var content = route.ToJsonStringContent(); var response = await HttpClient.PostAsync($"/services/{serviceId}/routes", content); var responseBody = await response.Content.ReadAsStringAsync(); var added = JsonConvert.DeserializeObject <KongRoute>(responseBody); route.Id = added.Id; route.Service = added.Service; }
public void Scenario4() { string serviceId = Guid.NewGuid().ToString(); KongRoute route = null; this.Given(() => route = Fixture.Build <KongRoute>().Without(x => x.Id).Create(), "A new kong route") .And(s => s.KongRespondsCorrectly <KongRoute>(HttpMethod.Post, $"/services/{serviceId}/routes", route.ToJsonStringContent(), x => x.WithIdAndCreatedAtAndServiceReference(serviceId)), KongRespondsCorrectlyToMethodAtPathTextTemplate) .When(async() => await Subject.AddRoute(serviceId, route), Invoking(nameof(KongAdminWriter.AddRoute))) .Then(() => route.Id.Should().NotBeNullOrWhiteSpace(), "the Id is set") .And(() => route.Service.Id.Should().Be(serviceId), "the ServiceReference is set") .BDDfy(); }
public async Task AddRoute(string serviceId, KongRoute route) { Log.Information(@"Adding route {route}", route); var content = route.ToJsonStringContent(); try { var response = await HttpClient.PostAsync($"/services/{serviceId}/routes", content); var responseBody = await response.Content.ReadAsStringAsync(); var added = JsonConvert.DeserializeObject <KongRoute>(responseBody); route.Id = added.Id; route.Service = added.Service; } catch (Exception e) { Log.Error(e, e.Message); throw; } }
public static bool CorrespondsToKongRoute(this KongPlugin kongPlugin, KongRoute kongRoute) => kongPlugin.Route?.Id == kongRoute.Id && !string.IsNullOrWhiteSpace(kongPlugin.Route?.Id) && kongPlugin.Consumer?.Id == null && kongPlugin.Service?.Id == null;
public Task PutRoute(KongRoute route) => PutKongObject("/routes", route);
public Task AddRoute(string serviceId, KongRoute route) { Log.Information(@"Adding route {route}", route); route.Id = Guid.NewGuid().ToString(); return(Task.CompletedTask); }
public Task AddRoute(string serviceId, KongRoute route) => Task.CompletedTask;
public Task PutRoute(KongRoute route) => Task.CompletedTask;