Skip to content

Commit

Permalink
Merge pull request #436 from DFE-Digital/release/v4.54
Browse files Browse the repository at this point in the history
Release/v4.54
  • Loading branch information
ScottDawsonDfE authored Aug 17, 2023
2 parents 6904d3f + 9c7371b commit f25843c
Show file tree
Hide file tree
Showing 25 changed files with 179 additions and 54 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build and Test

on:
push:
branches:
- master
- dev
pull_request:
types:
- opened
- synchronize
- reopened

jobs:
build:
runs-on: windows-latest
env:
DOTNET_VERSION: '6.0.x'

steps:
- uses: actions/checkout@v3

- name: Setup .NET Core SDK ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1

- name: Setup NuGet
uses: NuGet/[email protected]

- name: Setup VSTest
uses: darenm/Setup-VSTest@v1

- name: Restore Packages
working-directory: ./Web
run: nuget restore EdubaseWeb.sln

- name: Build Solution
working-directory: ./Web
run: |
msbuild.exe EdubaseWeb.sln /t:Rebuild /p:platform="Any CPU" /p:configuration="Release"
## Currently manually specifying the tests to trigger -- unclear if these can be picked up automatically?
- name: Run Tests
working-directory: ./Web
run: |
vstest.console.exe /Enablecodecoverage .\Edubase.CommonUnitTests\bin\Release\Edubase.CommonUnitTests.dll
vstest.console.exe /Enablecodecoverage .\Edubase.DataUnitTests\bin\Release\Edubase.DataUnitTests.dll
vstest.console.exe /Enablecodecoverage .\Edubase.ServicesUnitTests\bin\Release\Edubase.ServicesUnitTests.dll
vstest.console.exe /Enablecodecoverage .\Edubase.Web.ResourcesUnitTests\bin\Release\Edubase.Web.ResourcesUnitTests.dll
vstest.console.exe /Enablecodecoverage .\Edubase.Web.UIUnitTests\bin\Release\net48\Edubase.Web.UIUnitTests.dll
- name: Upload dotnet test results
uses: actions/[email protected]
with:
name: dotnet-results-${{ env.DOTNET_VERSION }}
path: ./Web/TestResults
if: ${{ always() }}
8 changes: 7 additions & 1 deletion Web/Edubase.Services.Texuna/Lookup/LookupApiService.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Threading.Tasks;
using Edubase.Services.Domain;
using Edubase.Services.Lookup;
using Edubase.Services.Security;

namespace Edubase.Services.Texuna.Lookup
{
public class LookupApiService : ILookupService
public class LookupApiService : ILookupService, IUserDependentLookupService
{
private const string ApiPrefix = "lookup/";
private readonly IHttpClientWrapper _httpClient;
Expand Down Expand Up @@ -386,6 +387,11 @@ public async Task<IEnumerable<LookupDto>> CASWardsGetAllAsync()
return await GetData("cas-wards");
}

public async Task<IEnumerable<LookupDto>> EstablishmentStatusesGetAllAsync(IPrincipal user)
{
return (await _httpClient.GetAsync<List<LookupDto>>(ApiPrefix + "establishment-statuses", user)).GetResponse();
}

private async Task<IEnumerable<LookupDto>> GetData(string name)
{
return (await _httpClient.GetAsync<List<LookupDto>>(ApiPrefix + name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public void LookupApiService_ConstructorTest()
public async Task AsyncLookupsTest(string lookupType)
{
//use reflection to construct method name
var method = _lookupApiService.GetType().GetMethod($"{lookupType}GetAllAsync");
var method = _lookupApiService.GetType().GetMethod($"{lookupType}GetAllAsync",
Type.EmptyTypes);
var taskResult = method.Invoke(_lookupApiService, null) as Task<IEnumerable<LookupDto>>;
var result = await taskResult;

Expand Down
1 change: 1 addition & 0 deletions Web/Edubase.Services/Edubase.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@
<Compile Include="IntegrationEndPoints\Smtp\SmtpEndPoint.cs" />
<Compile Include="Lookup\ICachedLookupService.cs" />
<Compile Include="Lookup\ILookupService.cs" />
<Compile Include="Lookup\IUserDependentLookupService.cs" />
<Compile Include="Nomenclature\NomenclatureService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Security\ClaimsIdentityConverters\StubClaimsIdConverter.cs" />
Expand Down
15 changes: 15 additions & 0 deletions Web/Edubase.Services/Lookup/IUserDependentLookupService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
using Edubase.Services.Domain;

namespace Edubase.Services.Lookup
{
public interface IUserDependentLookupService
{
Task<IEnumerable<LookupDto>> EstablishmentStatusesGetAllAsync(IPrincipal user);
}
}
2 changes: 1 addition & 1 deletion Web/Edubase.Web.Resources/IResourcesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ public interface IResourcesHelper
{
string GetResourceStringForEstablishment(string name, eLookupEstablishmentTypeGroup? establishmentType, IPrincipal user);
}
}
}
3 changes: 2 additions & 1 deletion Web/Edubase.Web.UI/App_Start/IocConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ private static void RegisterTypes(ContainerBuilder builder)
builder.Register(c => new LookupApiService(
c.ResolveNamed<HttpClientWrapper>("LookupHttpClientWrapper"),
c.Resolve<ISecurityService>()))
.As<ILookupService>();
.As<ILookupService>()
.As<IUserDependentLookupService>();

builder.RegisterType<GovernorDownloadApiService>().As<IGovernorDownloadService>();
builder.RegisterType<GovernorsReadApiService>().As<IGovernorsReadService>();
Expand Down
7 changes: 7 additions & 0 deletions Web/Edubase.Web.UI/App_Start/StartupSecureAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public partial class StartupSecureAccess
public static string ApplicationIdpEntityId => AppSettings[nameof(ApplicationIdpEntityId)];
public static Uri ExternalAuthDefaultCallbackUrl => new Uri(AppSettings[nameof(ExternalAuthDefaultCallbackUrl)]);
public static Uri MetadataLocation => new Uri(AppSettings[nameof(MetadataLocation)]);
public static Uri PublicOrigin => string.IsNullOrWhiteSpace(AppSettings[nameof(PublicOrigin)]) ? null : new Uri(AppSettings[nameof(PublicOrigin)]);

public void ConfigureAuth(IAppBuilder app)
{
Expand Down Expand Up @@ -84,6 +85,12 @@ private static Saml2AuthenticationOptions CreateAuthServicesOptions()
MinIncomingSigningAlgorithm = "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
};

if (PublicOrigin != null)
{
// Only set if provided via configuration
spOptions.PublicOrigin = PublicOrigin;
}

var authServicesOptions = new Saml2AuthenticationOptions(false) { SPOptions = spOptions };

var idp = new IdentityProvider(new EntityId(MetadataLocation.AbsoluteUri), spOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class EstablishmentController : EduBaseController
private readonly IMapper _mapper;
private readonly IResourcesHelper _resourcesHelper;
private readonly IExternalLookupService _externalLookupService;
private readonly IUserDependentLookupService _lookupService;

private readonly ISecurityService _securityService;
private readonly Lazy<string[]> _formKeys;
Expand Down Expand Up @@ -80,7 +81,8 @@ public EstablishmentController(IEstablishmentReadService establishmentReadServic
ICachedLookupService cachedLookupService,
IResourcesHelper resourcesHelper,
ISecurityService securityService,
IExternalLookupService externalLookupService)
IExternalLookupService externalLookupService,
IUserDependentLookupService lookupService)
{
_cachedLookupService = cachedLookupService;
_establishmentReadService = establishmentReadService;
Expand All @@ -90,6 +92,7 @@ public EstablishmentController(IEstablishmentReadService establishmentReadServic
_resourcesHelper = resourcesHelper;
_securityService = securityService;
_externalLookupService = externalLookupService;
_lookupService = lookupService;

_formKeys = new Lazy<string[]>(
() => Request?.Form?.AllKeys.Select(x => x.GetPart(".")).Distinct().ToArray(),
Expand Down Expand Up @@ -359,14 +362,20 @@ await Task.WhenAll(
PopulateLookupNames(viewModel),
PopulateGovernors(viewModel));

viewModel.AgeRangeToolTip = viewModel.Establishment.TypeId.OneOfThese(ET.OnlineProvider)
viewModel.AgeRangeToolTip = viewModel.Establishment.TypeId.OneOfThese(ET.OnlineProvider)
? _resourcesHelper.GetResourceStringForEstablishment("AgeRangeOnlineProvider", (eLookupEstablishmentTypeGroup?) viewModel.Establishment.EstablishmentTypeGroupId, User)
: _resourcesHelper.GetResourceStringForEstablishment("AgeRange", (eLookupEstablishmentTypeGroup?) viewModel.Establishment.EstablishmentTypeGroupId, User);

viewModel.AgeRangeToolTipLink = _resourcesHelper.GetResourceStringForEstablishment("AgeRangeLink", (eLookupEstablishmentTypeGroup?) viewModel.Establishment.EstablishmentTypeGroupId, User);
viewModel.AgeRangeToolTipLink = viewModel.Establishment.TypeId.Equals((int)ET.AcademySecure16to19)
? string.Empty
: _resourcesHelper.GetResourceStringForEstablishment("AgeRangeLink", (eLookupEstablishmentTypeGroup?) viewModel.Establishment.EstablishmentTypeGroupId, User);

viewModel.SchoolCapacityToolTip = _resourcesHelper.GetResourceStringForEstablishment("SchoolCapacity", (eLookupEstablishmentTypeGroup?) viewModel.Establishment.EstablishmentTypeGroupId, User);
viewModel.SchoolCapacityToolTipLink = _resourcesHelper.GetResourceStringForEstablishment("SchoolCapacityLink", (eLookupEstablishmentTypeGroup?) viewModel.Establishment.EstablishmentTypeGroupId, User);

viewModel.SchoolCapacityToolTipLink = viewModel.Establishment.TypeId.Equals((int)ET.AcademySecure16to19)
? string.Empty
: _resourcesHelper.GetResourceStringForEstablishment("SchoolCapacityLink", (eLookupEstablishmentTypeGroup?) viewModel.Establishment.EstablishmentTypeGroupId, User);

return View(viewModel);
}

Expand Down Expand Up @@ -885,7 +894,7 @@ private async Task PopulateCCSelectLists(CreateChildrensCentreViewModel viewMode
viewModel.GovernanceOptions = (await _cachedLookupService.CCGovernanceGetAllAsync()).ToSelectList();
viewModel.DisadvantagedAreaOptions = (await _cachedLookupService.CCDisadvantagedAreasGetAllAsync()).ToSelectList();
viewModel.DirectProvisionOfEarlyYearsOptions = (await _cachedLookupService.DirectProvisionOfEarlyYearsGetAllAsync()).ToSelectList();
viewModel.EstablishmentStatusOptions = (await _cachedLookupService.EstablishmentStatusesGetAllAsync()).ToSelectList();
viewModel.EstablishmentStatusOptions = (await _lookupService.EstablishmentStatusesGetAllAsync(User)).ToSelectList();
viewModel.Address.Counties = (await _cachedLookupService.CountiesGetAllAsync()).ToSelectList();
viewModel.Phases = (await _cachedLookupService.CCPhaseTypesGetAllAsync()).ToSelectList();
await PopulateSelectLists(viewModel);
Expand Down Expand Up @@ -915,7 +924,8 @@ private async Task PopulateDisplayPolicies(EstablishmentDetailViewModel viewMode
private async Task PopulateEditPermissions(EstablishmentDetailViewModel viewModel)
{
viewModel.UserCanEdit = await _establishmentReadService.CanEditAsync(viewModel.Establishment.Urn.Value, User);
viewModel.TabEditPolicy = new TabEditPolicy(viewModel.Establishment, viewModel.DisplayPolicy, User);
var editPolicyEnvelope = await _establishmentReadService.GetEditPolicyAsync(viewModel.Establishment, User);
viewModel.TabEditPolicy = new TabEditPolicy(viewModel.Establishment, editPolicyEnvelope.EditPolicy, User);
}

private async Task PopulateEstablishmentPageViewModel(IEstablishmentPageViewModel viewModel, int urn, string selectedTabName)
Expand Down Expand Up @@ -1051,7 +1061,7 @@ private async Task PopulateSelectLists(ViewModel viewModel)
viewModel.LocalAuthorities = localAuthorities.ToSelectList(viewModel.LocalAuthorityId);
viewModel.EstablishmentTypes = (await _cachedLookupService.EstablishmentTypesGetAllAsync()).ToSelectList(viewModel.TypeId);
viewModel.HeadTitles = (await _cachedLookupService.TitlesGetAllAsync()).ToSelectList(viewModel.HeadTitleId);
viewModel.Statuses = (await _cachedLookupService.EstablishmentStatusesGetAllAsync()).ToSelectList(viewModel.StatusId);
viewModel.Statuses = (await _lookupService.EstablishmentStatusesGetAllAsync(User)).ToSelectList(viewModel.StatusId);
viewModel.AdmissionsPolicies = (await _cachedLookupService.AdmissionsPoliciesGetAllAsync()).ToSelectList(viewModel.AdmissionsPolicyId);
viewModel.Inspectorates = (await _cachedLookupService.InspectoratesGetAllAsync()).ToSelectList(viewModel.InspectorateId);
viewModel.IndependentSchoolTypes = (await _cachedLookupService.IndependentSchoolTypesGetAllAsync()).ToSelectList(viewModel.IndependentSchoolTypeId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using System.Security.Principal;
using Edubase.Common;
using Edubase.Services.Enums;
Expand All @@ -22,6 +23,12 @@ public class TabEditPolicy
public TabEditPolicy(EstablishmentModel model, EstablishmentDisplayEditPolicy policy, IPrincipal principal)
{
Governance = !(principal.IsInRole(EdubaseRoles.ESTABLISHMENT) && model.StatusId.OneOfThese(ES.Closed));
Location = new[]
{
// these fields appear on the Locations tab
policy.RSCRegionId, policy.GovernmentOfficeRegionId, policy.AdministrativeDistrictId, policy.AdministrativeWardId, policy.ParliamentaryConstituencyId,
policy.UrbanRuralId, policy.GSSLAId, policy.Easting, policy.Northing, policy.MSOAId, policy.LSOAId
}.Any(x => x == true);
}

public TabEditPolicy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
<h3 class="govuk-heading-s make-modal-header">Middle super output area (MSOA)</h3>
<div class="govuk-body">
<p>
The data presented for the middle super output area (MSOA) is representative of the 2011 census.
The data presented for the middle super output area (MSOA) is representative of the 2021 census.
</p>
</div>
</div>
Expand All @@ -332,7 +332,7 @@
<h3 class="govuk-heading-s make-modal-header">Lower super output area (LSOA)</h3>
<div class="govuk-body">
<p>
The data presented for the lower super output area (LSOA) is representative of the 2011 census.
The data presented for the lower super output area (LSOA) is representative of the 2021 census.
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
}
<div class="detail-summary">
<dl class="govuk-summary-list">
<div class="govuk-summary-list__row">
<dt id="rsc-region-key" class="govuk-summary-list__key">Regional schools commissioner (RSC) region</dt>
<dd id="rsc-region-value" class="govuk-summary-list__value">@Model.RSCRegionName</dd>
</div>
<div class="govuk-summary-list__row">
<dt id="gor-key" class="govuk-summary-list__key">Government office region (GOR)</dt>
<dd id="gor-value" class="govuk-summary-list__value">@Model.GovernmentOfficeRegionName</dd>
</div>
<div class="govuk-summary-list__row">
<dt id="rsc-region-key" class="govuk-summary-list__key">Regional schools commissioner (RSC) region</dt>
<dd id="rsc-region-value" class="govuk-summary-list__value">@Model.RSCRegionName</dd>
</div>
<div class="govuk-summary-list__row">
<dt id="district-key" class="govuk-summary-list__key">District</dt>
<dd id="district-value" class="govuk-summary-list__value">@Model.AdministrativeDistrictName</dd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ else if (Model.Results.Count > 0)
@foreach (var result in Model.Results)
{
<li class="gias-result-tile">
<h3 class="govuk-heading-s govuk-!-margin-bottom-1">
<h3 class="govuk-heading-s govuk-!-margin-bottom-1 result-establishment-name">
@Html.ActionLink(result.Name.Clean() ?? "(name not recorded)",
"Details",
"Establishment",
Expand All @@ -60,16 +60,16 @@ else if (Model.Results.Count > 0)
@((result.TypeId != null && Model.EstablishmentTypeLookup.ContainsKey(result.TypeId.Value)) ? Model.EstablishmentTypeLookup[result.TypeId.Value] : "Not recorded")
@*@(Model.EstablishmentTypes.FirstOrDefault(x => x.Id == result.TypeId)?.Name ?? "Not recorded")*@
</dd>
<dt><abbr title="Unique Reference Number">URN</abbr>:</dt>
<dd>@result.Urn</dd>
<dt class="inline-details">
<dt class="result-urn-label"><abbr title="Unique Reference Number">URN</abbr>:</dt>
<dd class="result-urn-value">@result.Urn</dd>
<dt class="result-inline-details">
<abbr title="Local authority - Establishment number">LAESTAB</abbr>:
</dt>
<dd>@Model.LAESTABs[result]</dd>
<dt>Status:</dt>
<dd>@(Model.EstablishmentStatuses.FirstOrDefault(x => x.Id == result.StatusId)?.Name ?? "Not recorded")</dd>
<dt>Local authority name:</dt>
<dd>@(Model.LocalAuthorities.FirstOrDefault(x => x.Id == result.LocalAuthorityId)?.Name ?? "Not recorded")</dd>
<dd class="result-laestab-value">@Model.LAESTABs[result]</dd>
<dt class="result-status-label">Status:</dt>
<dd class="result-status-value">@(Model.EstablishmentStatuses.FirstOrDefault(x => x.Id == result.StatusId)?.Name ?? "Not recorded")</dd>
<dt class="result-la-name-label">Local authority name:</dt>
<dd class="result-la-name-value">@(Model.LocalAuthorities.FirstOrDefault(x => x.Id == result.LocalAuthorityId)?.Name ?? "Not recorded")</dd>
@if (Model.SearchType == eSearchType.Location)
{
var distanceInMiles = Math.Round(Edubase.Common.Spatial.DistanceCalculator.Calculate(Model.LocationSearchCoordinate, result.Location).Miles, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,9 @@ private void PrepopulateFields(GovernorModel model, ReplaceChairViewModel viewMo
private async Task<bool> RoleAllowed(eLookupGovernorRole roleId, int? groupUId, int? establishmentUrn,
IPrincipal user)
{
var existingGovernors = await _governorsReadService.GetGovernorListAsync(establishmentUrn, groupUId, user);

if (EnumSets.eSingularGovernorRoles.Contains(roleId))
{
var existingGovernors = await _governorsReadService.GetGovernorListAsync(establishmentUrn, groupUId, user);
if (roleId == eLookupGovernorRole.Establishment_SharedChairOfLocalGoverningBody ||
roleId == eLookupGovernorRole.ChairOfLocalGoverningBody)
{
Expand Down
Loading

0 comments on commit f25843c

Please sign in to comment.