mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-10-31 23:15:28 +08:00 
			
		
		
		
	first acceptance test failing..
This commit is contained in:
		| @@ -1,5 +1,6 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Threading.Tasks; | ||||
| using Ocelot.Configuration.Provider; | ||||
| using Ocelot.Logging; | ||||
| @@ -33,9 +34,11 @@ namespace Ocelot.Cache | ||||
|                 return new List<string>(); | ||||
|             } | ||||
|  | ||||
|             var cachedReRoutes = config.Data.ReRoutes.Where(x => x.IsCached); | ||||
|              | ||||
|             var regions = new List<string>(); | ||||
|  | ||||
|             foreach(var reRoute in config.Data.ReRoutes) | ||||
|             foreach(var reRoute in cachedReRoutes) | ||||
|             { | ||||
|                 var region = _creator.Region(reRoute); | ||||
|                 regions.Add(region); | ||||
|   | ||||
| @@ -7,7 +7,7 @@ using Ocelot.Configuration.Provider; | ||||
| namespace Ocelot.Controllers | ||||
| { | ||||
|     [Authorize] | ||||
|     [Route("cache")] | ||||
|     [Route("outputcache")] | ||||
|     public class OutputCacheController : Controller | ||||
|     { | ||||
|         private IOcelotCache<HttpResponseMessage> _cache; | ||||
|   | ||||
| @@ -218,6 +218,63 @@ namespace Ocelot.IntegrationTests | ||||
|                 .BDDfy(); | ||||
|         } | ||||
|  | ||||
|         [Fact] | ||||
|         public void should_return_regions() | ||||
|         { | ||||
|  | ||||
|             var initialConfiguration = new FileConfiguration | ||||
|             { | ||||
|                 GlobalConfiguration = new FileGlobalConfiguration | ||||
|                 { | ||||
|                     AdministrationPath = "/administration" | ||||
|                 }, | ||||
|                 ReRoutes = new List<FileReRoute>() | ||||
|                 { | ||||
|                     new FileReRoute() | ||||
|                     { | ||||
|                         DownstreamHost = "localhost", | ||||
|                         DownstreamPort = 80, | ||||
|                         DownstreamScheme = "https", | ||||
|                         DownstreamPathTemplate = "/", | ||||
|                         UpstreamHttpMethod = new List<string> { "get" }, | ||||
|                         UpstreamPathTemplate = "/", | ||||
|                         FileCacheOptions = new FileCacheOptions | ||||
|                         { | ||||
|                             TtlSeconds = 10 | ||||
|                         } | ||||
|                     }, | ||||
|                     new FileReRoute() | ||||
|                     { | ||||
|                         DownstreamHost = "localhost", | ||||
|                         DownstreamPort = 80, | ||||
|                         DownstreamScheme = "https", | ||||
|                         DownstreamPathTemplate = "/", | ||||
|                         UpstreamHttpMethod = new List<string> { "get" }, | ||||
|                         UpstreamPathTemplate = "/test", | ||||
|                         FileCacheOptions = new FileCacheOptions | ||||
|                         { | ||||
|                             TtlSeconds = 10 | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             }; | ||||
|  | ||||
|             var expected = new List<string> | ||||
|             { | ||||
|                 "get /", | ||||
|                 "get /test" | ||||
|             }; | ||||
|  | ||||
|             this.Given(x => GivenThereIsAConfiguration(initialConfiguration)) | ||||
|                 .And(x => GivenOcelotIsRunning()) | ||||
|                 .And(x => GivenIHaveAnOcelotToken("/administration")) | ||||
|                 .And(x => GivenIHaveAddedATokenToMyRequest()) | ||||
|                 .When(x => WhenIGetUrlOnTheApiGateway("/administration/outputcache")) | ||||
|                 .Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK)) | ||||
|                 .And(x => ThenTheResponseShouldBe(expected)) | ||||
|                 .BDDfy(); | ||||
|         } | ||||
|  | ||||
|         private void GivenAnotherOcelotIsRunning(string baseUrl) | ||||
|         { | ||||
|             _httpClientTwo.BaseAddress = new Uri(baseUrl); | ||||
| @@ -256,6 +313,13 @@ namespace Ocelot.IntegrationTests | ||||
|             _response = _httpClient.PostAsync(url, content).Result; | ||||
|         } | ||||
|  | ||||
|         private void ThenTheResponseShouldBe(List<string> expected) | ||||
|         { | ||||
|             var content = _response.Content.ReadAsStringAsync().Result; | ||||
|             var result = JsonConvert.DeserializeObject<List<string>>(content); | ||||
|             result.ShouldBe(expected); | ||||
|         } | ||||
|  | ||||
|         private void ThenTheResponseShouldBe(FileConfiguration expected) | ||||
|         { | ||||
|             var response = JsonConvert.DeserializeObject<FileConfiguration>(_response.Content.ReadAsStringAsync().Result); | ||||
|   | ||||
| @@ -38,9 +38,13 @@ namespace Ocelot.UnitTests.Cache | ||||
|         [Fact] | ||||
|         public void should_get_regions() | ||||
|         { | ||||
|             var cacheOptions = new CacheOptions(12); | ||||
|  | ||||
|             var reRoute = new ReRouteBuilder() | ||||
|                 .WithUpstreamHttpMethod(new List<string>{"Get"}) | ||||
|                 .WithUpstreamPathTemplate("/") | ||||
|                 .WithCacheOptions(cacheOptions) | ||||
|                 .WithIsCached(true) | ||||
|                 .Build(); | ||||
|  | ||||
|             var reRoutes = new List<ReRoute> | ||||
| @@ -62,7 +66,7 @@ namespace Ocelot.UnitTests.Cache | ||||
|                 .BDDfy(); | ||||
|         } | ||||
|  | ||||
|            [Fact] | ||||
|         [Fact] | ||||
|         public void should_return_empty_regions() | ||||
|         { | ||||
|             var expected = new List<string>(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Tom Gardham-Pallister
					Tom Gardham-Pallister