From c393d10ac8761414114f9b2361e2f5d744b9ac15 Mon Sep 17 00:00:00 2001 From: acn-sbuad Date: Wed, 5 Jun 2024 11:10:26 +0200 Subject: [PATCH] notification to org and person with resource working --- .../EmailNotificationOrdersController.cs | 2 - .../SmsNotificationOrdersController.cs | 3 - .../NotificationOrderRequestResponseMapper.cs | 4 +- .../API/Models/BaseNotificationOrderExt.cs | 2 +- .../EmailNotificationOrderRequestExt.cs | 7 +- .../Models/NotificationOrderRequestBaseExt.cs | 5 +- .../SmsNotificationOrderRequestValidator.cs | 35 ++------- .../Integrations/IAuthorizationService.cs | 22 ++++++ .../Core/Integrations/IProfileClient.cs | 8 +- .../Core/Models/Address/SmsAddressPoint.cs | 3 +- .../GenericServiceUpdate.cs | 74 +++++++++++++++++++ .../ResourceLimitExceeded.cs | 67 +++++++++++++++++ .../OrganizationContactPoints.cs | 24 +++++- .../Models/ContactPoints/UserContactPoints.cs | 16 ++++ .../NotificationTemplate/SmsTemplate.cs | 1 - .../Core/Models/Orders/NotificationOrder.cs | 2 +- .../Models/Orders/NotificationOrderRequest.cs | 8 +- .../NotificationOrderRequestResponse.cs | 2 +- .../Core/Services/ContactPointService.cs | 16 ++-- .../Interfaces/IOrderRequestService.cs | 7 +- .../Core/Services/OrderRequestService.cs | 5 +- .../LocalAuthorizationService.cs | 13 ++++ .../LocalProfileClient.cs | 7 +- .../LocalRegisterClient.cs | 2 - .../NotificationsServiceExtentions.cs | 5 +- testdata/Profile/User/1001.json | 5 +- testdata/Profile/User/1002.json | 5 +- testdata/Profile/User/1003.json | 7 +- testdata/Profile/User/12345.json | 7 +- testdata/Profile/User/1337.json | 7 +- testdata/Register/Person/01899699552.json | 2 +- 31 files changed, 286 insertions(+), 87 deletions(-) create mode 100644 src/Notifications/Core/Integrations/IAuthorizationService.cs create mode 100644 src/Notifications/Core/Models/AltinnServiceUpdate/GenericServiceUpdate.cs create mode 100644 src/Notifications/Core/Models/AltinnServiceUpdate/ResourceLimitExceeded.cs create mode 100644 src/Notifications/LocalTestNotifications/LocalAuthorizationService.cs diff --git a/src/Notifications/API/Controllers/EmailNotificationOrdersController.cs b/src/Notifications/API/Controllers/EmailNotificationOrdersController.cs index 1eeb9754..aeff0b44 100644 --- a/src/Notifications/API/Controllers/EmailNotificationOrdersController.cs +++ b/src/Notifications/API/Controllers/EmailNotificationOrdersController.cs @@ -12,8 +12,6 @@ using FluentValidation; -using LocalTest.Notifications.Core.Models.Orders; - #if !LOCALTEST using Microsoft.AspNetCore.Authorization; diff --git a/src/Notifications/API/Controllers/SmsNotificationOrdersController.cs b/src/Notifications/API/Controllers/SmsNotificationOrdersController.cs index 48747293..69da6e50 100644 --- a/src/Notifications/API/Controllers/SmsNotificationOrdersController.cs +++ b/src/Notifications/API/Controllers/SmsNotificationOrdersController.cs @@ -12,9 +12,6 @@ using FluentValidation; -using LocalTest.Notifications.Core.Models.Orders; - - #if !LOCALTEST using Microsoft.AspNetCore.Authorization; #endif diff --git a/src/Notifications/API/Mappers/NotificationOrderRequestResponseMapper.cs b/src/Notifications/API/Mappers/NotificationOrderRequestResponseMapper.cs index a3c3236b..7feee5fe 100644 --- a/src/Notifications/API/Mappers/NotificationOrderRequestResponseMapper.cs +++ b/src/Notifications/API/Mappers/NotificationOrderRequestResponseMapper.cs @@ -1,5 +1,5 @@ -using Altinn.Notifications.Models; -using LocalTest.Notifications.Core.Models.Orders; +using Altinn.Notifications.Core.Models.Orders; +using Altinn.Notifications.Models; namespace Altinn.Notifications.Mappers; diff --git a/src/Notifications/API/Models/BaseNotificationOrderExt.cs b/src/Notifications/API/Models/BaseNotificationOrderExt.cs index 75c6a608..e72b6c03 100644 --- a/src/Notifications/API/Models/BaseNotificationOrderExt.cs +++ b/src/Notifications/API/Models/BaseNotificationOrderExt.cs @@ -44,7 +44,7 @@ public class BaseNotificationOrderExt /// Gets or sets the preferred notification channel of the notification order /// [JsonPropertyName("notificationChannel")] - [JsonConverter(typeof(JsonStringEnumConverter))] + [JsonConverter(typeof(JsonStringEnumConverter))] public NotificationChannelExt NotificationChannel { get; set; } /// diff --git a/src/Notifications/API/Models/EmailNotificationOrderRequestExt.cs b/src/Notifications/API/Models/EmailNotificationOrderRequestExt.cs index a6569b96..61a87e53 100644 --- a/src/Notifications/API/Models/EmailNotificationOrderRequestExt.cs +++ b/src/Notifications/API/Models/EmailNotificationOrderRequestExt.cs @@ -1,4 +1,5 @@ -using System.Text.Json; +using System.ComponentModel.DataAnnotations; +using System.Text.Json; using System.Text.Json.Serialization; namespace Altinn.Notifications.Models; @@ -15,19 +16,21 @@ public class EmailNotificationOrderRequestExt : NotificationOrderRequestBaseExt /// Gets or sets the subject of the email /// [JsonPropertyName("subject")] + [Required] public string Subject { get; set; } = string.Empty; /// /// Gets or sets the body of the email /// [JsonPropertyName("body")] + [Required] public string Body { get; set; } = string.Empty; /// /// Gets or sets the content type of the email /// [JsonPropertyName("contentType")] - public EmailContentTypeExt ContentType { get; set; } = EmailContentTypeExt.Plain; + public EmailContentTypeExt? ContentType { get; set; } /// /// Json serialized the diff --git a/src/Notifications/API/Models/NotificationOrderRequestBaseExt.cs b/src/Notifications/API/Models/NotificationOrderRequestBaseExt.cs index fbc57ff1..164626f6 100644 --- a/src/Notifications/API/Models/NotificationOrderRequestBaseExt.cs +++ b/src/Notifications/API/Models/NotificationOrderRequestBaseExt.cs @@ -1,4 +1,4 @@ -using System.Text.Json; +using System.ComponentModel.DataAnnotations; using System.Text.Json.Serialization; namespace Altinn.Notifications.Models; @@ -24,13 +24,14 @@ public class NotificationOrderRequestBaseExt /// Gets or sets the list of recipients /// [JsonPropertyName("recipients")] + [Required] public List Recipients { get; set; } = new List(); /// /// Gets or sets whether notifications generated by this order should ignore KRR reservations /// [JsonPropertyName("ignoreReservation")] - public bool IgnoreReservation { get; set; } + public bool? IgnoreReservation { get; set; } /// /// Gets or sets the id of the resource that the notification is related to diff --git a/src/Notifications/API/Validators/SmsNotificationOrderRequestValidator.cs b/src/Notifications/API/Validators/SmsNotificationOrderRequestValidator.cs index 7f073df7..425d7e97 100644 --- a/src/Notifications/API/Validators/SmsNotificationOrderRequestValidator.cs +++ b/src/Notifications/API/Validators/SmsNotificationOrderRequestValidator.cs @@ -1,9 +1,7 @@ -using System.Text.RegularExpressions; - +using Altinn.Notifications.Core.Helpers; using Altinn.Notifications.Models; using FluentValidation; -using PhoneNumbers; namespace Altinn.Notifications.Validators; @@ -20,8 +18,13 @@ public SmsNotificationOrderRequestValidator() RuleFor(order => order.Recipients) .NotEmpty() .WithMessage("One or more recipient is required.") - .Must(recipients => recipients.TrueForAll(a => IsValidMobileNumber(a.MobileNumber))) - .WithMessage("A valid mobile number starting with country code must be provided for all recipients."); + .Must(recipients => recipients.TrueForAll(a => + { + return + (!string.IsNullOrWhiteSpace(a.MobileNumber) && MobileNumberHelper.IsValidMobileNumber(a.MobileNumber)) || + (!string.IsNullOrWhiteSpace(a.OrganizationNumber) ^ !string.IsNullOrWhiteSpace(a.NationalIdentityNumber)); + })) + .WithMessage("Either a valid mobile number starting with country code, organization number, or national identity number must be provided for each recipient."); RuleFor(order => order.RequestedSendTime) .Must(sendTime => sendTime.Kind != DateTimeKind.Unspecified) @@ -31,26 +34,4 @@ public SmsNotificationOrderRequestValidator() RuleFor(order => order.Body).NotEmpty(); } - - /// - /// Validated as mobile number based on the Altinn 2 regex - /// - /// The string to validate as an mobile number - /// A boolean indicating that the mobile number is valid or not - internal static bool IsValidMobileNumber(string? mobileNumber) - { - if (string.IsNullOrEmpty(mobileNumber) || (!mobileNumber.StartsWith('+') && !mobileNumber.StartsWith("00"))) - { - return false; - } - - if (mobileNumber.StartsWith("00")) - { - mobileNumber = "+" + mobileNumber.Remove(0, 2); - } - - PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.GetInstance(); - PhoneNumber phoneNumber = phoneNumberUtil.Parse(mobileNumber, null); - return phoneNumberUtil.IsValidNumber(phoneNumber); - } } diff --git a/src/Notifications/Core/Integrations/IAuthorizationService.cs b/src/Notifications/Core/Integrations/IAuthorizationService.cs new file mode 100644 index 00000000..a299b3cf --- /dev/null +++ b/src/Notifications/Core/Integrations/IAuthorizationService.cs @@ -0,0 +1,22 @@ +using Altinn.Notifications.Core.Models.ContactPoints; + +namespace Altinn.Notifications.Core.Integrations; + +/// +/// Describes the necessary functions of an authorization service that can perform +/// notification recipient filtering based on authorization +/// +public interface IAuthorizationService +{ + /// + /// Describes a method that can create an authorization request to authorize a set of + /// users for access to a resource. + /// + /// + /// The contact points of an organization including user registered contact points. + /// + /// The id of the resource. + /// A new list of with filtered list of recipients. + Task> AuthorizeUserContactPointsForResource( + List organizationContactPoints, string resourceId); +} diff --git a/src/Notifications/Core/Integrations/IProfileClient.cs b/src/Notifications/Core/Integrations/IProfileClient.cs index 28ed22d5..0f786e9d 100644 --- a/src/Notifications/Core/Integrations/IProfileClient.cs +++ b/src/Notifications/Core/Integrations/IProfileClient.cs @@ -15,10 +15,10 @@ public interface IProfileClient public Task> GetUserContactPoints(List nationalIdentityNumbers); /// - /// Retrieves the user registered contact points for a list of organization corresponding to a list of organization numbers + /// Retrieves the user registered contact points for a list of organizations identified by organization numbers /// - /// The id of the resource to look up contact points for /// The set or organizations to retrieve contact points for - /// - public Task> GetUserRegisteredOrganizationContactPoints(string resourceId, List organizationNumbers); + /// The id of the resource to look up contact points for + /// A list of organiation contact points containing user registered contact points + public Task> GetUserRegisteredContactPoints(List organizationNumbers, string resourceId); } diff --git a/src/Notifications/Core/Models/Address/SmsAddressPoint.cs b/src/Notifications/Core/Models/Address/SmsAddressPoint.cs index a09275aa..246943d4 100644 --- a/src/Notifications/Core/Models/Address/SmsAddressPoint.cs +++ b/src/Notifications/Core/Models/Address/SmsAddressPoint.cs @@ -1,5 +1,4 @@ -#nullable enable -using Altinn.Notifications.Core.Enums; +using Altinn.Notifications.Core.Enums; namespace Altinn.Notifications.Core.Models.Address; diff --git a/src/Notifications/Core/Models/AltinnServiceUpdate/GenericServiceUpdate.cs b/src/Notifications/Core/Models/AltinnServiceUpdate/GenericServiceUpdate.cs new file mode 100644 index 00000000..dad21498 --- /dev/null +++ b/src/Notifications/Core/Models/AltinnServiceUpdate/GenericServiceUpdate.cs @@ -0,0 +1,74 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +using Altinn.Notifications.Core.Enums; + +namespace Altinn.Notifications.Core.Models.AltinnServiceUpdate +{ + /// + /// A class representing a generic service update + /// + public class GenericServiceUpdate + { + private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions() + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault, + WriteIndented = true, + Converters = { new JsonStringEnumConverter() }, + PropertyNameCaseInsensitive = true + }; + + /// + /// The source of the service update + /// + public string Source { get; set; } = string.Empty; + + /// + /// The schema of the service update data + /// + public AltinnServiceUpdateSchema Schema { get; set; } + + /// + /// The data of the service update as a json serialized string + /// + public string Data { get; set; } = string.Empty; + + /// + /// Serialize the into a json string + /// + /// + public string Serialize() + { + return JsonSerializer.Serialize(this, _serializerOptions); + } + + /// + /// Try to parse a json string into a + /// + public static bool TryParse(string input, out GenericServiceUpdate value) + { + GenericServiceUpdate? parsedOutput; + value = new GenericServiceUpdate(); + + if (string.IsNullOrEmpty(input)) + { + return false; + } + + try + { + parsedOutput = JsonSerializer.Deserialize(input!, _serializerOptions); + + value = parsedOutput!; + return !string.IsNullOrEmpty(value.Source); + } + catch + { + // try parse, we simply return false if fails + } + + return false; + } + } +} diff --git a/src/Notifications/Core/Models/AltinnServiceUpdate/ResourceLimitExceeded.cs b/src/Notifications/Core/Models/AltinnServiceUpdate/ResourceLimitExceeded.cs new file mode 100644 index 00000000..bbe2a654 --- /dev/null +++ b/src/Notifications/Core/Models/AltinnServiceUpdate/ResourceLimitExceeded.cs @@ -0,0 +1,67 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Altinn.Notifications.Core.Models.AltinnServiceUpdate +{ + /// + /// A class holding data on an exceeded resource limit in an Altinn service + /// + public class ResourceLimitExceeded + { + private static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions() + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault, + WriteIndented = true, + Converters = { new JsonStringEnumConverter() }, + PropertyNameCaseInsensitive = true + }; + + /// + /// The resource that has reached its capacity limit + /// + public string Resource { get; set; } = string.Empty; + + /// + /// The timestamp for when the service is available again + /// + public DateTime ResetTime { get; set; } + + /// + /// Serialize the into a json string + /// + /// + public string Serialize() + { + return JsonSerializer.Serialize(this, _serializerOptions); + } + + /// + /// Try to parse a json string into a + /// + public static bool Tryparse(string input, out ResourceLimitExceeded value) + { + ResourceLimitExceeded? parsedOutput; + value = new ResourceLimitExceeded(); + + if (string.IsNullOrEmpty(input)) + { + return false; + } + + try + { + parsedOutput = JsonSerializer.Deserialize(input!, _serializerOptions); + + value = parsedOutput!; + return !string.IsNullOrEmpty(value.Resource); + } + catch + { + // try parse, we simply return false if fails + } + + return false; + } + } +} diff --git a/src/Notifications/Core/Models/ContactPoints/OrganizationContactPoints.cs b/src/Notifications/Core/Models/ContactPoints/OrganizationContactPoints.cs index 9703d4ce..269cf80a 100644 --- a/src/Notifications/Core/Models/ContactPoints/OrganizationContactPoints.cs +++ b/src/Notifications/Core/Models/ContactPoints/OrganizationContactPoints.cs @@ -1,4 +1,6 @@ -namespace Altinn.Notifications.Core.Models.ContactPoints; +using System.Linq; + +namespace Altinn.Notifications.Core.Models.ContactPoints; /// /// Class describing the contact points for an organization @@ -26,7 +28,25 @@ public class OrganizationContactPoints public List EmailList { get; set; } = new(); /// - /// Gets or sets a list of user registered contanct points associated with the organisation. + /// Gets or sets a list of user registered contact points associated with the organization. /// public List UserContactPoints { get; set; } = new(); + + /// + /// Create a new instance with the same values as the existing instance + /// + /// The new instance with copied values. + public OrganizationContactPoints CloneWithoutContactPoints() + { + OrganizationContactPoints clone = new() + { + OrganizationNumber = OrganizationNumber, + PartyId = PartyId, + MobileNumberList = new(), + EmailList = new(), + UserContactPoints = new() + }; + + return clone; + } } diff --git a/src/Notifications/Core/Models/ContactPoints/UserContactPoints.cs b/src/Notifications/Core/Models/ContactPoints/UserContactPoints.cs index 0ed6923b..38b058da 100644 --- a/src/Notifications/Core/Models/ContactPoints/UserContactPoints.cs +++ b/src/Notifications/Core/Models/ContactPoints/UserContactPoints.cs @@ -29,4 +29,20 @@ public class UserContactPoints /// Gets or sets the email address /// public string Email { get; set; } = string.Empty; + + /// + /// Create a new instance with the same values as the existing instance + /// + /// The new instance with copied values. + public UserContactPoints Clone() + { + return new() + { + UserId = UserId, + NationalIdentityNumber = NationalIdentityNumber, + IsReserved = IsReserved, + MobileNumber = MobileNumber, + Email = Email + }; + } } diff --git a/src/Notifications/Core/Models/NotificationTemplate/SmsTemplate.cs b/src/Notifications/Core/Models/NotificationTemplate/SmsTemplate.cs index 4e79c533..9d1cb2db 100644 --- a/src/Notifications/Core/Models/NotificationTemplate/SmsTemplate.cs +++ b/src/Notifications/Core/Models/NotificationTemplate/SmsTemplate.cs @@ -1,4 +1,3 @@ -#nullable enable using Altinn.Notifications.Core.Enums; namespace Altinn.Notifications.Core.Models.NotificationTemplate; diff --git a/src/Notifications/Core/Models/Orders/NotificationOrder.cs b/src/Notifications/Core/Models/Orders/NotificationOrder.cs index 94ab6ce1..729ad11d 100644 --- a/src/Notifications/Core/Models/Orders/NotificationOrder.cs +++ b/src/Notifications/Core/Models/Orders/NotificationOrder.cs @@ -122,4 +122,4 @@ public static bool TryParse(string input, out NotificationOrder value) return false; } -} \ No newline at end of file +} diff --git a/src/Notifications/Core/Models/Orders/NotificationOrderRequest.cs b/src/Notifications/Core/Models/Orders/NotificationOrderRequest.cs index 9ca22f4b..1a879f99 100644 --- a/src/Notifications/Core/Models/Orders/NotificationOrderRequest.cs +++ b/src/Notifications/Core/Models/Orders/NotificationOrderRequest.cs @@ -52,10 +52,10 @@ public class NotificationOrderRequest /// Initializes a new instance of the class. /// public NotificationOrderRequest( - string? sendersReference, - string creatorShortName, - List templates, - DateTime? requestedSendTime, + string? sendersReference, + string creatorShortName, + List templates, + DateTime? requestedSendTime, NotificationChannel notificationChannel, List recipients, bool? ignoreReservation, diff --git a/src/Notifications/Core/Models/Orders/NotificationOrderRequestResponse.cs b/src/Notifications/Core/Models/Orders/NotificationOrderRequestResponse.cs index 10938b86..5b4eb3a4 100644 --- a/src/Notifications/Core/Models/Orders/NotificationOrderRequestResponse.cs +++ b/src/Notifications/Core/Models/Orders/NotificationOrderRequestResponse.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace LocalTest.Notifications.Core.Models.Orders; +namespace Altinn.Notifications.Core.Models.Orders; /// /// A class representing an order request response. diff --git a/src/Notifications/Core/Services/ContactPointService.cs b/src/Notifications/Core/Services/ContactPointService.cs index c0319abf..68314747 100644 --- a/src/Notifications/Core/Services/ContactPointService.cs +++ b/src/Notifications/Core/Services/ContactPointService.cs @@ -14,14 +14,16 @@ public class ContactPointService : IContactPointService { private readonly IProfileClient _profileClient; private readonly IRegisterClient _registerClient; + private readonly IAuthorizationService _authorizationService; /// /// Initializes a new instance of the class. /// - public ContactPointService(IProfileClient profile, IRegisterClient register) + public ContactPointService(IProfileClient profile, IRegisterClient register, IAuthorizationService authorizationService) { _profileClient = profile; _registerClient = register; + _authorizationService = authorizationService; } /// @@ -88,7 +90,7 @@ private async Task> AugmentRecipients( Func createUserContactPoint, Func createOrgContactPoint) { - List augmentedRecipients = new(); + List augmentedRecipients = new(); var userLookupTask = LookupPersonContactPoints(recipients); var orgLookupTask = LookupOrganizationContactPoints(recipients, resourceId); @@ -147,7 +149,7 @@ private async Task> LookupPersonContactPoints(List> LookupOrganizationContactPoints(List recipients, string? resourceId = null) + private async Task> LookupOrganizationContactPoints(List recipients, string? resourceId) { List orgNos = recipients .Where(r => !string.IsNullOrEmpty(r.OrganizationNumber)) @@ -160,19 +162,19 @@ private async Task> LookupOrganizationContactPoi } Task> registerTask = _registerClient.GetOrganizationContactPoints(orgNos); - List userRegisteredContactPoints = new(); + List authorizedUserContactPoints = new(); if (!string.IsNullOrEmpty(resourceId)) { - // TODO: call authorization to filter list before moving forward - userRegisteredContactPoints = await _profileClient.GetUserRegisteredOrganizationContactPoints(resourceId, orgNos); + var allUserContactPoints = await _profileClient.GetUserRegisteredContactPoints(orgNos, resourceId); + authorizedUserContactPoints = await _authorizationService.AuthorizeUserContactPointsForResource(allUserContactPoints, resourceId); } List contactPoints = await registerTask; if (!string.IsNullOrEmpty(resourceId)) { - foreach (var userContactPoint in userRegisteredContactPoints) + foreach (var userContactPoint in authorizedUserContactPoints) { userContactPoint.UserContactPoints.ForEach(userContactPoint => { diff --git a/src/Notifications/Core/Services/Interfaces/IOrderRequestService.cs b/src/Notifications/Core/Services/Interfaces/IOrderRequestService.cs index 0b9cb4f1..361eb6cd 100644 --- a/src/Notifications/Core/Services/Interfaces/IOrderRequestService.cs +++ b/src/Notifications/Core/Services/Interfaces/IOrderRequestService.cs @@ -1,7 +1,4 @@ -#nullable enable -using Altinn.Notifications.Core.Models.Orders; - -using LocalTest.Notifications.Core.Models.Orders; +using Altinn.Notifications.Core.Models.Orders; namespace Altinn.Notifications.Core.Services.Interfaces; @@ -16,4 +13,4 @@ public interface IOrderRequestService /// The notification order request /// The order request response object public Task RegisterNotificationOrder(NotificationOrderRequest orderRequest); -} \ No newline at end of file +} diff --git a/src/Notifications/Core/Services/OrderRequestService.cs b/src/Notifications/Core/Services/OrderRequestService.cs index b3336ac6..4d41f103 100644 --- a/src/Notifications/Core/Services/OrderRequestService.cs +++ b/src/Notifications/Core/Services/OrderRequestService.cs @@ -5,9 +5,6 @@ using Altinn.Notifications.Core.Models.Orders; using Altinn.Notifications.Core.Persistence; using Altinn.Notifications.Core.Services.Interfaces; -using Altinn.Notifications.Models; - -using LocalTest.Notifications.Core.Models.Orders; using Microsoft.Extensions.Options; @@ -44,7 +41,7 @@ public OrderRequestService( } /// - public async Task RegisterNotificationOrder(NotificationOrderRequest orderRequest) + public async Task RegisterNotificationOrder(NotificationOrderRequest orderRequest) { Guid orderId = _guid.NewGuid(); DateTime currentime = _dateTime.UtcNow(); diff --git a/src/Notifications/LocalTestNotifications/LocalAuthorizationService.cs b/src/Notifications/LocalTestNotifications/LocalAuthorizationService.cs new file mode 100644 index 00000000..679366f0 --- /dev/null +++ b/src/Notifications/LocalTestNotifications/LocalAuthorizationService.cs @@ -0,0 +1,13 @@ +using Altinn.Notifications.Core.Integrations; +using Altinn.Notifications.Core.Models.ContactPoints; + +namespace LocalTest.Notifications.LocalTestNotifications +{ + public class LocalAuthorizationService : IAuthorizationService + { + public Task> AuthorizeUserContactPointsForResource(List organizationContactPoints, string resourceId) + { + return Task.FromResult(organizationContactPoints); + } + } +} diff --git a/src/Notifications/LocalTestNotifications/LocalProfileClient.cs b/src/Notifications/LocalTestNotifications/LocalProfileClient.cs index 92ad9848..a1f6f35b 100644 --- a/src/Notifications/LocalTestNotifications/LocalProfileClient.cs +++ b/src/Notifications/LocalTestNotifications/LocalProfileClient.cs @@ -1,8 +1,6 @@ using Altinn.Notifications.Core.Integrations; using Altinn.Notifications.Core.Models.ContactPoints; -using Altinn.Platform.Profile.Models; -using LocalTest.Services.Register.Interface; using LocalTest.Services.TestData; namespace LocalTest.Notifications.LocalTestNotifications @@ -40,9 +38,10 @@ public async Task> GetUserContactPoints(List nat } - public Task> GetUserRegisteredOrganizationContactPoints(string resourceId, List organizationNumbers) + public async Task> GetUserRegisteredContactPoints(List organizationNumbers, string resourceId) { - throw new NotImplementedException(); + await Task.CompletedTask; + return new List(); } } } diff --git a/src/Notifications/LocalTestNotifications/LocalRegisterClient.cs b/src/Notifications/LocalTestNotifications/LocalRegisterClient.cs index f01b8cf3..d8d92cc6 100644 --- a/src/Notifications/LocalTestNotifications/LocalRegisterClient.cs +++ b/src/Notifications/LocalTestNotifications/LocalRegisterClient.cs @@ -1,7 +1,5 @@ using Altinn.Notifications.Core.Integrations; using Altinn.Notifications.Core.Models.ContactPoints; -using Altinn.Platform.Profile.Models; -using Altinn.Platform.Register.Models; using LocalTest.Services.TestData; diff --git a/src/Notifications/LocalTestNotifications/NotificationsServiceExtentions.cs b/src/Notifications/LocalTestNotifications/NotificationsServiceExtentions.cs index 1f1e5f0d..43119522 100644 --- a/src/Notifications/LocalTestNotifications/NotificationsServiceExtentions.cs +++ b/src/Notifications/LocalTestNotifications/NotificationsServiceExtentions.cs @@ -8,8 +8,8 @@ using Altinn.Notifications.Validators; using FluentValidation; + using LocalTest.Notifications.Persistence.Repository; -using LocalTest.Services.TestData; namespace LocalTest.Notifications.LocalTestNotifications; @@ -22,7 +22,7 @@ public static void AddNotificationServices(this IServiceCollection services, str ResourceLinkExtensions.Initialize(baseUrl); services.Configure((c) => c.DefaultEmailFromAddress = "localtest@altinn.no"); - + services .AddSingleton, EmailNotificationOrderRequestValidator>() .AddSingleton, SmsNotificationOrderRequestValidator>() @@ -34,5 +34,6 @@ public static void AddNotificationServices(this IServiceCollection services, str services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); } } \ No newline at end of file diff --git a/testdata/Profile/User/1001.json b/testdata/Profile/User/1001.json index c36a9785..37715201 100644 --- a/testdata/Profile/User/1001.json +++ b/testdata/Profile/User/1001.json @@ -4,7 +4,10 @@ "PhoneNumber": "+4790000000", "Email": "test@test.com", "PartyId": 510001, - "Party": {}, + "Party": { + "partyId": "510001", + "ssn": "01899699552" + }, "UserType": 0, "ProfileSettingPreference": { "Language": "nb", diff --git a/testdata/Profile/User/1002.json b/testdata/Profile/User/1002.json index a7767b65..5ab7f9d3 100644 --- a/testdata/Profile/User/1002.json +++ b/testdata/Profile/User/1002.json @@ -4,7 +4,10 @@ "PhoneNumber": "12345678", "Email": "test@test.com", "PartyId": 510002, - "Party": {}, + "Party": { + "partyId": "510002", + "ssn": "17858296439" + }, "UserType": 0, "ProfileSettingPreference": { "Language": "nb", diff --git a/testdata/Profile/User/1003.json b/testdata/Profile/User/1003.json index b04e2df1..511e5594 100644 --- a/testdata/Profile/User/1003.json +++ b/testdata/Profile/User/1003.json @@ -4,10 +4,13 @@ "PhoneNumber": "12345678", "Email": "test@test.com", "PartyId": 510003, - "Party": {}, + "Party": { + "partyId": "510003", + "ssn": "08829698278" + }, "UserType": 0, "ProfileSettingPreference": { "Language": "nb", "doNotPromptForParty": true } -} +} \ No newline at end of file diff --git a/testdata/Profile/User/12345.json b/testdata/Profile/User/12345.json index d1ad5db1..1033c855 100644 --- a/testdata/Profile/User/12345.json +++ b/testdata/Profile/User/12345.json @@ -4,10 +4,13 @@ "PhoneNumber": "12345678", "Email": "test@test.com", "PartyId": 512345, - "Party": {}, + "Party": { + "partyId": "512345", + "ssn": "01017512345" + }, "UserType": 0, "ProfileSettingPreference": { "Language": "nb", "doNotPromptForParty": true } -} +} \ No newline at end of file diff --git a/testdata/Profile/User/1337.json b/testdata/Profile/User/1337.json index 7624c62b..0f7e15b7 100644 --- a/testdata/Profile/User/1337.json +++ b/testdata/Profile/User/1337.json @@ -4,10 +4,13 @@ "PhoneNumber": "90001337", "Email": "1337@altinnstudiotestusers.com", "PartyId": 501337, - "Party": {}, + "Party": { + "partyId": "501337", + "ssn": "01039012345" + }, "UserType": 1, "ProfileSettingPreference": { "Language": "nn", "doNotPromptForParty": true } -} +} \ No newline at end of file diff --git a/testdata/Register/Person/01899699552.json b/testdata/Register/Person/01899699552.json index d9979c89..e35b04b8 100644 --- a/testdata/Register/Person/01899699552.json +++ b/testdata/Register/Person/01899699552.json @@ -5,7 +5,7 @@ "MiddleName": "", "LastName": "Partner", "TelephoneNumber": "12345678", - "MobileNumber": "87654321", + "MobileNumber": "+4799315829", "MailingAddress": "Tuftekåsvegen 7 3920 PORSGRUNN", "MailingPostalCode": "3920", "MailingPostalCity": "PORSGRUNN",