Skip to content

Commit

Permalink
Add Quickstart Controller integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhiggins732 committed Feb 21, 2024
1 parent 4e86be7 commit bf41d07
Show file tree
Hide file tree
Showing 99 changed files with 3,091 additions and 151 deletions.
59 changes: 59 additions & 0 deletions IdentityServer8.AllProjects.sln
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,24 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{549BF3
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.IntegrationTests", "samples\Quickstarts\test\IdentityServer.IntegrationTests\IdentityServer.IntegrationTests.csproj", "{E1D7510D-D40F-4651-81DF-766D548E8FB0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IdentityServer.Samples.Shared.IntegrationTests", "samples\Quickstarts\test\IdentityServer.Samples.Shared.IntegrationTests\IdentityServer.Samples.Shared.IntegrationTests.csproj", "{7FC1B3AF-12F8-4100-9FA8-07EE7AA07C4E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Quickstarts.AspNetCore.IntegrationTests", "samples\Quickstarts\test\IdentityServer.Quickstarts.AspNetCore.IntegrationTests\IdentityServer.Quickstarts.AspNetCore.IntegrationTests.csproj", "{A816EE7A-50B0-40C7-990B-698D9F08DAEB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Quickstarts", "Quickstarts", "{3521EC6E-A8C1-4EC3-AEA0-A8CC2E3A54F9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests", "samples\Quickstarts\test\IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests\IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests.csproj", "{4490B6DA-24E8-4B2A-AF8B-56DDE5405548}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests", "samples\Quickstarts\test\IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests\IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests.csproj", "{409B04E0-6B4E-43FB-AE32-E5AD832C3761}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Quickstarts.ClientCredentials.IntegrationTests", "samples\Quickstarts\test\IdentityServer.Quickstarts.ClientCredentials.IntegrationTests\IdentityServer.Quickstarts.ClientCredentials.IntegrationTests.csproj", "{10C555F1-E2C5-4C64-AC34-814A8A2DA8E1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Quickstarts.EntityFramework.IntegrationTests", "samples\Quickstarts\test\IdentityServer.Quickstarts.EntityFramework.IntegrationTests\IdentityServer.Quickstarts.EntityFramework.IntegrationTests.csproj", "{B14CC575-018C-46C1-9A3A-0E9D11FF950D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Quickstarts.IdentityServer.IntegrationTests", "samples\Quickstarts\test\IdentityServer.Quickstarts.IdentityServer.IntegrationTests\IdentityServer.Quickstarts.IdentityServer.IntegrationTests.csproj", "{D2B84593-417D-465D-AAEA-0CE0F2E509C3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IdentityServer.Quickstarts.JavascriptClient.IntegrationTests", "samples\Quickstarts\test\IdentityServer.Quickstarts.JavascriptClient.IntegrationTests\IdentityServer.Quickstarts.JavascriptClient.IntegrationTests.csproj", "{41F5321C-2D41-44B3-94AC-94DDEA256911}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -543,6 +561,38 @@ Global
{E1D7510D-D40F-4651-81DF-766D548E8FB0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1D7510D-D40F-4651-81DF-766D548E8FB0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1D7510D-D40F-4651-81DF-766D548E8FB0}.Release|Any CPU.Build.0 = Release|Any CPU
{7FC1B3AF-12F8-4100-9FA8-07EE7AA07C4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FC1B3AF-12F8-4100-9FA8-07EE7AA07C4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FC1B3AF-12F8-4100-9FA8-07EE7AA07C4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FC1B3AF-12F8-4100-9FA8-07EE7AA07C4E}.Release|Any CPU.Build.0 = Release|Any CPU
{A816EE7A-50B0-40C7-990B-698D9F08DAEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A816EE7A-50B0-40C7-990B-698D9F08DAEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A816EE7A-50B0-40C7-990B-698D9F08DAEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A816EE7A-50B0-40C7-990B-698D9F08DAEB}.Release|Any CPU.Build.0 = Release|Any CPU
{4490B6DA-24E8-4B2A-AF8B-56DDE5405548}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4490B6DA-24E8-4B2A-AF8B-56DDE5405548}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4490B6DA-24E8-4B2A-AF8B-56DDE5405548}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4490B6DA-24E8-4B2A-AF8B-56DDE5405548}.Release|Any CPU.Build.0 = Release|Any CPU
{409B04E0-6B4E-43FB-AE32-E5AD832C3761}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{409B04E0-6B4E-43FB-AE32-E5AD832C3761}.Debug|Any CPU.Build.0 = Debug|Any CPU
{409B04E0-6B4E-43FB-AE32-E5AD832C3761}.Release|Any CPU.ActiveCfg = Release|Any CPU
{409B04E0-6B4E-43FB-AE32-E5AD832C3761}.Release|Any CPU.Build.0 = Release|Any CPU
{10C555F1-E2C5-4C64-AC34-814A8A2DA8E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10C555F1-E2C5-4C64-AC34-814A8A2DA8E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10C555F1-E2C5-4C64-AC34-814A8A2DA8E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10C555F1-E2C5-4C64-AC34-814A8A2DA8E1}.Release|Any CPU.Build.0 = Release|Any CPU
{B14CC575-018C-46C1-9A3A-0E9D11FF950D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B14CC575-018C-46C1-9A3A-0E9D11FF950D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B14CC575-018C-46C1-9A3A-0E9D11FF950D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B14CC575-018C-46C1-9A3A-0E9D11FF950D}.Release|Any CPU.Build.0 = Release|Any CPU
{D2B84593-417D-465D-AAEA-0CE0F2E509C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D2B84593-417D-465D-AAEA-0CE0F2E509C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2B84593-417D-465D-AAEA-0CE0F2E509C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2B84593-417D-465D-AAEA-0CE0F2E509C3}.Release|Any CPU.Build.0 = Release|Any CPU
{41F5321C-2D41-44B3-94AC-94DDEA256911}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{41F5321C-2D41-44B3-94AC-94DDEA256911}.Debug|Any CPU.Build.0 = Debug|Any CPU
{41F5321C-2D41-44B3-94AC-94DDEA256911}.Release|Any CPU.ActiveCfg = Release|Any CPU
{41F5321C-2D41-44B3-94AC-94DDEA256911}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -655,6 +705,15 @@ Global
{A80E8159-03FA-48EF-955F-C3F22FDC63A4} = {06FC2C45-FCD6-469C-8F2D-3E1A750D1EF9}
{549BF398-DF47-48E1-A1AA-32C1B66B0852} = {45C22EDD-91B1-4AEF-8620-77F4E3E7C544}
{E1D7510D-D40F-4651-81DF-766D548E8FB0} = {4D241138-307B-4EC2-B54B-7D3246CF5096}
{7FC1B3AF-12F8-4100-9FA8-07EE7AA07C4E} = {4D241138-307B-4EC2-B54B-7D3246CF5096}
{A816EE7A-50B0-40C7-990B-698D9F08DAEB} = {3521EC6E-A8C1-4EC3-AEA0-A8CC2E3A54F9}
{3521EC6E-A8C1-4EC3-AEA0-A8CC2E3A54F9} = {4D241138-307B-4EC2-B54B-7D3246CF5096}
{4490B6DA-24E8-4B2A-AF8B-56DDE5405548} = {3521EC6E-A8C1-4EC3-AEA0-A8CC2E3A54F9}
{409B04E0-6B4E-43FB-AE32-E5AD832C3761} = {3521EC6E-A8C1-4EC3-AEA0-A8CC2E3A54F9}
{10C555F1-E2C5-4C64-AC34-814A8A2DA8E1} = {3521EC6E-A8C1-4EC3-AEA0-A8CC2E3A54F9}
{B14CC575-018C-46C1-9A3A-0E9D11FF950D} = {3521EC6E-A8C1-4EC3-AEA0-A8CC2E3A54F9}
{D2B84593-417D-465D-AAEA-0CE0F2E509C3} = {3521EC6E-A8C1-4EC3-AEA0-A8CC2E3A54F9}
{41F5321C-2D41-44B3-94AC-94DDEA256911} = {3521EC6E-A8C1-4EC3-AEA0-A8CC2E3A54F9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {176723F7-4A9B-4F05-A9F3-3BA715E4BDC3}
Expand Down
2 changes: 0 additions & 2 deletions samples/Quickstarts/1_ClientCredentials/src/Host/Host.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<ItemGroup>
<PackageReference Include="HigginsSoft.IdentityServer8" />
<PackageReference Include="HigginsSoft.IdentityServer8.Security" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" />
</ItemGroup>
<ItemGroup>
Expand Down
84 changes: 84 additions & 0 deletions samples/Quickstarts/1_ClientCredentials/src/Host/StartupTest.cs
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();
});



}


}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<ItemGroup>
<PackageReference Include="HigginsSoft.IdentityServer8" />
<PackageReference Include="HigginsSoft.IdentityServer8.Security" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" />
</ItemGroup>
<ItemGroup>
Expand Down
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

View workflow job for this annotation

GitHub Actions / macOS-latest

The type 'Config' in '/Users/runner/work/IdentityServer8/IdentityServer8/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/Config.cs' conflicts with the imported type 'Config' in 'IdentityServer, Version=8.0.4.0, Culture=neutral, PublicKeyToken=f294d0afe402bb2b'. Using the type defined in '/Users/runner/work/IdentityServer8/IdentityServer8/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/Config.cs'.

Check warning on line 28 in samples/Quickstarts/2_InteractiveAspNetCore/src/Host/StartupTest.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

The type 'Config' in '/home/runner/work/IdentityServer8/IdentityServer8/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/Config.cs' conflicts with the imported type 'Config' in 'IdentityServer, Version=8.0.4.0, Culture=neutral, PublicKeyToken=f294d0afe402bb2b'. Using the type defined in '/home/runner/work/IdentityServer8/IdentityServer8/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/Config.cs'.
.AddInMemoryApiScopes(Config.ApiScopes)

Check warning on line 29 in samples/Quickstarts/2_InteractiveAspNetCore/src/Host/StartupTest.cs

View workflow job for this annotation

GitHub Actions / macOS-latest

The type 'Config' in '/Users/runner/work/IdentityServer8/IdentityServer8/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/Config.cs' conflicts with the imported type 'Config' in 'IdentityServer, Version=8.0.4.0, Culture=neutral, PublicKeyToken=f294d0afe402bb2b'. Using the type defined in '/Users/runner/work/IdentityServer8/IdentityServer8/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/Config.cs'.

Check warning on line 29 in samples/Quickstarts/2_InteractiveAspNetCore/src/Host/StartupTest.cs

View workflow job for this annotation

GitHub Actions / ubuntu-latest

The type 'Config' in '/home/runner/work/IdentityServer8/IdentityServer8/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/Config.cs' conflicts with the imported type 'Config' in 'IdentityServer, Version=8.0.4.0, Culture=neutral, PublicKeyToken=f294d0afe402bb2b'. Using the type defined in '/home/runner/work/IdentityServer8/IdentityServer8/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/Config.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();
});


}


}
2 changes: 0 additions & 2 deletions samples/Quickstarts/3_AspNetCoreAndApis/src/Host/Host.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<ItemGroup>
<PackageReference Include="HigginsSoft.IdentityServer8" />
<PackageReference Include="HigginsSoft.IdentityServer8.Security" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ copies or substantial portions of the Software.

using Secret = IdentityServer8.Models.Secret;

namespace IdentityServer;
namespace IdentityServer.QuickStarts;

public class StartupTest
{
Expand Down Expand Up @@ -66,7 +66,9 @@ public void Configure(IApplicationBuilder app)

app.UseStaticFiles()
.UseRouting()
.UseIdentityServer()
.UseIdentityServer();

app
.UseAuthorization();

app.UseEndpoints(endpoints =>
Expand Down
67 changes: 0 additions & 67 deletions samples/Quickstarts/4_JavaScriptClient/src/Host/Config.cs

This file was deleted.

2 changes: 0 additions & 2 deletions samples/Quickstarts/4_JavaScriptClient/src/Host/Host.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<ItemGroup>
<PackageReference Include="HigginsSoft.IdentityServer8" />
<PackageReference Include="HigginsSoft.IdentityServer8.Security" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" />
</ItemGroup>
<ItemGroup>
Expand Down
Loading

0 comments on commit bf41d07

Please # to comment.