Skip to content

Commit

Permalink
Merge branch 'master' into CON-2796-Create-version-5-legal-agreement
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Howes committed Jan 29, 2021
2 parents 2d469f5 + 2593be9 commit 73ac094
Show file tree
Hide file tree
Showing 17 changed files with 462 additions and 133 deletions.
48 changes: 33 additions & 15 deletions azure/finance.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@
},
"sharedApimName": {
"type": "string"
},
},
"appServiceAllowedIPs": {
"type": "array",
"defaultValue": [
]
"defaultValue": []
},
"sharedEnvVirtualNetworkName": {
"type": "string"
Expand Down Expand Up @@ -103,15 +102,13 @@
"workerAppServicePlanName": "[concat(variables('resourceNamePrefix'), 'wkr-asp')]",
"resourceGroupName": "[concat(variables('resourceNamePrefix'), '-rg')]"
},
"resources": [
{
"resources": [{
"apiVersion": "2020-06-01",
"name": "[variables('resourceGroupName')]",
"type": "Microsoft.Resources/resourceGroups",
"location": "[parameters('resourceGroupLocation')]",
"tags": "[parameters('tags')]",
"properties": {
}
"properties": {}
},
{
"apiVersion": "2020-06-01",
Expand Down Expand Up @@ -155,6 +152,27 @@
}
}
},
{
"apiVersion": "2020-06-01",
"name": "WorkerAppInsights",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[variables('resourceGroupName')]",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(variables('deploymentUrlBase'),'application-insights.json')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"appInsightsName": {
"value": "[variables('workerAppServiceName')]"
},
"attachedService": {
"value": "[variables('workerAppServiceName')]"
}
}
}
},
{
"condition": "[greater(length(parameters('uiCustomHostName')), 0)]",
"apiVersion": "2020-06-01",
Expand Down Expand Up @@ -206,8 +224,7 @@
},
"appServiceAppSettings": {
"value": {
"array": [
{
"array": [{
"name": "LoggingRedisConnectionString",
"value": "[parameters('loggingRedisConnectionString')]"
},
Expand Down Expand Up @@ -305,8 +322,7 @@
},
"appServiceAppSettings": {
"value": {
"array": [
{
"array": [{
"name": "LoggingRedisConnectionString",
"value": "[parameters('loggingRedisConnectionString')]"
},
Expand Down Expand Up @@ -424,8 +440,7 @@
},
"appServiceAppSettings": {
"value": {
"array": [
{
"array": [{
"name": "LoggingRedisConnectionString",
"value": "[parameters('loggingRedisConnectionString')]"
},
Expand All @@ -444,14 +459,17 @@
{
"name": "StorageConnectionString",
"value": "[parameters('storageConnectionString')]"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference('WorkerAppInsights').outputs.InstrumentationKey.value]"
}
]
}
},
"appServiceConnectionStrings": {
"value": {
"array": [
{
"array": [{
"name": "AzureWebJobsDashboard",
"connectionString": "[parameters('storageConnectionString')]",
"type": "Custom"
Expand Down
104 changes: 104 additions & 0 deletions src/SFA.DAS.EmployerAccounts.Api/ApplicationInsights.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
<TelemetryInitializers>
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.HttpDependenciesParsingTelemetryInitializer, Microsoft.AI.DependencyCollector"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureWebAppRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.BuildInfoConfigComponentVersionTelemetryInitializer, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.Web.WebTestTelemetryInitializer, Microsoft.AI.Web"/>
<Add Type="Microsoft.ApplicationInsights.Web.SyntheticUserAgentTelemetryInitializer, Microsoft.AI.Web">
<!-- Extended list of bots:
search|spider|crawl|Bot|Monitor|BrowserMob|BingPreview|PagePeeker|WebThumb|URL2PNG|ZooShot|GomezA|Google SketchUp|Read Later|KTXN|KHTE|Keynote|Pingdom|AlwaysOn|zao|borg|oegp|silk|Xenu|zeal|NING|htdig|lycos|slurp|teoma|voila|yahoo|Sogou|CiBra|Nutch|Java|JNLP|Daumoa|Genieo|ichiro|larbin|pompos|Scrapy|snappy|speedy|vortex|favicon|indexer|Riddler|scooter|scraper|scrubby|WhatWeb|WinHTTP|voyager|archiver|Icarus6j|mogimogi|Netvibes|altavista|charlotte|findlinks|Retreiver|TLSProber|WordPress|wsr-agent|http client|Python-urllib|AppEngine-Google|semanticdiscovery|facebookexternalhit|web/snippet|Google-HTTP-Java-Client-->
<Filters>search|spider|crawl|Bot|Monitor|AlwaysOn</Filters>
</Add>
<Add Type="Microsoft.ApplicationInsights.Web.ClientIpHeaderTelemetryInitializer, Microsoft.AI.Web"/>
<Add Type="Microsoft.ApplicationInsights.Web.OperationNameTelemetryInitializer, Microsoft.AI.Web"/>
<Add Type="Microsoft.ApplicationInsights.Web.OperationCorrelationTelemetryInitializer, Microsoft.AI.Web"/>
<Add Type="Microsoft.ApplicationInsights.Web.UserTelemetryInitializer, Microsoft.AI.Web"/>
<Add Type="Microsoft.ApplicationInsights.Web.AuthenticatedUserIdTelemetryInitializer, Microsoft.AI.Web"/>
<Add Type="Microsoft.ApplicationInsights.Web.AccountIdTelemetryInitializer, Microsoft.AI.Web"/>
<Add Type="Microsoft.ApplicationInsights.Web.SessionTelemetryInitializer, Microsoft.AI.Web"/>
</TelemetryInitializers>
<TelemetryModules>
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
<ExcludeComponentCorrelationHttpHeadersOnDomains>
<!--
Requests to the following hostnames will not be modified by adding correlation headers.
This is only applicable if Profiler is installed via either StatusMonitor or Azure Extension.
Add entries here to exclude additional hostnames.
NOTE: this configuration will be lost upon NuGet upgrade.
-->
<Add>core.windows.net</Add>
<Add>core.chinacloudapi.cn</Add>
<Add>core.cloudapi.de</Add>
<Add>core.usgovcloudapi.net</Add>
<Add>localhost</Add>
<Add>127.0.0.1</Add>
</ExcludeComponentCorrelationHttpHeadersOnDomains>
</Add>
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
<!--
Use the following syntax here to collect additional performance counters:
<Counters>
<Add PerformanceCounter="\Process(??APP_WIN32_PROC??)\Handle Count" ReportAs="Process handle count" />
...
</Counters>
PerformanceCounter must be either \CategoryName(InstanceName)\CounterName or \CategoryName\CounterName
NOTE: performance counters configuration will be lost upon NuGet upgrade.
The following placeholders are supported as InstanceName:
??APP_WIN32_PROC?? - instance name of the application process for Win32 counters.
??APP_W3SVC_PROC?? - instance name of the application IIS worker process for IIS/ASP.NET counters.
??APP_CLR_PROC?? - instance name of the application CLR process for .NET counters.
-->
</Add>
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnhandledExceptionTelemetryModule, Microsoft.AI.WindowsServer"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer">
<!--</Add>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.FirstChanceExceptionStatisticsTelemetryModule, Microsoft.AI.WindowsServer">-->
</Add>
<Add Type="Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule, Microsoft.AI.Web">
<Handlers>
<!--
Add entries here to filter out additional handlers:
NOTE: handler configuration will be lost upon NuGet upgrade.
-->
<Add>System.Web.Handlers.TransferRequestHandler</Add>
<Add>Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.RequestDataHttpHandler</Add>
<Add>System.Web.StaticFileHandler</Add>
<Add>System.Web.Handlers.AssemblyResourceLoader</Add>
<Add>System.Web.Optimization.BundleHandler</Add>
<Add>System.Web.Script.Services.ScriptHandlerFactory</Add>
<Add>System.Web.Handlers.TraceHandler</Add>
<Add>System.Web.Services.Discovery.DiscoveryRequestHandler</Add>
<Add>System.Web.HttpDebugHandler</Add>
</Handlers>
</Add>
<Add Type="Microsoft.ApplicationInsights.Web.ExceptionTrackingTelemetryModule, Microsoft.AI.Web"/>
<Add Type="Microsoft.ApplicationInsights.Web.AspNetDiagnosticTelemetryModule, Microsoft.AI.Web"/>
</TelemetryModules>
<TelemetryProcessors>
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector"/>
<Add Type="Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights"/>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
<MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
<ExcludedTypes>Event</ExcludedTypes>
</Add>
<Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
<MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
<IncludedTypes>Event</IncludedTypes>
</Add>
</TelemetryProcessors>
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel"/>
<!--
Learn more about Application Insights configuration with ApplicationInsights.config here:
http://go.microsoft.com/fwlink/?LinkID=513840
Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.
--></ApplicationInsights>
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@
</ItemGroup>
<ItemGroup>
<Content Include="App_Data\.keep" />
<Content Include="ApplicationInsights.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="NLog.xsd">
<SubType>Designer</SubType>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Moq" Version="4.5.28" />
<PackageReference Include="NUnit" Version="3.10.1" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using AutoFixture;
using Microsoft.Extensions.Logging;
using Moq;
using NServiceBus;
using NUnit.Framework;
using SFA.DAS.EmployerFinance.Data;
using SFA.DAS.EmployerFinance.Interfaces;
using SFA.DAS.EmployerFinance.Jobs.ScheduledJobs;
using SFA.DAS.EmployerFinance.Messages.Commands;
using SFA.DAS.EmployerFinance.Models.Account;
using SFA.DAS.Testing;

namespace SFA.DAS.EmployerFinance.Jobs.UnitTests.ScheduledJobs
Expand All @@ -15,27 +20,49 @@ namespace SFA.DAS.EmployerFinance.Jobs.UnitTests.ScheduledJobs
public class ExpireFundsJobTests : FluentTest<ExpireFundsJobTestsFixture>
{
[Test]
public Task Run_WhenRunningJob_ThenShouldSendCommand_Hotfix_ShouldNotSendCommand()
[TestCase(0, Description = "No accounts")]
[TestCase(1, Description = "Single account")]
[TestCase(99, Description = "Multiple accounts")]
public Task Run_WhenRunningJob_ThenShouldSendCommand(int numberOfAccounts)
{
return RunAsync(f => f.Run(), f => f.MessageSession.Verify(s => s.Send(It.IsAny<ExpireFundsCommand>(), It.IsAny<SendOptions>()), Times.Once));
return RunAsync(
f => f.SetupAccounts(numberOfAccounts),
f => f.Run(),
f => f.MessageSession.Verify(s => s.Send(It.IsAny<ExpireAccountFundsCommand>(), It.IsAny<SendOptions>()), Times.Exactly(numberOfAccounts)));
}
}

public class ExpireFundsJobTestsFixture
{
public Mock<IMessageSession> MessageSession { get; set; }
public Mock<ICurrentDateTime> CurrentDateTime { get; set; }
public Mock<IEmployerAccountRepository> EmployerAccountRepository;
public ExpireFundsJob Job { get; set; }
private readonly IFixture Fixture;

public ExpireFundsJobTestsFixture()
{
Fixture = new Fixture();

MessageSession = new Mock<IMessageSession>();
CurrentDateTime = new Mock<ICurrentDateTime>();
EmployerAccountRepository = new Mock<IEmployerAccountRepository>();

Job = new ExpireFundsJob(MessageSession.Object);
Job = new ExpireFundsJob(MessageSession.Object, CurrentDateTime.Object, EmployerAccountRepository.Object);
}

public Task Run()
{
return Job.Run(null, null);
return Job.Run(null, Mock.Of<ILogger>());
}

internal void SetupAccounts(int numberOfAccounts)
{
var accounts = Fixture
.Build<Account>().Without(acc => acc.AccountLegalEntities)
.CreateMany(numberOfAccounts);

EmployerAccountRepository.Setup(x => x.GetAllAccounts()).ReturnsAsync(accounts.ToList());
}
}
}
2 changes: 1 addition & 1 deletion src/SFA.DAS.EmployerFinance.Jobs/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<appSettings>
<add key="ConfigurationStorageConnectionString" value="UseDevelopmentStorage=true" />
<add key="EnvironmentName" value="LOCAL" />
<add key="InstrumentationKey" value="" />
<add key="APPINSIGHTS_INSTRUMENTATIONKEY" value="" />
<add key="StorageConnectionString" value="UseDevelopmentStorage=true" />
</appSettings>
<connectionStrings>
Expand Down
Loading

0 comments on commit 73ac094

Please sign in to comment.