From bf41d078d06f21de11bdc4da3440418f092f252f Mon Sep 17 00:00:00 2001 From: Alexander Higgins Date: Wed, 21 Feb 2024 13:36:46 -0500 Subject: [PATCH] Add Quickstart Controller integration tests. --- IdentityServer8.AllProjects.sln | 59 ++++ .../1_ClientCredentials/src/Host/Host.csproj | 2 - .../src/Host/StartupTest.cs | 84 ++++++ .../src/Host/Host.csproj | 2 - .../src/Host/StartupTest.cs | 82 ++++++ .../3_AspNetCoreAndApis/src/Host/Host.csproj | 2 - .../src/Host/StartupTest.cs | 6 +- .../4_JavaScriptClient/src/Host/Config.cs | 67 ----- .../4_JavaScriptClient/src/Host/Host.csproj | 2 - .../src/Host/StartupTest.cs | 83 ++++++ .../5_EntityFramework/src/Host/Host.csproj | 2 - .../5_EntityFramework/src/Host/Program.cs | 39 +-- .../5_EntityFramework/src/Host/StartupTest.cs | 131 +++++++++ .../6_AspNetIdentity/src/Host/Host.csproj | 2 - .../6_AspNetIdentity/src/Host/Program.cs | 6 +- .../6_AspNetIdentity/src/Host/StartupTest.cs | 116 ++++++++ .../Shared/src/IdentityServer/Config.cs | 1 - .../src/IdentityServer/IdentityServer.csproj | 10 +- .../Shared/src/IdentityServer/StartupTest.cs | 84 ++++++ .../Common/WebApplicationFactoryExtensions.cs | 5 +- .../GlobalUsings.cs | 1 + .../Tests/Base/TestFixture.cs | 2 +- .../GlobalUsings.cs | 4 + ...kstarts.AspNetCore.IntegrationTests.csproj | 35 +++ .../Tests/AccountControllerTests.cs | 26 ++ .../Tests/DiagnosticsControllerTests.cs | 23 ++ .../Tests/GrantsControllerTests.cs | 23 ++ .../Tests/HomeControllerTests.cs | 23 ++ .../Tests/IdentityServerTests.cs | 23 ++ .../Tests/ManageControllerTests.cs | 24 ++ .../GlobalUsings.cs | 4 + ....AspNetCoreAndApis.IntegrationTests.csproj | 35 +++ .../Tests/AccountControllerTests.cs | 26 ++ .../Tests/DiagnosticsControllerTests.cs | 23 ++ .../Tests/GrantsControllerTests.cs | 23 ++ .../Tests/HomeControllerTests.cs | 23 ++ .../Tests/IdentityServerTests.cs | 23 ++ .../Tests/ManageControllerTests.cs | 24 ++ .../GlobalUsings.cs | 6 + ...rts.AspNetIdentity.IntegrationTests.csproj | 35 +++ .../Tests/AccountControllerTests.cs | 26 ++ .../Tests/DiagnosticsControllerTests.cs | 24 ++ .../Tests/GrantsControllerTests.cs | 24 ++ .../Tests/HomeControllerTests.cs | 26 ++ .../Tests/IdentityServerTests.cs | 24 ++ .../Tests/ManageControllerTests.cs | 25 ++ .../GlobalUsings.cs | 5 + ....ClientCredentials.IntegrationTests.csproj | 35 +++ .../Tests/AccountControllerTests.cs | 26 ++ .../Tests/DiagnosticsControllerTests.cs | 23 ++ .../Tests/GrantsControllerTests.cs | 23 ++ .../Tests/HomeControllerTests.cs | 23 ++ .../Tests/IdentityServerTests.cs | 23 ++ .../Tests/ManageControllerTests.cs | 24 ++ .../GlobalUsings.cs | 5 + ...ts.EntityFramework.IntegrationTests.csproj | 35 +++ .../Tests/AccountControllerTests.cs | 26 ++ .../Tests/DiagnosticsControllerTests.cs | 23 ++ .../Tests/GrantsControllerTests.cs | 23 ++ .../Tests/HomeControllerTests.cs | 23 ++ .../Tests/IdentityServerTests.cs | 23 ++ .../Tests/ManageControllerTests.cs | 24 ++ .../GlobalUsings.cs | 5 + ...rts.IdentityServer.IntegrationTests.csproj | 36 +++ .../Tests/AccountControllerTests.cs | 26 ++ .../Tests/DiagnosticsControllerTests.cs | 23 ++ .../Tests/GrantsControllerTests.cs | 23 ++ .../Tests/HomeControllerTests.cs | 23 ++ .../Tests/IdentityServerTests.cs | 23 ++ .../Tests/ManageControllerTests.cs | 24 ++ .../GlobalUsings.cs | 5 + ...s.JavascriptClient.IntegrationTests.csproj | 36 +++ .../Tests/AccountControllerTests.cs | 26 ++ .../Tests/DiagnosticsControllerTests.cs | 23 ++ .../Tests/GrantsControllerTests.cs | 23 ++ .../Tests/HomeControllerTests.cs | 23 ++ .../Tests/IdentityServerTests.cs | 23 ++ .../Tests/ManageControllerTests.cs | 24 ++ .../Common/AntiForgeryHelper.cs | 40 +++ .../Common/CookiesHelper.cs | 77 +++++ .../Common/RequestHelper.cs | 71 +++++ .../Common/RoutesConstants.cs | 38 +++ .../GlobalUsings.cs | 1 + ...ver.Samples.Shared.IntegrationTests.csproj | 34 +++ .../Tests/AccountControllerTests.cs | 277 ++++++++++++++++++ .../Tests/Base/BaseClassFixture.cs | 33 +++ .../Tests/Base/TestFixture.cs | 57 ++++ .../Tests/DiagnosticsControllerTests.cs | 85 ++++++ .../Tests/GrantsControllerTests.cs | 85 ++++++ .../Tests/HomeControllerTests.cs | 43 +++ .../Tests/IdentityServerTests.cs | 42 +++ .../Tests/ManageControllerTests.cs | 119 ++++++++ .../Tests/Mocks/UserMocks.cs | 104 +++++++ .../identityserver_testing.cer | 20 ++ .../identityserver_testing.pfx | Bin 0 -> 2654 bytes .../xunit.runner.json | 3 + samples/SamplesGlobalUsings.cs | 26 +- .../BuilderExtensions/Crypto.cs | 16 +- .../IdentityServer.IntegrationTests.csproj | 1 + 99 files changed, 3091 insertions(+), 151 deletions(-) create mode 100644 samples/Quickstarts/1_ClientCredentials/src/Host/StartupTest.cs create mode 100644 samples/Quickstarts/2_InteractiveAspNetCore/src/Host/StartupTest.cs delete mode 100644 samples/Quickstarts/4_JavaScriptClient/src/Host/Config.cs create mode 100644 samples/Quickstarts/4_JavaScriptClient/src/Host/StartupTest.cs create mode 100644 samples/Quickstarts/5_EntityFramework/src/Host/StartupTest.cs create mode 100644 samples/Quickstarts/6_AspNetIdentity/src/Host/StartupTest.cs create mode 100644 samples/Quickstarts/Shared/src/IdentityServer/StartupTest.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/GlobalUsings.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/IdentityServer.Quickstarts.AspNetCore.IntegrationTests.csproj create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/AccountControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/DiagnosticsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/GrantsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/HomeControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/IdentityServerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/ManageControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/GlobalUsings.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests.csproj create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/AccountControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/DiagnosticsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/GrantsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/HomeControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/IdentityServerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/ManageControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/GlobalUsings.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests.csproj create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/AccountControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/DiagnosticsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/GrantsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/HomeControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/IdentityServerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/ManageControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/GlobalUsings.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests.csproj create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/AccountControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/DiagnosticsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/GrantsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/HomeControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/IdentityServerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/ManageControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/GlobalUsings.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/IdentityServer.Quickstarts.EntityFramework.IntegrationTests.csproj create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/AccountControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/DiagnosticsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/GrantsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/HomeControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/IdentityServerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/ManageControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/GlobalUsings.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/IdentityServer.Quickstarts.IdentityServer.IntegrationTests.csproj create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/AccountControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/DiagnosticsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/GrantsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/HomeControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/IdentityServerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/ManageControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/GlobalUsings.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests.csproj create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/AccountControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/DiagnosticsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/GrantsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/HomeControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/IdentityServerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/ManageControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/AntiForgeryHelper.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/CookiesHelper.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/RequestHelper.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/RoutesConstants.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/GlobalUsings.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/IdentityServer.Samples.Shared.IntegrationTests.csproj create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/AccountControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/Base/BaseClassFixture.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/Base/TestFixture.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/DiagnosticsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/GrantsControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/HomeControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/IdentityServerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/ManageControllerTests.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/Mocks/UserMocks.cs create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/identityserver_testing.cer create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/identityserver_testing.pfx create mode 100644 samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/xunit.runner.json diff --git a/IdentityServer8.AllProjects.sln b/IdentityServer8.AllProjects.sln index a9454a88..bcb35cc0 100644 --- a/IdentityServer8.AllProjects.sln +++ b/IdentityServer8.AllProjects.sln @@ -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 @@ -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 @@ -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} diff --git a/samples/Quickstarts/1_ClientCredentials/src/Host/Host.csproj b/samples/Quickstarts/1_ClientCredentials/src/Host/Host.csproj index c28d162b..b9daab45 100644 --- a/samples/Quickstarts/1_ClientCredentials/src/Host/Host.csproj +++ b/samples/Quickstarts/1_ClientCredentials/src/Host/Host.csproj @@ -1,7 +1,5 @@ - - diff --git a/samples/Quickstarts/1_ClientCredentials/src/Host/StartupTest.cs b/samples/Quickstarts/1_ClientCredentials/src/Host/StartupTest.cs new file mode 100644 index 00000000..a5447fb3 --- /dev/null +++ b/samples/Quickstarts/1_ClientCredentials/src/Host/StartupTest.cs @@ -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 = ""; + options.ClientSecret = ""; + }) + .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(); + if (environment.IsDevelopment()) + app.UseDeveloperExceptionPage(); + + app.UseStaticFiles() + .UseRouting() + .UseIdentityServer(); + app + .UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapDefaultControllerRoute(); + }); + + + + } + + +} diff --git a/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/Host.csproj b/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/Host.csproj index c28d162b..b9daab45 100644 --- a/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/Host.csproj +++ b/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/Host.csproj @@ -1,7 +1,5 @@ - - diff --git a/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/StartupTest.cs b/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/StartupTest.cs new file mode 100644 index 00000000..7014cd1b --- /dev/null +++ b/samples/Quickstarts/2_InteractiveAspNetCore/src/Host/StartupTest.cs @@ -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) + .AddInMemoryApiScopes(Config.ApiScopes) + .AddInMemoryClients(Config.Clients) + .AddTestUsers(TestUsers.Users) + .AddDeveloperSigningCredential(); + + services.AddAuthentication() + .AddGoogle("Google", options => + { + options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme; + + options.ClientId = ""; + options.ClientSecret = ""; + }) + .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(); + if (env.IsDevelopment()) + app.UseDeveloperExceptionPage(); + + app.UseStaticFiles() + .UseRouting() + .UseIdentityServer(); + app + .UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapDefaultControllerRoute(); + }); + + + } + + +} diff --git a/samples/Quickstarts/3_AspNetCoreAndApis/src/Host/Host.csproj b/samples/Quickstarts/3_AspNetCoreAndApis/src/Host/Host.csproj index c28d162b..b9daab45 100644 --- a/samples/Quickstarts/3_AspNetCoreAndApis/src/Host/Host.csproj +++ b/samples/Quickstarts/3_AspNetCoreAndApis/src/Host/Host.csproj @@ -1,7 +1,5 @@ - - diff --git a/samples/Quickstarts/3_AspNetCoreAndApis/src/Host/StartupTest.cs b/samples/Quickstarts/3_AspNetCoreAndApis/src/Host/StartupTest.cs index 3a2e439b..daea780b 100644 --- a/samples/Quickstarts/3_AspNetCoreAndApis/src/Host/StartupTest.cs +++ b/samples/Quickstarts/3_AspNetCoreAndApis/src/Host/StartupTest.cs @@ -12,7 +12,7 @@ copies or substantial portions of the Software. using Secret = IdentityServer8.Models.Secret; -namespace IdentityServer; +namespace IdentityServer.QuickStarts; public class StartupTest { @@ -66,7 +66,9 @@ public void Configure(IApplicationBuilder app) app.UseStaticFiles() .UseRouting() - .UseIdentityServer() + .UseIdentityServer(); + + app .UseAuthorization(); app.UseEndpoints(endpoints => diff --git a/samples/Quickstarts/4_JavaScriptClient/src/Host/Config.cs b/samples/Quickstarts/4_JavaScriptClient/src/Host/Config.cs deleted file mode 100644 index d8a123d2..00000000 --- a/samples/Quickstarts/4_JavaScriptClient/src/Host/Config.cs +++ /dev/null @@ -1,67 +0,0 @@ -/* - 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; - -public static class Config -{ - public static IEnumerable IdentityResources => - new List - { - new IdentityResources.OpenId(), - new IdentityResources.Profile(), - }; - - - public static IEnumerable ApiScopes => - new List - { - new ApiScope("api1", "My API") - }; - - public static IEnumerable Clients => - new List - { - // machine to machine client - new Client - { - ClientId = "client", - ClientSecrets = { new Secret("secret".Sha256()) }, - - AllowedGrantTypes = GrantTypes.ClientCredentials, - // scopes that client has access to - AllowedScopes = { "api1" } - }, - - // interactive ASP.NET Core MVC client - new Client - { - ClientId = "mvc", - ClientSecrets = { new Secret("secret".Sha256()) }, - - AllowedGrantTypes = GrantTypes.Code, - - // where to redirect to after login - RedirectUris = { "https://localhost:5002/signin-oidc" }, - - // where to redirect to after logout - PostLogoutRedirectUris = { "https://localhost:5002/signout-callback-oidc" }, - - AllowedScopes = new List - { - IdentityServerConstants.StandardScopes.OpenId, - IdentityServerConstants.StandardScopes.Profile, - "api1" - } - } - }; -} diff --git a/samples/Quickstarts/4_JavaScriptClient/src/Host/Host.csproj b/samples/Quickstarts/4_JavaScriptClient/src/Host/Host.csproj index c28d162b..b9daab45 100644 --- a/samples/Quickstarts/4_JavaScriptClient/src/Host/Host.csproj +++ b/samples/Quickstarts/4_JavaScriptClient/src/Host/Host.csproj @@ -1,7 +1,5 @@ - - diff --git a/samples/Quickstarts/4_JavaScriptClient/src/Host/StartupTest.cs b/samples/Quickstarts/4_JavaScriptClient/src/Host/StartupTest.cs new file mode 100644 index 00000000..a7247fb5 --- /dev/null +++ b/samples/Quickstarts/4_JavaScriptClient/src/Host/StartupTest.cs @@ -0,0 +1,83 @@ +/* + 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 = ""; + options.ClientSecret = ""; + }) + .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(); + if (env.IsDevelopment()) + app.UseDeveloperExceptionPage(); + + app.UseStaticFiles() + .UseRouting() + .UseIdentityServer(); + + app.UseAuthorization(); + + + app.UseEndpoints(endpoints => + { + endpoints.MapDefaultControllerRoute(); + }); + + + } + + +} diff --git a/samples/Quickstarts/5_EntityFramework/src/Host/Host.csproj b/samples/Quickstarts/5_EntityFramework/src/Host/Host.csproj index c28d162b..b9daab45 100644 --- a/samples/Quickstarts/5_EntityFramework/src/Host/Host.csproj +++ b/samples/Quickstarts/5_EntityFramework/src/Host/Host.csproj @@ -1,7 +1,5 @@ - - diff --git a/samples/Quickstarts/5_EntityFramework/src/Host/Program.cs b/samples/Quickstarts/5_EntityFramework/src/Host/Program.cs index 277959e4..2f4f107a 100644 --- a/samples/Quickstarts/5_EntityFramework/src/Host/Program.cs +++ b/samples/Quickstarts/5_EntityFramework/src/Host/Program.cs @@ -9,6 +9,7 @@ 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 IdentityServer.QuickStarts; ConfigureLogger(); @@ -69,7 +70,7 @@ copies or substantial portions of the Software. using (var app = builder.Build()) { // this will do the initial DB population - InitializeDatabase(app); + StartupTest.InitializeDatabase(app); if (app.Environment.IsDevelopment()) app.UseDeveloperExceptionPage(); @@ -114,39 +115,3 @@ copies or substantial portions of the Software. .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Code) .CreateLogger(); - void InitializeDatabase(IApplicationBuilder app) -{ - using (var serviceScope = app.ApplicationServices.GetService().CreateScope()) - { - serviceScope.ServiceProvider.GetRequiredService().Database.Migrate(); - - var context = serviceScope.ServiceProvider.GetRequiredService(); - context.Database.Migrate(); - if (!context.Clients.Any()) - { - foreach (var client in Shared.Config.Clients) - { - context.Clients.Add(client.ToEntity()); - } - context.SaveChanges(); - } - - if (!context.IdentityResources.Any()) - { - foreach (var resource in Shared.Config.IdentityResources) - { - context.IdentityResources.Add(resource.ToEntity()); - } - context.SaveChanges(); - } - - if (!context.ApiScopes.Any()) - { - foreach (var resource in Shared.Config.ApiScopes) - { - context.ApiScopes.Add(resource.ToEntity()); - } - context.SaveChanges(); - } - } -} diff --git a/samples/Quickstarts/5_EntityFramework/src/Host/StartupTest.cs b/samples/Quickstarts/5_EntityFramework/src/Host/StartupTest.cs new file mode 100644 index 00000000..5e40e9fa --- /dev/null +++ b/samples/Quickstarts/5_EntityFramework/src/Host/StartupTest.cs @@ -0,0 +1,131 @@ +/* + 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.AddScoped(); + services.AddControllersWithViews(); + + var migrationsAssembly = typeof(Program).GetTypeInfo().Assembly.GetName().Name; + const string connectionString = @"Data Source=(LocalDb)\MSSQLLocalDB;database=IdentityServer8.Quickstart.EntityFramework-4.0.0;trusted_connection=yes;"; + + services.AddIdentityServer() + .AddTestUsers(TestUsers.Users) + .AddConfigurationStore(options => + { + options.ConfigureDbContext = b => b.UseSqlServer(connectionString, + sql => sql.MigrationsAssembly(migrationsAssembly)); + }) + .AddOperationalStore(options => + { + options.ConfigureDbContext = b => b.UseSqlServer(connectionString, + sql => sql.MigrationsAssembly(migrationsAssembly)); + }) + .AddDeveloperSigningCredential(); + + services.AddAuthentication() + .AddGoogle("Google", options => + { + options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme; + + options.ClientId = ""; + options.ClientSecret = ""; + }) + .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) + { + InitializeDatabase(app); + + var env = app.ApplicationServices.GetRequiredService(); + if (env.IsDevelopment()) + app.UseDeveloperExceptionPage(); + + app.UseStaticFiles() + .UseRouting() + .UseIdentityServer(); + app + .UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapDefaultControllerRoute(); + }); + + + + } + + internal static void InitializeDatabase(IApplicationBuilder app) + { + using (var serviceScope = app.ApplicationServices.GetService().CreateScope()) + { + serviceScope.ServiceProvider.GetRequiredService().Database.Migrate(); + + var context = serviceScope.ServiceProvider.GetRequiredService(); + context.Database.Migrate(); + if (!context.Clients.Any()) + { + foreach (var client in Config.Clients) + { + context.Clients.Add(client.ToEntity()); + } + context.SaveChanges(); + } + + if (!context.IdentityResources.Any()) + { + foreach (var resource in Config.IdentityResources) + { + context.IdentityResources.Add(resource.ToEntity()); + } + context.SaveChanges(); + } + + if (!context.ApiScopes.Any()) + { + foreach (var resource in Config.ApiScopes) + { + context.ApiScopes.Add(resource.ToEntity()); + } + context.SaveChanges(); + } + } + } + +} diff --git a/samples/Quickstarts/6_AspNetIdentity/src/Host/Host.csproj b/samples/Quickstarts/6_AspNetIdentity/src/Host/Host.csproj index c28d162b..b9daab45 100644 --- a/samples/Quickstarts/6_AspNetIdentity/src/Host/Host.csproj +++ b/samples/Quickstarts/6_AspNetIdentity/src/Host/Host.csproj @@ -1,7 +1,5 @@ - - diff --git a/samples/Quickstarts/6_AspNetIdentity/src/Host/Program.cs b/samples/Quickstarts/6_AspNetIdentity/src/Host/Program.cs index 43c15037..e83a46c1 100644 --- a/samples/Quickstarts/6_AspNetIdentity/src/Host/Program.cs +++ b/samples/Quickstarts/6_AspNetIdentity/src/Host/Program.cs @@ -38,9 +38,9 @@ copies or substantial portions of the Software. // see https://IdentityServer8.readthedocs.io/en/latest/topics/resources.html options.EmitStaticAudienceClaim = true; }) - .AddInMemoryIdentityResources(Shared.Config.IdentityResources) - .AddInMemoryApiScopes(Shared.Config.ApiScopes) - .AddInMemoryClients(Shared.Config.Clients) + .AddInMemoryIdentityResources(Config.IdentityResources) + .AddInMemoryApiScopes(Config.ApiScopes) + .AddInMemoryClients(Config.Clients) .AddAspNetIdentity() // not recommended for production - you need to store your key material somewhere secure .AddDeveloperSigningCredential(); diff --git a/samples/Quickstarts/6_AspNetIdentity/src/Host/StartupTest.cs b/samples/Quickstarts/6_AspNetIdentity/src/Host/StartupTest.cs new file mode 100644 index 00000000..44131d6a --- /dev/null +++ b/samples/Quickstarts/6_AspNetIdentity/src/Host/StartupTest.cs @@ -0,0 +1,116 @@ +/* + 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. +*/ + + + +namespace IdentityServer.QuickStarts; + +public class StartupTest +{ + public IConfiguration Configuration { get; } + + public StartupTest(IConfiguration configuration) + { + Configuration = configuration; + } + + public void ConfigureServices(IServiceCollection services) + { + + services.AddControllersWithViews(); + + services.AddScoped(); + services.AddControllersWithViews(); + + services.AddDbContext(options => + options.UseSqlite(Configuration.GetConnectionString("DefaultConnection"))); + + services.AddIdentity() + .AddEntityFrameworkStores() + .AddDefaultTokenProviders(); + + services.AddIdentityServer(options => + { + options.Events.RaiseErrorEvents = true; + options.Events.RaiseInformationEvents = true; + options.Events.RaiseFailureEvents = true; + options.Events.RaiseSuccessEvents = true; + + // see https://IdentityServer8.readthedocs.io/en/latest/topics/resources.html + options.EmitStaticAudienceClaim = true; + }) + .AddInMemoryIdentityResources(Config.IdentityResources) + .AddInMemoryApiScopes(Config.ApiScopes) + .AddInMemoryClients(Config.Clients) + .AddAspNetIdentity() + // not recommended for production - you need to store your key material somewhere secure + .AddDeveloperSigningCredential(); + + + services.AddAuthentication() + .AddGoogle(options => + { + options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme; + + // register your IdentityServer with Google at https://console.developers.google.com + // enable the Google+ API + // set the redirect URI to https://localhost:5001/signin-google + options.ClientId = "copy client ID from Google here"; + options.ClientSecret = "copy client secret from Google here"; + }); + + } + + public void Configure(IApplicationBuilder app) + { + var env = app.ApplicationServices.GetRequiredService(); + + + var args = Environment.GetCommandLineArgs(); + //if (args.Contains("/seed")) + // { + Log.Information("Seeding database..."); + var config = app.ApplicationServices.GetRequiredService(); + var connectionString = config.GetConnectionString("DefaultConnection"); + Shared.SeedData.EnsureSeedData(connectionString); + Log.Information("Done seeding database."); + + // } + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + app.UseMigrationsEndPoint(); + app.UseDatabaseErrorPage(); + } + else + { + app.UseExceptionHandler("/Home/Error"); + app.UseHsts(); + } + + + app.UseStaticFiles(); + + app.UseRouting(); + app.UseIdentityServer(); + app.UseAuthorization(); + app.UseEndpoints(endpoints => + { + endpoints.MapDefaultControllerRoute(); + }); + + + } + + +} diff --git a/samples/Quickstarts/Shared/src/IdentityServer/Config.cs b/samples/Quickstarts/Shared/src/IdentityServer/Config.cs index 7ce28bcc..efc6fa7c 100644 --- a/samples/Quickstarts/Shared/src/IdentityServer/Config.cs +++ b/samples/Quickstarts/Shared/src/IdentityServer/Config.cs @@ -12,7 +12,6 @@ copies or substantial portions of the Software. using Secret = IdentityServer8.Models.Secret; -namespace Shared; public static class Config { public static IEnumerable IdentityResources => diff --git a/samples/Quickstarts/Shared/src/IdentityServer/IdentityServer.csproj b/samples/Quickstarts/Shared/src/IdentityServer/IdentityServer.csproj index d9d78c94..28ac1b82 100644 --- a/samples/Quickstarts/Shared/src/IdentityServer/IdentityServer.csproj +++ b/samples/Quickstarts/Shared/src/IdentityServer/IdentityServer.csproj @@ -3,11 +3,7 @@ - - - - @@ -19,4 +15,10 @@ + + + + + + \ No newline at end of file diff --git a/samples/Quickstarts/Shared/src/IdentityServer/StartupTest.cs b/samples/Quickstarts/Shared/src/IdentityServer/StartupTest.cs new file mode 100644 index 00000000..f0a71c57 --- /dev/null +++ b/samples/Quickstarts/Shared/src/IdentityServer/StartupTest.cs @@ -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.IdentityServer; + +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 = ""; + options.ClientSecret = ""; + }) + .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(); + if (environment.IsDevelopment()) + app.UseDeveloperExceptionPage(); + + app.UseStaticFiles() + .UseRouting() + .UseIdentityServer(); + app + .UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapDefaultControllerRoute(); + }); + + + + } + + +} diff --git a/samples/Quickstarts/test/IdentityServer.IntegrationTests/Common/WebApplicationFactoryExtensions.cs b/samples/Quickstarts/test/IdentityServer.IntegrationTests/Common/WebApplicationFactoryExtensions.cs index cfeb5f40..c9ca02f6 100644 --- a/samples/Quickstarts/test/IdentityServer.IntegrationTests/Common/WebApplicationFactoryExtensions.cs +++ b/samples/Quickstarts/test/IdentityServer.IntegrationTests/Common/WebApplicationFactoryExtensions.cs @@ -13,6 +13,7 @@ copies or substantial portions of the Software. */ using System.Net.Http; +using IdentityServer.QuickStarts; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.TestHost; @@ -22,7 +23,7 @@ namespace IdentityServer8.STS.Identity.IntegrationTests.Common { public static class WebApplicationFactoryExtensions { - public static HttpClient SetupClient(this WebApplicationFactory fixture) + public static HttpClient SetupClient(this WebApplicationFactory fixture) { var options = new WebApplicationFactoryClientOptions { @@ -31,7 +32,7 @@ public static HttpClient SetupClient(this WebApplicationFactory builder - .UseStartup() + .UseStartup() .ConfigureTestServices(services => { }) ).CreateClient(options); } diff --git a/samples/Quickstarts/test/IdentityServer.IntegrationTests/GlobalUsings.cs b/samples/Quickstarts/test/IdentityServer.IntegrationTests/GlobalUsings.cs index 6206a0cc..1b77b182 100644 --- a/samples/Quickstarts/test/IdentityServer.IntegrationTests/GlobalUsings.cs +++ b/samples/Quickstarts/test/IdentityServer.IntegrationTests/GlobalUsings.cs @@ -4,3 +4,4 @@ global using static IdentityServer8.Constants; global using Endpoint = IdentityServer8.Hosting.Endpoint; global using ClaimValueTypes = System.Security.Claims.ClaimValueTypes; +global using StartupTest = IdentityServer.QuickStarts.StartupTest; \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.IntegrationTests/Tests/Base/TestFixture.cs b/samples/Quickstarts/test/IdentityServer.IntegrationTests/Tests/Base/TestFixture.cs index 96ff4015..17ecd218 100644 --- a/samples/Quickstarts/test/IdentityServer.IntegrationTests/Tests/Base/TestFixture.cs +++ b/samples/Quickstarts/test/IdentityServer.IntegrationTests/Tests/Base/TestFixture.cs @@ -41,7 +41,7 @@ public TestFixture() configApp.AddJsonFile($"serilog.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); configApp.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); }) - .UseStartup(); + .UseStartup(); TestServer = new TestServer(builder); Client = TestServer.CreateClient(); diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/GlobalUsings.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/GlobalUsings.cs new file mode 100644 index 00000000..33a137ed --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/GlobalUsings.cs @@ -0,0 +1,4 @@ +global using StartupTests = IdentityServer.QuickStarts.StartupTest; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests.Base; +global using IdentityServer.Samples.Shared.IntegrationTests; \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/IdentityServer.Quickstarts.AspNetCore.IntegrationTests.csproj b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/IdentityServer.Quickstarts.AspNetCore.IntegrationTests.csproj new file mode 100644 index 00000000..ec99a1b6 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/IdentityServer.Quickstarts.AspNetCore.IntegrationTests.csproj @@ -0,0 +1,35 @@ + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + Always + + + Always + + + PreserveNewest + + + + \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/AccountControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/AccountControllerTests.cs new file mode 100644 index 00000000..1ca1cb5d --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/AccountControllerTests.cs @@ -0,0 +1,26 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + + + + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class AccountControllerTests : AccountControllerTests + { + public AccountControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/DiagnosticsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/DiagnosticsControllerTests.cs new file mode 100644 index 00000000..9599e2f6 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/DiagnosticsControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class DiagnosticsControllerTests : DiagnosticsControllerTests + { + public DiagnosticsControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/GrantsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/GrantsControllerTests.cs new file mode 100644 index 00000000..15a00651 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/GrantsControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class GrantsControllerTests : GrantsControllerTests + { + public GrantsControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/HomeControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/HomeControllerTests.cs new file mode 100644 index 00000000..e7b856bd --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/HomeControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class HomeControllerTests : HomeControllerTests + { + public HomeControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/IdentityServerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/IdentityServerTests.cs new file mode 100644 index 00000000..9eee1b26 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/IdentityServerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class IdentityServerTests : IdentityServerTests + { + public IdentityServerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/ManageControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/ManageControllerTests.cs new file mode 100644 index 00000000..f882a841 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCore.IntegrationTests/Tests/ManageControllerTests.cs @@ -0,0 +1,24 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class ManageControllerTests : ManageControllerTests + { + public ManageControllerTests(TestFixture fixture) : base(fixture) + { + } + + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/GlobalUsings.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/GlobalUsings.cs new file mode 100644 index 00000000..0c353a12 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/GlobalUsings.cs @@ -0,0 +1,4 @@ +global using StartupTests = IdentityServer.QuickStarts.StartupTest; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests.Base; +global using IdentityServer.Samples.Shared.IntegrationTests; \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests.csproj b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests.csproj new file mode 100644 index 00000000..6474915c --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests.csproj @@ -0,0 +1,35 @@ + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + Always + + + Always + + + PreserveNewest + + + + \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/AccountControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/AccountControllerTests.cs new file mode 100644 index 00000000..1ca1cb5d --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/AccountControllerTests.cs @@ -0,0 +1,26 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + + + + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class AccountControllerTests : AccountControllerTests + { + public AccountControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/DiagnosticsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/DiagnosticsControllerTests.cs new file mode 100644 index 00000000..9599e2f6 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/DiagnosticsControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class DiagnosticsControllerTests : DiagnosticsControllerTests + { + public DiagnosticsControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/GrantsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/GrantsControllerTests.cs new file mode 100644 index 00000000..15a00651 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/GrantsControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class GrantsControllerTests : GrantsControllerTests + { + public GrantsControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/HomeControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/HomeControllerTests.cs new file mode 100644 index 00000000..e7b856bd --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/HomeControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class HomeControllerTests : HomeControllerTests + { + public HomeControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/IdentityServerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/IdentityServerTests.cs new file mode 100644 index 00000000..9eee1b26 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/IdentityServerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class IdentityServerTests : IdentityServerTests + { + public IdentityServerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/ManageControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/ManageControllerTests.cs new file mode 100644 index 00000000..f882a841 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetCoreAndApis.IntegrationTests/Tests/ManageControllerTests.cs @@ -0,0 +1,24 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class ManageControllerTests : ManageControllerTests + { + public ManageControllerTests(TestFixture fixture) : base(fixture) + { + } + + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/GlobalUsings.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/GlobalUsings.cs new file mode 100644 index 00000000..b1914bd8 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/GlobalUsings.cs @@ -0,0 +1,6 @@ +global using Xunit; +global using StartupTests = IdentityServer.QuickStarts.StartupTest; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests.Base; +global using IdentityServer.Samples.Shared.IntegrationTests; +global using IdentityServer.Samples.Shared.IntegrationTests.Mocks; \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests.csproj b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests.csproj new file mode 100644 index 00000000..0c47ae6a --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests.csproj @@ -0,0 +1,35 @@ + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + Always + + + Always + + + PreserveNewest + + + + \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/AccountControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/AccountControllerTests.cs new file mode 100644 index 00000000..40f3ef3c --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/AccountControllerTests.cs @@ -0,0 +1,26 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + + + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class AccountControllerTests : AccountControllerTests + { + public AccountControllerTests(TestFixture fixture) : base(fixture) + { + UserMocks.SetTestUser(new() { Username = "alice", Password = "Pass123$" }); + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/DiagnosticsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/DiagnosticsControllerTests.cs new file mode 100644 index 00000000..50b777c7 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/DiagnosticsControllerTests.cs @@ -0,0 +1,24 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class DiagnosticsControllerTests : DiagnosticsControllerTests + { + public DiagnosticsControllerTests(TestFixture fixture) : base(fixture) + { + UserMocks.SetTestUser(new() { Username = "alice", Password = "Pass123$" }); + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/GrantsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/GrantsControllerTests.cs new file mode 100644 index 00000000..0b6bc528 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/GrantsControllerTests.cs @@ -0,0 +1,24 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class GrantsControllerTests : GrantsControllerTests + { + public GrantsControllerTests(TestFixture fixture) : base(fixture) + { + UserMocks.SetTestUser(new() { Username = "alice", Password = "Pass123$" }); + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/HomeControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/HomeControllerTests.cs new file mode 100644 index 00000000..77599e30 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/HomeControllerTests.cs @@ -0,0 +1,26 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using IdentityServer.Samples.Shared.IntegrationTests.Mocks; + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class HomeControllerTests : HomeControllerTests + { + public HomeControllerTests(TestFixture fixture) : base(fixture) + { + UserMocks.SetTestUser(new() { Username = "alice", Password = "Pass123$" }); + } + } +} \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/IdentityServerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/IdentityServerTests.cs new file mode 100644 index 00000000..a30d19d5 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/IdentityServerTests.cs @@ -0,0 +1,24 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class IdentityServerTests : IdentityServerTests + { + public IdentityServerTests(TestFixture fixture) : base(fixture) + { + UserMocks.SetTestUser(new() { Username = "alice", Password = "Pass123$" }); + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/ManageControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/ManageControllerTests.cs new file mode 100644 index 00000000..23b6ee8c --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.AspNetIdentity.IntegrationTests/Tests/ManageControllerTests.cs @@ -0,0 +1,25 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class ManageControllerTests : ManageControllerTests + { + public ManageControllerTests(TestFixture fixture) : base(fixture) + { + UserMocks.SetTestUser(new() { Username = "alice", Password = "Pass123$" }); + } + + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/GlobalUsings.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/GlobalUsings.cs new file mode 100644 index 00000000..6affaaf3 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/GlobalUsings.cs @@ -0,0 +1,5 @@ +global using Xunit; +global using StartupTests = IdentityServer.QuickStarts.ClientCredentials.StartupTest; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests.Base; +global using IdentityServer.Samples.Shared.IntegrationTests; \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests.csproj b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests.csproj new file mode 100644 index 00000000..c8ae55cb --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests.csproj @@ -0,0 +1,35 @@ + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + Always + + + Always + + + PreserveNewest + + + + \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/AccountControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/AccountControllerTests.cs new file mode 100644 index 00000000..1ca1cb5d --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/AccountControllerTests.cs @@ -0,0 +1,26 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + + + + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class AccountControllerTests : AccountControllerTests + { + public AccountControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/DiagnosticsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/DiagnosticsControllerTests.cs new file mode 100644 index 00000000..9599e2f6 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/DiagnosticsControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class DiagnosticsControllerTests : DiagnosticsControllerTests + { + public DiagnosticsControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/GrantsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/GrantsControllerTests.cs new file mode 100644 index 00000000..15a00651 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/GrantsControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class GrantsControllerTests : GrantsControllerTests + { + public GrantsControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/HomeControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/HomeControllerTests.cs new file mode 100644 index 00000000..e7b856bd --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/HomeControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class HomeControllerTests : HomeControllerTests + { + public HomeControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/IdentityServerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/IdentityServerTests.cs new file mode 100644 index 00000000..9eee1b26 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/IdentityServerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class IdentityServerTests : IdentityServerTests + { + public IdentityServerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/ManageControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/ManageControllerTests.cs new file mode 100644 index 00000000..f882a841 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.ClientCredentials.IntegrationTests/Tests/ManageControllerTests.cs @@ -0,0 +1,24 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class ManageControllerTests : ManageControllerTests + { + public ManageControllerTests(TestFixture fixture) : base(fixture) + { + } + + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/GlobalUsings.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/GlobalUsings.cs new file mode 100644 index 00000000..b2382e31 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/GlobalUsings.cs @@ -0,0 +1,5 @@ +global using Xunit; +global using StartupTests = IdentityServer.QuickStarts.StartupTest; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests.Base; +global using IdentityServer.Samples.Shared.IntegrationTests; \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/IdentityServer.Quickstarts.EntityFramework.IntegrationTests.csproj b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/IdentityServer.Quickstarts.EntityFramework.IntegrationTests.csproj new file mode 100644 index 00000000..ce9459bf --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/IdentityServer.Quickstarts.EntityFramework.IntegrationTests.csproj @@ -0,0 +1,35 @@ + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + Always + + + Always + + + PreserveNewest + + + + \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/AccountControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/AccountControllerTests.cs new file mode 100644 index 00000000..1ca1cb5d --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/AccountControllerTests.cs @@ -0,0 +1,26 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + + + + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class AccountControllerTests : AccountControllerTests + { + public AccountControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/DiagnosticsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/DiagnosticsControllerTests.cs new file mode 100644 index 00000000..9599e2f6 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/DiagnosticsControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class DiagnosticsControllerTests : DiagnosticsControllerTests + { + public DiagnosticsControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/GrantsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/GrantsControllerTests.cs new file mode 100644 index 00000000..15a00651 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/GrantsControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class GrantsControllerTests : GrantsControllerTests + { + public GrantsControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/HomeControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/HomeControllerTests.cs new file mode 100644 index 00000000..e7b856bd --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/HomeControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class HomeControllerTests : HomeControllerTests + { + public HomeControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/IdentityServerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/IdentityServerTests.cs new file mode 100644 index 00000000..9eee1b26 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/IdentityServerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class IdentityServerTests : IdentityServerTests + { + public IdentityServerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/ManageControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/ManageControllerTests.cs new file mode 100644 index 00000000..f882a841 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.EntityFramework.IntegrationTests/Tests/ManageControllerTests.cs @@ -0,0 +1,24 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class ManageControllerTests : ManageControllerTests + { + public ManageControllerTests(TestFixture fixture) : base(fixture) + { + } + + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/GlobalUsings.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/GlobalUsings.cs new file mode 100644 index 00000000..fdb3a412 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/GlobalUsings.cs @@ -0,0 +1,5 @@ +global using Xunit; +global using StartupTests = IdentityServer.QuickStarts.IdentityServer.StartupTest; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests.Base; +global using IdentityServer.Samples.Shared.IntegrationTests; \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/IdentityServer.Quickstarts.IdentityServer.IntegrationTests.csproj b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/IdentityServer.Quickstarts.IdentityServer.IntegrationTests.csproj new file mode 100644 index 00000000..ce0746de --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/IdentityServer.Quickstarts.IdentityServer.IntegrationTests.csproj @@ -0,0 +1,36 @@ + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + + Always + + + Always + + + PreserveNewest + + + + \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/AccountControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/AccountControllerTests.cs new file mode 100644 index 00000000..1ca1cb5d --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/AccountControllerTests.cs @@ -0,0 +1,26 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + + + + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class AccountControllerTests : AccountControllerTests + { + public AccountControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/DiagnosticsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/DiagnosticsControllerTests.cs new file mode 100644 index 00000000..9599e2f6 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/DiagnosticsControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class DiagnosticsControllerTests : DiagnosticsControllerTests + { + public DiagnosticsControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/GrantsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/GrantsControllerTests.cs new file mode 100644 index 00000000..15a00651 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/GrantsControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class GrantsControllerTests : GrantsControllerTests + { + public GrantsControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/HomeControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/HomeControllerTests.cs new file mode 100644 index 00000000..e7b856bd --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/HomeControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class HomeControllerTests : HomeControllerTests + { + public HomeControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/IdentityServerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/IdentityServerTests.cs new file mode 100644 index 00000000..9eee1b26 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/IdentityServerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class IdentityServerTests : IdentityServerTests + { + public IdentityServerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/ManageControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/ManageControllerTests.cs new file mode 100644 index 00000000..f882a841 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.IdentityServer.IntegrationTests/Tests/ManageControllerTests.cs @@ -0,0 +1,24 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class ManageControllerTests : ManageControllerTests + { + public ManageControllerTests(TestFixture fixture) : base(fixture) + { + } + + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/GlobalUsings.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/GlobalUsings.cs new file mode 100644 index 00000000..6affaaf3 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/GlobalUsings.cs @@ -0,0 +1,5 @@ +global using Xunit; +global using StartupTests = IdentityServer.QuickStarts.ClientCredentials.StartupTest; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests; +global using IdentityServer.Samples.Shared.IntegrationTests.Tests.Base; +global using IdentityServer.Samples.Shared.IntegrationTests; \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests.csproj b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests.csproj new file mode 100644 index 00000000..67db244f --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests.csproj @@ -0,0 +1,36 @@ + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + + Always + + + Always + + + PreserveNewest + + + + \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/AccountControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/AccountControllerTests.cs new file mode 100644 index 00000000..1ca1cb5d --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/AccountControllerTests.cs @@ -0,0 +1,26 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + + + + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class AccountControllerTests : AccountControllerTests + { + public AccountControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/DiagnosticsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/DiagnosticsControllerTests.cs new file mode 100644 index 00000000..9599e2f6 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/DiagnosticsControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class DiagnosticsControllerTests : DiagnosticsControllerTests + { + public DiagnosticsControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/GrantsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/GrantsControllerTests.cs new file mode 100644 index 00000000..15a00651 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/GrantsControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class GrantsControllerTests : GrantsControllerTests + { + public GrantsControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/HomeControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/HomeControllerTests.cs new file mode 100644 index 00000000..e7b856bd --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/HomeControllerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class HomeControllerTests : HomeControllerTests + { + public HomeControllerTests(TestFixture fixture) : base(fixture) + { + } + } +} \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/IdentityServerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/IdentityServerTests.cs new file mode 100644 index 00000000..9eee1b26 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/IdentityServerTests.cs @@ -0,0 +1,23 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class IdentityServerTests : IdentityServerTests + { + public IdentityServerTests(TestFixture fixture) : base(fixture) + { + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/ManageControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/ManageControllerTests.cs new file mode 100644 index 00000000..f882a841 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Quickstarts.JavascriptClient.IntegrationTests/Tests/ManageControllerTests.cs @@ -0,0 +1,24 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +namespace IdentityServer.QuickStarts.ClientCredentials.IntegrationTests +{ + public class ManageControllerTests : ManageControllerTests + { + public ManageControllerTests(TestFixture fixture) : base(fixture) + { + } + + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/AntiForgeryHelper.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/AntiForgeryHelper.cs new file mode 100644 index 00000000..27b4a95b --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/AntiForgeryHelper.cs @@ -0,0 +1,40 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using System; +using System.Net.Http; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace IdentityServer.Samples.Shared.IntegrationTests.Common +{ + public static class AntiForgeryHelper + { + public static string ExtractAntiForgeryToken(string htmlResponseText) + { + if (htmlResponseText == null) throw new ArgumentNullException(nameof(htmlResponseText)); + + var match = Regex.Match(htmlResponseText, @"\"); + + return match.Success ? match.Groups[1].Captures[0].Value : null; + } + + public static async Task ExtractAntiForgeryToken(this HttpResponseMessage response) + { + var responseAsString = await response.Content.ReadAsStringAsync(); + + return await Task.FromResult(ExtractAntiForgeryToken(responseAsString)); + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/CookiesHelper.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/CookiesHelper.cs new file mode 100644 index 00000000..7efe6d68 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/CookiesHelper.cs @@ -0,0 +1,77 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using Microsoft.Net.Http.Headers; + +namespace IdentityServer.Samples.Shared.IntegrationTests.Common +{ + public static class CookiesHelper + { + public static void PutCookiesOnRequest(this HttpClient client, HttpResponseMessage message) + { + var cookies = ExtractCookiesFromResponse(message); + + cookies.Keys.ToList().ForEach(key => + { + client.DefaultRequestHeaders.Add("Cookie", new CookieHeaderValue(key, cookies[key]).ToString()); + }); + } + + public static IDictionary ExtractCookiesFromResponse(HttpResponseMessage response) + { + IDictionary result = new Dictionary(); + + if (response.Headers.TryGetValues("Set-Cookie", out var values)) + { + SetCookieHeaderValue.ParseList(values.ToList()).ToList().ForEach(cookie => + { + result.Add(cookie.Name.Value, cookie.Value.Value); + }); + } + + return result; + } + + public static HttpRequestMessage PutCookiesOnRequest(HttpRequestMessage request, IDictionary cookies) + { + cookies.Keys.ToList().ForEach(key => + { + request.Headers.Add("Cookie", new CookieHeaderValue(key, cookies[key]).ToString()); + }); + + return request; + } + + public static HttpRequestMessage CopyCookiesFromResponse(HttpRequestMessage request, HttpResponseMessage response) + { + return PutCookiesOnRequest(request, ExtractCookiesFromResponse(response)); + } + + public static bool ExistsCookie(HttpResponseMessage responseMessage, string cookieName) + { + var existsCookie = false; + const string cookieHeader = "Set-Cookie"; + + if (responseMessage.Headers.TryGetValues(cookieHeader, out var cookies)) + { + existsCookie = cookies.Any(x => x.Contains(cookieName)); + } + + return existsCookie; + } + } +} \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/RequestHelper.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/RequestHelper.cs new file mode 100644 index 00000000..ea19be25 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/RequestHelper.cs @@ -0,0 +1,71 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; + +namespace IdentityServer.Samples.Shared.IntegrationTests.Common +{ + public class RequestHelper + { + /// + /// Create post request + /// + /// + /// + /// + public static HttpRequestMessage CreatePostRequest(string path, Dictionary formPostBodyData) + { + var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, path) + { + Content = new FormUrlEncodedContent(ToFormPostData(formPostBodyData)) + }; + + return httpRequestMessage; + } + + /// + /// Prepare form data + /// + /// + /// + public static List> ToFormPostData(Dictionary formPostBodyData) + { + var result = new List>(); + + formPostBodyData.Keys.ToList().ForEach(key => + { + result.Add(new KeyValuePair(key, formPostBodyData[key])); + }); + + return result; + } + + /// + /// Create post request with cookies from response + /// + /// + /// + /// + /// + public static HttpRequestMessage CreatePostRequestWithCookies(string path, Dictionary formPostBodyData, + HttpResponseMessage response) + { + var httpRequestMessage = CreatePostRequest(path, formPostBodyData); + + return CookiesHelper.CopyCookiesFromResponse(httpRequestMessage, response); + } + } +} \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/RoutesConstants.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/RoutesConstants.cs new file mode 100644 index 00000000..709916e7 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Common/RoutesConstants.cs @@ -0,0 +1,38 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using System.Collections.Generic; + +namespace IdentityServer.Samples.Shared.IntegrationTests.Common +{ + public static class RoutesConstants + { + public static List GetManageRoutes() + { + var manageRoutes = new List + { + "Index", + "ChangePassword", + "PersonalData", + "DeletePersonalData", + "ExternalLogins", + "TwoFactorAuthentication", + "ResetAuthenticatorWarning", + "EnableAuthenticator" + }; + + return manageRoutes; + } + } +} \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/GlobalUsings.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/GlobalUsings.cs new file mode 100644 index 00000000..8c927eb7 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/GlobalUsings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/IdentityServer.Samples.Shared.IntegrationTests.csproj b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/IdentityServer.Samples.Shared.IntegrationTests.csproj new file mode 100644 index 00000000..17e14c3f --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/IdentityServer.Samples.Shared.IntegrationTests.csproj @@ -0,0 +1,34 @@ + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + Always + + + Always + + + PreserveNewest + + + + \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/AccountControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/AccountControllerTests.cs new file mode 100644 index 00000000..99587128 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/AccountControllerTests.cs @@ -0,0 +1,277 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using FluentAssertions; +using HtmlAgilityPack; +using IdentityServer.Samples.Shared.IntegrationTests.Common; +using IdentityServer.Samples.Shared.IntegrationTests.Mocks; +using IdentityServer.Samples.Shared.IntegrationTests.Tests.Base; +using Microsoft.AspNetCore.Components.Forms; +using Xunit; + +namespace IdentityServer.Samples.Shared.IntegrationTests +{ + public abstract class AccountControllerTests : BaseClassFixture + where TFixture : class + { + public AccountControllerTests(TestFixture fixture) : base(fixture) + { + } + + [Fact] + public async Task UserIsNotAbleToRegister() + { + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + // Register new user + var registerFormData = UserMocks.GenerateRegisterData(); + var registerResponse = await UserMocks.RegisterNewUserAsync(Client, registerFormData); + + registerResponse.StatusCode.Should().Be(HttpStatusCode.NotFound); + } + + [Fact(Skip = "Base Identity Server Does Not Have Regisration Enabled")] + public async Task UserIsNotAbleToRegisterWithSameUserName() + { + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + // Register new user + var registerFormData = UserMocks.GenerateRegisterData(); + + var registerResponseFirst = await UserMocks.RegisterNewUserAsync(Client, registerFormData); + + // Assert + registerResponseFirst.StatusCode.Should().Be(HttpStatusCode.Redirect); + + //The redirect to login + registerResponseFirst.Headers.Location.ToString().Should().Be("/"); + + var registerResponseSecond = await UserMocks.RegisterNewUserAsync(Client, registerFormData); + + // Assert response + registerResponseSecond.StatusCode.Should().Be(HttpStatusCode.OK); + + // Get html content + var contentWithErrorMessage = await registerResponseSecond.Content.ReadAsStringAsync(); + + // From String + var doc = new HtmlDocument(); + doc.LoadHtml(contentWithErrorMessage); + + // Get error messages from validation summary + var errorNodes = doc.DocumentNode + .SelectNodes("//div[contains(@class, 'validation-summary-errors')]/ul/li"); + + errorNodes.Should().HaveCount(2); + + // Build expected error messages + var expectedErrorMessages = new List + { + $"Username '{registerFormData["UserName"]}' is already taken.", + $"Email '{registerFormData["Email"]}' is already taken." + }; + + // Assert + var containErrors = errorNodes.Select(x => x.InnerText).ToList().SequenceEqual(expectedErrorMessages); + + containErrors.Should().BeTrue(); + } + + [Fact] + public async Task UserIsAbleToLoginAndLogout() + { + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + const string accountLoginAction = "/Account/Login"; + var loginResponse = await Client.GetAsync(accountLoginAction); + loginResponse.EnsureSuccessStatusCode(); + + // Clear headers + Client.DefaultRequestHeaders.Clear(); + var antiForgeryToken = await loginResponse.ExtractAntiForgeryToken(); + // Prepare request to login + var testUser = UserMocks.TestUser; + var loginDataForm = UserMocks.GenerateLoginData(testUser.Username, testUser.Password, antiForgeryToken); + + // Login + var requestMessage = RequestHelper.CreatePostRequestWithCookies(accountLoginAction, loginDataForm, loginResponse); + var responseMessage = await Client.SendAsync(requestMessage); + var responseBody = await responseMessage.Content.ReadAsStringAsync(); + // Assert status code + responseMessage.StatusCode.Should().Be(HttpStatusCode.Redirect); + responseBody.Should().Be(""); + // Assert redirect location + responseMessage.Headers.Location.ToString().Should().Be("/"); + + // Check if response contain cookie with Identity + const string identityCookieName = "idsrv"; + var existsCookie = CookiesHelper.ExistsCookie(responseMessage, identityCookieName); + + // Assert Identity cookie + existsCookie.Should().BeTrue(); + + var logoutUrl = "/Account/Logout"; + Client.DefaultRequestHeaders.Clear(); + Client.PutCookiesOnRequest(responseMessage); + var logoutResponse = await Client.GetAsync(logoutUrl); + logoutResponse.EnsureSuccessStatusCode(); + + var content = await logoutResponse.Content.ReadAsStringAsync(); + content.Should().Contain("Would you like to logout"); + + Client.DefaultRequestHeaders.Clear(); + + var antiForgeryTokenLogout = await logoutResponse.ExtractAntiForgeryToken(); + var logoutFormData = UserMocks.GenerateLogoutData(null, antiForgeryTokenLogout); + //logoutFormData.Add("__RequestVerificationToken", value); + var logoutRequestMessage = RequestHelper.CreatePostRequestWithCookies(logoutUrl, logoutFormData, logoutResponse); + var doLogoutResponse = await Client.SendAsync(logoutRequestMessage); + var logoutContent = await doLogoutResponse.Content.ReadAsStringAsync(); + logoutContent.Should().Contain("You are now logged out"); + existsCookie = CookiesHelper.ExistsCookie(responseMessage, identityCookieName); + existsCookie.Should().BeTrue(); + } + + [Fact] + public async Task CanGetLocalLoginRedirect() + { + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + const string accountLoginAction = "/Account/Login"; + string loginUrl = accountLoginAction + "?returnUrl=~/"; + var loginResponse = await Client.GetAsync(loginUrl); + loginResponse.EnsureSuccessStatusCode(); + + + var content = await loginResponse.Content.ReadAsStringAsync(); + content.Should().Contain("login-page"); + // Clear headers + Client.DefaultRequestHeaders.Clear(); + var antiForgeryToken = await loginResponse.ExtractAntiForgeryToken(); + // Prepare request to login + var testUser = UserMocks.TestUser; + var loginDataForm = UserMocks.GenerateLoginData(testUser.Username, testUser.Password, antiForgeryToken); + + // Login + var requestMessage = RequestHelper.CreatePostRequestWithCookies(loginUrl, loginDataForm, loginResponse); + var responseMessage = await Client.SendAsync(requestMessage); + var responseBody = await responseMessage.Content.ReadAsStringAsync(); + // Assert status code + responseMessage.StatusCode.Should().Be(HttpStatusCode.Redirect); + responseBody.Should().Be(""); + + + } + + [Fact] + public async Task CanNotGetArbirtraryExternalLoginRedirect() + { + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + const string accountLoginAction = "/Account/Login"; + string loginUrl = accountLoginAction + "?returnUrl=https://restricted.domainname.com"; + var loginResponse = await Client.GetAsync(loginUrl); + loginResponse.EnsureSuccessStatusCode(); + var content = await loginResponse.Content.ReadAsStringAsync(); + + // Clear headers + Client.DefaultRequestHeaders.Clear(); + var antiForgeryToken = await loginResponse.ExtractAntiForgeryToken(); + // Prepare request to login + + var testUser = UserMocks.TestUser; + var loginDataForm = UserMocks.GenerateLoginData(testUser.Username, testUser.Password, antiForgeryToken); + // Login + var requestMessage = RequestHelper.CreatePostRequestWithCookies(loginUrl, loginDataForm, loginResponse); + var response = await Client.SendAsync(requestMessage); + response.StatusCode.Should().Be(HttpStatusCode.InternalServerError); + + } + [Fact] + public async Task AnymousUserCanGetAccessDenied() + { + // Clear headers + Client.DefaultRequestHeaders.Clear(); + const string accountLoginAction = "/Account/AccessDenied"; + var responseMessage = await Client.GetAsync(accountLoginAction); + responseMessage.EnsureSuccessStatusCode(); + + var contentWithErrorMessage = await responseMessage.Content.ReadAsStringAsync(); + contentWithErrorMessage.Should().Contain("Access Denied"); + } + [Fact] + public async Task UserIsNotAbleToLoginWithIncorrectPassword() + { + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + // Register new user + var registerFormData = UserMocks.GenerateRegisterData(); + + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + // Prepare request to login + const string accountLoginAction = "/Account/Login"; + var loginResponse = await Client.GetAsync(accountLoginAction); + var antiForgeryToken = await loginResponse.ExtractAntiForgeryToken(); + + // User Guid like fake password + var loginDataForm = UserMocks.GenerateLoginData(registerFormData["UserName"], Guid.NewGuid().ToString(), antiForgeryToken); + + // Login + var requestMessage = RequestHelper.CreatePostRequestWithCookies(accountLoginAction, loginDataForm, loginResponse); + var responseMessage = await Client.SendAsync(requestMessage); + + // Get html content + var contentWithErrorMessage = await responseMessage.Content.ReadAsStringAsync(); + + // Assert status code + responseMessage.StatusCode.Should().Be(HttpStatusCode.OK); + + // From String + var doc = new HtmlDocument(); + doc.LoadHtml(contentWithErrorMessage); + + // Get error messages from validation summary + var errorNodes = doc.DocumentNode + .SelectNodes("//div[contains(@class, 'validation-summary-errors')]/ul/li"); + + errorNodes.Should().HaveCount(1); + + // Build expected error messages + var expectedErrorMessages = new List + { + "Invalid username or password" + }; + + // Assert + var containErrors = errorNodes.Select(x => x.InnerText).ToList().SequenceEqual(expectedErrorMessages); + + containErrors.Should().BeTrue(); + + // Check if response contain cookie with Identity + const string identityCookieName = "idsvr"; + var existsCookie = CookiesHelper.ExistsCookie(responseMessage, identityCookieName); + + // Assert Identity cookie + existsCookie.Should().BeFalse(); + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/Base/BaseClassFixture.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/Base/BaseClassFixture.cs new file mode 100644 index 00000000..4b45b8af --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/Base/BaseClassFixture.cs @@ -0,0 +1,33 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using System.Net.Http; +using Microsoft.AspNetCore.TestHost; +using Xunit; + +namespace IdentityServer.Samples.Shared.IntegrationTests.Tests.Base +{ + public class BaseClassFixture : IClassFixture> + where TFixture : class + { + protected readonly HttpClient Client; + protected readonly TestServer TestServer; + + public BaseClassFixture(TestFixture fixture) + { + Client = fixture.Client; + TestServer = fixture.TestServer; + } + } +} \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/Base/TestFixture.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/Base/TestFixture.cs new file mode 100644 index 00000000..2f8764c2 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/Base/TestFixture.cs @@ -0,0 +1,57 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using System; +using System.Net.Http; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.TestHost; +using Microsoft.Extensions.Configuration; +using IdentityServer; + +namespace IdentityServer.Samples.Shared.IntegrationTests.Tests.Base +{ + public class TestFixture : IDisposable + where TFixture : class + { + public TestServer TestServer; + + public HttpClient Client { get; } + + public TestFixture() + { + Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development"); + var builder = new WebHostBuilder() + .ConfigureAppConfiguration((hostContext, configApp) => + { + configApp.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); + configApp.AddJsonFile("serilog.json", optional: true, reloadOnChange: true); + + var env = hostContext.HostingEnvironment; + + configApp.AddJsonFile($"serilog.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); + configApp.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); + }) + .UseStartup(); + + TestServer = new TestServer(builder); + Client = TestServer.CreateClient(); + } + + public void Dispose() + { + Client.Dispose(); + TestServer.Dispose(); + } + } +} \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/DiagnosticsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/DiagnosticsControllerTests.cs new file mode 100644 index 00000000..06a50981 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/DiagnosticsControllerTests.cs @@ -0,0 +1,85 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using System.Net; +using System.Threading.Tasks; +using FluentAssertions; +using IdentityServer.Samples.Shared.IntegrationTests.Common; +using IdentityServer.Samples.Shared.IntegrationTests.Mocks; +using IdentityServer.Samples.Shared.IntegrationTests.Tests.Base; +using Xunit; + +namespace IdentityServer.Samples.Shared.IntegrationTests.Tests +{ + public abstract class DiagnosticsControllerTests : BaseClassFixture + where TFixture : class + { + public DiagnosticsControllerTests(TestFixture fixture) : base(fixture) + { + } + + [Fact] + public async Task UnAuthorizeUserCannotAccessDiagnosticsView() + { + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + // Act + var response = await Client.GetAsync("/Diagnostics/Index"); + + // Assert + response.StatusCode.Should().Be(HttpStatusCode.Redirect); + + //The redirect to login + response.Headers.Location.ToString().Should().Contain("Account/Login"); + } + + [Fact] + public async Task AuthorizedUserCanAccessDiagnosticsView() + { + Client.DefaultRequestHeaders.Clear(); + const string accountLoginAction = "/Account/Login"; + var loginUrl = accountLoginAction + "?ReturnUrl=%2FDiagnostics%2FIndex"; + var loginResponse = await Client.GetAsync(accountLoginAction); + loginResponse.EnsureSuccessStatusCode(); + + // Clear headers + Client.DefaultRequestHeaders.Clear(); + var antiForgeryToken = await loginResponse.ExtractAntiForgeryToken(); + // Prepare request to login + var testUser = UserMocks.TestUser; + var loginDataForm = UserMocks.GenerateLoginData(testUser.Username, testUser.Password, antiForgeryToken); + + // Login + var requestMessage = RequestHelper.CreatePostRequestWithCookies(accountLoginAction, loginDataForm, loginResponse); + var responseMessage = await Client.SendAsync(requestMessage); + var responseBody = await responseMessage.Content.ReadAsStringAsync(); + + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + // Act + Client.PutCookiesOnRequest(responseMessage); + var response = await Client.GetAsync("/Diagnostics/Index"); + + + // Assert + response.StatusCode.Should().Be(HttpStatusCode.OK); + + //The redirect to login + var content = await response.Content.ReadAsStringAsync(); + content.Should().Contain("Claims"); + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/GrantsControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/GrantsControllerTests.cs new file mode 100644 index 00000000..f4c8c2b3 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/GrantsControllerTests.cs @@ -0,0 +1,85 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using System.Net; +using System.Threading.Tasks; +using FluentAssertions; +using IdentityServer.Samples.Shared.IntegrationTests.Common; +using IdentityServer.Samples.Shared.IntegrationTests.Mocks; +using IdentityServer.Samples.Shared.IntegrationTests.Tests.Base; +using IdentityServer8.Test; +using Xunit; + +namespace IdentityServer.Samples.Shared.IntegrationTests.Tests +{ + public abstract class GrantsControllerTests : BaseClassFixture + where TFixture : class + { + public GrantsControllerTests(TestFixture fixture) : base(fixture) + { + + } + + [Fact] + public async Task AuthorizeUserCanAccessGrantsView() + { + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + const string accountLoginAction = "/Account/Login"; + var loginUrl = accountLoginAction + "?ReturnUrl=%2FGrants%2FIndex"; + var loginResponse = await Client.GetAsync(accountLoginAction); + loginResponse.EnsureSuccessStatusCode(); + + // Clear headers + Client.DefaultRequestHeaders.Clear(); + var antiForgeryToken = await loginResponse.ExtractAntiForgeryToken(); + // Prepare request to login + var testUser = UserMocks.TestUser; + var loginDataForm = UserMocks.GenerateLoginData(testUser.Username, testUser.Password, antiForgeryToken); + + // Login + var requestMessage = RequestHelper.CreatePostRequestWithCookies(accountLoginAction, loginDataForm, loginResponse); + var responseMessage = await Client.SendAsync(requestMessage); + var responseBody = await responseMessage.Content.ReadAsStringAsync(); + responseMessage.StatusCode.Should().Be(HttpStatusCode.Redirect); + + // Get cookie with user identity for next request + Client.PutCookiesOnRequest(responseMessage); + + // Act + var response = await Client.GetAsync("/Grants/Index"); + + // Assert + response.EnsureSuccessStatusCode(); + response.StatusCode.Should().Be(HttpStatusCode.OK); + } + + [Fact] + public async Task UnAuthorizeUserCannotAccessGrantsView() + { + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + // Act + var response = await Client.GetAsync("/Grants/Index"); + + // Assert + response.StatusCode.Should().Be(HttpStatusCode.Redirect); + + //The redirect to login + response.Headers.Location.ToString().Should().Contain("Account/Login"); + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/HomeControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/HomeControllerTests.cs new file mode 100644 index 00000000..c40bf328 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/HomeControllerTests.cs @@ -0,0 +1,43 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using System.Net; +using System.Threading.Tasks; +using FluentAssertions; +using IdentityServer.Samples.Shared.IntegrationTests.Tests.Base; +using Xunit; + +namespace IdentityServer.Samples.Shared.IntegrationTests.Tests +{ + public abstract class HomeControllerTests : BaseClassFixture + where TFixture : class + { + public HomeControllerTests(TestFixture fixture) : base(fixture) + { + } + + [Fact] + public async Task EveryoneHasAccessToHomepage() + { + Client.DefaultRequestHeaders.Clear(); + + // Act + var response = await Client.GetAsync("/home/index"); + + // Assert + response.EnsureSuccessStatusCode(); + response.StatusCode.Should().Be(HttpStatusCode.OK); + } + } +} \ No newline at end of file diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/IdentityServerTests.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/IdentityServerTests.cs new file mode 100644 index 00000000..2b6d864f --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/IdentityServerTests.cs @@ -0,0 +1,42 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using System.Threading.Tasks; +using FluentAssertions; +using IdentityModel.Client; +using IdentityServer.Samples.Shared.IntegrationTests.Tests.Base; +using Xunit; + +namespace IdentityServer.Samples.Shared.IntegrationTests.Tests +{ + public abstract class IdentityServerTests : BaseClassFixture + where TFixture : class + { + public IdentityServerTests(TestFixture fixture) : base(fixture) + { + } + + + [Fact] + public async Task CanShowDiscoveryEndpoint() + { + var disco = await Client.GetDiscoveryDocumentAsync("http://localhost"); + + disco.Should().NotBeNull(); + disco.IsError.Should().Be(false); + + disco.KeySet.Keys.Count.Should().Be(1); + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/ManageControllerTests.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/ManageControllerTests.cs new file mode 100644 index 00000000..85ea5ac2 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/ManageControllerTests.cs @@ -0,0 +1,119 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using System.Net; +using System.Threading.Tasks; +using FluentAssertions; +using IdentityServer.Samples.Shared.IntegrationTests.Common; +using IdentityServer.Samples.Shared.IntegrationTests.Mocks; +using IdentityServer.Samples.Shared.IntegrationTests.Tests.Base; +using Xunit; + +namespace IdentityServer.Samples.Shared.IntegrationTests.Tests +{ + public abstract class ManageControllerTests : BaseClassFixture + where TFixture : class + { + public ManageControllerTests(TestFixture fixture) : base(fixture) + { + } + + [Fact] + public async Task ManageDoesNotExistInBaseIdentityServer() + { + // Act + var response = await Client.GetAsync("/Manage"); + + // Assert + response.StatusCode.Should().Be(HttpStatusCode.NotFound); + } + + [Fact(Skip = "Base Identity Server Does Not Have Manage Contoller")] + public async Task AuthorizeUserCanAccessManageViews() + { + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + // Register new user + var registerFormData = UserMocks.GenerateRegisterData(); + var registerResponse = await UserMocks.RegisterNewUserAsync(Client,registerFormData); + + // Get cookie with user identity for next request + Client.PutCookiesOnRequest(registerResponse); + + foreach (var route in RoutesConstants.GetManageRoutes()) + { + // Act + var response = await Client.GetAsync($"/Manage/{route}"); + + // Assert + response.EnsureSuccessStatusCode(); + response.StatusCode.Should().Be(HttpStatusCode.OK); + } + } + + + [Fact(Skip = "Base Identity Server Does Not Have Manage Contoller")] + public async Task UnAuthorizeUserCannotAccessManageViews() + { + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + foreach (var route in RoutesConstants.GetManageRoutes()) + { + // Act + var response = await Client.GetAsync($"/Manage/{route}"); + + // Assert + response.StatusCode.Should().Be(HttpStatusCode.Redirect); + + //The redirect to login + response.Headers.Location.ToString().Should().Contain("Account/Login"); + } + } + + + [Fact(Skip = "Base Identity Server Does Not Have Manage Contoller")] + public async Task UserIsAbleToUpdateProfile() + { + // Clear headers + Client.DefaultRequestHeaders.Clear(); + + // Register new user + var registerFormData = UserMocks.GenerateRegisterData(); + var registerResponse = await UserMocks.RegisterNewUserAsync(Client, registerFormData); + + // Get cookie with user identity for next request + Client.PutCookiesOnRequest(registerResponse); + + // Prepare request to update profile + const string manageAction = "/Manage/Index"; + var manageResponse = await Client.GetAsync(manageAction); + var antiForgeryToken = await manageResponse.ExtractAntiForgeryToken(); + + var manageProfileData = UserMocks.GenerateManageProfileData(registerFormData["Email"], antiForgeryToken); + + // Update profile + var requestWithAntiForgeryCookie = RequestHelper.CreatePostRequestWithCookies(manageAction, manageProfileData, manageResponse); + var requestWithIdentityCookie = CookiesHelper.CopyCookiesFromResponse(requestWithAntiForgeryCookie, registerResponse); + var responseMessage = await Client.SendAsync(requestWithIdentityCookie); + + // Assert + responseMessage.StatusCode.Should().Be(HttpStatusCode.Redirect); + + //The redirect to login + responseMessage.Headers.Location.ToString().Should().Be("/Manage"); + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/Mocks/UserMocks.cs b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/Mocks/UserMocks.cs new file mode 100644 index 00000000..7c6a0e2f --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/Tests/Mocks/UserMocks.cs @@ -0,0 +1,104 @@ +/* + Copyright (c) 2024 HigginsSoft + Written by Alexander Higgins https://github.com/alexhiggins732/ + + Copyright (c) 2018 Jan Skoruba + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code for this software can be found at https://github.com/alexhiggins732/IdentityServer8 + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + +*/ + +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using IdentityServer.Samples.Shared.IntegrationTests.Common; +using IdentityServer8.Test; + +namespace IdentityServer.Samples.Shared.IntegrationTests.Mocks +{ + public static class UserMocks + { + public static string UserPassword = "Pa$$word123"; + public static string AntiForgeryTokenKey = "__RequestVerificationToken"; + + public static TestUser GenerateDefaultTestUser() + { + return new TestUser + { + Username = "alice", + Password = "alice", + + }; + } + + public static TestUser TestUser { get; set; } = GenerateDefaultTestUser(); + public static void SetTestUser(TestUser user) => TestUser = user; + + public static Dictionary GenerateRegisterData() + { + return new Dictionary + { + { "UserName", Guid.NewGuid().ToString()}, + { "Password", UserPassword }, + { "ConfirmPassword", UserPassword}, + { "Email", $"{Guid.NewGuid().ToString()}@{Guid.NewGuid().ToString()}.com"} + }; + } + + public static Dictionary GenerateLoginData(string userName, string password, string antiForgeryToken) + { + var loginDataForm = new Dictionary + { + {"Username", userName}, + {"Password", password}, + {"button", "login"}, + {AntiForgeryTokenKey, antiForgeryToken} + }; + + return loginDataForm; + } + public static Dictionary GenerateLogoutData(string logoutId, string antiForgeryToken) + { + var logoutFormData = new Dictionary + { + {"logoutId", logoutId}, + {AntiForgeryTokenKey, antiForgeryToken} + }; + + return logoutFormData; + } + + public static Dictionary GenerateManageProfileData(string email, string antiForgeryToken) + { + var manageData = new Dictionary + { + { "Name", Guid.NewGuid().ToString()}, + { AntiForgeryTokenKey, antiForgeryToken}, + { "Email", email } + }; + + return manageData; + } + + public static async Task RegisterNewUserAsync(HttpClient client, Dictionary registerDataForm) + { + const string accountRegisterAction = "/Account/Register"; + + var registerResponse = await client.GetAsync(accountRegisterAction); + var antiForgeryToken = await registerResponse.ExtractAntiForgeryToken(); + + registerDataForm.Remove(AntiForgeryTokenKey); + registerDataForm.Add(AntiForgeryTokenKey, antiForgeryToken); + + var requestMessage = RequestHelper.CreatePostRequestWithCookies(accountRegisterAction, registerDataForm, registerResponse); + var responseMessage = await client.SendAsync(requestMessage); + + return responseMessage; + } + } +} diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/identityserver_testing.cer b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/identityserver_testing.cer new file mode 100644 index 00000000..71c61c74 --- /dev/null +++ b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/identityserver_testing.cer @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDQTCCAimgAwIBAgIQO+9qzaJY9I5Ewq81kNEKWTANBgkqhkiG9w0BAQsFADAh +MR8wHQYDVQQDDBZpZGVudGl0eXNlcnZlcl90ZXN0aW5nMCAXDTIwMDEyMjIzMTYz +OFoYDzIxMDMwNTIyMjMyNjM5WjAhMR8wHQYDVQQDDBZpZGVudGl0eXNlcnZlcl90 +ZXN0aW5nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuyZQvE+6gEoB +a+LV3dxjk/Xj4DRJ/tefQKR2AZoYAAfKN4ditFmEfRC1A6rckBpMVihTeb1kwwQT +7H4HTS6O/ERHVjOdghoOjEsVakWhAkvh8gphC4IU0upXlYqMh2WzgXEXwYRFB9Tk +7zoHb1/zjEEAhCf2Xbi6YslBoU71bFWyAaeOTl859wV6WaiBIK5L8nJUaIaq4zmC +k8caPZq5E867mZiMdL4TcW9/YoAAO96Wa/W9o6OiuZrP414TlEjVuccpLXvjk0hB +U5OZD2bTvD3MQZu1n1QMLwXfaOBrcv1/RqYJkK7vpP6Pp1YYlo7b2PBDVAIrRSVT +laViBP0owQIDAQABo3MwcTAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYB +BQUHAwIGCCsGAQUFBwMBMCEGA1UdEQQaMBiCFmlkZW50aXR5c2VydmVyX3Rlc3Rp +bmcwHQYDVR0OBBYEFCVXNpKp8QlHywXEBFfpXxWcOMcsMA0GCSqGSIb3DQEBCwUA +A4IBAQBsEAzwyN6V6N5ggN9G1O0ZpviSjixGkWtySNCBjbGXAhOvfW4M3ysNkDwZ +ltk/Q17ihZzw135MrDCmnr5pRiN4CbEGbe1qsb+Z0uCCn8/WcIVYYooW66H/Jez+ +dg5RxUukA67ZDnjzRskIer7L2t1C4pDqpvPVcneUxkiYDSgcKpTuCVjkPNQKQTIw +Sm98NkQG8G8V8+ENIU837ytkiC5nqQa4zDRHexzWrYhiuayWWxJKcNRVF9YaE8ts +vp5N1ewmWbSgF8caJuKraVOISj9R4iqf0XuhfSpW/7eIWYmXfqy/UloeqlALfP5C +2d2FdDSfsQ4Jgc3ebrECAQaCC3Gq +-----END CERTIFICATE----- diff --git a/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/identityserver_testing.pfx b/samples/Quickstarts/test/IdentityServer.Samples.Shared.IntegrationTests/identityserver_testing.pfx new file mode 100644 index 0000000000000000000000000000000000000000..dfb1a0f25e88edc779324eab21aba417d481384b GIT binary patch literal 2654 zcmZWrc{tST7yphKW0{D?HnNPRti!})ELnb(2$N;3xkQ#+dngQIXfn34PRJ73*9s9g zS(4?-z9gyaW6wT>-`t+x@80M4{GRtY?|aVY^Ev0d&-=%DUNn)_h5-ad6IpqnEYc)B z(jFU#36x7@Wr7e{=`hO)ng|8{hhqEzAu_I_iHuab%|T)R$vVXfV#p;zj?qNO0a^gc z`d^q{oE^d((Ny#rd%pP*0|Qe(ga{cY!-KYShth7F-Y04)_E=siK^VK;cT#!igmWZp5AxF3Dk{L<)3WuQ*maV~zzGwB^FrlRTVq43A5)3A$=JP_h%YY^V*P9JiBHbH zHZn++;IvNJ=|m;^`K|}VoH^h(rtpCH5h1)vnuJ72PR5c1DIK5b zT8f08{38*$nlL`i&?CLa_uO0Sdm@FAw#w1p%%ys2OGo#IC|wKEQGaG~ADa5s_j``Z z*=MBfH77k-LwxO9ipU6SSnoY`FC6T^T`ki)G*H??=@NZ}852zxsPNx@r;%q^8u@*| zV}r)bt#HK!JCihQ=18fcQrwcdXyIYs5uc5+6m?+s^HmtV5B-=#-0$vnU)nbt@D0uT z4Nu!Xk?tbiJIQX94`hjJK&NwDcQ!^W`jaEgO%8twFP+^AdEC`*(6At!e?3#InsX9d zY2jKlGOH6iv~|c4$A|i6fCnL8C)XWM4)H$zC{nUJbruIw3ty}RO|P47g(}jR3>FLayTYpNp#+Obeno5 z(5L@pdwks!5s9LQrrjr{SQ^o?YuMfI66fQ^xSj@{Dvd0d#fb1sMRagT06ziGrG!6~ zz5U7tG<|d4q1DX`3|pc_V@^NTO!m5yL?b_ja zE*mni>E3)KXFb(AZBejc&-OFDFZEC^Y46o^j8)vG=Me7fT#gKHlwO&SK*bo_h^d!G z4WZ0wd!8M~TJ!vQEkDmtSl=l9hEjxN-ZO=%6mQLX4tj)%Gqb zTw8_JaE5EF%k7M8u;=(s6>nZUtj?7*o)uM7wa{`SrKee#;xoqvSH1sr*a>i;GYWKbpmWZDm6w5n zARr=^6ZEUR5#UA_-T}M;Kf1Zl+aUon`u-Q<1-Q~99l9R`_|P$LdVGgo$OpLnD+>u2 z|I*#1M^5y%chE%e-rx6Ug60yzi*#s~0R+&GFaI#0{~!Dcc5O!1=4q*a4gPQ<$XGtf-?=L@>F=Jj0)Nxn{XSuyN!AtnqDzk@dRbq`H1!?bkPa zVQ!tOB3*2?6U!@8Wv?ea+wNs zg;{z1sh;1}+Iuyz@=~9F^M2Cg7(j4P>LxiY`d8DGTu%hjZAZNslR3MLGRJ8WGBZ>) zQc8WFcsezSw#6Y`_2~hh@8qYX2>tFUcs_T{buX8>PX-y+x)fOK>Y8ZbwPq$E&xp!u z{VG?nb?Pc!XKkClG;&I`av9hTCtN;#`m0&nzK5ZXSyyMdH%d^BdVO``zSW%0__C}s z@_;MIiI=Tm>3&r%Mn)oCR`!4~o_KQAY4TZ=&?mGd>+R$6r>RL28z7Ph#9z{MVleGIP) z+GnERCH7dUO=Q4o-h-}$@9IK_?-odIn#K7!!=K*M(364ra6TRrIh+pyQ^>Vfx(Ztg zXgmHgmvRdg$!x4}pD+-5^K7M!?(_NX6+isC2O{#+tWR#2$0;ky#F;;ZN$-bygK>6F z(wc*L6@C;*%Kk0iKGLHwY?>xV@t&)w6&ei7Kn%twM2+MHzJ(d^S+d7-AOiJ|w4$hJ ze0IIC<_*47iA44Ohtnz5-=J)gha#iwo{zNlqs@^ggUw;N- zTqZ_G35JSUEjCGB?5^b}&!d7nn9J7XHP1Q9?U=g1S79QEskds4H(FK2?TNK#|KT30 zXez$3mZr!j=O^wL+m@7XCVF+{!3Co&WgM*ePw{?<=jB|Uxs}Vu{>Z^{<~E=3Y;w89 z`T4w#&97^wx^@}h{mq*%FXO&M@05iVYAT?%y{XAFKYIFQG>zxgmfUr^f0s0;zgW)Y zOAt@8>?+<>axp8Mf)go)RFC7dwmD2Sul(35Xu3%VcUx^fDeuWx5bCtkI9(DI|7MrQ zb<7XIRz58^_FWSg3FBF83Ndqb)<0m~>Cl?en2>J%@YMd?<}K~^v7B!LTk$rLhl7I4 ztJK+ZXW{*g8!l!sG?H4!AG>CVXy(#mw{pe4bVBiWr9=m#HAX^jenNtBnX}_+_F+qL zm1IELVkue;EsSP@GRm-n8TcVwlvCDyBm@(4%&SB8I#R;7T} /// Sets the temporary signing credential. /// @@ -165,17 +166,19 @@ public static IIdentityServerBuilder AddDeveloperSigningCredential( string filename = null, IdentityServerConstants.RsaSigningAlgorithm signingAlgorithm = IdentityServerConstants.RsaSigningAlgorithm.RS256) { + Mutex.WaitOne(); if (filename == null) { filename = Path.Combine(Directory.GetCurrentDirectory(), "tempkey.jwk"); } - + IIdentityServerBuilder result; if (File.Exists(filename)) { var json = File.ReadAllText(filename); var jwk = new JsonWebKey(json); - return builder.AddSigningCredential(jwk, jwk.Alg); + result = builder.AddSigningCredential(jwk, jwk.Alg); + } else { @@ -188,8 +191,11 @@ public static IIdentityServerBuilder AddDeveloperSigningCredential( File.WriteAllText(filename, JsonConvert.SerializeObject(jwk)); } - return builder.AddSigningCredential(key, signingAlgorithm); + result = builder.AddSigningCredential(key, signingAlgorithm); } + + Mutex.ReleaseMutex(); + return result; } /// @@ -265,7 +271,7 @@ public static IIdentityServerBuilder AddValidationKey( // add signing algorithm name to key ID to allow using the same key for two different algorithms (e.g. RS256 and PS56); var key = new X509SecurityKey(certificate); key.KeyId += signingAlgorithm; - + var keyInfo = new SecurityKeyInfo { Key = key, diff --git a/src/IdentityServer8/test/IdentityServer.IntegrationTests/IdentityServer.IntegrationTests.csproj b/src/IdentityServer8/test/IdentityServer.IntegrationTests/IdentityServer.IntegrationTests.csproj index 8a80ba9b..d5ddac6f 100644 --- a/src/IdentityServer8/test/IdentityServer.IntegrationTests/IdentityServer.IntegrationTests.csproj +++ b/src/IdentityServer8/test/IdentityServer.IntegrationTests/IdentityServer.IntegrationTests.csproj @@ -33,6 +33,7 @@ +