mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 16:10:50 +08:00 
			
		
		
		
	test passing with authentication being provided by the user and mapped to the re route in config
This commit is contained in:
		@@ -1,8 +1,6 @@
 | 
			
		||||
namespace Ocelot.UnitTests.TestData
 | 
			
		||||
{
 | 
			
		||||
    using System.Collections.Generic;
 | 
			
		||||
 | 
			
		||||
    using Ocelot.Configuration.Builder;
 | 
			
		||||
    using Ocelot.Configuration.File;
 | 
			
		||||
 | 
			
		||||
    public class AuthenticationConfigTestData
 | 
			
		||||
@@ -11,31 +9,8 @@
 | 
			
		||||
        {
 | 
			
		||||
            yield return new object[] 
 | 
			
		||||
            {
 | 
			
		||||
                "IdentityServer",
 | 
			
		||||
                new IdentityServerConfigBuilder()
 | 
			
		||||
                    .WithRequireHttps(true)
 | 
			
		||||
                    .WithApiName("test")
 | 
			
		||||
                    .WithApiSecret("test")
 | 
			
		||||
                    .WithProviderRootUrl("test")
 | 
			
		||||
                    .Build(),
 | 
			
		||||
                new FileConfiguration
 | 
			
		||||
                {
 | 
			
		||||
                    AuthenticationOptions = new List<FileAuthenticationOptions>
 | 
			
		||||
                    {
 | 
			
		||||
                        new FileAuthenticationOptions
 | 
			
		||||
                        {
 | 
			
		||||
                            AllowedScopes = new List<string>(),
 | 
			
		||||
                            Provider = "IdentityServer",
 | 
			
		||||
                            IdentityServerConfig = new FileIdentityServerConfig
 | 
			
		||||
                            {
 | 
			
		||||
                                ProviderRootUrl = "http://localhost:51888",
 | 
			
		||||
                                RequireHttps = false,
 | 
			
		||||
                                ApiName = "api",
 | 
			
		||||
                                ApiSecret = "secret"
 | 
			
		||||
                            }  ,
 | 
			
		||||
                            AuthenticationProviderKey = "Test"                              
 | 
			
		||||
                        }
 | 
			
		||||
                    },
 | 
			
		||||
                    ReRoutes = new List<FileReRoute>
 | 
			
		||||
                    {
 | 
			
		||||
                        new FileReRoute
 | 
			
		||||
@@ -44,11 +19,15 @@
 | 
			
		||||
                            DownstreamPathTemplate = "/products/{productId}",
 | 
			
		||||
                            UpstreamHttpMethod = new List<string> { "Get" },
 | 
			
		||||
                            ReRouteIsCaseSensitive = true,
 | 
			
		||||
                                AuthenticationProviderKey = "Test",                              
 | 
			
		||||
                            AuthenticationOptions = new FileAuthenticationOptions
 | 
			
		||||
                            {
 | 
			
		||||
                                AuthenticationProviderKey = "Test",
 | 
			
		||||
                                AllowedScopes = new List<string>(),
 | 
			
		||||
                            },
 | 
			
		||||
                            AddHeadersToRequest =
 | 
			
		||||
                                {
 | 
			
		||||
                                    { "CustomerId", "Claims[CustomerId] > value" },
 | 
			
		||||
                                }
 | 
			
		||||
                            {
 | 
			
		||||
                                { "CustomerId", "Claims[CustomerId] > value" },
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
@@ -56,27 +35,8 @@
 | 
			
		||||
 | 
			
		||||
            yield return new object[]
 | 
			
		||||
            {
 | 
			
		||||
                "Jwt",
 | 
			
		||||
                new JwtConfigBuilder()
 | 
			
		||||
                    .WithAudience("a")
 | 
			
		||||
                    .WithAuthority("au")
 | 
			
		||||
                    .Build(),
 | 
			
		||||
                new FileConfiguration
 | 
			
		||||
                {
 | 
			
		||||
                    AuthenticationOptions = new List<FileAuthenticationOptions>
 | 
			
		||||
                    {
 | 
			
		||||
                        new FileAuthenticationOptions
 | 
			
		||||
                            {
 | 
			
		||||
                                AllowedScopes = new List<string>(),
 | 
			
		||||
                                Provider = "IdentityServer",
 | 
			
		||||
                                JwtConfig = new FileJwtConfig
 | 
			
		||||
                                {
 | 
			
		||||
                                    Audience = "a",
 | 
			
		||||
                                    Authority = "au"
 | 
			
		||||
                                },
 | 
			
		||||
                                AuthenticationProviderKey = "Test"
 | 
			
		||||
                            }
 | 
			
		||||
                    },
 | 
			
		||||
                    ReRoutes = new List<FileReRoute>
 | 
			
		||||
                    {
 | 
			
		||||
                        new FileReRoute
 | 
			
		||||
@@ -85,7 +45,11 @@
 | 
			
		||||
                            DownstreamPathTemplate = "/products/{productId}",
 | 
			
		||||
                            UpstreamHttpMethod = new List<string> { "Get" },
 | 
			
		||||
                            ReRouteIsCaseSensitive = true,
 | 
			
		||||
                            AuthenticationProviderKey = "Test",
 | 
			
		||||
                            AuthenticationOptions = new FileAuthenticationOptions
 | 
			
		||||
                            {
 | 
			
		||||
                                AuthenticationProviderKey = "Test",
 | 
			
		||||
                                AllowedScopes = new List<string>(),
 | 
			
		||||
                            },
 | 
			
		||||
                            AddHeadersToRequest =
 | 
			
		||||
                            {
 | 
			
		||||
                                { "CustomerId", "Claims[CustomerId] > value" },
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user