-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nick Sharp
committed
Jun 29, 2017
1 parent
9532d94
commit 1168eb3
Showing
2 changed files
with
197 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
test/Ocelot.UnitTests/TestData/AuthenticationConfigTestData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
namespace Ocelot.UnitTests.TestData | ||
{ | ||
using System.Collections.Generic; | ||
|
||
using Ocelot.Configuration.Builder; | ||
using Ocelot.Configuration.File; | ||
|
||
public class AuthenticationConfigTestData | ||
{ | ||
public static IEnumerable<object[]> GetAuthenticationData() | ||
{ | ||
yield return new object[] | ||
{ | ||
"IdentityServer", | ||
new IdentityServerConfigBuilder() | ||
.WithRequireHttps(true) | ||
.WithApiName("test") | ||
.WithApiSecret("test") | ||
.WithProviderRootUrl("test") | ||
.Build(), | ||
new FileConfiguration | ||
{ | ||
ReRoutes = new List<FileReRoute> | ||
{ | ||
new FileReRoute | ||
{ | ||
UpstreamPathTemplate = "/api/products/{productId}", | ||
DownstreamPathTemplate = "/products/{productId}", | ||
UpstreamHttpMethod = new List<string> { "Get" }, | ||
ReRouteIsCaseSensitive = true, | ||
AuthenticationOptions = new FileAuthenticationOptions | ||
{ | ||
AllowedScopes = new List<string>(), | ||
Provider = "IdentityServer", | ||
IdentityServerConfig = new FileIdentityServerConfig | ||
{ | ||
ProviderRootUrl = "http://localhost:51888", | ||
RequireHttps = false, | ||
ApiName = "api", | ||
ApiSecret = "secret" | ||
} | ||
}, | ||
AddHeadersToRequest = | ||
{ | ||
{ "CustomerId", "Claims[CustomerId] > value" }, | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
yield return new object[] | ||
{ | ||
"Jwt", | ||
new JwtConfigBuilder() | ||
.WithAudience("a") | ||
.WithAuthority("au") | ||
.Build(), | ||
new FileConfiguration | ||
{ | ||
ReRoutes = new List<FileReRoute> | ||
{ | ||
new FileReRoute | ||
{ | ||
UpstreamPathTemplate = "/api/products/{productId}", | ||
DownstreamPathTemplate = "/products/{productId}", | ||
UpstreamHttpMethod = new List<string> { "Get" }, | ||
ReRouteIsCaseSensitive = true, | ||
AuthenticationOptions = new FileAuthenticationOptions | ||
{ | ||
AllowedScopes = new List<string>(), | ||
Provider = "IdentityServer", | ||
JwtConfig = new FileJwtConfig | ||
{ | ||
Audience = "a", | ||
Authority = "au" | ||
} | ||
}, | ||
AddHeadersToRequest = | ||
{ | ||
{ "CustomerId", "Claims[CustomerId] > value" }, | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
} |