Skip to content

Commit 6108727

Browse files
committed
New code.
1 parent 7966a75 commit 6108727

24 files changed

+331
-192
lines changed

.azure-devops/pipelines/build.yml

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ jobs:
2424
Windows:
2525
imageName: 'windows-latest'
2626
matrixName: Windows
27-
#Mac:
28-
# imageName: 'macOS-latest'
29-
# matrixName: Mac
27+
Mac:
28+
imageName: 'macOS-latest'
29+
matrixName: Mac
3030

3131
pool:
3232
vmImage: $(imageName)
@@ -35,13 +35,6 @@ jobs:
3535

3636
# Build .NET solution
3737

38-
- task: UseDotNet@2
39-
displayName: 'Setup .NET'
40-
inputs:
41-
packageType: sdk
42-
version: '6.x'
43-
installationPath: $(Agent.ToolsDirectory)/dotnet
44-
4538
- task: DotNetCoreCLI@2
4639
displayName: 'Restore dependencies'
4740
inputs:
@@ -58,26 +51,16 @@ jobs:
5851

5952
# Install and configure Logic Apps runtime environment
6053

61-
- task: NodeTool@0
62-
displayName: 'Setup node'
63-
inputs:
64-
versionSpec: '18.x'
65-
6654
- task: FuncToolsInstaller@0
6755
displayName: 'Install Functions core tools'
6856
inputs:
6957
version: 'latest'
7058

71-
- task: CmdLine@2
72-
displayName: 'Check Functions Core tools installation'
73-
inputs:
74-
script: func
75-
7659
- task: Npm@1
7760
displayName: 'Install Azurite'
7861
inputs:
7962
command: 'custom'
80-
customCommand: 'install -g azurite@3.33.0'
63+
customCommand: 'install -g azurite@3.34.0'
8164

8265
- task: CmdLine@2
8366
displayName: 'Start Azurite services (not Windows)'
@@ -91,6 +74,23 @@ jobs:
9174
inputs:
9275
script: 'start /b azurite'
9376

77+
# Check software versions
78+
79+
- task: CmdLine@2
80+
displayName: 'Check dotnet SDK installation'
81+
inputs:
82+
script: dotnet --info
83+
84+
- task: CmdLine@2
85+
displayName: 'Check node installation'
86+
inputs:
87+
script: node --version
88+
89+
- task: CmdLine@2
90+
displayName: 'Check Functions Core tools installation'
91+
inputs:
92+
script: func --version
93+
9494
# Run tests and publish test results to Azure DevOps
9595

9696
- task: DotNetCoreCLI@2
@@ -104,16 +104,16 @@ jobs:
104104
publishTestResults: true
105105
testRunTitle: 'Tests ($(matrixName))'
106106

107-
- task: DotNetCoreCLI@2
108-
displayName: 'Run tests (Windows)'
109-
condition: and(succeeded(), eq(variables.matrixName, 'Windows'))
110-
continueOnError: true
111-
inputs:
112-
command: test
113-
arguments: '--no-restore --verbosity normal --configuration ${{ parameters.buildConfiguration }}'
114-
projects: '$(System.DefaultWorkingDirectory)/src/LogicAppUnit.sln'
115-
publishTestResults: true
116-
testRunTitle: 'Tests ($(matrixName))'
107+
# - task: DotNetCoreCLI@2 # there is an issue with Azurite ports being blocked when running tests on Windows build servers
108+
# displayName: 'Run tests (Windows)'
109+
# condition: and(succeeded(), eq(variables.matrixName, 'Windows'))
110+
# continueOnError: true
111+
# inputs:
112+
# command: test
113+
# arguments: '--no-restore --verbosity normal --configuration ${{ parameters.buildConfiguration }}'
114+
# projects: '$(System.DefaultWorkingDirectory)/src/LogicAppUnit.sln'
115+
# publishTestResults: true
116+
# testRunTitle: 'Tests ($(matrixName))'
117117

118118
# Publish NuGet package
119119

.github/workflows/build.yml

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ jobs:
2525
uses: actions/checkout@v3
2626

2727
# Build .NET solution
28-
29-
- name: Setup .NET
30-
uses: actions/setup-dotnet@v3
31-
with:
32-
dotnet-version: 6.0.x
3328

3429
- name: Restore dependencies
3530
run: dotnet restore ${{ github.workspace }}/src/LogicAppUnit.sln
@@ -39,11 +34,6 @@ jobs:
3934

4035
# Install and configure Logic Apps runtime environment
4136

42-
- name: Setup node
43-
uses: actions/setup-node@v3
44-
with:
45-
node-version: 18
46-
4737
- name: Install Functions Core tools
4838
run: 'npm install -g azure-functions-core-tools@4 --unsafe-perm true'
4939

@@ -52,40 +42,48 @@ jobs:
5242
run: 'setx /m Path "C:\npm\prefix\node_modules\azure-functions-core-tools\bin;%Path%"'
5343
shell: cmd
5444

55-
- name: Check Functions Core tools installation
56-
run: 'func'
57-
5845
- name: Install Azurite
59-
run: 'npm install -g azurite@3.33.0'
46+
run: 'npm install -g azurite@3.34.0'
6047

6148
- name: Start Azurite services
6249
run: 'azurite &'
6350
shell: bash
6451

52+
# Check software versions
53+
54+
- name: Check dotnet SDK installation
55+
run: 'dotnet --info'
56+
57+
- name: Check node installation
58+
run: 'node --version'
59+
60+
- name: Check Functions Core tools installation
61+
run: 'func --version'
62+
6563
# Run tests
6664

67-
# - name: Run tests
68-
# if: success() && matrix.os != 'windows-latest'
69-
# run: dotnet test ${{ github.workspace }}/src/LogicAppUnit.sln --no-restore --verbosity normal --logger "trx" --filter TestCategory!="WindowsOnly"
65+
- name: Run tests
66+
if: success() && matrix.os != 'windows-latest'
67+
run: dotnet test ${{ github.workspace }}/src/LogicAppUnit.sln --no-restore --verbosity normal --logger "trx" --filter TestCategory!="WindowsOnly"
7068

71-
# - name: Run tests
72-
# if: success() && matrix.os == 'windows-latest'
73-
# run: dotnet test ${{ github.workspace }}/src/LogicAppUnit.sln --no-restore --verbosity normal --logger "trx"
69+
- name: Run tests
70+
if: success() && matrix.os == 'windows-latest'
71+
run: dotnet test ${{ github.workspace }}/src/LogicAppUnit.sln --no-restore --verbosity normal --logger "trx"
7472

7573
# Publish artefacts and test results
7674

77-
# - name: Publish test log
78-
# uses: actions/upload-artifact@v3
79-
# if: success() || failure()
80-
# with:
81-
# name: test-results.${{ matrix.os }}
82-
# path: ${{ github.workspace }}/src/LogicAppUnit.Samples.LogicApps.Tests/TestResults/*.trx
83-
84-
# - name: Publish test results
85-
# if: (success() || failure()) && github.event_name != 'pull_request'
86-
# uses: dorny/test-reporter@v1
87-
# with:
88-
# name: Test Results (${{ matrix.os }})
89-
# path: ${{ github.workspace }}/src/LogicAppUnit.Samples.LogicApps.Tests/TestResults/*.trx
90-
# path-replace-backslashes: true
91-
# reporter: dotnet-trx
75+
- name: Publish test log
76+
uses: actions/upload-artifact@v4
77+
if: success() || failure()
78+
with:
79+
name: test-results.${{ matrix.os }}
80+
path: ${{ github.workspace }}/src/LogicAppUnit.Samples.LogicApps.Tests/TestResults/*.trx
81+
82+
- name: Publish test results
83+
if: (success() || failure()) && github.event_name != 'pull_request'
84+
uses: dorny/test-reporter@v2
85+
with:
86+
name: Test Results (${{ matrix.os }})
87+
path: ${{ github.workspace }}/src/LogicAppUnit.Samples.LogicApps.Tests/TestResults/*.trx
88+
path-replace-backslashes: true
89+
reporter: dotnet-trx

ChangeLog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# 1.11.0 (1st April 2025)
2+
3+
LogicAppUnit Testing Framework:
4+
5+
- The framework now supports parameterised connections that are created by the Standard Logic App extension. [[Issue #42](https://github.com/LogicAppUnit/TestingFramework/issues/42)]
6+
- Bumped versions of NuGet packages to remove critical vulnerabilities in some of the transitive packages.
7+
- Added configuration for NuGet Audit so that any future vulnerabilities are logged as build warnings and do not break the LogicAppUnit build. [[Issue #40](https://github.com/LogicAppUnit/TestingFramework/issues/40)]
8+
9+
110
# 1.10.0 (4th November 2024)
211

312
LogicAppUnit Testing Framework:

src/Directory.Build.props

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
5+
<!-- Enable code analysis -->
6+
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
7+
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
8+
<AnalysisLevel>latest-recommended</AnalysisLevel>
9+
10+
<!-- Enable NuGet package auditing -->
11+
<NuGetAudit>true</NuGetAudit>
12+
<NuGetAuditMode>all</NuGetAuditMode>
13+
<NuGetAuditLevel>low</NuGetAuditLevel>
14+
15+
<!-- Warnings and Errors -->
16+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
17+
<WarningsNotAsErrors>NU1901;NU1902;NU1903;NU1904</WarningsNotAsErrors>
18+
19+
</PropertyGroup>
20+
</Project>

src/LogicAppUnit.Samples.LogicApps/connections.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"connection": {
4646
"id": "/subscriptions/@{appsetting('WORKFLOWS_SUBSCRIPTION_ID')}/resourceGroups/@{appsetting('WORKFLOWS_RESOURCE_GROUP_NAME')}/providers/Microsoft.Web/connections/salesforce01"
4747
},
48-
"connectionRuntimeUrl": "https://7606763fdc09952f.10.common.logic-uksouth.azure-apihub.net/apim/salesforce/fba515601ef14f9193eee596a9dcfd1c/",
48+
"connectionRuntimeUrl": "@parameters('salesforce-ConnectionRuntimeUrl')",
4949
"authentication": {
5050
"type": "Raw",
5151
"scheme": "Key",
@@ -59,12 +59,8 @@
5959
"connection": {
6060
"id": "/subscriptions/@{appsetting('WORKFLOWS_SUBSCRIPTION_ID')}/resourceGroups/@{appsetting('WORKFLOWS_RESOURCE_GROUP_NAME')}/providers/Microsoft.Web/connections/outlook01"
6161
},
62-
"connectionRuntimeUrl": "@appsetting('Outlook-ManagedConnectionRuntimeUrl')",
63-
"authentication": {
64-
"type": "Raw",
65-
"scheme": "Key",
66-
"parameter": "@appsetting('Outlook-ConnectionKey')"
67-
}
62+
"connectionRuntimeUrl": "@parameters('outlook-ConnectionRuntimeUrl')",
63+
"authentication": "@parameters('outlook-Authentication')"
6864
}
6965
}
7066
}

src/LogicAppUnit.Samples.LogicApps/local.settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
"AzureQueue-ConnectionString": "any-queue-connection-string",
1212
"Outlook-ConnectionKey": "any-outlook-connection-key",
1313
"Outlook-SubjectPrefix": "INFORMATION",
14-
"Outlook-ManagedConnectionRuntimeUrl": "https://7606763fdc09952f.10.common.logic-uksouth.azure-apihub.net/apim/outlook/79a0bc680716416e90e17323b581695d/",
14+
"Outlook-ConnectionRuntimeUrl": "https://7606763fdc09952f.10.common.logic-uksouth.azure-apihub.net/apim/outlook/79a0bc680716416e90e17323b581695d/",
1515
"Salesforce-ConnectionKey": "any-salesforce-connection-key",
16+
"Salesforce-ConnectionRuntimeUrl": "https://7606763fdc09952f.10.common.logic-uksouth.azure-apihub.net/apim/salesforce/fba515601ef14f9193eee596a9dcfd1c/",
1617
"ServiceOne-Url": "https://external-service-one.testing.net/api/v1",
1718
"ServiceOne-Authentication-APIKey": "serviceone-auth-apikey",
1819
"ServiceOne-Authentication-WebHook-APIKey": "serviceone-auth-webhook-apikey",

src/LogicAppUnit.Samples.LogicApps/parameters.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,21 @@
1818
"ServiceTwo-Authentication-APIKey": {
1919
"type": "String",
2020
"value": "@appsetting('ServiceTwo-Authentication-APIKey')"
21+
},
22+
"salesforce-ConnectionRuntimeUrl": {
23+
"type": "String",
24+
"value": "@appsetting('Salesforce-ConnectionRuntimeUrl')"
25+
},
26+
"outlook-ConnectionRuntimeUrl": {
27+
"type": "String",
28+
"value": "@appsetting('Outlook-ConnectionRuntimeUrl')"
29+
},
30+
"outlook-Authentication": {
31+
"type": "Object",
32+
"value": {
33+
"type": "Raw",
34+
"scheme": "Key",
35+
"parameter": "@appsetting('Outlook-ConnectionKey')"
36+
}
2137
}
2238
}

src/LogicAppUnit/Helper/ContentHelper.cs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ public static class ContentHelper
2929
/// <returns>The HTTP content.</returns>
3030
public static StreamContent CreateStreamContent(Stream stream, string contentType)
3131
{
32-
if (stream == null)
33-
throw new ArgumentNullException(nameof(stream));
32+
ArgumentNullException.ThrowIfNull(stream);
3433
if (string.IsNullOrEmpty(contentType))
3534
throw new ArgumentNullException(nameof(contentType));
3635

@@ -72,8 +71,7 @@ public static StreamContent CreatePlainStreamContent(Stream stream)
7271
/// <returns>The HTTP content.</returns>
7372
public static StringContent CreateStringContent(string value, string contentType, Encoding encoding = null)
7473
{
75-
if (value == null)
76-
throw new ArgumentNullException(nameof(value));
74+
ArgumentNullException.ThrowIfNull(value);
7775
if (string.IsNullOrEmpty(contentType))
7876
throw new ArgumentNullException(nameof(contentType));
7977

@@ -87,8 +85,7 @@ public static StringContent CreateStringContent(string value, string contentType
8785
/// <returns>The HTTP content.</returns>
8886
public static StringContent CreateJsonStringContent(string jsonString)
8987
{
90-
if (jsonString == null)
91-
throw new ArgumentNullException(nameof(jsonString));
88+
ArgumentNullException.ThrowIfNull(jsonString);
9289

9390
return new StringContent(jsonString, Encoding.UTF8, JsonContentType);
9491
}
@@ -123,8 +120,7 @@ public static StringContent CreateXmlStringContent(string xmlString)
123120
public static StringContent CreateJsonStringContent(object jsonObject)
124121
{
125122
// The name of this method is inconsistent
126-
if (jsonObject == null)
127-
throw new ArgumentNullException(nameof(jsonObject));
123+
ArgumentNullException.ThrowIfNull(jsonObject);
128124

129125
var json = JsonConvert.SerializeObject(jsonObject);
130126
return new StringContent(json, Encoding.UTF8, JsonContentType);
@@ -138,8 +134,7 @@ public static StringContent CreateJsonStringContent(object jsonObject)
138134
public static StringContent CreateXmlStringContent(XmlDocument xmlDoc)
139135
{
140136
// The name of this method is inconsistent
141-
if (xmlDoc == null)
142-
throw new ArgumentNullException(nameof(xmlDoc));
137+
ArgumentNullException.ThrowIfNull(xmlDoc);
143138

144139
return new StringContent(xmlDoc.ToString(), Encoding.UTF8, XmlContentType);
145140
}
@@ -153,8 +148,7 @@ public static StringContent CreateXmlStringContent(XmlDocument xmlDoc)
153148
/// <returns>The stream content as a <see cref="string"/>.</returns>
154149
public static string ConvertStreamToString(Stream input)
155150
{
156-
if (input == null)
157-
throw new ArgumentNullException(nameof(input));
151+
ArgumentNullException.ThrowIfNull(input);
158152

159153
string convertedValue = string.Empty;
160154
using (var sr = new StreamReader(input))
@@ -172,8 +166,7 @@ public static string ConvertStreamToString(Stream input)
172166
/// <returns>The stream representation.</returns>
173167
public static Stream ConvertStringToStream(string input)
174168
{
175-
if (input == null)
176-
throw new ArgumentNullException(nameof(input));
169+
ArgumentNullException.ThrowIfNull(input);
177170

178171
byte[] byteArray = Encoding.ASCII.GetBytes(input);
179172
return new MemoryStream(byteArray);
@@ -217,8 +210,7 @@ public static string FormatJson(string json)
217210
/// </remarks>
218211
public static string FormatXml(Stream xmlStream)
219212
{
220-
if (xmlStream == null)
221-
throw new ArgumentNullException(nameof(xmlStream));
213+
ArgumentNullException.ThrowIfNull(xmlStream);
222214

223215
XmlDocument xmlDoc = new XmlDocument();
224216
xmlDoc.Load(xmlStream);
@@ -236,8 +228,7 @@ public static string FormatXml(Stream xmlStream)
236228
/// </remarks>
237229
public static string FormatXml(string xml)
238230
{
239-
if (xml == null)
240-
throw new ArgumentNullException(nameof(xml));
231+
ArgumentNullException.ThrowIfNull(xml);
241232

242233
XmlDocument xmlDoc = new XmlDocument();
243234
xmlDoc.LoadXml(xml);
@@ -252,8 +243,7 @@ public static string FormatXml(string xml)
252243
/// <returns>The formatted XML.</returns>
253244
private static string FormatXml(XmlDocument xmlDoc)
254245
{
255-
if (xmlDoc == null)
256-
throw new ArgumentNullException(nameof(xmlDoc));
246+
ArgumentNullException.ThrowIfNull(xmlDoc);
257247

258248
XmlDsigC14NTransform xmlTransform = new XmlDsigC14NTransform();
259249
xmlTransform.LoadInput(xmlDoc);

0 commit comments

Comments
 (0)