mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-10-31 23:15:28 +08:00 
			
		
		
		
	Updated manual testing configuration and added postman scripts for it
This commit is contained in:
		| @@ -1,5 +1,6 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Text; | ||||
| using Microsoft.Extensions.Logging; | ||||
| using Microsoft.Extensions.Options; | ||||
| using Ocelot.Configuration.Parser; | ||||
| @@ -48,18 +49,26 @@ namespace Ocelot.Configuration.Creator | ||||
|         { | ||||
|             var response = _configurationValidator.IsValid(_options.Value); | ||||
|  | ||||
|             var reRoutes = new List<ReRoute>(); | ||||
|  | ||||
|             if (!response.IsError && !response.Data.IsError) | ||||
|             if (response.Data.IsError) | ||||
|             { | ||||
|                 var errorBuilder = new StringBuilder(); | ||||
|  | ||||
|                 foreach (var yamlReRoute in _options.Value.ReRoutes) | ||||
|                 foreach (var error in response.Errors) | ||||
|                 { | ||||
|                     var ocelotReRoute = SetUpReRoute(yamlReRoute); | ||||
|                     reRoutes.Add(ocelotReRoute); | ||||
|                     errorBuilder.AppendLine(error.Message); | ||||
|                 } | ||||
|  | ||||
|                 throw new Exception($"Unable to start Ocelot..configuration, errors were {errorBuilder}"); | ||||
|             } | ||||
|  | ||||
|             var reRoutes = new List<ReRoute>(); | ||||
|  | ||||
|             foreach (var yamlReRoute in _options.Value.ReRoutes) | ||||
|             { | ||||
|                 var ocelotReRoute = SetUpReRoute(yamlReRoute); | ||||
|                 reRoutes.Add(ocelotReRoute); | ||||
|             } | ||||
|              | ||||
|             return new OcelotConfiguration(reRoutes); | ||||
|         } | ||||
|  | ||||
|   | ||||
							
								
								
									
										184
									
								
								test/Ocelot.ManualTest/Ocelot.postman_collection.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										184
									
								
								test/Ocelot.ManualTest/Ocelot.postman_collection.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,184 @@ | ||||
| { | ||||
| 	"id": "4dbde9fe-89f5-be35-bb9f-d3b438e16375", | ||||
| 	"name": "Ocelot", | ||||
| 	"description": "", | ||||
| 	"order": [ | ||||
| 		"a1c95935-ed18-d5dc-bcb8-a3db8ba1934f", | ||||
| 		"ea0ed57a-2cb9-8acc-47dd-006b8db2f1b2", | ||||
| 		"c4494401-3985-a5bf-71fb-6e4171384ac6", | ||||
| 		"09af8dda-a9cb-20d2-5ee3-0a3023773a1a", | ||||
| 		"e8825dc3-4137-99a7-0000-ef5786610dc3", | ||||
| 		"fddfc4fa-5114-69e3-4744-203ed71a526b", | ||||
| 		"c45d30d7-d9c4-fa05-8110-d6e769bb6ff9", | ||||
| 		"4684c2fa-f38c-c193-5f55-bf563a1978c6" | ||||
| 	], | ||||
| 	"folders": [], | ||||
| 	"timestamp": 1477767328599, | ||||
| 	"owner": "212120", | ||||
| 	"public": false, | ||||
| 	"requests": [ | ||||
| 		{ | ||||
| 			"id": "09af8dda-a9cb-20d2-5ee3-0a3023773a1a", | ||||
| 			"headers": "", | ||||
| 			"url": "http://localhost:5000/comments?postId=1", | ||||
| 			"pathVariables": {}, | ||||
| 			"preRequestScript": null, | ||||
| 			"method": "GET", | ||||
| 			"collectionId": "4dbde9fe-89f5-be35-bb9f-d3b438e16375", | ||||
| 			"data": null, | ||||
| 			"dataMode": "params", | ||||
| 			"name": "GET http://localhost:5000/comments?postId=1", | ||||
| 			"description": "", | ||||
| 			"descriptionFormat": "html", | ||||
| 			"time": 1477768105592, | ||||
| 			"version": 2, | ||||
| 			"responses": [], | ||||
| 			"tests": null, | ||||
| 			"currentHelper": "normal", | ||||
| 			"helperAttributes": {} | ||||
| 		}, | ||||
| 		{ | ||||
| 			"id": "4684c2fa-f38c-c193-5f55-bf563a1978c6", | ||||
| 			"headers": "", | ||||
| 			"url": "http://localhost:5000/posts/1", | ||||
| 			"pathVariables": {}, | ||||
| 			"preRequestScript": null, | ||||
| 			"method": "DELETE", | ||||
| 			"collectionId": "4dbde9fe-89f5-be35-bb9f-d3b438e16375", | ||||
| 			"data": null, | ||||
| 			"dataMode": "params", | ||||
| 			"name": "DELETE http://localhost:5000/posts/1", | ||||
| 			"description": "", | ||||
| 			"descriptionFormat": "html", | ||||
| 			"time": 1477768404376, | ||||
| 			"version": 2, | ||||
| 			"responses": [], | ||||
| 			"tests": null, | ||||
| 			"currentHelper": "normal", | ||||
| 			"helperAttributes": {} | ||||
| 		}, | ||||
| 		{ | ||||
| 			"id": "a1c95935-ed18-d5dc-bcb8-a3db8ba1934f", | ||||
| 			"headers": "", | ||||
| 			"url": "http://localhost:5000/posts", | ||||
| 			"pathVariables": {}, | ||||
| 			"preRequestScript": null, | ||||
| 			"method": "GET", | ||||
| 			"collectionId": "4dbde9fe-89f5-be35-bb9f-d3b438e16375", | ||||
| 			"data": null, | ||||
| 			"dataMode": "params", | ||||
| 			"name": "GET http://localhost:5000/posts", | ||||
| 			"description": "", | ||||
| 			"descriptionFormat": "html", | ||||
| 			"time": 1477768007806, | ||||
| 			"version": 2, | ||||
| 			"responses": [], | ||||
| 			"tests": null, | ||||
| 			"currentHelper": "normal", | ||||
| 			"helperAttributes": {} | ||||
| 		}, | ||||
| 		{ | ||||
| 			"id": "c4494401-3985-a5bf-71fb-6e4171384ac6", | ||||
| 			"headers": "", | ||||
| 			"url": "http://localhost:5000/posts/1/comments", | ||||
| 			"pathVariables": {}, | ||||
| 			"preRequestScript": null, | ||||
| 			"method": "GET", | ||||
| 			"collectionId": "4dbde9fe-89f5-be35-bb9f-d3b438e16375", | ||||
| 			"data": null, | ||||
| 			"dataMode": "params", | ||||
| 			"name": "GET http://localhost:5000/posts/1/comments", | ||||
| 			"description": "", | ||||
| 			"descriptionFormat": "html", | ||||
| 			"time": 1477768043524, | ||||
| 			"version": 2, | ||||
| 			"responses": [], | ||||
| 			"tests": null, | ||||
| 			"currentHelper": "normal", | ||||
| 			"helperAttributes": {} | ||||
| 		}, | ||||
| 		{ | ||||
| 			"id": "c45d30d7-d9c4-fa05-8110-d6e769bb6ff9", | ||||
| 			"headers": "", | ||||
| 			"url": "http://localhost:5000/posts/1", | ||||
| 			"pathVariables": {}, | ||||
| 			"preRequestScript": null, | ||||
| 			"method": "PATCH", | ||||
| 			"collectionId": "4dbde9fe-89f5-be35-bb9f-d3b438e16375", | ||||
| 			"data": [], | ||||
| 			"dataMode": "raw", | ||||
| 			"name": "PATCH http://localhost:5000/posts/1", | ||||
| 			"description": "", | ||||
| 			"descriptionFormat": "html", | ||||
| 			"time": 1477768379775, | ||||
| 			"version": 2, | ||||
| 			"responses": [], | ||||
| 			"tests": null, | ||||
| 			"currentHelper": "normal", | ||||
| 			"helperAttributes": {}, | ||||
| 			"rawModeData": "{\n  \"title\": \"gfdgsgsdgsdfgsdfgdfg\",\n}" | ||||
| 		}, | ||||
| 		{ | ||||
| 			"id": "e8825dc3-4137-99a7-0000-ef5786610dc3", | ||||
| 			"headers": "", | ||||
| 			"url": "http://localhost:5000/posts", | ||||
| 			"pathVariables": {}, | ||||
| 			"preRequestScript": null, | ||||
| 			"method": "POST", | ||||
| 			"collectionId": "4dbde9fe-89f5-be35-bb9f-d3b438e16375", | ||||
| 			"data": [], | ||||
| 			"dataMode": "raw", | ||||
| 			"name": "POST http://localhost:5000/posts/1", | ||||
| 			"description": "", | ||||
| 			"descriptionFormat": "html", | ||||
| 			"time": 1477768186023, | ||||
| 			"version": 2, | ||||
| 			"responses": [], | ||||
| 			"tests": null, | ||||
| 			"currentHelper": "normal", | ||||
| 			"helperAttributes": {}, | ||||
| 			"rawModeData": "{\n  \"userId\": 1,\n  \"title\": \"test\",\n  \"body\": \"test\"\n}" | ||||
| 		}, | ||||
| 		{ | ||||
| 			"id": "ea0ed57a-2cb9-8acc-47dd-006b8db2f1b2", | ||||
| 			"headers": "", | ||||
| 			"url": "http://localhost:5000/posts/1", | ||||
| 			"pathVariables": {}, | ||||
| 			"preRequestScript": null, | ||||
| 			"method": "GET", | ||||
| 			"collectionId": "4dbde9fe-89f5-be35-bb9f-d3b438e16375", | ||||
| 			"data": null, | ||||
| 			"dataMode": "params", | ||||
| 			"name": "GET http://localhost:5000/posts/1", | ||||
| 			"description": "", | ||||
| 			"descriptionFormat": "html", | ||||
| 			"time": 1477768023989, | ||||
| 			"version": 2, | ||||
| 			"responses": [], | ||||
| 			"tests": null, | ||||
| 			"currentHelper": "normal", | ||||
| 			"helperAttributes": {} | ||||
| 		}, | ||||
| 		{ | ||||
| 			"id": "fddfc4fa-5114-69e3-4744-203ed71a526b", | ||||
| 			"headers": "", | ||||
| 			"url": "http://localhost:5000/posts/1", | ||||
| 			"pathVariables": {}, | ||||
| 			"preRequestScript": null, | ||||
| 			"method": "PUT", | ||||
| 			"collectionId": "4dbde9fe-89f5-be35-bb9f-d3b438e16375", | ||||
| 			"data": [], | ||||
| 			"dataMode": "raw", | ||||
| 			"name": "PUT http://localhost:5000/posts/1", | ||||
| 			"description": "", | ||||
| 			"descriptionFormat": "html", | ||||
| 			"time": 1477768307036, | ||||
| 			"version": 2, | ||||
| 			"responses": [], | ||||
| 			"tests": null, | ||||
| 			"currentHelper": "normal", | ||||
| 			"helperAttributes": {}, | ||||
| 			"rawModeData": "{\n  \"userId\": 1,\n  \"title\": \"test\",\n  \"body\": \"test\"\n}" | ||||
| 		} | ||||
| 	] | ||||
| } | ||||
| @@ -30,7 +30,7 @@ ReRoutes: | ||||
| # it as a claim with the given key before the colon (:). The index selection on value  | ||||
| # means that Ocelot will use the delimiter specified after the next > to split the  | ||||
| # claim value and return the index specified. | ||||
| AddClaimsToRequest: | ||||
|   AddClaimsToRequest: | ||||
|     CustomerId: Claims[CustomerId] > value | ||||
|     LocationId: Claims[LocationId] > value | ||||
|     UserType: Claims[sub] > value[0] > | | ||||
| @@ -40,7 +40,7 @@ AddClaimsToRequest: | ||||
| # it as a query string with the given key before the colon (:). The index selection on value  | ||||
| # means that Ocelot will use the delimiter specified after the next > to split the  | ||||
| # claim value and return the index specified. | ||||
| AddQueriesToRequest: | ||||
|   AddQueriesToRequest: | ||||
|     CustomerId: Claims[CustomerId] > value | ||||
|     LocationId: Claims[LocationId] > value | ||||
|     UserType: Claims[sub] > value[0] > | | ||||
| @@ -48,9 +48,37 @@ AddQueriesToRequest: | ||||
| # This specifies any claims that are required for the user to access this re route. | ||||
| # In this example the user must have the claim type UserType and  | ||||
| # the value must be registered | ||||
| RouteClaimsRequirement: | ||||
|   RouteClaimsRequirement: | ||||
|     UserType: registered | ||||
| # The next re route... | ||||
| - DownstreamTemplate: http://jsonplaceholder.typicode.com/posts | ||||
|   UpstreamTemplate: /posts | ||||
|   UpstreamHttpMethod: Get | ||||
| # The next re route... | ||||
| - DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId} | ||||
|   UpstreamTemplate: /posts/{postId} | ||||
|   UpstreamHttpMethod: Get | ||||
| # The next re route... | ||||
| - DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId}/comments | ||||
|   UpstreamTemplate: /posts/{postId}/comments | ||||
|   UpstreamHttpMethod: Get | ||||
| # The next re route... | ||||
| - DownstreamTemplate: http://jsonplaceholder.typicode.com/comments | ||||
|   UpstreamTemplate: /comments | ||||
|   UpstreamHttpMethod: Get | ||||
| # The next re route... | ||||
| - DownstreamTemplate: http://jsonplaceholder.typicode.com/posts | ||||
|   UpstreamTemplate: /posts | ||||
|   UpstreamHttpMethod: Post | ||||
| # The next re route... | ||||
| - DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId} | ||||
|   UpstreamTemplate: /posts/{postId} | ||||
|   UpstreamHttpMethod: Put | ||||
| # The next re route... | ||||
| - DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId} | ||||
|   UpstreamTemplate: /posts/{postId} | ||||
|   UpstreamHttpMethod: Patch | ||||
| # The next re route... | ||||
| - DownstreamTemplate: http://jsonplaceholder.typicode.com/posts/{postId} | ||||
|   UpstreamTemplate: /posts/{postId} | ||||
|   UpstreamHttpMethod: Delete | ||||
		Reference in New Issue
	
	Block a user
	 TomPallister
					TomPallister