diff --git a/src/Digdir.Domain.Dialogporten.Application/Externals/IResourceRegistry.cs b/src/Digdir.Domain.Dialogporten.Application/Externals/IResourceRegistry.cs index 6f6ccc59b..4c0cbc83c 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Externals/IResourceRegistry.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Externals/IResourceRegistry.cs @@ -14,13 +14,15 @@ public sealed record ServiceResourceInformation { public string ResourceType { get; } public string OwnerOrgNumber { get; } + public string OwnOrgShortName { get; } public string ResourceId { get; } - public ServiceResourceInformation(string resourceId, string resourceType, string ownerOrgNumber) + public ServiceResourceInformation(string resourceId, string resourceType, string ownerOrgNumber, string ownOrgShortName) { ResourceId = resourceId.ToLowerInvariant(); ResourceType = resourceType.ToLowerInvariant(); OwnerOrgNumber = ownerOrgNumber.ToLowerInvariant(); + OwnOrgShortName = ownOrgShortName.ToLowerInvariant(); } } diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogActivities/Queries/Get/GetActivityQuery.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogActivities/Queries/Get/GetActivityQuery.cs index 9d68d7f10..48ff61bba 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogActivities/Queries/Get/GetActivityQuery.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogActivities/Queries/Get/GetActivityQuery.cs @@ -1,5 +1,6 @@ using AutoMapper; using Digdir.Domain.Dialogporten.Application.Common; +using Digdir.Domain.Dialogporten.Application.Common.Extensions; using Digdir.Domain.Dialogporten.Application.Common.ReturnTypes; using Digdir.Domain.Dialogporten.Application.Externals; using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities; @@ -43,7 +44,7 @@ public async Task Handle(GetActivityQuery request, .Include(x => x.Activities.Where(x => x.Id == request.ActivityId)) .ThenInclude(x => x.Description!.Localizations) .IgnoreQueryFilters() - .Where(x => resourceIds.Contains(x.ServiceResource)) + .WhereIf(!_userResourceRegistry.IsCurrentUserServiceOwnerAdmin(), x => resourceIds.Contains(x.ServiceResource)) .FirstOrDefaultAsync(x => x.Id == request.DialogId, cancellationToken: cancellationToken); diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogActivities/Queries/Search/SearchActivityQuery.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogActivities/Queries/Search/SearchActivityQuery.cs index 2659970ea..f1f6d2cf2 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogActivities/Queries/Search/SearchActivityQuery.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogActivities/Queries/Search/SearchActivityQuery.cs @@ -1,5 +1,6 @@ using AutoMapper; using Digdir.Domain.Dialogporten.Application.Common; +using Digdir.Domain.Dialogporten.Application.Common.Extensions; using Digdir.Domain.Dialogporten.Application.Common.ReturnTypes; using Digdir.Domain.Dialogporten.Application.Externals; using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities; @@ -37,7 +38,7 @@ public async Task Handle(SearchActivityQuery request, Canc var dialog = await _db.Dialogs .Include(x => x.Activities) .IgnoreQueryFilters() - .Where(x => resourceIds.Contains(x.ServiceResource)) + .WhereIf(!_userResourceRegistry.IsCurrentUserServiceOwnerAdmin(), x => resourceIds.Contains(x.ServiceResource)) .FirstOrDefaultAsync(x => x.Id == request.DialogId, cancellationToken: cancellationToken); diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Get/GetSeenLogQuery.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Get/GetSeenLogQuery.cs index 9f68f416f..f72e352fe 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Get/GetSeenLogQuery.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Get/GetSeenLogQuery.cs @@ -1,5 +1,6 @@ using AutoMapper; using Digdir.Domain.Dialogporten.Application.Common; +using Digdir.Domain.Dialogporten.Application.Common.Extensions; using Digdir.Domain.Dialogporten.Application.Common.ReturnTypes; using Digdir.Domain.Dialogporten.Application.Externals; using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities; @@ -44,7 +45,7 @@ public async Task Handle(GetSeenLogQuery request, .Include(x => x.SeenLog.Where(x => x.Id == request.SeenLogId)) .ThenInclude(x => x.SeenBy) .IgnoreQueryFilters() - .Where(x => resourceIds.Contains(x.ServiceResource)) + .WhereIf(!_userResourceRegistry.IsCurrentUserServiceOwnerAdmin(), x => resourceIds.Contains(x.ServiceResource)) .FirstOrDefaultAsync(x => x.Id == request.DialogId, cancellationToken: cancellationToken); diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Search/SearchSeenLogQuery.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Search/SearchSeenLogQuery.cs index de530bb3d..1b201e12b 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Search/SearchSeenLogQuery.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Search/SearchSeenLogQuery.cs @@ -1,5 +1,6 @@ using AutoMapper; using Digdir.Domain.Dialogporten.Application.Common; +using Digdir.Domain.Dialogporten.Application.Common.Extensions; using Digdir.Domain.Dialogporten.Application.Common.ReturnTypes; using Digdir.Domain.Dialogporten.Application.Externals; using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities; @@ -42,7 +43,7 @@ public async Task Handle(SearchSeenLogQuery request, Cancel .Include(x => x.SeenLog) .ThenInclude(x => x.SeenBy) .IgnoreQueryFilters() - .Where(x => resourceIds.Contains(x.ServiceResource)) + .WhereIf(!_userResourceRegistry.IsCurrentUserServiceOwnerAdmin(), x => resourceIds.Contains(x.ServiceResource)) .FirstOrDefaultAsync(x => x.Id == request.DialogId, cancellationToken: cancellationToken); diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Get/GetTransmissionQuery.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Get/GetTransmissionQuery.cs index 97c6c1d26..9a903e24d 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Get/GetTransmissionQuery.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Get/GetTransmissionQuery.cs @@ -1,5 +1,6 @@ using AutoMapper; using Digdir.Domain.Dialogporten.Application.Common; +using Digdir.Domain.Dialogporten.Application.Common.Extensions; using Digdir.Domain.Dialogporten.Application.Common.ReturnTypes; using Digdir.Domain.Dialogporten.Application.Externals; using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities; @@ -50,7 +51,7 @@ public async Task Handle(GetTransmissionQuery request, .Include(x => x.Transmissions) .ThenInclude(x => x.Sender) .IgnoreQueryFilters() - .Where(x => resourceIds.Contains(x.ServiceResource)) + .WhereIf(!_userResourceRegistry.IsCurrentUserServiceOwnerAdmin(), x => resourceIds.Contains(x.ServiceResource)) .FirstOrDefaultAsync(x => x.Id == request.DialogId, cancellationToken: cancellationToken); diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Search/SearchTransmissionQuery.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Search/SearchTransmissionQuery.cs index cb207e3bb..2ae72e87d 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Search/SearchTransmissionQuery.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Search/SearchTransmissionQuery.cs @@ -1,5 +1,6 @@ using AutoMapper; using Digdir.Domain.Dialogporten.Application.Common; +using Digdir.Domain.Dialogporten.Application.Common.Extensions; using Digdir.Domain.Dialogporten.Application.Common.ReturnTypes; using Digdir.Domain.Dialogporten.Application.Externals; using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities; @@ -47,7 +48,7 @@ public async Task Handle(SearchTransmissionQuery reque .Include(x => x.Transmissions) .ThenInclude(x => x.Sender) .IgnoreQueryFilters() - .Where(x => resourceIds.Contains(x.ServiceResource)) + .WhereIf(!_userResourceRegistry.IsCurrentUserServiceOwnerAdmin(), x => resourceIds.Contains(x.ServiceResource)) .FirstOrDefaultAsync(x => x.Id == request.DialogId, cancellationToken: cancellationToken); diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs index f16b28f29..2fee13aa3 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs @@ -30,7 +30,7 @@ internal sealed class CreateDialogCommandHandler : IRequestHandler Handle(CreateDialogCommand request, CancellationToken cancellationToken) @@ -63,12 +63,17 @@ public async Task Handle(CreateDialogCommand request, Cancel return forbiddenResult; } - dialog.Org = await _userOrganizationRegistry.GetCurrentUserOrgShortName(cancellationToken) ?? string.Empty; - if (string.IsNullOrWhiteSpace(dialog.Org)) + var serviceResourceInformation = await _resourceRegistry.GetResourceInformation(dialog.ServiceResource, cancellationToken); + if (serviceResourceInformation is null) { _domainContext.AddError(new DomainFailure(nameof(DialogEntity.Org), - "Cannot find service owner organization shortname for current user. Please ensure that you are logged in as a service owner.")); + "Cannot find service owner organization shortname for referenced service resource.")); } + else + { + dialog.Org = serviceResourceInformation.OwnOrgShortName; + } + CreateDialogEndUserContext(request, dialog); await EnsureNoExistingUserDefinedIds(dialog, cancellationToken); diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Delete/DeleteDialogCommand.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Delete/DeleteDialogCommand.cs index 7a82ef8df..95576b34f 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Delete/DeleteDialogCommand.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Delete/DeleteDialogCommand.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using Digdir.Domain.Dialogporten.Application.Common; +using Digdir.Domain.Dialogporten.Application.Common.Extensions; using Digdir.Domain.Dialogporten.Application.Common.ReturnTypes; using Digdir.Domain.Dialogporten.Application.Externals; using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities; @@ -42,7 +43,7 @@ public async Task Handle(DeleteDialogCommand request, Cancel var dialog = await _db.Dialogs .Include(x => x.Activities) - .Where(x => resourceIds.Contains(x.ServiceResource)) + .WhereIf(!_userResourceRegistry.IsCurrentUserServiceOwnerAdmin(), x => resourceIds.Contains(x.ServiceResource)) .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken); if (dialog is null) diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Purge/PurgeDialogCommand.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Purge/PurgeDialogCommand.cs index 72aee089f..4430853ad 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Purge/PurgeDialogCommand.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Purge/PurgeDialogCommand.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using Digdir.Domain.Dialogporten.Application.Common; +using Digdir.Domain.Dialogporten.Application.Common.Extensions; using Digdir.Domain.Dialogporten.Application.Common.ReturnTypes; using Digdir.Domain.Dialogporten.Application.Externals; using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities; @@ -42,7 +43,7 @@ public async Task Handle(PurgeDialogCommand request, Cancella var dialog = await _db.Dialogs .Include(x => x.Attachments) .Include(x => x.Activities) - .Where(x => resourceIds.Contains(x.ServiceResource)) + .WhereIf(!_userResourceRegistry.IsCurrentUserServiceOwnerAdmin(), x => resourceIds.Contains(x.ServiceResource)) .IgnoreQueryFilters() .FirstOrDefaultAsync(x => x.Id == request.DialogId, cancellationToken); diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs index e00af78a3..59bc62a8a 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs @@ -83,7 +83,7 @@ public async Task Handle(UpdateDialogCommand request, Cancel .Include(x => x.Transmissions) .Include(x => x.DialogEndUserContext) .IgnoreQueryFilters() - .Where(x => resourceIds.Contains(x.ServiceResource)) + .WhereIf(!_userResourceRegistry.IsCurrentUserServiceOwnerAdmin(), x => resourceIds.Contains(x.ServiceResource)) .FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken); if (dialog is null) diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Queries/Get/GetDialogQuery.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Queries/Get/GetDialogQuery.cs index f257f87a6..d33d7fe5c 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Queries/Get/GetDialogQuery.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Queries/Get/GetDialogQuery.cs @@ -2,6 +2,7 @@ using AutoMapper; using Digdir.Domain.Dialogporten.Application.Common; using Digdir.Domain.Dialogporten.Application.Common.Authorization; +using Digdir.Domain.Dialogporten.Application.Common.Extensions; using Digdir.Domain.Dialogporten.Application.Common.ReturnTypes; using Digdir.Domain.Dialogporten.Application.Externals; using Digdir.Domain.Dialogporten.Application.Externals.AltinnAuthorization; @@ -85,7 +86,7 @@ public async Task Handle(GetDialogQuery request, CancellationTo .ThenInclude(x => x.SeenBy) .Include(x => x.DialogEndUserContext) .IgnoreQueryFilters() - .Where(x => resourceIds.Contains(x.ServiceResource)) + .WhereIf(!_userResourceRegistry.IsCurrentUserServiceOwnerAdmin(), x => resourceIds.Contains(x.ServiceResource)) .FirstOrDefaultAsync(x => x.Id == request.DialogId, cancellationToken); if (dialog is null) diff --git a/src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/ResourceRegistry/LocalDevelopmentResourceRegistry.cs b/src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/ResourceRegistry/LocalDevelopmentResourceRegistry.cs index d16c55b04..6d649b341 100644 --- a/src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/ResourceRegistry/LocalDevelopmentResourceRegistry.cs +++ b/src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/ResourceRegistry/LocalDevelopmentResourceRegistry.cs @@ -9,6 +9,7 @@ internal sealed class LocalDevelopmentResourceRegistry : IResourceRegistry { private const string LocalResourceType = "LocalResourceType"; private const string LocalOrgId = "742859274"; + private const string LocalOrgShortName = "ttd"; private static readonly HashSet CachedResourceIds = new(new ServiceResourceInformationEqualityComparer()); private readonly IDialogDbContext _db; @@ -26,7 +27,7 @@ public async Task> GetResourceIn foreach (var id in newIds) { - CachedResourceIds.Add(new ServiceResourceInformation(id, LocalResourceType, orgNumber)); + CachedResourceIds.Add(new ServiceResourceInformation(id, LocalResourceType, orgNumber, LocalOrgShortName)); } return CachedResourceIds; @@ -35,7 +36,7 @@ public async Task> GetResourceIn public Task GetResourceInformation(string serviceResourceId, CancellationToken cancellationToken) { return Task.FromResult( - new ServiceResourceInformation(serviceResourceId, LocalResourceType, LocalOrgId)); + new ServiceResourceInformation(serviceResourceId, LocalResourceType, LocalOrgId, LocalOrgShortName)); } [SuppressMessage("Performance", "CA1822:Mark members as static")] diff --git a/src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/ResourceRegistry/ResourceRegistryClient.cs b/src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/ResourceRegistry/ResourceRegistryClient.cs index c2b11d310..4aa01cad7 100644 --- a/src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/ResourceRegistry/ResourceRegistryClient.cs +++ b/src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/ResourceRegistry/ResourceRegistryClient.cs @@ -192,7 +192,8 @@ ResourceTypeAltinnApp or .Select(x => new ServiceResourceInformation( $"{Constants.ServiceResourcePrefix}{x.Identifier}", x.ResourceType, - x.HasCompetentAuthority.Organization!)) + x.HasCompetentAuthority.Organization!, + x.HasCompetentAuthority.OrgCode)) .ToArray(); }, token: cancellationToken); diff --git a/tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs index 12c539b55..3d7b11590 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs @@ -26,8 +26,7 @@ public async Task CreateDialogCommand_Should_Return_Forbidden_When_Scope_Is_Miss var unitOfWorkSub = Substitute.For(); var domainContextSub = Substitute.For(); - var userResourceRegistrySub = Substitute.For(); - var userOrganizationRegistrySub = Substitute.For(); + var resourceRegistrySub = Substitute.For(); var serviceAuthorizationSub = Substitute.For(); var userSub = Substitute.For(); @@ -37,13 +36,13 @@ public async Task CreateDialogCommand_Should_Return_Forbidden_When_Scope_Is_Miss .AuthorizeServiceResources(Arg.Any(), Arg.Any()) .Returns(new Forbidden()); - userResourceRegistrySub - .CurrentUserIsOwner(createCommand.ServiceResource, Arg.Any()) - .Returns(true); + resourceRegistrySub + .GetResourceInformation(createCommand.ServiceResource, Arg.Any()) + .Returns(new ServiceResourceInformation(createCommand.ServiceResource, "foo", "912345678", "ttd")); var commandHandler = new CreateDialogCommandHandler(userSub, dialogDbContextSub, mapper, unitOfWorkSub, domainContextSub, - userOrganizationRegistrySub, serviceAuthorizationSub); + resourceRegistrySub, serviceAuthorizationSub); // Act var result = await commandHandler.Handle(createCommand, CancellationToken.None); @@ -65,8 +64,7 @@ public async Task CreateDialogCommand_Should_Return_Forbidden_When_User_Is_Not_O var unitOfWorkSub = Substitute.For(); var domainContextSub = Substitute.For(); - var userResourceRegistrySub = Substitute.For(); - var userOrganizationRegistrySub = Substitute.For(); + var resourceRegistrySub = Substitute.For(); var serviceAuthorizationSub = Substitute.For(); var userSub = Substitute.For(); var createCommand = DialogGenerator.GenerateSimpleFakeDialog(); @@ -75,13 +73,13 @@ public async Task CreateDialogCommand_Should_Return_Forbidden_When_User_Is_Not_O .AuthorizeServiceResources(Arg.Any(), Arg.Any()) .Returns(new Forbidden()); - userResourceRegistrySub - .CurrentUserIsOwner(createCommand.ServiceResource, Arg.Any()) - .Returns(false); + resourceRegistrySub + .GetResourceInformation(createCommand.ServiceResource, Arg.Any()) + .Returns(new ServiceResourceInformation(createCommand.ServiceResource, "foo", "912345678", "ttd")); var commandHandler = new CreateDialogCommandHandler(userSub, dialogDbContextSub, mapper, unitOfWorkSub, domainContextSub, - userOrganizationRegistrySub, serviceAuthorizationSub); + resourceRegistrySub, serviceAuthorizationSub); // Act var result = await commandHandler.Handle(createCommand, CancellationToken.None); diff --git a/tests/k6/common/sentinel.js b/tests/k6/common/sentinel.js index 57615bf90..14054d676 100644 --- a/tests/k6/common/sentinel.js +++ b/tests/k6/common/sentinel.js @@ -12,7 +12,7 @@ export default function () { let continuationToken = ""; let dialogIdsToPurge = []; do { - let r = getSO('dialogs/?Search=' + sentinelValue + continuationToken, null, tokenOptions); + let r = getSO('dialogs/?Limit=1000&Search=' + sentinelValue + continuationToken, null, tokenOptions); expectStatusFor(r).to.equal(200); expect(r, 'response').to.have.validJsonBody(); let response = r.json(); diff --git a/tests/k6/tests/serviceowner/authorization.js b/tests/k6/tests/serviceowner/authorization.js index 3af102ca1..39ae0a6c1 100644 --- a/tests/k6/tests/serviceowner/authorization.js +++ b/tests/k6/tests/serviceowner/authorization.js @@ -5,6 +5,7 @@ export default function () { let validSo = null; let invalidSo = { orgName: "other", orgNo: "310778737" }; + let validSoAdmin = { orgName: "other", orgNo: "310778737", scopes: "digdir:dialogporten.serviceprovider digdir:dialogporten.serviceprovider.admin" }; let dialog = dialogToInsert(); let transmissionId = null; // known after successful insert @@ -18,12 +19,16 @@ export default function () { let permutations = [ [ true, validSo ], - [ false, invalidSo ] + [ false, invalidSo ], + [ true, validSoAdmin ] ]; permutations.forEach(([shouldSucceed, tokenOptions]) => { let logPrefix = shouldSucceed ? "Allow" : "Deny"; let logSuffix = shouldSucceed ? "valid serviceowner" : "invalid serviceowner" + if (tokenOptions && tokenOptions["scopes"] && tokenOptions["scopes"].indexOf("admin") > -1) { + logSuffix += " (admin)"; + } describe(`${logPrefix} dialog create as ${logSuffix}`, () => { let r = postSO('dialogs', dialog, null, tokenOptions);