-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Quickstart Controller integration tests.
- Loading branch information
1 parent
4e86be7
commit bf41d07
Showing
99 changed files
with
3,091 additions
and
151 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
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
84 changes: 84 additions & 0 deletions
84
samples/Quickstarts/1_ClientCredentials/src/Host/StartupTest.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,84 @@ | ||
/* | ||
Copyright (c) 2024 HigginsSoft, Alexander Higgins - https://github.com/alexhiggins732/ | ||
Copyright (c) 2018, Brock Allen & Dominick Baier. All rights reserved. | ||
Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. | ||
Source code and license this software can be found | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
*/ | ||
|
||
using Secret = IdentityServer8.Models.Secret; | ||
|
||
namespace IdentityServer.QuickStarts.ClientCredentials; | ||
|
||
public class StartupTest | ||
{ | ||
|
||
|
||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
|
||
services.AddControllersWithViews(); | ||
|
||
services | ||
.AddIdentityServer() | ||
.AddInMemoryIdentityResources(Config.IdentityResources) | ||
.AddInMemoryApiScopes(Config.ApiScopes) | ||
.AddInMemoryClients(Config.Clients) | ||
.AddTestUsers(TestUsers.Users) | ||
.AddDeveloperSigningCredential(); | ||
|
||
services.AddAuthentication() | ||
.AddGoogle("Google", options => | ||
{ | ||
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme; | ||
|
||
options.ClientId = "<insert here>"; | ||
options.ClientSecret = "<insert here>"; | ||
}) | ||
.AddOpenIdConnect("oidc", "Demo IdentityServer", options => | ||
{ | ||
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme; | ||
options.SignOutScheme = IdentityServerConstants.SignoutScheme; | ||
options.SaveTokens = true; | ||
|
||
options.Authority = "https://demo.identityserver8.io/"; | ||
options.ClientId = "interactive.confidential"; | ||
options.ClientSecret = "secret"; | ||
options.ResponseType = "code"; | ||
|
||
options.TokenValidationParameters = new() | ||
{ | ||
NameClaimType = "name", | ||
RoleClaimType = "role" | ||
}; | ||
}); | ||
|
||
} | ||
|
||
public void Configure(IApplicationBuilder app) | ||
{ | ||
var environment = app.ApplicationServices.GetRequiredService<Microsoft.AspNetCore.Hosting.IHostingEnvironment>(); | ||
if (environment.IsDevelopment()) | ||
app.UseDeveloperExceptionPage(); | ||
|
||
app.UseStaticFiles() | ||
.UseRouting() | ||
.UseIdentityServer(); | ||
app | ||
.UseAuthorization(); | ||
|
||
app.UseEndpoints(endpoints => | ||
{ | ||
endpoints.MapDefaultControllerRoute(); | ||
}); | ||
|
||
|
||
|
||
} | ||
|
||
|
||
} |
2 changes: 0 additions & 2 deletions
2
samples/Quickstarts/2_InteractiveAspNetCore/src/Host/Host.csproj
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
82 changes: 82 additions & 0 deletions
82
samples/Quickstarts/2_InteractiveAspNetCore/src/Host/StartupTest.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,82 @@ | ||
/* | ||
Copyright (c) 2024 HigginsSoft, Alexander Higgins - https://github.com/alexhiggins732/ | ||
Copyright (c) 2018, Brock Allen & Dominick Baier. All rights reserved. | ||
Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. | ||
Source code and license this software can be found | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
*/ | ||
|
||
using Secret = IdentityServer8.Models.Secret; | ||
|
||
namespace IdentityServer.QuickStarts; | ||
|
||
public class StartupTest | ||
{ | ||
|
||
|
||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
|
||
services.AddControllersWithViews(); | ||
|
||
services | ||
.AddIdentityServer() | ||
.AddInMemoryIdentityResources(Config.IdentityResources) | ||
Check warning on line 28 in samples/Quickstarts/2_InteractiveAspNetCore/src/Host/StartupTest.cs
|
||
.AddInMemoryApiScopes(Config.ApiScopes) | ||
Check warning on line 29 in samples/Quickstarts/2_InteractiveAspNetCore/src/Host/StartupTest.cs
|
||
.AddInMemoryClients(Config.Clients) | ||
.AddTestUsers(TestUsers.Users) | ||
.AddDeveloperSigningCredential(); | ||
|
||
services.AddAuthentication() | ||
.AddGoogle("Google", options => | ||
{ | ||
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme; | ||
|
||
options.ClientId = "<insert here>"; | ||
options.ClientSecret = "<insert here>"; | ||
}) | ||
.AddOpenIdConnect("oidc", "Demo IdentityServer", options => | ||
{ | ||
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme; | ||
options.SignOutScheme = IdentityServerConstants.SignoutScheme; | ||
options.SaveTokens = true; | ||
|
||
options.Authority = "https://demo.identityserver8.io/"; | ||
options.ClientId = "interactive.confidential"; | ||
options.ClientSecret = "secret"; | ||
options.ResponseType = "code"; | ||
|
||
options.TokenValidationParameters = new() | ||
{ | ||
NameClaimType = "name", | ||
RoleClaimType = "role" | ||
}; | ||
}); | ||
} | ||
|
||
public void Configure(IApplicationBuilder app) | ||
{ | ||
var env= app.ApplicationServices.GetRequiredService<Microsoft.AspNetCore.Hosting.IHostingEnvironment>(); | ||
if (env.IsDevelopment()) | ||
app.UseDeveloperExceptionPage(); | ||
|
||
app.UseStaticFiles() | ||
.UseRouting() | ||
.UseIdentityServer(); | ||
app | ||
.UseAuthorization(); | ||
|
||
app.UseEndpoints(endpoints => | ||
{ | ||
endpoints.MapDefaultControllerRoute(); | ||
}); | ||
|
||
|
||
} | ||
|
||
|
||
} |
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
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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.