Skip to content

Commit

Permalink
Merge pull request #4404 from dfe-analytical-services/dev
Browse files Browse the repository at this point in the history
Merging Dev into Master
  • Loading branch information
N-moh authored Nov 13, 2023
2 parents 6daeda5 + f4bb132 commit 4d4bbe2
Show file tree
Hide file tree
Showing 133 changed files with 5,598 additions and 1,741 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.17.0
18.18.2
4 changes: 2 additions & 2 deletions azure-pipelines.dfe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ variables:
BuildConfiguration: 'Release'
IsBranchDeployable: ${{ containsValue(parameters.DeployBranches, variables['Build.SourceBranchName']) }}
CI: true
NODE_VERSION: 18.17.0
NODE_VERSION: 18.18.2
DOTNET_VERSION: 6.0.x

trigger:
Expand All @@ -20,7 +20,7 @@ trigger:
- dev
paths:
exclude:
- infrastructure/
- infrastructure/
pr:
- master
- dev
Expand Down
2 changes: 1 addition & 1 deletion docker/public-frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18.17.0-alpine AS base
FROM node:18.18.2-alpine AS base

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/templates/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,7 @@
"NEXT_CONFIG_MODE": "server",
"NODE_ENV": "production",
"PUBLIC_URL": "[concat(variables('publicAppUrl'), '/')]",
"WEBSITE_NODE_DEFAULT_VERSION": "18.17.0",
"WEBSITE_NODE_DEFAULT_VERSION": "18.18.2",
"WEBSITES_PORT": 3000
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"packageManager": "[email protected]",
"engines": {
"node": "18.17.0",
"node": "18.18.2",
"pnpm": ">=8.8.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using static GovUk.Education.ExploreEducationStatistics.Admin.Security.SecurityClaimTypes;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Security.AuthorizationHandlers.Utils.AuthorizationHandlersTestUtil;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Security.Utils.ClaimsPrincipalUtils;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Services.DbUtils;
using static GovUk.Education.ExploreEducationStatistics.Common.Tests.Utils.MockUtils;
using static GovUk.Education.ExploreEducationStatistics.Content.Model.PublicationRole;
using static Moq.MockBehavior;
Expand Down Expand Up @@ -98,9 +99,11 @@ private static AdoptMethodologyForSpecificPublicationAuthorizationHandler SetupH
)
{
return new AdoptMethodologyForSpecificPublicationAuthorizationHandler(
new AuthorizationHandlerResourceRoleService(
Mock.Of<IUserReleaseRoleRepository>(Strict),
userPublicationRoleRepository ?? Mock.Of<IUserPublicationRoleRepository>(Strict)));
new AuthorizationHandlerService(
InMemoryApplicationDbContext(),
Mock.Of<IUserReleaseRoleRepository>(Strict),
userPublicationRoleRepository ?? Mock.Of<IUserPublicationRoleRepository>(Strict),
Mock.Of<IPreReleaseService>(Strict)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
using System.Threading.Tasks;
using GovUk.Education.ExploreEducationStatistics.Admin.Security.AuthorizationHandlers;
using GovUk.Education.ExploreEducationStatistics.Admin.Services;
using GovUk.Education.ExploreEducationStatistics.Admin.Services.Interfaces;
using GovUk.Education.ExploreEducationStatistics.Content.Model;
using GovUk.Education.ExploreEducationStatistics.Content.Model.Database;
using Microsoft.AspNetCore.Authorization;
using Moq;
using Xunit;
using static GovUk.Education.ExploreEducationStatistics.Admin.Security.SecurityClaimTypes;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Security.AuthorizationHandlers.Utils.AuthorizationHandlersTestUtil;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Security.AuthorizationHandlers.Utils.ReleaseAuthorizationHandlersTestUtil;
using static Moq.MockBehavior;

namespace GovUk.Education.ExploreEducationStatistics.Admin.Tests.Security.AuthorizationHandlers
{
Expand All @@ -22,8 +26,8 @@ public async Task AssignPrereleaseContactsToSpecificReleaseAuthorizationHandler_
{
// Assert that users with the "UpdateAllReleases" claim can assign pre release contacts to a release
// that's unapproved
await AssertReleaseHandlerSucceedsWithCorrectClaims
<AssignPrereleaseContactsToSpecificReleaseRequirement>(
await AssertHandlerSucceedsWithCorrectClaims
<Release, AssignPrereleaseContactsToSpecificReleaseRequirement>(
CreateHandler,
new Release
{
Expand All @@ -37,8 +41,8 @@ public async Task AssignPrereleaseContactsToSpecificReleaseAuthorizationHandler_
{
// Assert that users with the "UpdateAllReleases" claim can assign pre release contacts to a release
// that's approved
await AssertReleaseHandlerSucceedsWithCorrectClaims
<AssignPrereleaseContactsToSpecificReleaseRequirement>(
await AssertHandlerSucceedsWithCorrectClaims
<Release, AssignPrereleaseContactsToSpecificReleaseRequirement>(
CreateHandler,
new Release
{
Expand Down Expand Up @@ -117,6 +121,7 @@ await AssertReleaseHandlerSucceedsWithCorrectReleaseRoles<
CreateHandler,
new Release
{
Id = Guid.NewGuid(),
ApprovalStatus = ReleaseApprovalStatus.Draft
},
ReleaseRole.Approver, ReleaseRole.Contributor, ReleaseRole.Lead);
Expand All @@ -132,6 +137,7 @@ await AssertReleaseHandlerSucceedsWithCorrectReleaseRoles<
CreateHandler,
new Release
{
Id = Guid.NewGuid(),
ApprovalStatus = ReleaseApprovalStatus.Approved
},
ReleaseRole.Approver, ReleaseRole.Contributor, ReleaseRole.Lead);
Expand All @@ -141,9 +147,11 @@ await AssertReleaseHandlerSucceedsWithCorrectReleaseRoles<
private static IAuthorizationHandler CreateHandler(ContentDbContext contentDbContext)
{
return new AssignPrereleaseContactsToSpecificReleaseAuthorizationHandler(
new AuthorizationHandlerResourceRoleService(
new AuthorizationHandlerService(
contentDbContext,
new UserReleaseRoleRepository(contentDbContext),
new UserPublicationRoleRepository(contentDbContext))
new UserPublicationRoleRepository(contentDbContext),
Mock.Of<IPreReleaseService>(Strict))
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public async Task UserCannotCreateMethodologyForPublicationWithoutPublicationOwn
await handler.HandleAsync(authContext);
VerifyAllMocks(userPublicationRoleRepository);

// Verify that the user can't create a Methodology for this Publication because they don't have
// Verify that the user can't create a Methodology for this Publication because they don't have
// Publication Owner role on it
Assert.False(authContext.HasSucceeded);
}
Expand Down Expand Up @@ -241,15 +241,17 @@ private static AuthorizationHandlerContext CreateAuthContext(ClaimsPrincipal use

private static (CreateMethodologyForSpecificPublicationAuthorizationHandler,
Mock<IUserPublicationRoleRepository>)
CreateHandlerAndDependencies(ContentDbContext context)
CreateHandlerAndDependencies(ContentDbContext contentDbContext)
{
var userPublicationRoleRepository = new Mock<IUserPublicationRoleRepository>(Strict);

var handler = new CreateMethodologyForSpecificPublicationAuthorizationHandler(
context,
new AuthorizationHandlerResourceRoleService(
Mock.Of<IUserReleaseRoleRepository>(Strict),
userPublicationRoleRepository.Object));
contentDbContext,
new AuthorizationHandlerService(
contentDbContext,
Mock.Of<IUserReleaseRoleRepository>(Strict),
userPublicationRoleRepository.Object,
Mock.Of<IPreReleaseService>(Strict)));

return (handler, userPublicationRoleRepository);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
using Microsoft.AspNetCore.Authorization;
using Moq;
using Xunit;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Services.DbUtils;
using static Moq.MockBehavior;

namespace GovUk.Education.ExploreEducationStatistics.Admin.Tests.Security.AuthorizationHandlers;

Expand Down Expand Up @@ -138,13 +140,15 @@ private static
Mock<IUserPublicationRoleRepository>)
CreateHandlerAndDependencies()
{
var userReleaseRoleRepository = new Mock<IUserReleaseRoleRepository>(MockBehavior.Strict);
var userPublicationRoleRepository = new Mock<IUserPublicationRoleRepository>(MockBehavior.Strict);
var userReleaseRoleRepository = new Mock<IUserReleaseRoleRepository>(Strict);
var userPublicationRoleRepository = new Mock<IUserPublicationRoleRepository>(Strict);

var handler = new CreateReleaseForSpecificPublicationAuthorizationHandler(
new AuthorizationHandlerResourceRoleService(
new AuthorizationHandlerService(
InMemoryApplicationDbContext(),
userReleaseRoleRepository.Object,
userPublicationRoleRepository.Object)
userPublicationRoleRepository.Object,
Mock.Of<IPreReleaseService>(Strict))
);

return (handler, userPublicationRoleRepository);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using GovUk.Education.ExploreEducationStatistics.Admin.Security.AuthorizationHandlers;
using GovUk.Education.ExploreEducationStatistics.Admin.Services;
using GovUk.Education.ExploreEducationStatistics.Admin.Services.Interfaces;
using GovUk.Education.ExploreEducationStatistics.Common.Services.Interfaces;
using GovUk.Education.ExploreEducationStatistics.Content.Model;
using Moq;
using Xunit;
Expand Down Expand Up @@ -46,10 +45,11 @@ await AssertHandlerOnlySucceedsWithReleaseRoles<DeleteSpecificCommentRequirement
contentDbContext => contentDbContext.Add(release),
contentDbContext => new DeleteSpecificCommentAuthorizationHandler(
contentDbContext,
new ReleasePublishingStatusRepository(Mock.Of<IPublisherTableStorageService>()),
new AuthorizationHandlerResourceRoleService(
new AuthorizationHandlerService(
contentDbContext,
new UserReleaseRoleRepository(contentDbContext),
new UserPublicationRoleRepository(contentDbContext))),
new UserPublicationRoleRepository(contentDbContext),
Mock.Of<IPreReleaseService>(Strict))),
ReleaseRole.Approver, ReleaseRole.Contributor, ReleaseRole.Lead);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using static GovUk.Education.ExploreEducationStatistics.Admin.Security.SecurityClaimTypes;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Security.AuthorizationHandlers.Utils.AuthorizationHandlersTestUtil;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Security.Utils.ClaimsPrincipalUtils;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Services.DbUtils;
using static GovUk.Education.ExploreEducationStatistics.Common.Services.CollectionUtils;
using static GovUk.Education.ExploreEducationStatistics.Common.Services.EnumUtil;
using static GovUk.Education.ExploreEducationStatistics.Common.Tests.Utils.MockUtils;
Expand Down Expand Up @@ -81,7 +82,7 @@ await ForEachSecurityClaimAsync(async claim =>
) = CreateHandlerAndDependencies();
// If the Claim given to the handler isn't enough to make the handler succeed, it'll go on to check
// the user's Publication Roles.
// the user's Publication Roles.
if (!expectClaimToSucceed)
{
methodologyRepository.Setup(s =>
Expand Down Expand Up @@ -141,7 +142,7 @@ await ForEachSecurityClaimAsync(async claim =>
) = CreateHandlerAndDependencies();
// If the Claim given to the handler isn't enough to make the handler succeed, it'll go on to check
// the user's Publication Roles.
// the user's Publication Roles.
if (!expectClaimToSucceed)
{
methodologyRepository.Setup(s =>
Expand Down Expand Up @@ -342,9 +343,11 @@ private static (

var handler = new DeleteSpecificMethodologyAuthorizationHandler(
methodologyRepository.Object,
new AuthorizationHandlerResourceRoleService(
Mock.Of<IUserReleaseRoleRepository>(Strict),
userPublicationRoleRepository.Object));
new AuthorizationHandlerService(
InMemoryApplicationDbContext(),
Mock.Of<IUserReleaseRoleRepository>(Strict),
userPublicationRoleRepository.Object,
Mock.Of<IPreReleaseService>(Strict)));

return (handler, methodologyRepository, userPublicationRoleRepository);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
using System.Threading.Tasks;
using GovUk.Education.ExploreEducationStatistics.Admin.Security.AuthorizationHandlers;
using GovUk.Education.ExploreEducationStatistics.Admin.Services;
using GovUk.Education.ExploreEducationStatistics.Admin.Services.Interfaces;
using GovUk.Education.ExploreEducationStatistics.Content.Model;
using GovUk.Education.ExploreEducationStatistics.Content.Model.Database;
using Moq;
using Xunit;
using static GovUk.Education.ExploreEducationStatistics.Admin.Security.SecurityClaimTypes;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Security.AuthorizationHandlers.Utils.AuthorizationHandlersTestUtil;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Security.AuthorizationHandlers.Utils.ReleaseAuthorizationHandlersTestUtil;
using static GovUk.Education.ExploreEducationStatistics.Content.Model.PublicationRole;
using static Moq.MockBehavior;

namespace GovUk.Education.ExploreEducationStatistics.Admin.Tests.Security.AuthorizationHandlers
{
Expand All @@ -21,7 +25,7 @@ public class ClaimsTests
public async Task DeleteSpecificReleaseAuthorizationHandler_NotAmendment()
{
// Assert that no users can delete a non-amendment release
await AssertReleaseHandlerSucceedsWithCorrectClaims<DeleteSpecificReleaseRequirement>(
await AssertHandlerSucceedsWithCorrectClaims<Release, DeleteSpecificReleaseRequirement>(
CreateHandler,
new Release
{
Expand All @@ -34,7 +38,7 @@ await AssertReleaseHandlerSucceedsWithCorrectClaims<DeleteSpecificReleaseRequire
public async Task DeleteSpecificReleaseAuthorizationHandler_AmendmentButApproved()
{
// Assert that no users can delete an amendment release that is approved
await AssertReleaseHandlerSucceedsWithCorrectClaims<DeleteSpecificReleaseRequirement>(
await AssertHandlerSucceedsWithCorrectClaims<Release, DeleteSpecificReleaseRequirement>(
CreateHandler,
new Release
{
Expand All @@ -48,7 +52,7 @@ public async Task DeleteSpecificReleaseAuthorizationHandler_UnapprovedAmendment(
{
// Assert that users with the "DeleteAllReleaseAmendments" claim can delete an amendment release that is not
// yet approved
await AssertReleaseHandlerSucceedsWithCorrectClaims<DeleteSpecificReleaseRequirement>(
await AssertHandlerSucceedsWithCorrectClaims<Release, DeleteSpecificReleaseRequirement>(
CreateHandler,
new Release
{
Expand Down Expand Up @@ -183,9 +187,11 @@ await AssertReleaseHandlerSucceedsWithCorrectReleaseRoles<DeleteSpecificReleaseR
private static DeleteSpecificReleaseAuthorizationHandler CreateHandler(ContentDbContext contentDbContext)
{
return new DeleteSpecificReleaseAuthorizationHandler(
new AuthorizationHandlerResourceRoleService(
new AuthorizationHandlerService(
contentDbContext,
new UserReleaseRoleRepository(contentDbContext),
new UserPublicationRoleRepository(contentDbContext)));
new UserPublicationRoleRepository(contentDbContext),
Mock.Of<IPreReleaseService>(Strict)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using static GovUk.Education.ExploreEducationStatistics.Admin.Security.SecurityClaimTypes;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Security.AuthorizationHandlers.Utils.AuthorizationHandlersTestUtil;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Security.Utils.ClaimsPrincipalUtils;
using static GovUk.Education.ExploreEducationStatistics.Admin.Tests.Services.DbUtils;
using static GovUk.Education.ExploreEducationStatistics.Common.Services.CollectionUtils;
using static GovUk.Education.ExploreEducationStatistics.Common.Tests.Utils.MockUtils;
using static GovUk.Education.ExploreEducationStatistics.Content.Model.PublicationRole;
Expand Down Expand Up @@ -182,9 +183,11 @@ private static DropMethodologyLinkAuthorizationHandler SetupHandler(
)
{
return new(
new AuthorizationHandlerResourceRoleService(
new AuthorizationHandlerService(
InMemoryApplicationDbContext(),
Mock.Of<IUserReleaseRoleRepository>(Strict),
userPublicationRoleRepository ?? Mock.Of<IUserPublicationRoleRepository>(Strict)));
userPublicationRoleRepository ?? Mock.Of<IUserPublicationRoleRepository>(Strict),
Mock.Of<IPreReleaseService>(Strict)));
}
}
}
Loading

0 comments on commit 4d4bbe2

Please sign in to comment.