├── unit-tests ├── PasswordValidator │ ├── PasswordValidator.csproj │ └── PasswordValidator.cs └── PasswordValidator.Tests │ ├── PasswordValidator.Tests.csproj │ └── ValidityTests.cs ├── integration-tests ├── Glossary.IntegrationTests │ ├── appsettings.json │ ├── Glossary.IntegrationTests.csproj │ └── IntegrationTests.cs └── glossary-web-api-aspnet-core │ ├── GlossaryItem.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── Glossary.csproj │ ├── Program.cs │ ├── Glossary.sln │ ├── Properties │ └── launchSettings.json │ ├── README.md │ ├── LICENSE │ ├── Startup.cs │ └── Controllers │ └── GlossaryController.cs ├── integration-tests-mock ├── glossary-web-api-aspnet-core │ ├── GlossaryItem.cs │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── Glossary.csproj │ ├── Program.cs │ ├── Glossary.sln │ ├── Properties │ │ └── launchSettings.json │ ├── README.md │ ├── LICENSE │ ├── Startup.cs │ └── Controllers │ │ └── GlossaryController.cs └── Glossary.IntegrationTests │ ├── Glossary.IntegrationTests.csproj │ ├── CustomWebApplicationFactory.cs │ ├── FakeJwtManager.cs │ └── IntegrationTests.cs ├── README.md └── .gitignore /unit-tests/PasswordValidator/PasswordValidator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /integration-tests/Glossary.IntegrationTests/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Auth0": { 3 | "ClientId": "YOUR_CLIENT_ID", 4 | "ClientSecret": "YOUR_CLIENT_SECRET", 5 | "Domain": "YOUR_DOMAIN", 6 | "Audience": "YOUR_AUDIENCE" 7 | } 8 | } -------------------------------------------------------------------------------- /integration-tests/glossary-web-api-aspnet-core/GlossaryItem.cs: -------------------------------------------------------------------------------- 1 | namespace Glossary 2 | { 3 | public class GlossaryItem 4 | { 5 | public string Term { get; set; } 6 | public string Definition { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration-tests-mock/glossary-web-api-aspnet-core/GlossaryItem.cs: -------------------------------------------------------------------------------- 1 | namespace Glossary 2 | { 3 | public class GlossaryItem 4 | { 5 | public string Term { get; set; } 6 | public string Definition { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /integration-tests/glossary-web-api-aspnet-core/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /integration-tests-mock/glossary-web-api-aspnet-core/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /integration-tests/glossary-web-api-aspnet-core/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "Auth0": { 11 | "Domain": "YOUR_DOMAIN", 12 | "Audience": "YOUR_AUDIENCE" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /integration-tests-mock/glossary-web-api-aspnet-core/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "Auth0": { 11 | "Domain": "YOUR_DOMAIN", 12 | "Audience": "YOUR_AUDIENCE" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /integration-tests/glossary-web-api-aspnet-core/Glossary.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /integration-tests-mock/glossary-web-api-aspnet-core/Glossary.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /unit-tests/PasswordValidator/PasswordValidator.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | 3 | namespace Validators.Password 4 | { 5 | public class PasswordValidator 6 | { 7 | public bool IsValid(string password) 8 | { 9 | Regex passwordPolicyExpression = new Regex(@"((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#!$%]).{8,20})"); 10 | return passwordPolicyExpression.IsMatch(password); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /unit-tests/PasswordValidator.Tests/PasswordValidator.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /integration-tests/glossary-web-api-aspnet-core/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Glossary 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /integration-tests-mock/glossary-web-api-aspnet-core/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.Extensions.Configuration; 7 | using Microsoft.Extensions.Hosting; 8 | using Microsoft.Extensions.Logging; 9 | 10 | namespace Glossary 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /integration-tests/glossary-web-api-aspnet-core/Glossary.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "glossary", "glossary.csproj", "{4AC9F68D-BA4E-40D8-9AD2-F77F87E12899}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {4AC9F68D-BA4E-40D8-9AD2-F77F87E12899}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {4AC9F68D-BA4E-40D8-9AD2-F77F87E12899}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {4AC9F68D-BA4E-40D8-9AD2-F77F87E12899}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {4AC9F68D-BA4E-40D8-9AD2-F77F87E12899}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | EndGlobal 18 | -------------------------------------------------------------------------------- /integration-tests-mock/glossary-web-api-aspnet-core/Glossary.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "glossary", "glossary.csproj", "{4AC9F68D-BA4E-40D8-9AD2-F77F87E12899}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {4AC9F68D-BA4E-40D8-9AD2-F77F87E12899}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {4AC9F68D-BA4E-40D8-9AD2-F77F87E12899}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {4AC9F68D-BA4E-40D8-9AD2-F77F87E12899}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {4AC9F68D-BA4E-40D8-9AD2-F77F87E12899}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | EndGlobal 18 | -------------------------------------------------------------------------------- /integration-tests/glossary-web-api-aspnet-core/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:47402", 8 | "sslPort": 44316 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "glossary": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "api/glossary", 24 | "environmentVariables": { 25 | "ASPNETCORE_ENVIRONMENT": "Development" 26 | }, 27 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /integration-tests-mock/glossary-web-api-aspnet-core/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:47402", 8 | "sslPort": 44316 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "launchUrl": "weatherforecast", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "glossary": { 21 | "commandName": "Project", 22 | "launchBrowser": true, 23 | "launchUrl": "api/glossary", 24 | "environmentVariables": { 25 | "ASPNETCORE_ENVIRONMENT": "Development" 26 | }, 27 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /integration-tests/Glossary.IntegrationTests/Glossary.IntegrationTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | PreserveNewest 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /integration-tests-mock/Glossary.IntegrationTests/Glossary.IntegrationTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | PreserveNewest 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /integration-tests-mock/Glossary.IntegrationTests/CustomWebApplicationFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Authentication.JwtBearer; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.Mvc.Testing; 4 | using Microsoft.AspNetCore.TestHost; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using Microsoft.IdentityModel.Tokens; 7 | 8 | namespace Glossary.IntegrationTests 9 | { 10 | public class CustomWebApplicationFactory : WebApplicationFactory 11 | { 12 | protected override void ConfigureWebHost(IWebHostBuilder builder) 13 | { 14 | builder.ConfigureTestServices(services => 15 | { 16 | services.PostConfigure(JwtBearerDefaults.AuthenticationScheme, options => 17 | { 18 | options.TokenValidationParameters = new TokenValidationParameters() 19 | { 20 | IssuerSigningKey = FakeJwtManager.SecurityKey, 21 | ValidIssuer = FakeJwtManager.Issuer, 22 | ValidAudience = FakeJwtManager.Audience 23 | }; 24 | }); 25 | }); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /integration-tests/glossary-web-api-aspnet-core/README.md: -------------------------------------------------------------------------------- 1 | This repository contains a basic glossary Web API implemented in ASP.NET Core 3.0 and secured with [Auth0](https://auth0.com/). 2 | 3 | The following article describes the implementation details: [Building and Securing Web APIs with ASP.NET Core 3.0](https://auth0.com/blog/how-to-build-and-secure-web-apis-with-aspnet-core-3/) 4 | 5 | ## To run this: 6 | 7 | 1. Clone the repo: `git clone https://github.com/auth0-blog/glossary-web-api-aspnet-core.git` 8 | 2. Move to the `glossary` folder 9 | 3. Add Auth0 credentials to the `appsettings.json` configuration file. 10 | 4. Type `dotnet run` in a terminal window to launch the Web API. 11 | 5. Point your browser to `https://localhost:5001/api/glossary` to get the list of all glossary terms and ensure that the application is working. 12 | 13 | ## Requirements: 14 | 15 | - [.NET Core 3.0](https://dotnet.microsoft.com/download/dotnet-core/3.0) installed on your machine 16 | - An [Auth0](https://auth0.com/) account. 17 | - [curl](https://curl.haxx.se/), [Postman](https://www.getpostman.com/), [Insomnia](https://insomnia.rest/) or any other HTTP client. 18 | 19 | -------------------------------------------------------------------------------- /integration-tests-mock/glossary-web-api-aspnet-core/README.md: -------------------------------------------------------------------------------- 1 | This repository contains a basic glossary Web API implemented in ASP.NET Core 3.0 and secured with [Auth0](https://auth0.com/). 2 | 3 | The following article describes the implementation details: [Building and Securing Web APIs with ASP.NET Core 3.0](https://auth0.com/blog/how-to-build-and-secure-web-apis-with-aspnet-core-3/) 4 | 5 | ## To run this: 6 | 7 | 1. Clone the repo: `git clone https://github.com/auth0-blog/glossary-web-api-aspnet-core.git` 8 | 2. Move to the `glossary` folder 9 | 3. Add Auth0 credentials to the `appsettings.json` configuration file. 10 | 4. Type `dotnet run` in a terminal window to launch the Web API. 11 | 5. Point your browser to `https://localhost:5001/api/glossary` to get the list of all glossary terms and ensure that the application is working. 12 | 13 | ## Requirements: 14 | 15 | - [.NET Core 3.0](https://dotnet.microsoft.com/download/dotnet-core/3.0) installed on your machine 16 | - An [Auth0](https://auth0.com/) account. 17 | - [curl](https://curl.haxx.se/), [Postman](https://www.getpostman.com/), [Insomnia](https://insomnia.rest/) or any other HTTP client. 18 | 19 | -------------------------------------------------------------------------------- /integration-tests/glossary-web-api-aspnet-core/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Auth0 Blog Samples 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /integration-tests-mock/glossary-web-api-aspnet-core/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Auth0 Blog Samples 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /integration-tests-mock/Glossary.IntegrationTests/FakeJwtManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IdentityModel.Tokens.Jwt; 3 | using System.Security.Cryptography; 4 | using Microsoft.IdentityModel.Tokens; 5 | 6 | namespace Glossary.IntegrationTests 7 | { 8 | public static class FakeJwtManager 9 | { 10 | public static string Issuer { get; } = Guid.NewGuid().ToString(); 11 | public static string Audience { get; } = Guid.NewGuid().ToString(); 12 | public static SecurityKey SecurityKey { get; } 13 | public static SigningCredentials SigningCredentials { get; } 14 | 15 | private static readonly JwtSecurityTokenHandler tokenHandler = new JwtSecurityTokenHandler(); 16 | private static readonly RandomNumberGenerator generator = RandomNumberGenerator.Create(); 17 | private static readonly byte[] key = new byte[32]; 18 | 19 | static FakeJwtManager() 20 | { 21 | generator.GetBytes(key); 22 | SecurityKey = new SymmetricSecurityKey(key) { KeyId = Guid.NewGuid().ToString() }; 23 | SigningCredentials = new SigningCredentials(SecurityKey, SecurityAlgorithms.HmacSha256); 24 | } 25 | 26 | public static string GenerateJwtToken() 27 | { 28 | return tokenHandler.WriteToken(new JwtSecurityToken(Issuer, Audience, null, null, DateTime.UtcNow.AddMinutes(10), SigningCredentials)); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /unit-tests/PasswordValidator.Tests/ValidityTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | using Validators.Password; 4 | 5 | namespace PasswordValidatorTests 6 | { 7 | public class ValidityTest 8 | { 9 | [Fact] 10 | public void ValidPassword() 11 | { 12 | //Arrange 13 | var passwordValidator = new PasswordValidator(); 14 | const string password = "Th1sIsapassword!"; 15 | 16 | //Act 17 | bool isValid = passwordValidator.IsValid(password); 18 | 19 | //Assert 20 | Assert.True(isValid, $"The password {password} is not valid"); 21 | } 22 | 23 | [Fact] 24 | public void NotValidPassword() 25 | { 26 | //Arrange 27 | var passwordValidator = new PasswordValidator(); 28 | const string password = "thisIsaPassword"; 29 | 30 | //Act 31 | bool isValid = passwordValidator.IsValid(password); 32 | 33 | //Assert 34 | Assert.False(isValid, $"The password {password} should not be valid!"); 35 | } 36 | 37 | [Theory] 38 | [InlineData("Th1sIsapassword!", true)] 39 | [InlineData("thisIsapassword123!", true)] 40 | [InlineData("Abc$123456", true)] 41 | [InlineData("Th1s!", false)] 42 | [InlineData("thisIsAPassword", false)] 43 | [InlineData("thisisapassword#", false)] 44 | [InlineData("THISISAPASSWORD123!", false)] 45 | [InlineData("", false)] 46 | public void ValidatePassword(string password, bool expectedResult) 47 | { 48 | //Arrange 49 | var passwordValidator = new PasswordValidator(); 50 | 51 | //Act 52 | bool isValid = passwordValidator.IsValid(password); 53 | 54 | //Assert 55 | Assert.Equal(expectedResult, isValid); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This repository contains three folders with the .NET Core projects showing how to use xUnit to create unit and integration tests for C# applications. 2 | 3 | The following article describes the implementation details: [Using xUnit to Test your C# Code](https://auth0.com/blog/xunit-to-test-csharp-code/) 4 | 5 | ## Running the projects 6 | 7 | 1. Clone the repo: `git clone https://github.com/auth0-blog/unit-integration-test-xunit.git` 8 | 2. Move to the `unit-integration-test-xunit` folder (*root folder of the repository*) 9 | 10 | 11 | 12 | ### Running the unit test project 13 | 14 | 1. Move to the `/unit-test/PasswordValidator.Tests` folder 15 | 2. Type `dotnet test` in a terminal window to run the tests 16 | 17 | 18 | 19 | ### Running the integration test project 20 | 21 | 1. Move to the `/integration-tests/glossary-web-api-aspnet-core` folder 22 | 2. Add Auth0 configuration data to the `appsettings.json` configuration file. 23 | 3. Move to the `/integration-tests/Glossary.IntegrationTests` folder 24 | 4. Add Auth0 configuration data to the `appsettings.json` configuration file. 25 | 5. Type `dotnet test` in a terminal window to run the tests 26 | 27 | 28 | 29 | ### Running the integration test with mock project 30 | 31 | 1. Move to the `/integration-tests-mock/glossary-web-api-aspnet-core` folder 32 | 2. Add Auth0 configuration data to the `appsettings.json` configuration file. 33 | 3. Move to the `/integration-tests-mock/Glossary.IntegrationTests` folder 34 | 4. Add Auth0 configuration data to the `appsettings.json` configuration file. 35 | 5. Type `dotnet test` in a terminal window to run the tests 36 | 37 | 38 | 39 | ## Requirements: 40 | 41 | - [.NET Core 3.1](https://dotnet.microsoft.com/download/dotnet-core/3.1) installed on your machine 42 | - An [Auth0](https://auth0.com/) account. 43 | 44 | -------------------------------------------------------------------------------- /integration-tests/glossary-web-api-aspnet-core/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using Microsoft.Extensions.Hosting; 6 | using Microsoft.AspNetCore.Authentication.JwtBearer; 7 | 8 | namespace Glossary 9 | { 10 | public class Startup 11 | { 12 | public Startup(IConfiguration configuration) 13 | { 14 | Configuration = configuration; 15 | } 16 | 17 | public IConfiguration Configuration { get; } 18 | 19 | // This method gets called by the runtime. Use this method to add services to the container. 20 | public void ConfigureServices(IServiceCollection services) 21 | { 22 | services.AddAuthentication(options => 23 | { 24 | options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; 25 | options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; 26 | }).AddJwtBearer(options => 27 | { 28 | options.Authority = $"https://{Configuration["Auth0:Domain"]}/"; 29 | options.Audience = Configuration["Auth0:Audience"]; 30 | }); 31 | services.AddControllers(); 32 | } 33 | 34 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 35 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 36 | { 37 | if (env.IsDevelopment()) 38 | { 39 | app.UseDeveloperExceptionPage(); 40 | } 41 | 42 | app.UseHttpsRedirection(); 43 | app.UseRouting(); 44 | app.UseAuthentication(); 45 | app.UseAuthorization(); 46 | app.UseEndpoints(endpoints => 47 | { 48 | endpoints.MapControllers(); 49 | }); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /integration-tests-mock/glossary-web-api-aspnet-core/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using Microsoft.Extensions.Hosting; 6 | using Microsoft.AspNetCore.Authentication.JwtBearer; 7 | 8 | namespace Glossary 9 | { 10 | public class Startup 11 | { 12 | public Startup(IConfiguration configuration) 13 | { 14 | Configuration = configuration; 15 | } 16 | 17 | public IConfiguration Configuration { get; } 18 | 19 | // This method gets called by the runtime. Use this method to add services to the container. 20 | public void ConfigureServices(IServiceCollection services) 21 | { 22 | services.AddAuthentication(options => 23 | { 24 | options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; 25 | options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; 26 | }).AddJwtBearer(options => 27 | { 28 | options.Authority = $"https://{Configuration["Auth0:Domain"]}/"; 29 | options.Audience = Configuration["Auth0:Audience"]; 30 | }); 31 | services.AddControllers(); 32 | } 33 | 34 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 35 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 36 | { 37 | if (env.IsDevelopment()) 38 | { 39 | app.UseDeveloperExceptionPage(); 40 | } 41 | 42 | app.UseHttpsRedirection(); 43 | app.UseRouting(); 44 | app.UseAuthentication(); 45 | app.UseAuthorization(); 46 | app.UseEndpoints(endpoints => 47 | { 48 | endpoints.MapControllers(); 49 | }); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /integration-tests-mock/Glossary.IntegrationTests/IntegrationTests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.Http; 6 | using System.Net.Http.Headers; 7 | using System.Text; 8 | using System.Text.Json; 9 | using System.Threading.Tasks; 10 | using Xunit; 11 | 12 | namespace Glossary.IntegrationTests 13 | { 14 | public class IntegrationTests : IClassFixture> 15 | { 16 | private readonly HttpClient httpClient; 17 | public IntegrationTests(CustomWebApplicationFactory factory) 18 | { 19 | httpClient = factory.CreateClient(); 20 | } 21 | 22 | [Fact] 23 | public async Task GetGlossaryList() 24 | { 25 | // Act 26 | var response = await httpClient.GetAsync("api/glossary"); 27 | 28 | // Assert 29 | response.EnsureSuccessStatusCode(); 30 | var stringResponse = await response.Content.ReadAsStringAsync(); 31 | var terms = JsonSerializer.Deserialize>(stringResponse, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); 32 | 33 | Assert.Equal(3, terms.Count); 34 | Assert.Contains(terms, t => t.Term == "Access Token"); 35 | Assert.Contains(terms, t => t.Term == "JWT"); 36 | Assert.Contains(terms, t => t.Term == "OpenID"); 37 | } 38 | 39 | [Fact] 40 | public async Task AddTermWithoutAuthorization() 41 | { 42 | // Arrange 43 | var request = new HttpRequestMessage(HttpMethod.Post, "api/glossary"); 44 | 45 | request.Content = new StringContent(JsonSerializer.Serialize(new 46 | { 47 | term = "MFA", 48 | definition = "An authentication process that considers multiple factors." 49 | }), Encoding.UTF8, "application/json"); 50 | 51 | // Act 52 | var response = await httpClient.SendAsync(request); 53 | 54 | // Assert 55 | Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); 56 | } 57 | 58 | [Fact] 59 | public async Task ChangeTermWithInvalidAuthorization() 60 | { 61 | // Arrange 62 | var request = new HttpRequestMessage(HttpMethod.Post, "api/glossary"); 63 | 64 | request.Content = new StringContent(JsonSerializer.Serialize(new 65 | { 66 | term = "MFA", 67 | definition = "An authentication process that considers multiple factors." 68 | }), Encoding.UTF8, "application/json"); 69 | request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "This is an invalid token"); 70 | 71 | // Act 72 | var response = await httpClient.SendAsync(request); 73 | 74 | // Assert 75 | Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); 76 | } 77 | 78 | [Fact] 79 | public async Task AddTermWithAuthorization() 80 | { 81 | // Arrange 82 | var request = new HttpRequestMessage(HttpMethod.Post, "api/glossary"); 83 | 84 | request.Content = new StringContent(JsonSerializer.Serialize(new 85 | { 86 | term = "MFA", 87 | definition = "An authentication process that considers multiple factors." 88 | }), Encoding.UTF8, "application/json"); 89 | 90 | var accessToken = FakeJwtManager.GenerateJwtToken(); 91 | request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); 92 | 93 | // Act 94 | HttpResponseMessage response = new HttpResponseMessage(); 95 | try 96 | { 97 | response = await httpClient.SendAsync(request); 98 | } 99 | catch (Exception ex) 100 | { 101 | Console.WriteLine(ex.Message); 102 | } 103 | 104 | 105 | // Assert 106 | Assert.Equal(HttpStatusCode.Created, response.StatusCode); 107 | Assert.Equal("/api/glossary/MFA", response.Headers.GetValues("Location").FirstOrDefault()); 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /integration-tests/glossary-web-api-aspnet-core/Controllers/GlossaryController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using Microsoft.AspNetCore.Authorization; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace Glossary.Controllers 8 | { 9 | [ApiController] 10 | [Route("api/[controller]")] 11 | public class GlossaryController : ControllerBase 12 | { 13 | private static List Glossary = new List { 14 | new GlossaryItem 15 | { 16 | Term= "Access Token", 17 | Definition = "A credential that can be used by an application to access an API. It informs the API that the bearer of the token has been authorized to access the API and perform specific actions specified by the scope that has been granted." 18 | }, 19 | new GlossaryItem 20 | { 21 | Term= "JWT", 22 | Definition = "An open, industry standard RFC 7519 method for representing claims securely between two parties. " 23 | }, 24 | new GlossaryItem 25 | { 26 | Term= "OpenID", 27 | Definition = "An open standard for authentication that allows applications to verify users are who they say they are without needing to collect, store, and therefore become liable for a user’s login information." 28 | } 29 | }; 30 | 31 | [HttpGet] 32 | public ActionResult> Get() 33 | { 34 | return Ok(Glossary); 35 | } 36 | 37 | 38 | [HttpGet] 39 | [Route("{term}")] 40 | public ActionResult Get(string term) 41 | { 42 | var glossaryItem = Glossary.Find(item => 43 | item.Term.Equals(term, StringComparison.InvariantCultureIgnoreCase)); 44 | 45 | if (glossaryItem == null) 46 | { 47 | return NotFound(); 48 | } 49 | else 50 | { 51 | return Ok(glossaryItem); 52 | } 53 | } 54 | 55 | [HttpPost] 56 | [Authorize] 57 | public ActionResult Post(GlossaryItem glossaryItem) 58 | { 59 | var existingGlossaryItem = Glossary.Find(item => 60 | item.Term.Equals(glossaryItem.Term, StringComparison.InvariantCultureIgnoreCase)); 61 | 62 | if (existingGlossaryItem != null) 63 | { 64 | return Conflict("Cannot create the term because it already exists."); 65 | } 66 | else 67 | { 68 | Glossary.Add(glossaryItem); 69 | var resourceUrl = Path.Combine(Request.Path.ToString(), Uri.EscapeUriString(glossaryItem.Term)); 70 | return Created(resourceUrl, glossaryItem); 71 | } 72 | } 73 | 74 | [HttpPut] 75 | [Authorize] 76 | public ActionResult Put(GlossaryItem glossaryItem) 77 | { 78 | var existingGlossaryItem = Glossary.Find(item => 79 | item.Term.Equals(glossaryItem.Term, StringComparison.InvariantCultureIgnoreCase)); 80 | 81 | if (existingGlossaryItem == null) 82 | { 83 | return BadRequest("Cannot update a nont existing term."); 84 | } 85 | else 86 | { 87 | existingGlossaryItem.Definition = glossaryItem.Definition; 88 | return Ok(); 89 | } 90 | } 91 | 92 | [HttpDelete] 93 | [Route("{term}")] 94 | [Authorize] 95 | public ActionResult Delete(string term) 96 | { 97 | var glossaryItem = Glossary.Find(item => 98 | item.Term.Equals(term, StringComparison.InvariantCultureIgnoreCase)); 99 | 100 | if (glossaryItem == null) 101 | { 102 | return NotFound(); 103 | } 104 | else 105 | { 106 | Glossary.Remove(glossaryItem); 107 | return NoContent(); 108 | } 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /integration-tests-mock/glossary-web-api-aspnet-core/Controllers/GlossaryController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using Microsoft.AspNetCore.Authorization; 5 | using Microsoft.AspNetCore.Mvc; 6 | 7 | namespace Glossary.Controllers 8 | { 9 | [ApiController] 10 | [Route("api/[controller]")] 11 | public class GlossaryController : ControllerBase 12 | { 13 | private static List Glossary = new List { 14 | new GlossaryItem 15 | { 16 | Term= "Access Token", 17 | Definition = "A credential that can be used by an application to access an API. It informs the API that the bearer of the token has been authorized to access the API and perform specific actions specified by the scope that has been granted." 18 | }, 19 | new GlossaryItem 20 | { 21 | Term= "JWT", 22 | Definition = "An open, industry standard RFC 7519 method for representing claims securely between two parties. " 23 | }, 24 | new GlossaryItem 25 | { 26 | Term= "OpenID", 27 | Definition = "An open standard for authentication that allows applications to verify users are who they say they are without needing to collect, store, and therefore become liable for a user’s login information." 28 | } 29 | }; 30 | 31 | [HttpGet] 32 | public ActionResult> Get() 33 | { 34 | return Ok(Glossary); 35 | } 36 | 37 | 38 | [HttpGet] 39 | [Route("{term}")] 40 | public ActionResult Get(string term) 41 | { 42 | var glossaryItem = Glossary.Find(item => 43 | item.Term.Equals(term, StringComparison.InvariantCultureIgnoreCase)); 44 | 45 | if (glossaryItem == null) 46 | { 47 | return NotFound(); 48 | } 49 | else 50 | { 51 | return Ok(glossaryItem); 52 | } 53 | } 54 | 55 | [HttpPost] 56 | [Authorize] 57 | public ActionResult Post(GlossaryItem glossaryItem) 58 | { 59 | var existingGlossaryItem = Glossary.Find(item => 60 | item.Term.Equals(glossaryItem.Term, StringComparison.InvariantCultureIgnoreCase)); 61 | 62 | if (existingGlossaryItem != null) 63 | { 64 | return Conflict("Cannot create the term because it already exists."); 65 | } 66 | else 67 | { 68 | Glossary.Add(glossaryItem); 69 | var resourceUrl = Path.Combine(Request.Path.ToString(), Uri.EscapeUriString(glossaryItem.Term)); 70 | return Created(resourceUrl, glossaryItem); 71 | } 72 | } 73 | 74 | [HttpPut] 75 | [Authorize] 76 | public ActionResult Put(GlossaryItem glossaryItem) 77 | { 78 | var existingGlossaryItem = Glossary.Find(item => 79 | item.Term.Equals(glossaryItem.Term, StringComparison.InvariantCultureIgnoreCase)); 80 | 81 | if (existingGlossaryItem == null) 82 | { 83 | return BadRequest("Cannot update a nont existing term."); 84 | } 85 | else 86 | { 87 | existingGlossaryItem.Definition = glossaryItem.Definition; 88 | return Ok(); 89 | } 90 | } 91 | 92 | [HttpDelete] 93 | [Route("{term}")] 94 | [Authorize] 95 | public ActionResult Delete(string term) 96 | { 97 | var glossaryItem = Glossary.Find(item => 98 | item.Term.Equals(term, StringComparison.InvariantCultureIgnoreCase)); 99 | 100 | if (glossaryItem == null) 101 | { 102 | return NotFound(); 103 | } 104 | else 105 | { 106 | Glossary.Remove(glossaryItem); 107 | return NoContent(); 108 | } 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /integration-tests/Glossary.IntegrationTests/IntegrationTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Net.Http; 6 | using System.Net.Http.Headers; 7 | using System.Text; 8 | using System.Text.Json; 9 | using System.Threading.Tasks; 10 | using Auth0.AuthenticationApi; 11 | using Auth0.AuthenticationApi.Models; 12 | using Microsoft.AspNetCore.Mvc.Testing; 13 | using Microsoft.Extensions.Configuration; 14 | using Xunit; 15 | 16 | namespace Glossary.IntegrationTests 17 | { 18 | public class IntegrationTests : IClassFixture> 19 | { 20 | private readonly HttpClient httpClient; 21 | private readonly IConfigurationSection auth0Settings; 22 | 23 | public IntegrationTests(WebApplicationFactory factory) 24 | { 25 | httpClient = factory.CreateClient(); 26 | 27 | auth0Settings = new ConfigurationBuilder() 28 | .SetBasePath(Directory.GetCurrentDirectory()) 29 | .AddJsonFile("appsettings.json") 30 | .Build() 31 | .GetSection("Auth0"); 32 | } 33 | 34 | async Task GetAccessToken() 35 | { 36 | var auth0Client = new AuthenticationApiClient(auth0Settings["Domain"]); 37 | var tokenRequest = new ClientCredentialsTokenRequest() 38 | { 39 | ClientId = auth0Settings["ClientId"], 40 | ClientSecret = auth0Settings["ClientSecret"], 41 | Audience = auth0Settings["Audience"] 42 | }; 43 | var tokenResponse = await auth0Client.GetTokenAsync(tokenRequest); 44 | 45 | return tokenResponse.AccessToken; 46 | } 47 | 48 | [Fact] 49 | public async Task GetGlossaryList() 50 | { 51 | // Act 52 | var response = await httpClient.GetAsync("api/glossary"); 53 | 54 | // Assert 55 | response.EnsureSuccessStatusCode(); 56 | var stringResponse = await response.Content.ReadAsStringAsync(); 57 | var terms = JsonSerializer.Deserialize>(stringResponse, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); 58 | 59 | Assert.Equal(3, terms.Count); 60 | Assert.Contains(terms, t => t.Term == "Access Token"); 61 | Assert.Contains(terms, t => t.Term == "JWT"); 62 | Assert.Contains(terms, t => t.Term == "OpenID"); 63 | } 64 | 65 | [Fact] 66 | public async Task AddTermWithoutAuthorization() 67 | { 68 | // Arrange 69 | var request = new HttpRequestMessage(HttpMethod.Post, "api/glossary"); 70 | 71 | request.Content = new StringContent(JsonSerializer.Serialize(new 72 | { 73 | term = "MFA", 74 | definition = "An authentication process that considers multiple factors." 75 | }), Encoding.UTF8, "application/json"); 76 | 77 | // Act 78 | var response = await httpClient.SendAsync(request); 79 | 80 | // Assert 81 | Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); 82 | } 83 | 84 | [Fact] 85 | public async Task ChangeTermWithInvalidAuthorization() 86 | { 87 | // Arrange 88 | var request = new HttpRequestMessage(HttpMethod.Post, "api/glossary"); 89 | 90 | request.Content = new StringContent(JsonSerializer.Serialize(new 91 | { 92 | term = "MFA", 93 | definition = "An authentication process that considers multiple factors." 94 | }), Encoding.UTF8, "application/json"); 95 | request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "This is an invalid token"); 96 | 97 | // Act 98 | var response = await httpClient.SendAsync(request); 99 | 100 | // Assert 101 | Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); 102 | } 103 | 104 | [Fact] 105 | public async Task AddTermWithAuthorization() 106 | { 107 | // Arrange 108 | var request = new HttpRequestMessage(HttpMethod.Post, "api/glossary"); 109 | 110 | request.Content = new StringContent(JsonSerializer.Serialize(new 111 | { 112 | term = "MFA", 113 | definition = "An authentication process that considers multiple factors." 114 | }), Encoding.UTF8, "application/json"); 115 | 116 | var accessToken = await GetAccessToken(); 117 | request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); 118 | 119 | // Act 120 | var response = await httpClient.SendAsync(request); 121 | 122 | // Assert 123 | Assert.Equal(HttpStatusCode.Created, response.StatusCode); 124 | Assert.Equal("/api/glossary/MFA", response.Headers.GetValues("Location").FirstOrDefault()); 125 | } 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | --------------------------------------------------------------------------------