Permalink
Browse files

Add some sample test projects

  • Loading branch information...
Ibon
Ibon committed Jul 20, 2016
1 parent bf083c4 commit 2a6ed78a4551b17b69c77adae7b230d1f1c92a02
Showing with 866 additions and 60 deletions.
  1. +10 −2 01_Demos_ASPNET5.sln
  2. +52 −26 04_Demos_NativeXamarinApps.sln
  3. +6 −5 src/MyHealth.API/Controllers/TenantsController.cs
  4. +6 −5 src/MyHealth.API/Controllers/UsersController.cs
  5. +24 −0 src/MyHealth.API/Infrastructure/Policies.cs
  6. +55 −0 src/MyHealth.Client.Cordova/gulp/tasks/tests.js
  7. +4 −1 src/MyHealth.Client.Cordova/gulpfile.js
  8. +11 −1 src/MyHealth.Client.Cordova/package.json
  9. +1 −0 src/MyHealth.Client.Cordova/www/index.html
  10. +1 −1 src/MyHealth.Client.Core/ServiceAgents/MicrosoftGraphService.cs
  11. +9 −5 src/MyHealth.Data/MyHealthContext.cs
  12. +2 −13 src/MyHealth.Web/Startup.cs
  13. +1 −1 src/MyHealth.Web/bower.json
  14. +36 −0 test/MyHealth.API.IntegrationTests/Api.cs
  15. +21 −0 test/MyHealth.API.IntegrationTests/Identities.cs
  16. +7 −0 test/MyHealth.API.IntegrationTests/Infrastructure/Fixtures/Collections.cs
  17. +12 −0 test/MyHealth.API.IntegrationTests/Infrastructure/Fixtures/DatabaseCollection.cs
  18. +35 −0 test/MyHealth.API.IntegrationTests/Infrastructure/Fixtures/DatabaseFixture.cs
  19. +16 −0 test/MyHealth.API.IntegrationTests/Infrastructure/HttpContentExtensions.cs
  20. +34 −0 test/MyHealth.API.IntegrationTests/Infrastructure/RequestBuilderExtensions.cs
  21. +21 −0 test/MyHealth.API.IntegrationTests/MyHealth.API.IntegrationTests.xproj
  22. +26 −0 test/MyHealth.API.IntegrationTests/Specs/DatabaseTestBase.cs
  23. +58 −0 test/MyHealth.API.IntegrationTests/Specs/DoctorsController/CreateDoctors.cs
  24. +81 −0 test/MyHealth.API.IntegrationTests/Specs/DoctorsController/GetDoctors.cs
  25. +82 −0 test/MyHealth.API.IntegrationTests/TestStartup.cs
  26. +13 −0 test/MyHealth.API.IntegrationTests/appsettings.json
  27. +32 −0 test/MyHealth.API.IntegrationTests/project.json
  28. +27 −0 test/MyHealth.UITest.Droid/AppInitializer.cs
  29. +74 −0 test/MyHealth.UITest.Droid/MyHealth.UITest.Droid.csproj
  30. +103 −0 test/MyHealth.UITest.Droid/Tests.cs
  31. +6 −0 test/MyHealth.UITest.Droid/packages.config
View
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
-VisualStudioVersion = 14.0.24720.0
+VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{372998F0-9076-4CCF-8DA2-1F0534BF05F4}"
EndProject
@@ -19,6 +19,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyHealth.API", "src\MyHealt
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyHealth.Web", "src\MyHealth.Web\MyHealth.Web.xproj", "{278356DC-80DD-408F-9DE8-6FC4787C2F6E}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E59ECF10-F681-410C-B416-5345A33C869D}"
+EndProject
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyHealth.API.IntegrationTests", "test\MyHealth.API.IntegrationTests\MyHealth.API.IntegrationTests.xproj", "{6334D527-D046-4C5A-80D8-69E930EC77EC}"
+EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MyHealth.Office365", "src\MyHealth.Office365\MyHealth.Office365.xproj", "{DFD09056-6B10-415F-A254-D05670F350F7}"
EndProject
Global
@@ -44,9 +48,12 @@ Global
{278356DC-80DD-408F-9DE8-6FC4787C2F6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{278356DC-80DD-408F-9DE8-6FC4787C2F6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{278356DC-80DD-408F-9DE8-6FC4787C2F6E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6334D527-D046-4C5A-80D8-69E930EC77EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6334D527-D046-4C5A-80D8-69E930EC77EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6334D527-D046-4C5A-80D8-69E930EC77EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6334D527-D046-4C5A-80D8-69E930EC77EC}.Release|Any CPU.Build.0 = Release|Any CPU
{DFD09056-6B10-415F-A254-D05670F350F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DFD09056-6B10-415F-A254-D05670F350F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DFD09056-6B10-415F-A254-D05670F350F7}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{DFD09056-6B10-415F-A254-D05670F350F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DFD09056-6B10-415F-A254-D05670F350F7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
@@ -58,6 +65,7 @@ Global
{887EE144-8399-44CE-A636-06719E750915} = {372998F0-9076-4CCF-8DA2-1F0534BF05F4}
{7DB08917-FAE6-4AD5-9E7D-EA6444227C21} = {372998F0-9076-4CCF-8DA2-1F0534BF05F4}
{278356DC-80DD-408F-9DE8-6FC4787C2F6E} = {372998F0-9076-4CCF-8DA2-1F0534BF05F4}
+ {6334D527-D046-4C5A-80D8-69E930EC77EC} = {E59ECF10-F681-410C-B416-5345A33C869D}
{DFD09056-6B10-415F-A254-D05670F350F7} = {372998F0-9076-4CCF-8DA2-1F0534BF05F4}
EndGlobalSection
EndGlobal
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
-VisualStudioVersion = 14.0.24720.0
+# Visual Studio 14
+VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyHealth.Client.Core", "src\MyHealth.Client.Core\MyHealth.Client.Core.csproj", "{8815D5DB-4912-4A7B-8097-C8B29DCDB75D}"
EndProject
@@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyHealth.Client.iOSWatchKit
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyHealth.Client.iOSWatchKitExtension", "src\MyHealth.Client.iOSWatchKitExtension\MyHealth.Client.iOSWatchKitExtension.csproj", "{A05C87D2-D8DA-40D8-AD82-C1CDE39562C7}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyHealth.UITest.Droid", "test\MyHealth.UITest.Droid\MyHealth.UITest.Droid.csproj", "{93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
@@ -29,6 +31,30 @@ Global
Release|iPhoneSimulator = Release|iPhoneSimulator
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.AppStore|Any CPU.Build.0 = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.AppStore|iPhone.ActiveCfg = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.AppStore|iPhone.Build.0 = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Debug|iPhone.Build.0 = Debug|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Release|iPhone.Build.0 = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{14C09982-15CC-4337-8762-98DABAA22863}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
{14C09982-15CC-4337-8762-98DABAA22863}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
{14C09982-15CC-4337-8762-98DABAA22863}.Ad-Hoc|Any CPU.Deploy.0 = Release|Any CPU
@@ -65,30 +91,6 @@ Global
{14C09982-15CC-4337-8762-98DABAA22863}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{14C09982-15CC-4337-8762-98DABAA22863}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{14C09982-15CC-4337-8762-98DABAA22863}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.AppStore|Any CPU.Build.0 = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.AppStore|iPhone.ActiveCfg = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.AppStore|iPhone.Build.0 = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Debug|iPhone.ActiveCfg = Debug|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Debug|iPhone.Build.0 = Debug|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Release|Any CPU.Build.0 = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Release|iPhone.ActiveCfg = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Release|iPhone.Build.0 = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
- {8815D5DB-4912-4A7B-8097-C8B29DCDB75D}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{8F9F1CB1-4D76-400F-B57D-68DF3C5977A6}.Ad-Hoc|Any CPU.ActiveCfg = Ad-Hoc|iPhone
{8F9F1CB1-4D76-400F-B57D-68DF3C5977A6}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
{8F9F1CB1-4D76-400F-B57D-68DF3C5977A6}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
@@ -158,6 +160,30 @@ Global
{A05C87D2-D8DA-40D8-AD82-C1CDE39562C7}.Release|iPhone.Build.0 = Release|iPhone
{A05C87D2-D8DA-40D8-AD82-C1CDE39562C7}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{A05C87D2-D8DA-40D8-AD82-C1CDE39562C7}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.AppStore|Any CPU.Build.0 = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.AppStore|iPhone.ActiveCfg = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.AppStore|iPhone.Build.0 = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Debug|iPhone.Build.0 = Debug|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Release|iPhone.Build.0 = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+ {93F72FAC-6D9D-41F4-BFE3-D627348FE8EC}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -6,6 +6,7 @@
using MyHealth.Model;
using System.Collections.Generic;
using System.Threading.Tasks;
+using MyHealth.API.Infrastructure;
namespace MyHealth.API.Controllers
{
@@ -43,7 +44,7 @@ public TenantsController(TenantsRepository tenantsRepository, ApplicationUsersRe
}
[HttpGet("list")]
- [Authorize("Tenant")]
+ [Authorize(Policies.Tenant)]
public async Task<IEnumerable<Tenant>> GetAsync(int pageSize, int pageCount)
{
ApplicationUser user = await _ApplicationUsersRepository.GetByUserNameAsync(User.Identity.Name);
@@ -58,14 +59,14 @@ public TenantsController(TenantsRepository tenantsRepository, ApplicationUsersRe
}
[HttpGet("{tenantId}")]
- [Authorize("Tenant")]
+ [Authorize(Policies.Tenant)]
public async Task<Tenant> GetAsync(int tenantId)
{
return await _TenantsRepository.GetAsync(tenantId);
}
[HttpPost]
- [Authorize("Tenant")]
+ [Authorize(Policies.Tenant)]
public async Task<TenantResponse> AddAsync([FromBody]TenantRequest request)
{
if (!await _UserValidators.ValidatePasswordAsync(new ApplicationUser(), request.password))
@@ -101,7 +102,7 @@ public TenantsController(TenantsRepository tenantsRepository, ApplicationUsersRe
}
[HttpPut]
- [Authorize("Tenant")]
+ [Authorize(Policies.Tenant)]
public async Task<TenantResponse> UpdateAsync([FromBody]TenantRequest request)
{
if (request.password != null && !await _UserValidators.ValidatePasswordAsync(new ApplicationUser(), request.password))
@@ -132,7 +133,7 @@ public TenantsController(TenantsRepository tenantsRepository, ApplicationUsersRe
}
[HttpDelete("{tenantId}")]
- [Authorize("Tenant")]
+ [Authorize(Policies.Tenant)]
public async Task DeleteAsync(int tenantId)
{
await _TenantsRepository.DeleteAsync(tenantId);
@@ -11,6 +11,7 @@
using MyHealth.Data.Repositories;
using MyHealth.Data.Infraestructure;
using System;
+using MyHealth.API.Infrastructure;
using MyHealth.API.Validators;
namespace MyHealth.API.Controllers
@@ -48,21 +49,21 @@ public UsersController(ApplicationUsersRepository applicationUsersRepository, Ap
}
[HttpGet]
- [Authorize("Admin")]
+ [Authorize(Policies.Admin)]
public async Task<IEnumerable<ApplicationUser>> Get(int pageSize, int pageCount)
{
return await _applicationUsersRepository.GetAsync(pageSize, pageCount);
}
[HttpGet("{username}")]
- [Authorize("Admin")]
+ [Authorize(Policies.Admin)]
public async Task<ApplicationUser> GetAsync(string username)
{
return await _applicationUsersRepository.GetAsync(username);
}
[HttpPost]
- [Authorize("Admin")]
+ [Authorize(Policies.Admin)]
public async Task<ApplicationUserResponse> AddAsync([FromBody]ApplicationUserAddRequest request)
{
if (!await _userValidators.ValidatePasswordAsync(request.user, request.password))
@@ -77,7 +78,7 @@ public UsersController(ApplicationUsersRepository applicationUsersRepository, Ap
}
[HttpPut]
- [Authorize("Admin")]
+ [Authorize(Policies.Admin)]
public async Task<ApplicationUserResponse> UpdateAsync([FromBody]ApplicationUserAddRequest request)
{
if (request.password != null && !await _userValidators.ValidatePasswordAsync(request.user, request.password))
@@ -106,7 +107,7 @@ public UsersController(ApplicationUsersRepository applicationUsersRepository, Ap
}
[HttpDelete("{username}")]
- [Authorize("Admin")]
+ [Authorize(Policies.Admin)]
public async Task<ApplicationUserResponse> DeleteAsync(string username)
{
var result = await _applicationUsersRepository.DeleteAsync(username);
@@ -0,0 +1,24 @@
+using Microsoft.AspNet.Authorization;
+
+namespace MyHealth.API.Infrastructure
+{
+ public static class Policies
+ {
+ public const string Admin = "Admin";
+ public const string Tenant = "Tenant";
+
+ public static void Configuration(AuthorizationOptions options)
+ {
+ options.AddPolicy(Admin, policy =>
+ {
+ policy.RequireClaim("ManageUsers", "Allowed");
+ policy.RequireClaim("ManageTenants", "Allowed");
+ });
+
+ options.AddPolicy(Tenant, policy =>
+ {
+ policy.RequireClaim("ManageTenants", "Allowed");
+ });
+ }
+ }
+}
@@ -0,0 +1,55 @@
+var gulp = require('gulp');
+var del = require('del');
+var $ = require('gulp-load-plugins')({ lazy: true });
+
+module.exports = function (gulp) {
+
+ gulp.task('test', ['typescript-tests'], function () {
+ // When executing this task from gulp, this files overrides the
+ // files configuration in tests/karma.conf.js
+ var files = [
+ 'tests/phantomBindPolyfill.js',
+ 'tests/out/**/*.spec.js'
+ ];
+ return gulp.src(files)
+ .pipe($.karma({
+ configFile: './tests/karma.conf.js',
+ action: 'run'
+ }))
+ .on('error', function (err) {
+ throw err;
+ });
+ });
+
+ gulp.task('typescript-tests', ['clean-typescript-tests'], function () {
+ var options = {
+ target: 'ES5',
+ };
+ return gulp.src(['./tests/**/*.ts'])
+ .pipe($.tsc(options))
+ .pipe(gulp.dest('./tests/out'));
+ });
+
+ gulp.task('clean-typescript-tests', function (done) {
+ clean('./tests/out', done);
+ });
+
+ ////////////
+
+ function clean(path, done) {
+ log('Cleaning: ' + $.util.colors.blue(path));
+ del(path, done);
+ }
+
+ function log(msg) {
+ if (typeof (msg) === 'object') {
+ for (var item in msg) {
+ if (msg.hasOwnProperty(item)) {
+ $.util.log($.util.colors.blue(msg[item]));
+ }
+ }
+ } else {
+ $.util.log($.util.colors.blue(msg));
+ }
+ }
+}
@@ -9,6 +9,9 @@ require('./gulp/tasks/preview.js')(gulp);
require('./gulp/tasks/sass.js')(gulp);
require('./gulp/tasks/watch.js')(gulp);
require('./gulp/tasks/typescript.js')(gulp);
+require('./gulp/tasks/tests.js')(gulp);
gulp.task('default', ['sass', 'copy', 'ts:transpile']);
-gulp.task('dev', ['sass', 'copy', 'lint:ts','ts:transpile', 'watch', 'preview']);
+gulp.task('dev', ['sass', 'copy', 'lint:ts', 'ts:transpile', 'watch', 'preview']);
+
+
@@ -20,6 +20,16 @@
"xml2js": "~0.4.13"
},
"devDependencies": {
- "gulp-typescript": "^2.9.2"
+ "karma-junit-reporter": "^1.0.0",
+ "del": "^1.1.1",
+ "gulp-typescript": "^2.9.2",
+ "gulp-load-plugins": "^0.10.0",
+ "gulp-karma": "^0.0.4",
+ "gulp-tsc": "^0.9.4",
+ "jasmine": "^2.2.1",
+ "karma": "^0.12.31",
+ "karma-cli": "0.0.4",
+ "karma-jasmine": "^0.3.5",
+ "karma-phantomjs-launcher": "^0.1.4"
}
}
@@ -2,6 +2,7 @@
<html>
<head>
<meta charset="utf-8">
+ <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<!-- CDLTLL -->
<!-- To use if setting security of remote endpoints, Codepush, AppsInsight or HealthClinic URI should be added ...
@@ -219,7 +219,7 @@ static byte[] ReadStream(Stream input)
if (result != null && !string.IsNullOrWhiteSpace(result.AccessToken))
accessToken = result.AccessToken;
}
- catch (Exception e)
+ catch (Exception)
{
throw;
}
Oops, something went wrong.

0 comments on commit 2a6ed78

Please sign in to comment.