Skip to content

Commit

Permalink
Improving project templates (#229)
Browse files Browse the repository at this point in the history
- Adding more case tests
- Fixing the weird namespaces inside namespaces in Startup.cs and controllers
- removing a wrong .AddMicrosoftIdentityUi() call in a startup.cs for mvc2 project templates
  • Loading branch information
jmprieur authored Jun 22, 2020
1 parent 2e68423 commit be99a87
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.Identity.Web;
using System.Net;
using System.Net.Http;
using Company.WebApplication1.Services;
#endif
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
Expand All @@ -15,8 +16,6 @@
namespace Company.WebApplication1.Pages
{
#if (GenerateApi)
using Services;

[AuthorizeForScopes(ScopeKeySection = "CalledApi:CalledApiScopes")]
#endif
public class IndexModel : PageModel
Expand Down
10 changes: 4 additions & 6 deletions ProjectTemplates/templates/RazorPagesWeb-CSharp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@
#if(MultiOrgAuth)
using Microsoft.IdentityModel.Tokens;
#endif

namespace Company.WebApplication1
{
#if (GenerateApi)
using Services;
using Company.WebApplication1.Services;
#endif

namespace Company.WebApplication1
{
public class Startup
{
public Startup(IConfiguration configuration)
Expand Down Expand Up @@ -100,8 +99,7 @@ public void ConfigureServices(IServiceCollection services)
options.Filters.Add(new AuthorizeFilter(policy));
}).AddMicrosoftIdentityUI();
#else
services.AddRazorPages()
.AddMicrosoftIdentityUI();
services.AddRazorPages();
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@
using Microsoft.Identity.Web;
using System.Net;
using System.Net.Http;
using Company.WebApplication1.Services;
#endif
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Company.WebApplication1.Models;

namespace Company.WebApplication1.Controllers
{
#if (GenerateApi)
using Services;

#endif
#if (OrganizationalAuth)
[Authorize]
#endif
Expand Down
7 changes: 3 additions & 4 deletions ProjectTemplates/templates/StarterWeb-CSharp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@
#if(MultiOrgAuth)
using Microsoft.IdentityModel.Tokens;
#endif

namespace Company.WebApplication1
{
#if (GenerateApi)
using Services;
using Company.WebApplication1.Services;
#endif

namespace Company.WebApplication1
{
public class Startup
{
public Startup(IConfiguration configuration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@
using Microsoft.Identity.Web;
using System.Net;
using System.Net.Http;
using Company.WebApplication1.Services;
#endif
using Microsoft.AspNetCore.Mvc;
using Microsoft.Identity.Web.Resource;
using Microsoft.Extensions.Logging;

namespace Company.WebApplication1.Controllers
{
#if (GenerateApi)
using Services;

#endif
#if (!NoAuth)
[Authorize]
#endif
Expand Down
7 changes: 3 additions & 4 deletions ProjectTemplates/templates/WebApi-CSharp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authentication.JwtBearer;
#if (GenerateApi)
using Company.WebApplication1.Services;
#endif

namespace Company.WebApplication1
{
#if (GenerateApi)
using Services;

#endif
public class Startup
{
public Startup(IConfiguration configuration)
Expand Down
24 changes: 22 additions & 2 deletions ProjectTemplates/test-templates.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@ echo "Test templates"
mkdir tests
cd tests

echo " Test Web app (No Auth)"
mkdir webapp-noauth
cd webapp-noauth
dotnet new webapp2
dotnet build
cd ..

echo " Test Web app (No Auth)"
mkdir mvcwebapp-noauth
cd mvcwebapp-noauth
dotnet new mvc2
dotnet build
cd ..

echo " Test Web API (No auth)"
mkdir webapi-noauth
cd webapi-noauth
dotnet new webapi2
dotnet build
cd ..


echo " Test Web app (Microsoft identity platform, MVC, Single Org)"
mkdir mvcwebapp
cd mvcwebapp
Expand Down Expand Up @@ -51,7 +73,6 @@ dotnet new mvc2 --auth IndividualB2C --called-api-url "https://localhost:44332"
dotnet build
cd ..


echo " Test Web app (Microsoft identity platform, Razor, Single Org)"
mkdir webapp
cd webapp
Expand All @@ -73,7 +94,6 @@ dotnet new webapp2 --auth IndividualB2C
dotnet build
cd ..


echo " Test Web app calling Web API (Microsoft identity platform, Razor, Single Org)"
mkdir webapp-api
cd webapp-api
Expand Down
51 changes: 0 additions & 51 deletions ProjectTemplates/test-templates.sh

This file was deleted.

0 comments on commit be99a87

Please sign in to comment.