diff --git a/.github/workflows/monthly-scan.yml b/.github/workflows/monthly-scan.yml
new file mode 100644
index 0000000..bc5d7f5
--- /dev/null
+++ b/.github/workflows/monthly-scan.yml
@@ -0,0 +1,51 @@
+name: Trufflehog Monthly Deep Scan
+
+
+on:
+ schedule:
+ - cron: "0 0 28-31 * *"
+
+ #This scan will run on the last day of every month
+
+ push:
+ branches: [main, p3sprint/*, feature/*]
+jobs:
+ trufflehog-scan:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+ - name: Install Trufflehog-latest
+ run: |
+ pip3 install trufflehog
+ - name: Run Trufflehog Monthly Deep Scan
+
+ #Configure the correct git url of the repo to be scanned
+ run: |
+ trufflehog https://github.com/Crown-Commercial-Service/ccs-ppg-notification-api.git --regex --entropy=FALSE
+
+ - name: Send email notification
+ uses:
+ dawidd6/action-send-mail@v3.1.0
+ if: always()
+
+ with:
+ server_address: ${{ secrets.SERVER_ADDRESS }}
+ server_port: ${{ secrets.SERVER_PORT }}
+ username: ${{ secrets.USER_NAME }}
+ password: ${{ secrets.PASSWORD }}
+ subject: Trufflehog Monthly Deep Scan
+ to: "rahulgandhi.jayabalan@brickendon.com,ponselvam.sakthivel@brickendon.com"
+ from: "secops@brickendon.com"
+ body: |
+
+ Hi,
+
+ The Trufflehog Monthly Deep Scan has completed for "${{ github.repository }}". Please review the results below:
+
+ Scan Job URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
+
+ Scan Status: **${{ job.status }}**
+
+ Thank You.
+ Brickendon SecOps
diff --git a/.github/workflows/secrets-scan.yml b/.github/workflows/secrets-scan.yml
new file mode 100644
index 0000000..5c41624
--- /dev/null
+++ b/.github/workflows/secrets-scan.yml
@@ -0,0 +1,64 @@
+name: Git Secrets Scan
+
+on:
+ schedule:
+ - cron: "0 0 * * *"
+ push:
+ branches: [main, feature/*, p3sprint/*]
+
+jobs:
+ git-secrets-scan:
+ name: Git Secrets Scan
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Install git secrets
+ run: sudo apt-get update && sudo apt-get install git-secrets -y
+
+ - name: Add custom secrets patterns
+ run: git secrets --add '(\bBEGIN\b).*(PRIVATE KEY\b)'
+ && git secrets --add 'AKIA[0-9A-Z]{16}'
+ && git secrets --add '^([A-Za-z0-9/+=]{40,})$'
+ && git secrets --add '^ghp_[a-zA-Z0-9]{36}'
+ && git secrets --add '^github_pat_[a-zA-Z0-9]{22}_[a-zA-Z0-9]{59}'
+ && git secrets --add '^v[0-9]\\.[0-9a-f]{40}'
+ && git secrets --add '[A-Za-z0-9+/]{88}=='
+ && git secrets --add '[A-Za-z0-9_-]{32}$'
+ && git secrets --add 'conclavesso[0-9a-z-]{84}'
+ && git secrets --add '\\b[a-z0-9]{80}\\b'
+ && git secrets --add '\\b[A-Z0-9]{50}\\b'
+ && git secrets --add '\\b[A-Z0-9]{58}\\b'
+ && git secrets --add '^[a-zA-Z0-9_-]{32,64}$'
+
+ - name: Run git secrets scan
+ run: |
+ git secrets --scan
+
+ - name: Send email notification
+ uses:
+ dawidd6/action-send-mail@v3.1.0
+ if: always()
+
+ with:
+ server_address: ${{ secrets.SERVER_ADDRESS }}
+ server_port: ${{ secrets.SERVER_PORT }}
+ username: ${{ secrets.USER_NAME }}
+ password: ${{ secrets.PASSWORD }}
+ subject: Git Secrets Scan Results
+ to: "ponselvam.sakthivel@brickendon.com, rahulgandhi.jayabalan@brickendon.com"
+ from: "secops@brickendon.com"
+ body: |
+
+ Hi,
+
+ The Git Secrets scan has completed for "${{ github.repository }}". Please review the results below:
+
+ Scan Job URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
+
+ Scan Status: **${{ job.status }}**
+
+ Thank You.
+ Brickendon SecOps
diff --git a/Ccs.Ppg.NotificationService.API/Ccs.Ppg.NotificationService.API.csproj b/Ccs.Ppg.NotificationService.API/Ccs.Ppg.NotificationService.API.csproj
index 4c2a553..0ff6047 100644
--- a/Ccs.Ppg.NotificationService.API/Ccs.Ppg.NotificationService.API.csproj
+++ b/Ccs.Ppg.NotificationService.API/Ccs.Ppg.NotificationService.API.csproj
@@ -12,20 +12,26 @@
-
+
-
+
-
+
+
+
+
+
+
+
diff --git a/Ccs.Ppg.NotificationService.API/Controllers/NotificationController.cs b/Ccs.Ppg.NotificationService.API/Controllers/NotificationController.cs
index 33eebda..65247df 100644
--- a/Ccs.Ppg.NotificationService.API/Controllers/NotificationController.cs
+++ b/Ccs.Ppg.NotificationService.API/Controllers/NotificationController.cs
@@ -12,10 +12,12 @@ namespace Ccs.Ppg.NotificationService.API.Controllers
public class NotificationController : ControllerBase
{
private readonly IMessageProviderService _messageProviderService;
- public NotificationController(IMessageProviderService messageProviderService)
+ private readonly IEmailProviderService _emailProviderService;
+ public NotificationController(IMessageProviderService messageProviderService, IEmailProviderService emailProviderService)
{
_messageProviderService = messageProviderService;
- }
+ _emailProviderService = emailProviderService;
+ }
///
/// Allows a user to send SMS
///
@@ -39,11 +41,42 @@ public NotificationController(IMessageProviderService messageProviderService)
///
[HttpPost("sms")]
- [SwaggerOperation(Tags = new[] { "notification/sms" })]
+ [SwaggerOperation(Tags = new[] { "Notification - SMS" })]
[ProducesResponseType(typeof(bool), 200)]
public async Task Post(MessageRequestModel message)
{
return await _messageProviderService.SendMessage(message);
- }
- }
+ }
+
+ ///
+ /// Allows a user to send email
+ ///
+ /// Ok
+ /// Unauthorised
+ /// Forbidden
+ /// Not found
+ /// Bad request.
+ ///
+ /// Sample request:
+ ///
+ /// POST /notification/email
+ /// {
+ /// "to": "username@xxxx.com",
+ /// "templateId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
+ /// "bodyContent": {
+ /// "email": "UserName@xxxx.com",
+ /// "additionalProp3": "string",
+ /// "additionalProp3": "string"
+ /// }
+ /// }
+ ///
+ ///
+
+ [HttpPost("email")]
+ [SwaggerOperation(Tags = new[] { "Notification - Email" })]
+ public async Task SendEmailAsync(EmailInfo emailInfo)
+ {
+ await _emailProviderService.SendEmailAsync(emailInfo);
+ }
+ }
}
diff --git a/Ccs.Ppg.NotificationService.API/CustomOptions/ParameterStoreConfigurationProvider.cs b/Ccs.Ppg.NotificationService.API/CustomOptions/ParameterStoreConfigurationProvider.cs
index be45477..fed5754 100644
--- a/Ccs.Ppg.NotificationService.API/CustomOptions/ParameterStoreConfigurationProvider.cs
+++ b/Ccs.Ppg.NotificationService.API/CustomOptions/ParameterStoreConfigurationProvider.cs
@@ -39,7 +39,9 @@ public async Task GetSecrets()
configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "Message/ApiKey", "Message:ApiKey"));
configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "Message/TemplateId", "Message:TemplateId"));
- var dbName = _awsParameterStoreService.FindParameterByName(parameters, path + "ConnectionStrings/Name");
+ configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "Email/ApiKey", "Email:ApiKey"));
+
+ var dbName = _awsParameterStoreService.FindParameterByName(parameters, path + "ConnectionStrings/Name");
var dbConnection = _awsParameterStoreService.FindParameterByName(parameters, path + "ConnectionStrings/CcsSso");
if (!string.IsNullOrEmpty(dbName))
@@ -53,6 +55,22 @@ public async Task GetSecrets()
}
configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "apis/OrganisationUrl", "apis:OrganisationUrl"));
+ configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "EnableXRay", "EnableXRay"));
+
+ configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "WrapperApiSettings/ConfigApiKey", "WrapperApiSettings:ConfigApiKey"));
+ configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "WrapperApiSettings/ApiGatewayEnabledConfigUrl", "WrapperApiSettings:ApiGatewayEnabledConfigUrl"));
+ configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "WrapperApiSettings/ApiGatewayDisabledConfigUrl", "WrapperApiSettings:ApiGatewayDisabledConfigUrl"));
+
+ configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "NotificationValidationConfigurations/EnableValidation", "NotificationValidationConfigurations:EnableValidation"));
+ configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "NotificationValidationConfigurations/SmsMsgLength", "NotificationValidationConfigurations:SmsMsgLength"));
+ configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "NotificationValidationConfigurations/OrgNameLegnth", "NotificationValidationConfigurations:OrgNameLegnth"));
+ configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "NotificationValidationConfigurations/EmailRegex", "NotificationValidationConfigurations:EmailRegex"));
+ configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "NotificationValidationConfigurations/FirstNameLength", "NotificationValidationConfigurations:FirstNameLength"));
+ configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "NotificationValidationConfigurations/LastNameLength", "NotificationValidationConfigurations:LastNameLength"));
+ configurations.AddRange(_awsParameterStoreService.GetParameterFromCommaSeparated(parameters, path + "NotificationValidationConfigurations/SignInProviders", "NotificationValidationConfigurations:SignInProviders"));
+ configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "NotificationValidationConfigurations/LinkRegex", "NotificationValidationConfigurations:LinkRegex"));
+ configurations.Add(_awsParameterStoreService.GetParameter(parameters, path + "NotificationValidationConfigurations/CcsMsg", "NotificationValidationConfigurations:CcsMsg"));
+
foreach (var configuration in configurations)
{
diff --git a/Ccs.Ppg.NotificationService.API/CustomOptions/VaultConfiguration.cs b/Ccs.Ppg.NotificationService.API/CustomOptions/VaultConfiguration.cs
index 3be7052..ab881d5 100644
--- a/Ccs.Ppg.NotificationService.API/CustomOptions/VaultConfiguration.cs
+++ b/Ccs.Ppg.NotificationService.API/CustomOptions/VaultConfiguration.cs
@@ -56,7 +56,13 @@ public async Task GetSecrets()
Data.Add("Message:TemplateId", messageSettingsVault.TemplateId);
}
- if (_secrets.Data.ContainsKey("ConnectionStrings"))
+ if (_secrets.Data.ContainsKey("Email"))
+ {
+ var messageSettingsVault = JsonConvert.DeserializeObject(_secrets.Data["Email"].ToString());
+ Data.Add("Email:ApiKey", messageSettingsVault.ApiKey);
+ }
+
+ if (_secrets.Data.ContainsKey("ConnectionStrings"))
{
var connectionStringsSettingsVault = JsonConvert.DeserializeObject(_secrets.Data["ConnectionStrings"].ToString());
Data.Add("ConnectionStrings:CcsSso", connectionStringsSettingsVault.CcsSso);
diff --git a/Ccs.Ppg.NotificationService.API/Program.cs b/Ccs.Ppg.NotificationService.API/Program.cs
index 8645124..fa79eaf 100644
--- a/Ccs.Ppg.NotificationService.API/Program.cs
+++ b/Ccs.Ppg.NotificationService.API/Program.cs
@@ -1,3 +1,5 @@
+using Amazon.XRay.Recorder.Core;
+using Amazon.XRay.Recorder.Handlers.AwsSdk;
using Ccs.Ppg.NotificationService.API;
using Ccs.Ppg.NotificationService.API.CustomOptions;
@@ -30,9 +32,22 @@
// Add services to the container.
builder.Services.ConfigureServices(builder.Configuration);
+string startupUrl = Environment.GetEnvironmentVariable("STARTUP_URL");
+if (!string.IsNullOrWhiteSpace(startupUrl))
+{
+ builder.WebHost.UseUrls(startupUrl);
+}
+
var app = builder.Build();
-app.ConfigurePipeline();
+if (!string.IsNullOrEmpty(builder.Configuration["EnableXRay"]) && Convert.ToBoolean(builder.Configuration["EnableXRay"]))
+{
+ Console.WriteLine("x-ray is enabled.");
+ AWSXRayRecorder.InitializeInstance(configuration: builder.Configuration);
+ app.UseXRay("NotificationApi");
+ AWSSDKHandler.RegisterXRayForAllServices();
+}
+app.ConfigurePipeline();
-app.Run();
+app.Run();
\ No newline at end of file
diff --git a/Ccs.Ppg.NotificationService.API/Properties/launchSettings.json b/Ccs.Ppg.NotificationService.API/Properties/launchSettings.json
index 9a5270e..df9d9c6 100644
--- a/Ccs.Ppg.NotificationService.API/Properties/launchSettings.json
+++ b/Ccs.Ppg.NotificationService.API/Properties/launchSettings.json
@@ -13,7 +13,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
- "launchUrl": "swagger",
+ "launchUrl": "notification-service/swagger",
"applicationUrl": "https://localhost:7247;http://localhost:5247",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
diff --git a/Ccs.Ppg.NotificationService.API/Startup.cs b/Ccs.Ppg.NotificationService.API/Startup.cs
index baf8d21..7c0bcb9 100644
--- a/Ccs.Ppg.NotificationService.API/Startup.cs
+++ b/Ccs.Ppg.NotificationService.API/Startup.cs
@@ -1,5 +1,7 @@
-using Ccs.Ppg.Utility.Authorization;
+using Ccs.Ppg.NotificationService.Model;
+using Ccs.Ppg.Utility.Authorization;
using Ccs.Ppg.Utility.Cache;
+using Ccs.Ppg.Utility.Exceptions;
using Ccs.Ppg.Utility.Logging;
using Ccs.Ppg.Utility.Swagger;
using System.Reflection;
@@ -7,7 +9,7 @@
namespace Ccs.Ppg.NotificationService.API
{
public static class Startup
- {
+ {
public static void ConfigureServices(this IServiceCollection services, ConfigurationManager config)
{
services.AddCustomLogging();
@@ -18,6 +20,60 @@ public static void ConfigureServices(this IServiceCollection services, Configura
services.AddServices(config);
services.AddControllers();
services.AddRedis(config);
+ services.AddSingleton(s =>
+ {
+ bool.TryParse(config["IsApiGatewayEnabled"], out bool isApiGatewayEnabled);
+ bool.TryParse(config["EnableXRay"], out bool enableXray);
+ bool.TryParse(config["RedisCache:IsEnabled"], out bool redisCacheEnabled);
+ bool.TryParse(config["NotificationValidationConfigurations:EnableValidation"], out bool validationEnabled);
+ int.TryParse(config["NotificationValidationConfigurations:SmsMsgLength"], out int smsMsgLength);
+ int.TryParse(config["NotificationValidationConfigurations:OrgNameLegnth"], out int orgNameLegnth);
+ int.TryParse(config["NotificationValidationConfigurations:FirstNameLength"], out int firstNameLength);
+ int.TryParse(config["NotificationValidationConfigurations:LastNameLength"], out int LastNameLength);
+ ApplicationConfigurationInfo appConfigInfo = new ApplicationConfigurationInfo()
+ {
+ IsApiGatewayEnabled = isApiGatewayEnabled,
+ ApiKey = config["ApiKey"],
+ OrganisationApiUrl = config["OrganisationApiUrl"],
+ EnableXRay = enableXray,
+ RedisCacheSettings = new RedisCacheSettings()
+ {
+ IsEnabled = redisCacheEnabled
+ },
+ MessageSettings = new MessageSettings()
+ {
+ ApiKey = config["Message:ApiKey"],
+ TemplateId = config["Message:TemplateId"]
+ },
+ ConnectionStrings = new ConnectionStrings()
+ {
+ CcsSso = config["ConnectionStrings:CcsSso"]
+ },
+ EmailSettings = new EmailSettings()
+ {
+ ApiKey = config["Email:ApiKey"]
+ },
+ WrapperApiSettings = new WrapperApiSettings()
+ {
+ ApiGatewayDisabledConfigUrl = config["WrapperApiSettings:ApiGatewayDisabledConfigUrl"],
+ ApiGatewayEnabledConfigUrl = config["WrapperApiSettings:ApiGatewayEnabledConfigUrl"],
+ ConfigApiKey = config["WrapperApiSettings:ConfigApiKey"]
+ },
+ NotificationValidationConfigurations = new NotificationValidationConfigurations()
+ {
+ EnableValidation = validationEnabled,
+ SmsMsgLength = smsMsgLength,
+ OrgNameLegnth = orgNameLegnth,
+ FirstNameLength = firstNameLength,
+ LastNameLength = LastNameLength,
+ EmailRegex = config["NotificationValidationConfigurations:EmailRegex"],
+ LinkRegex = config["NotificationValidationConfigurations:LinkRegex"],
+ CcsMsg = config["NotificationValidationConfigurations:CcsMsg"],
+ SignInProviders = config.GetSection("NotificationValidationConfigurations:SignInProviders").Get>(),
+ }
+ };
+ return appConfigInfo;
+ });
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
services.AddEndpointsApiExplorer();
@@ -29,10 +85,9 @@ public static void ConfigureServices(this IServiceCollection services, Configura
public static void ConfigurePipeline(this WebApplication app)
{
- if (app.Environment.IsDevelopment())
- {
- app.ConfigureSwagger();
- }
+ app.ConfigureSwagger();
+
+ app.UseMiddleware();
app.UseHttpsRedirection();
diff --git a/Ccs.Ppg.NotificationService.API/Swagger/notification-service-swagger.json b/Ccs.Ppg.NotificationService.API/Swagger/notification-service-swagger.json
new file mode 100644
index 0000000..34f7455
--- /dev/null
+++ b/Ccs.Ppg.NotificationService.API/Swagger/notification-service-swagger.json
@@ -0,0 +1,178 @@
+{
+ "openapi": "3.0.1",
+ "info": {
+ "title": "Ccs.Ppg.NotificationService.API",
+ "version": "v1"
+ },
+ "paths": {
+ "/notification-service/sms": {
+ "post": {
+ "tags": [
+ "Notification Service - SMS"
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/MessageRequestModel"
+ }
+ },
+ "text/json": {
+ "schema": {
+ "$ref": "#/components/schemas/MessageRequestModel"
+ }
+ },
+ "application/*+json": {
+ "schema": {
+ "$ref": "#/components/schemas/MessageRequestModel"
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Success",
+ "content": {
+ "text/plain": {
+ "schema": {
+ "type": "boolean"
+ }
+ },
+ "application/json": {
+ "schema": {
+ "type": "boolean"
+ }
+ },
+ "text/json": {
+ "schema": {
+ "type": "boolean"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/notification-service/email": {
+ "post": {
+ "tags": [
+ "Notification Service - Email"
+ ],
+ "summary": "Allows a user to send email",
+ "description": "Sample request:\r\n \r\n POST /notification-service/email\r\n {\r\n \"to\": \"username@xxxx.com\",\r\n \"templateId\": \"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\",\r\n \"bodyContent\": {\r\n \"email\": \"UserName@xxxx.com\",\r\n \"additionalProp3\": \"string\",\r\n \"additionalProp3\": \"string\"\r\n }\r\n }",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/EmailInfo"
+ }
+ },
+ "text/json": {
+ "schema": {
+ "$ref": "#/components/schemas/EmailInfo"
+ }
+ },
+ "application/*+json": {
+ "schema": {
+ "$ref": "#/components/schemas/EmailInfo"
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Ok"
+ },
+ "400": {
+ "description": "Bad request."
+ },
+ "401": {
+ "description": "Unauthorised"
+ },
+ "403": {
+ "description": "Forbidden"
+ },
+ "404": {
+ "description": "Not found"
+ }
+ }
+ }
+ }
+ },
+ "components": {
+ "schemas": {
+ "EmailInfo": {
+ "required": [
+ "templateId",
+ "to"
+ ],
+ "type": "object",
+ "properties": {
+ "to": {
+ "type": "string"
+ },
+ "templateId": {
+ "type": "string"
+ },
+ "bodyContent": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ },
+ "nullable": true
+ }
+ },
+ "additionalProperties": false
+ },
+ "MessageInfo": {
+ "type": "object",
+ "properties": {
+ "key": {
+ "type": "string",
+ "nullable": true
+ },
+ "message": {
+ "type": "string",
+ "nullable": true
+ }
+ },
+ "additionalProperties": false
+ },
+ "MessageRequestModel": {
+ "required": [
+ "message",
+ "phoneNumber",
+ "templateId"
+ ],
+ "type": "object",
+ "properties": {
+ "phoneNumber": {
+ "type": "string"
+ },
+ "templateId": {
+ "type": "string"
+ },
+ "message": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/MessageInfo"
+ }
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "securitySchemes": {
+ "ApiKey": {
+ "type": "apiKey",
+ "name": "X-API-KEY",
+ "in": "header"
+ }
+ }
+ },
+ "security": [
+ {
+ "ApiKey": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/Ccs.Ppg.NotificationService.API/appsecrets.json b/Ccs.Ppg.NotificationService.API/appsecrets.json
index 08a6438..e31b52b 100644
--- a/Ccs.Ppg.NotificationService.API/appsecrets.json
+++ b/Ccs.Ppg.NotificationService.API/appsecrets.json
@@ -14,6 +14,26 @@
},
"apis": {
"OrganisationUrl": ""
+ },
+ "Email": {
+ "ApiKey": ""
+ },
+ "EnableXRay": "false",
+ "WrapperApiSettings": {
+ "ConfigApiKey": "",
+ "ApiGatewayEnabledConfigUrl": "",
+ "ApiGatewayDisabledConfigUrl": ""
+ },
+ "NotificationValidationConfigurations": {
+ "EnableValidation": true,
+ "SmsMsgLength": 6,
+ "OrgNameLegnth": 150,
+ "EmailRegex": "",
+ "FirstNameLength": 50,
+ "LastNameLength": 50,
+ "SignInProviders": [],
+ "LinkRegex": "",
+ "CcsMsg": ""
}
}
diff --git a/Ccs.Ppg.NotificationService.Tests/Ccs.Ppg.NotificationService.Tests.csproj b/Ccs.Ppg.NotificationService.Tests/Ccs.Ppg.NotificationService.Tests.csproj
new file mode 100644
index 0000000..68481a1
--- /dev/null
+++ b/Ccs.Ppg.NotificationService.Tests/Ccs.Ppg.NotificationService.Tests.csproj
@@ -0,0 +1,31 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+ false
+ true
+
+
+
+
+
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
diff --git a/Ccs.Ppg.NotificationService.Tests/Infrastructure/DtoHelper.cs b/Ccs.Ppg.NotificationService.Tests/Infrastructure/DtoHelper.cs
new file mode 100644
index 0000000..418cfe5
--- /dev/null
+++ b/Ccs.Ppg.NotificationService.Tests/Infrastructure/DtoHelper.cs
@@ -0,0 +1,31 @@
+using Ccs.Ppg.NotificationService.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Ccs.Ppg.NotificationService.Tests.Infrastructure
+{
+ public class DtoHelper
+ {
+ public static EmailInfo GetEmailInfoRequest(string toMailId,string templateId, Dictionary BodyContent)
+ {
+ return new EmailInfo
+ {
+ To = toMailId,
+ TemplateId = templateId,
+ BodyContent = BodyContent
+ };
+ }
+ public static MessageRequestModel GetSMSInfoRequest(string mobileNumber, string templateId, List BodyContent)
+ {
+ return new MessageRequestModel
+ {
+ PhoneNumber = mobileNumber,
+ TemplateId = templateId,
+ Message = BodyContent
+ };
+ }
+ }
+}
diff --git a/Ccs.Ppg.NotificationService.Tests/Services/EmailProviderServiceTests.cs b/Ccs.Ppg.NotificationService.Tests/Services/EmailProviderServiceTests.cs
new file mode 100644
index 0000000..1306814
--- /dev/null
+++ b/Ccs.Ppg.NotificationService.Tests/Services/EmailProviderServiceTests.cs
@@ -0,0 +1,342 @@
+using Amazon.Runtime;
+using Ccs.Ppg.NotificationService.Model;
+using Ccs.Ppg.NotificationService.Services;
+using Ccs.Ppg.NotificationService.Services.IServices;
+using Ccs.Ppg.NotificationService.Tests.Infrastructure;
+using Ccs.Ppg.Utility.Constants.Constants;
+using Ccs.Ppg.Utility.Exceptions.Exceptions;
+using Moq;
+using Notify.Client;
+using Notify.Interfaces;
+using Notify.Models.Responses;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using Xunit;
+using static System.Net.WebRequestMethods;
+
+namespace Ccs.Ppg.NotificationService.Tests.Services
+{
+ public class EmailProviderServiceTests
+ {
+ private readonly Mock _mockHttpClientFactory;
+ private readonly Mock _mockWrapperConfigurationService;
+ private readonly ApplicationConfigurationInfo _mockApplicationConfigurationInfo;
+
+ public EmailProviderServiceTests()
+ {
+ _mockHttpClientFactory = new Mock();
+ _mockWrapperConfigurationService = new Mock();
+ _mockApplicationConfigurationInfo = new ApplicationConfigurationInfo();
+ }
+
+ public static List SetupConfigRoles()
+ {
+ List configRoles = new List();
+ configRoles.AddRange(new List { "sampleRole1", "sampleRole2", "sampleRole3" });
+ return configRoles;
+ }
+
+ public class SendEmail
+ {
+ public static IEnumerable