Skip to content

Commit

Permalink
Merge pull request #1462 from bcgov/test
Browse files Browse the repository at this point in the history
merge test to master for IS27 BVT release.
  • Loading branch information
devinleighsmith authored May 25, 2022
2 parents 62e5c9a + 87c7c00 commit be94d5c
Show file tree
Hide file tree
Showing 351 changed files with 46,931 additions and 25,695 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/api-dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
env:
working-directory: ./backend
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_BRANCH: "${{github.ref}}"

steps:
- uses: actions/checkout@v2
Expand All @@ -24,7 +25,7 @@ jobs:
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
dotnet-version: "6.0.x"

- name: Install dependencies
run: dotnet restore
Expand Down Expand Up @@ -115,6 +116,19 @@ jobs:
# The SonarQube server URL. For SonarCloud, skip this setting.
sonarHostname: ${{secrets.SONAR_URL}}

# Send notifications only if MS_TEAMS_NOTIFY_URL secret has been set
- name: Failure notification to Teams Channel
env:
MS_TEAMS_NOTIFY_URL: ${{ secrets.MS_TEAMS_NOTIFY_URL }}
if: env.MS_TEAMS_NOTIFY_URL != '' && failure() && steps.scan.outcome == 'failure' && github.event_name == 'push'
uses: jdcargile/[email protected]
with:
github-token: ${{ github.token }}
ms-teams-webhook-uri: ${{ env.MS_TEAMS_NOTIFY_URL }}
notification-summary: PIMS Sonar Scan FAILED in ${{env.GIT_BRANCH}} environment
notification-color: ff0000
timezone: America/Los_Angeles

- name: Find Comment
if: failure() && steps.scan.outcome == 'failure' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/find-comment@v1
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/app-react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
env:
CI: true
working-directory: ./frontend
GIT_BRANCH: "${{github.ref}}"

strategy:
matrix:
Expand Down Expand Up @@ -73,6 +74,19 @@ jobs:
-Dsonar.projectName=${{env.PROJECT_NAME}}
-Dsonar.qualitygate.wait=true
# Send notifications only if MS_TEAMS_NOTIFY_URL secret has been set
- name: Failure notification to Teams Channel
env:
MS_TEAMS_NOTIFY_URL: ${{ secrets.MS_TEAMS_NOTIFY_URL }}
if: env.MS_TEAMS_NOTIFY_URL != '' && failure() && steps.scan.outcome == 'failure' && github.event_name == 'push'
uses: jdcargile/[email protected]
with:
github-token: ${{ github.token }}
ms-teams-webhook-uri: ${{ env.MS_TEAMS_NOTIFY_URL }}
notification-summary: PIMS Sonar Scan FAILED in ${{env.GIT_BRANCH}} environment
notification-color: ff0000
timezone: America/Los_Angeles

- name: Find Comment
if: failure() && steps.scan.outcome == 'failure' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: peter-evans/find-comment@v1
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,10 @@ backend-coverage: ## Generate coverage report for backend
@echo "$(P) Generate coverage report for backend"
@cd backend/tests/unit/api; dotnet build;
@cd backend/tests/unit/dal; dotnet build;
@cd backend/tests/unit/mockdal; dotnet build;
@cd backend; coverlet ./tests/unit/api/bin/Debug/net6.0/Pims.Api.Test.dll --target "dotnet" --targetargs "test ./ --no-build" -o "./tests/TestResults/coverage.json" --exclude "[*.Test]*" --exclude "[*]*Model" --exclude-by-attribute "CompilerGenerated" -f json
@cd backend; coverlet ./tests/unit/dal/bin/Debug/net6.0/Pims.Dal.Test.dll --target "dotnet" --targetargs "test ./ --no-build" -o "./tests/TestResults/coverage.xml" --exclude "[*.Test]*" --exclude "[*]*Model" --exclude-by-attribute "CompilerGenerated" --merge-with "tests/TestResults/coverage.json" -f cobertura
@cd backend; coverlet ./tests/unit/mockdal/bin/Debug/net6.0/Pims.Dal.Mock.Test.dll --target "dotnet" --targetargs "test ./ --no-build" -o "./tests/TestResults/coverage.xml" --exclude "[*.Test]*" --exclude "[*]*Model" --exclude-by-attribute "CompilerGenerated" --merge-with "tests/TestResults/coverage.json" -f cobertura
@cd backend; reportgenerator "-reports:./tests/TestResults/coverage.xml" "-targetdir:./tests/TestResults/Coverage" -reporttypes:Html
@cd backend; start ./tests/TestResults/Coverage/index.htm

Expand Down
1 change: 1 addition & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ COPY entities/*.csproj entities/
COPY tests/core/*.csproj tests/core/
COPY tests/unit/api/*.csproj tests/unit/api/
COPY tests/unit/dal/*.csproj tests/unit/dal/
COPY tests/unit/mockdal/*.csproj tests/unit/mockdal/
COPY dal/*.csproj dal/
COPY dal.keycloak/*.csproj dal.keycloak/
COPY keycloak/*.csproj keycloak/
Expand Down
15 changes: 15 additions & 0 deletions backend/Pims.sln
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pims.Geocoder", "geocoder\P
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pims.Ltsa", "ltsa\Pims.Ltsa.csproj", "{1ED5DF03-7784-44EC-B02B-516167210CCF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pims.Dal.Mock.Test", "tests\unit\mockdal\Pims.Dal.Mock.Test.csproj", "{2C31E92C-9C95-45FF-9F95-928C2962F37D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -200,6 +202,18 @@ Global
{1ED5DF03-7784-44EC-B02B-516167210CCF}.Release|x64.Build.0 = Release|Any CPU
{1ED5DF03-7784-44EC-B02B-516167210CCF}.Release|x86.ActiveCfg = Release|Any CPU
{1ED5DF03-7784-44EC-B02B-516167210CCF}.Release|x86.Build.0 = Release|Any CPU
{2C31E92C-9C95-45FF-9F95-928C2962F37D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C31E92C-9C95-45FF-9F95-928C2962F37D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C31E92C-9C95-45FF-9F95-928C2962F37D}.Debug|x64.ActiveCfg = Debug|Any CPU
{2C31E92C-9C95-45FF-9F95-928C2962F37D}.Debug|x64.Build.0 = Debug|Any CPU
{2C31E92C-9C95-45FF-9F95-928C2962F37D}.Debug|x86.ActiveCfg = Debug|Any CPU
{2C31E92C-9C95-45FF-9F95-928C2962F37D}.Debug|x86.Build.0 = Debug|Any CPU
{2C31E92C-9C95-45FF-9F95-928C2962F37D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C31E92C-9C95-45FF-9F95-928C2962F37D}.Release|Any CPU.Build.0 = Release|Any CPU
{2C31E92C-9C95-45FF-9F95-928C2962F37D}.Release|x64.ActiveCfg = Release|Any CPU
{2C31E92C-9C95-45FF-9F95-928C2962F37D}.Release|x64.Build.0 = Release|Any CPU
{2C31E92C-9C95-45FF-9F95-928C2962F37D}.Release|x86.ActiveCfg = Release|Any CPU
{2C31E92C-9C95-45FF-9F95-928C2962F37D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -217,6 +231,7 @@ Global
{5A83C636-741A-4795-8588-70F033E79B5A} = {04780892-FC30-4B6B-A10C-5795C657E574}
{BF7450E8-B3C5-46FB-BEC1-C5FC1C5964DC} = {5237F8A4-67F5-4751-B8B2-B93A06791480}
{1ED5DF03-7784-44EC-B02B-516167210CCF} = {5237F8A4-67F5-4751-B8B2-B93A06791480}
{2C31E92C-9C95-45FF-9F95-928C2962F37D} = {3D70B211-74A8-484C-9B86-B0A2835C71E7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3433C5DD-DC49-4A96-A1AE-90C1A1EBA87C}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.Id, src => src.Id)
.Map(dest => dest.PersonId, src => src.PersonId)
.Map(dest => dest.OrganizationId, src => src.OrganizationId)
.Map(dest => dest.Organization, src => src.Organization)
.Map(dest => dest.Summary, src => src.Summary)
.Map(dest => dest.Surname, src => src.Surname)
.Map(dest => dest.FirstName, src => src.FirstName)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Pims.Api.Models.Concepts;
namespace Pims.Api.Areas.Contact.Models.Search
{
public class ContactSummaryModel
Expand All @@ -18,6 +19,8 @@ public class ContactSummaryModel
/// </summary>
public long? OrganizationId { get; set; }

public OrganizationModel Organization { get; set; }

/// <summary>
/// get/set - The concurrency row version.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion backend/api/Areas/Leases/Mapping/Lease/LeaseMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.IsOtherImprovement, src => src.IsOtherImprovement)
.Map(dest => dest.Persons, src => src.GetPersons())
.Map(dest => dest.Organizations, src => src.GetOrganizations())
.Map(dest => dest.TenantNotes, src => src.PimsLeaseTenants != null ? src.PimsLeaseTenants.Select(t => t.Note) : null)
.Map(dest => dest.TenantNotes, src => src.PimsLeaseTenants.Select(t => t.Note))
.Map(dest => dest.Improvements, src => src.GetImprovements())
.Map(dest => dest.SecurityDeposits, src => src.PimsSecurityDeposits)
.Map(dest => dest.Tenants, src => src.PimsLeaseTenants)
Expand Down
23 changes: 0 additions & 23 deletions backend/api/Areas/Leases/Mapping/Lease/OrganizationMap.cs

This file was deleted.

8 changes: 6 additions & 2 deletions backend/api/Areas/Leases/Mapping/Lease/TenantMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.Organization, src => src.Organization)
.Map(dest => dest.PersonId, src => src.PersonId)
.Map(dest => dest.Person, src => src.Person)
.Map(dest => dest.PrimaryContactId, src => src.PrimaryContactId)
.Map(dest => dest.PrimaryContact, src => src.PrimaryContact)
.Map(dest => dest.LessorType, src => src.LessorTypeCodeNavigation)
.Map(dest => dest.Note, src => src.Note)
.Inherits<Entity.IBaseAppEntity, Api.Models.BaseAppModel>();

config.NewConfig<Model.TenantModel, Entity.PimsLeaseTenant>()
.Map(dest => dest.LeaseTenantId, src => src.LeaseTenantId)
.Map(dest => dest.LeaseId, src => src.LeaseId)
.Map(dest => dest.OrganizationId, src => src.Id != null && src.Id.StartsWith('O') ? src.OrganizationId : null)
.Map(dest => dest.PersonId, src => src.Id != null && src.Id.StartsWith('P') ? src.PersonId : null)
.Map(dest => dest.OrganizationId, src => src.OrganizationId)
.Map(dest => dest.PersonId, src => src.PersonId)
.Map(dest => dest.PrimaryContactId, src => src.PrimaryContactId)
.Map(dest => dest.Note, src => src.Note)
.Map(dest => dest.LessorTypeCode, src => src.PersonId != null ? LessorTypes.PERSON : LessorTypes.ORGANIZATION)
.Inherits<Api.Models.BaseAppModel, Entity.IBaseAppEntity>();
Expand Down
45 changes: 0 additions & 45 deletions backend/api/Areas/Leases/Models/Lease/OrganizationModel.cs

This file was deleted.

4 changes: 4 additions & 0 deletions backend/api/Areas/Leases/Models/Lease/TenantModel.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Pims.Api.Models;
using Pims.Api.Models.Concepts;

namespace Pims.Api.Areas.Lease.Models.Lease
Expand All @@ -12,5 +13,8 @@ public class TenantModel : Api.Models.BaseAppModel
public long? OrganizationId { get; set; }
public OrganizationModel Organization { get; set; }
public string Note { get; set; }
public PersonModel PrimaryContact { get; set; }
public long? PrimaryContactId { get; set; }
public TypeModel<string> LessorType { get; set; }
}
}
17 changes: 17 additions & 0 deletions backend/api/Areas/Research/Controllers/ResearchFileController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@ public IActionResult UpdateResearchFile([FromBody] ResearchFileModel researchFil
return new JsonResult(_mapper.Map<ResearchFileModel>(researchFile));
}

/// <summary>
/// Update the specified property on the passed research file.
/// </summary>
/// <returns></returns>
[HttpPut("{researchFileId:long}/properties/{researchFilePropertyId:long}")]
[HasPermission(Permissions.ResearchFileEdit)]
[Produces("application/json")]
[ProducesResponseType(typeof(ResearchFilePropertyModel), 200)]
[SwaggerOperation(Tags = new[] { "researchFile" })]
public IActionResult UpdateTerm(long researchFileId, long researchFilePropertyId, [FromBody] ResearchFilePropertyModel researchFilePropertyModel)
{
var researchFilePropertyEntity = _mapper.Map<Dal.Entities.PimsPropertyResearchFile>(researchFilePropertyModel);
var researchFile = _pimsService.ResearchFileService.UpdateProperty(researchFileId, researchFilePropertyId, researchFilePropertyModel.ResearchFile.RowVersion, researchFilePropertyEntity);

return new JsonResult(_mapper.Map<ResearchFileModel>(researchFile));
}


#endregion
}
Expand Down
2 changes: 2 additions & 0 deletions backend/api/Controllers/LookupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public IActionResult GetAll()
var researchStatusTypes = _mapper.Map<Model.LookupModel[]>(_pimsService.Lookup.GetResearchFileStatusTypes());
var requestSourceTypes = _mapper.Map<Model.LookupModel[]>(_pimsService.Lookup.GeRequestSourceTypes());
var researchPurposeTypes = _mapper.Map<Model.LookupModel[]>(_pimsService.Lookup.GetResearchPurposeTypes());
var propertyResearchPurposeTypes = _mapper.Map<Model.LookupModel[]>(_pimsService.Lookup.GetPropertyResearchPurposeTypes());

var codes = new List<object>();
codes.AddRange(areaUnitTypes);
Expand Down Expand Up @@ -137,6 +138,7 @@ public IActionResult GetAll()
codes.AddRange(researchStatusTypes);
codes.AddRange(requestSourceTypes);
codes.AddRange(researchPurposeTypes);
codes.AddRange(propertyResearchPurposeTypes);

return new JsonResult(codes);
}
Expand Down
33 changes: 32 additions & 1 deletion backend/api/Controllers/UserController.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using MapsterMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Pims.Api.Helpers.Extensions;
using Pims.Core.Http;
using Pims.Dal.Repositories;
using Swashbuckle.AspNetCore.Annotations;
using System;
using System.Threading.Tasks;
using KModel = Pims.Keycloak.Models;
using Model = Pims.Api.Areas.Admin.Models.User;

namespace Pims.Api.Controllers
{
Expand All @@ -22,6 +26,8 @@ public class UserController : ControllerBase
#region Variables
private readonly Keycloak.Configuration.KeycloakOptions _optionsKeycloak;
private readonly IProxyRequestClient _requestClient;
private readonly IUserService _userService;
private readonly IMapper _mapper;
#endregion

#region Constructors
Expand All @@ -30,10 +36,14 @@ public class UserController : ControllerBase
/// </summary>
/// <param name="optionsKeycloak"></param>
/// <param name="requestClient"></param>
public UserController(IOptionsMonitor<Keycloak.Configuration.KeycloakOptions> optionsKeycloak, IProxyRequestClient requestClient)
/// <param name="userService"></param>
/// <param name="mapper"></param>
public UserController(IOptionsMonitor<Keycloak.Configuration.KeycloakOptions> optionsKeycloak, IProxyRequestClient requestClient, IUserService userService, IMapper mapper)
{
_optionsKeycloak = optionsKeycloak.CurrentValue;
_requestClient = requestClient;
_userService = userService;
_mapper = mapper;
}
#endregion

Expand All @@ -54,6 +64,27 @@ public async Task<IActionResult> UserInfoAsync()
var response = await _requestClient.ProxyGetAsync(Request, $"{_optionsKeycloak.Authority}{_optionsKeycloak.OpenIdConnect.UserInfo}");
return await response.HandleResponseAsync<KModel.UserInfoModel>();
}

/// <summary>
/// Returns user person info for given keycloakUserId.
/// </summary>
/// <param name="keycloakUserId"></param>
/// <returns>User person info.</returns>
[HttpGet("info/{keycloakUserId}")]
[Produces("application/json")]
[ProducesResponseType(typeof(Model.UserModel), 200)]
[ProducesResponseType(typeof(Models.ErrorResponseModel), 400)]
[SwaggerOperation(Tags = new[] { "userInfo" })]
public IActionResult UserBasicInfo([FromRoute] Guid keycloakUserId)
{
if (keycloakUserId == Guid.Empty)
{
return new JsonResult(new Models.ErrorResponseModel("Invalid keycloakUserId", "keycloakUserId should be a valid non empty guid"));
}
var entity = _userService.GetUserInfo(keycloakUserId);
var user = _mapper.Map<Model.UserModel>(entity);
return new JsonResult(user);
}
#endregion
}
}
4 changes: 4 additions & 0 deletions backend/api/Mapping/BaseAppMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.AppLastUpdateTimestamp, src => src.AppLastUpdateTimestamp)
.Map(dest => dest.AppLastUpdateUserid, src => src.AppLastUpdateUserid)
.Map(dest => dest.AppCreateUserid, src => src.AppCreateUserid)
.Map(dest => dest.AppLastUpdateUserGuid, src => src.AppLastUpdateUserGuid)
.Map(dest => dest.AppCreateUserGuid, src => src.AppCreateUserGuid)
.Inherits<Entity.IBaseEntity, Models.BaseModel>();

config.NewConfig<Models.BaseAppModel, Entity.IDisableBaseAppEntity>()
Expand All @@ -25,6 +27,8 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.AppLastUpdateTimestamp, src => src.AppLastUpdateTimestamp)
.Map(dest => dest.AppLastUpdateUserid, src => src.AppLastUpdateUserid)
.Map(dest => dest.AppCreateUserid, src => src.AppCreateUserid)
.Map(dest => dest.AppLastUpdateUserGuid, src => src.AppLastUpdateUserGuid)
.Map(dest => dest.AppCreateUserGuid, src => src.AppCreateUserGuid)
.Inherits<Models.BaseModel, Entity.IBaseEntity>();
}
}
Expand Down
4 changes: 4 additions & 0 deletions backend/api/Models/BaseAppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ public abstract class BaseAppModel : BaseModel
public string AppLastUpdateUserid { get; set; }

public string AppCreateUserid { get; set; }

public Guid? AppLastUpdateUserGuid { get; set; }

public Guid? AppCreateUserGuid { get; set; }
#endregion
}
}
Loading

0 comments on commit be94d5c

Please sign in to comment.