Skip to content

Commit b6b8f54

Browse files
nhudinh0309andr317cZeegaan
authored
V15 QA Added the authorization integration tests (#18419)
* Added authorization integration tests * Removed unnecessary tests and update tests for preview controller * Updated to use the newest changes from v15/dev and added an override for the AuthenticateClientAsync to use the userGroupKey * Updated CompatibilitySuppressions to include changes from integration tests * Updated pipelines * Skips managementApi tests * Only run necessary tests * Added new schema per fixture to reduce test setup time * Fixed failing tests * Updated test setup * Updated test * Added suppression * Fixed failing tests * Updated addOnTeardown methods to protected * Added method for clearing the host * Added teardown * Updated model usage * Added a lot of cleanup for memory leak issues when running tests * Added CompatibilitySuppressions.xml * Updated tests * Cleaned up * Adjusted base classes * Updated pipeline * Updated CompatibilitySuppressions.xml * Updated test logging * Fixed reponse * Updated condition to skip tests * Updated tests, not done * Reworked test to expect correct responses with correct setup * Updated tests * More updates to tests * Updated tests * Cleaned up tests * Updated setup * Cleaned up tests to match setup * Cleaned up setup * Removed suppression * Fixed tests * Move order of checks * Fix naming * Formatting * Dispose of host * Keep track of if we're disposed * Compat suppression * Dont dispose * Fix failing tests * removed unused virtual * Updated CompatibilitySuppressions.xml --------- Co-authored-by: Andreas Zerbst <[email protected]> Co-authored-by: Zeegaan <[email protected]> Co-authored-by: Nikolaj Geisle <[email protected]>
1 parent 50139ee commit b6b8f54

File tree

246 files changed

+14152
-643
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+14152
-643
lines changed

build/azure-pipelines.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ stages:
313313
testFilter: "(FullyQualifiedName~Umbraco.Infrastructure.Service)"
314314
LinuxPart3Of3:
315315
vmImage: "ubuntu-latest"
316-
# Filter tests that are not part of the Umbraco.Infrastructure namespace. So this will run all tests that are not part of the Umbraco.Infrastructure namespace
317-
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure)"
316+
# Filter tests that are not part of the Umbraco.Infrastructure and ManagementApi namespace. So this will run all tests that are not part of the Umbraco.Infrastructure namespace
317+
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure) & (FullyQualifiedName!~ManagementApi)"
318318
macOSPart1Of3:
319319
vmImage: "macOS-latest"
320320
# Filter tests that are part of the Umbraco.Infrastructure namespace but not part of the Umbraco.Infrastructure.Service namespace
@@ -325,8 +325,8 @@ stages:
325325
testFilter: "(FullyQualifiedName~Umbraco.Infrastructure.Service)"
326326
macOSPart3Of3:
327327
vmImage: "macOS-latest"
328-
# Filter tests that are not part of the Umbraco.Infrastructure namespace.
329-
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure)"
328+
# Filter tests that are not part of the Umbraco.Infrastructure and ManagementApi namespace. So this will run all tests that are not part of the Umbraco.Infrastructure namespace
329+
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure) & (FullyQualifiedName!~ManagementApi)"
330330
pool:
331331
vmImage: $(vmImage)
332332
variables:
@@ -389,8 +389,8 @@ stages:
389389
vmImage: "windows-latest"
390390
Tests__Database__DatabaseType: LocalDb
391391
Tests__Database__SQLServerMasterConnectionString: N/A
392-
# Filter tests that are not part of the Umbraco.Infrastructure namespace. So this will run all tests that are not part of the Umbraco.Infrastructure namespace
393-
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure)"
392+
# Filter tests that are not part of the Umbraco.Infrastructure and ManagementApi namespace. So this will run all tests that are not part of the Umbraco.Infrastructure namespace
393+
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure) & (FullyQualifiedName!~ManagementApi)"
394394
LinuxPart1Of3:
395395
vmImage: "ubuntu-latest"
396396
SA_PASSWORD: UmbracoIntegration123!
@@ -410,8 +410,8 @@ stages:
410410
SA_PASSWORD: UmbracoIntegration123!
411411
Tests__Database__DatabaseType: SqlServer
412412
Tests__Database__SQLServerMasterConnectionString: "Server=(local);User Id=sa;Password=$(SA_PASSWORD);TrustServerCertificate=True"
413-
# Filter tests that are not part of the Umbraco.Infrastructure namespace. So this will run all tests that are not part of the Umbraco.Infrastructure namespace
414-
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure)"
413+
# Filter tests that are not part of the Umbraco.Infrastructure and ManagementApi namespace. So this will run all tests that are not part of the Umbraco.Infrastructure namespace
414+
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure) & (FullyQualifiedName!~ManagementApi)"
415415
pool:
416416
vmImage: $(vmImage)
417417
steps:

build/nightly-E2E-test-pipelines.yml

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -121,31 +121,39 @@ stages:
121121
matrix:
122122
# Windows:
123123
# vmImage: 'windows-latest'
124-
# We split the tests into 3 parts for each OS to reduce the time it takes to run them on the pipeline
125-
LinuxPart1Of3:
124+
# We split the tests into 4 parts for each OS to reduce the time it takes to run them on the pipeline
125+
LinuxPart1Of4:
126126
vmImage: "ubuntu-latest"
127127
# Filter tests that are part of the Umbraco.Infrastructure namespace but not part of the Umbraco.Infrastructure.Service namespace
128128
testFilter: "(FullyQualifiedName~Umbraco.Infrastructure) & (FullyQualifiedName!~Umbraco.Infrastructure.Service)"
129-
LinuxPart2Of3:
129+
LinuxPart2Of4:
130130
vmImage: "ubuntu-latest"
131131
# Filter tests that are part of the Umbraco.Infrastructure.Service namespace
132132
testFilter: "(FullyQualifiedName~Umbraco.Infrastructure.Service)"
133-
LinuxPart3Of3:
133+
LinuxPart3Of4:
134134
vmImage: "ubuntu-latest"
135-
# Filter tests that are not part of the Umbraco.Infrastructure namespace. So this will run all tests that are not part of the Umbraco.Infrastructure namespace
136-
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure)"
137-
macOSPart1Of3:
135+
# Filter tests that are not part of the Umbraco.Infrastructure and ManagementApi namespace. So this will run all tests that are not part of the Umbraco.Infrastructure namespace
136+
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure) & (FullyQualifiedName!~ManagementApi)"
137+
LinuxPart4Of4:
138+
vmImage: "ubuntu-latest"
139+
# Filter tests that are part of the ManagementApi namespace
140+
testFilter: "(FullyQualifiedName~ManagementApi)"
141+
macOSPart1Of4:
138142
vmImage: "macOS-latest"
139143
# Filter tests that are part of the Umbraco.Infrastructure namespace but not part of the Umbraco.Infrastructure.Service namespace
140144
testFilter: "(FullyQualifiedName~Umbraco.Infrastructure) & (FullyQualifiedName!~Umbraco.Infrastructure.Service)"
141-
macOSPart2Of3:
145+
macOSPart2Of4:
142146
vmImage: "macOS-latest"
143147
# Filter tests that are part of the Umbraco.Infrastructure.Service namespace
144148
testFilter: "(FullyQualifiedName~Umbraco.Infrastructure.Service)"
145-
macOSPart3Of3:
149+
macOSPart3Of4:
150+
vmImage: "macOS-latest"
151+
# Filter tests that are not part of the Umbraco.Infrastructure and ManagementApi namespace.
152+
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure) & (FullyQualifiedName!~ManagementApi)"
153+
macOSPart4Of4:
146154
vmImage: "macOS-latest"
147-
# Filter tests that are not part of the Umbraco.Infrastructure namespace.
148-
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure)"
155+
# Filter tests that are part of the ManagementApi namespace.
156+
testFilter: "(FullyQualifiedName~ManagementApi)"
149157
pool:
150158
vmImage: $(vmImage)
151159
variables:
@@ -185,43 +193,55 @@ stages:
185193
SA_PASSWORD: UmbracoAcceptance123!
186194
strategy:
187195
matrix:
188-
# We split the tests into 3 parts for each OS to reduce the time it takes to run them on the pipeline
189-
WindowsPart1Of3:
196+
# We split the tests into 4 parts for each OS to reduce the time it takes to run them on the pipeline
197+
WindowsPart1Of4:
190198
vmImage: "windows-latest"
191199
Tests__Database__DatabaseType: LocalDb
192200
Tests__Database__SQLServerMasterConnectionString: N/A
193201
# Filter tests that are part of the Umbraco.Infrastructure namespace but not part of the Umbraco.Infrastructure.Service namespace
194202
testFilter: "(FullyQualifiedName~Umbraco.Infrastructure) & (FullyQualifiedName!~Umbraco.Infrastructure.Service)"
195-
WindowsPart2Of3:
203+
WindowsPart2Of4:
196204
vmImage: "windows-latest"
197205
Tests__Database__DatabaseType: LocalDb
198206
Tests__Database__SQLServerMasterConnectionString: N/A
199207
# Filter tests that are part of the Umbraco.Infrastructure.Service namespace
200208
testFilter: "(FullyQualifiedName~Umbraco.Infrastructure.Service)"
201-
WindowsPart3Of3:
209+
WindowsPart3Of4:
202210
vmImage: "windows-latest"
203211
Tests__Database__DatabaseType: LocalDb
204212
Tests__Database__SQLServerMasterConnectionString: N/A
205-
# Filter tests that are not part of the Umbraco.Infrastructure namespace. So this will run all tests that are not part of the Umbraco.Infrastructure namespace
206-
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure)"
207-
LinuxPart1Of3:
213+
# Filter tests that are not part of the Umbraco.Infrastructure and ManagementApi namespace.
214+
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure) & (FullyQualifiedName!~ManagementApi)"
215+
WindowsPart4Of4:
216+
vmImage: "windows-latest"
217+
Tests__Database__DatabaseType: LocalDb
218+
Tests__Database__SQLServerMasterConnectionString: N/A
219+
# Filter tests that are part of the ManagementApi namespace.
220+
testFilter: "(FullyQualifiedName~ManagementApi)"
221+
LinuxPart1Of4:
208222
vmImage: "ubuntu-latest"
209223
Tests__Database__DatabaseType: SqlServer
210224
Tests__Database__SQLServerMasterConnectionString: "Server=(local);User Id=sa;Password=$(SA_PASSWORD);Encrypt=True;TrustServerCertificate=True"
211225
# Filter tests that are part of the Umbraco.Infrastructure namespace but not part of the Umbraco.Infrastructure.Service namespace
212226
testFilter: "(FullyQualifiedName~Umbraco.Infrastructure) & (FullyQualifiedName!~Umbraco.Infrastructure.Service)"
213-
LinuxPart2Of3:
227+
LinuxPart2Of4:
214228
vmImage: "ubuntu-latest"
215229
Tests__Database__DatabaseType: SqlServer
216230
Tests__Database__SQLServerMasterConnectionString: "Server=(local);User Id=sa;Password=$(SA_PASSWORD);Encrypt=True;TrustServerCertificate=True"
217231
# Filter tests that are part of the Umbraco.Infrastructure.Service namespace
218232
testFilter: "(FullyQualifiedName~Umbraco.Infrastructure.Service)"
219-
LinuxPart3Of3:
233+
LinuxPart3Of4:
234+
vmImage: "ubuntu-latest"
235+
Tests__Database__DatabaseType: SqlServer
236+
Tests__Database__SQLServerMasterConnectionString: "Server=(local);User Id=sa;Password=$(SA_PASSWORD);Encrypt=True;TrustServerCertificate=True"
237+
# Filter tests that are not part of the Umbraco.Infrastructure and ManagementApi namespace.
238+
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure) & (FullyQualifiedName!~ManagementApi)"
239+
LinuxPart4Of4:
220240
vmImage: "ubuntu-latest"
221241
Tests__Database__DatabaseType: SqlServer
222242
Tests__Database__SQLServerMasterConnectionString: "Server=(local);User Id=sa;Password=$(SA_PASSWORD);Encrypt=True;TrustServerCertificate=True"
223-
# Filter tests that are not part of the Umbraco.Infrastructure namespace. So this will run all tests that are not part of the Umbraco.Infrastructure namespace
224-
testFilter: "(FullyQualifiedName!~Umbraco.Infrastructure)"
243+
# Filter tests that are part of the ManagementApi namespace.
244+
testFilter: "(FullyQualifiedName~ManagementApi)"
225245
pool:
226246
vmImage: $(vmImage)
227247
steps:
@@ -479,7 +499,7 @@ stages:
479499
jobs:
480500
- job:
481501
displayName: E2E Tests with Different App settings (SQL Server)
482-
condition: ${{ or(eq(parameters.differentAppSettingsAcceptanceTests, true), eq(parameters.skipDefaultConfigAcceptanceTests, true)) }}
502+
condition: ${{ eq(parameters.differentAppSettingsAcceptanceTests, true) }}
483503
timeoutInMinutes: 180
484504
variables:
485505
SA_PASSWORD: UmbracoAcceptance123!

tests/Umbraco.Tests.Integration/CompatibilitySuppressions.xml

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
33
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
4+
<Suppression>
5+
<DiagnosticId>CP0001</DiagnosticId>
6+
<Target>T:Umbraco.Cms.Tests.Integration.ManagementApi.Policies.AllCultureControllerTests</Target>
7+
<Left>lib/net9.0/Umbraco.Tests.Integration.dll</Left>
8+
<Right>lib/net9.0/Umbraco.Tests.Integration.dll</Right>
9+
<IsBaselineSuppression>true</IsBaselineSuppression>
10+
</Suppression>
11+
<Suppression>
12+
<DiagnosticId>CP0001</DiagnosticId>
13+
<Target>T:Umbraco.Cms.Tests.Integration.ManagementApi.Preview.EndPreviewTests</Target>
14+
<Left>lib/net9.0/Umbraco.Tests.Integration.dll</Left>
15+
<Right>lib/net9.0/Umbraco.Tests.Integration.dll</Right>
16+
<IsBaselineSuppression>true</IsBaselineSuppression>
17+
</Suppression>
18+
<Suppression>
19+
<DiagnosticId>CP0001</DiagnosticId>
20+
<Target>T:Umbraco.Cms.Tests.Integration.ManagementApi.Preview.EnterPreviewTests</Target>
21+
<Left>lib/net9.0/Umbraco.Tests.Integration.dll</Left>
22+
<Right>lib/net9.0/Umbraco.Tests.Integration.dll</Right>
23+
<IsBaselineSuppression>true</IsBaselineSuppression>
24+
</Suppression>
425
<Suppression>
526
<DiagnosticId>CP0001</DiagnosticId>
627
<Target>T:Umbraco.Cms.Tests.Integration.Umbraco.Core.Services.DocumentUrlServiceTest</Target>
@@ -78,6 +99,20 @@
7899
<Right>lib/net9.0/Umbraco.Tests.Integration.dll</Right>
79100
<IsBaselineSuppression>true</IsBaselineSuppression>
80101
</Suppression>
102+
<Suppression>
103+
<DiagnosticId>CP0002</DiagnosticId>
104+
<Target>M:Umbraco.Cms.Tests.Integration.ManagementApi.ManagementApiTest`1.Setup</Target>
105+
<Left>lib/net9.0/Umbraco.Tests.Integration.dll</Left>
106+
<Right>lib/net9.0/Umbraco.Tests.Integration.dll</Right>
107+
<IsBaselineSuppression>true</IsBaselineSuppression>
108+
</Suppression>
109+
<Suppression>
110+
<DiagnosticId>CP0002</DiagnosticId>
111+
<Target>M:Umbraco.Cms.Tests.Integration.Testing.UmbracoIntegrationTestBase.UseTestDatabase(Microsoft.AspNetCore.Builder.IApplicationBuilder)</Target>
112+
<Left>lib/net9.0/Umbraco.Tests.Integration.dll</Left>
113+
<Right>lib/net9.0/Umbraco.Tests.Integration.dll</Right>
114+
<IsBaselineSuppression>true</IsBaselineSuppression>
115+
</Suppression>
81116
<Suppression>
82117
<DiagnosticId>CP0002</DiagnosticId>
83118
<Target>M:Umbraco.Cms.Tests.Integration.Umbraco.Core.Services.DocumentNavigationServiceTests.Bin_Structure_Can_Rebuild</Target>
@@ -141,4 +176,46 @@
141176
<Right>lib/net9.0/Umbraco.Tests.Integration.dll</Right>
142177
<IsBaselineSuppression>true</IsBaselineSuppression>
143178
</Suppression>
144-
</Suppressions>
179+
<Suppression>
180+
<DiagnosticId>CP0005</DiagnosticId>
181+
<Target>M:Umbraco.Cms.Tests.Integration.ManagementApi.ManagementApiTest`1.set_MethodSelector(System.Linq.Expressions.Expression{System.Func{`0,System.Object}})</Target>
182+
<Left>lib/net9.0/Umbraco.Tests.Integration.dll</Left>
183+
<Right>lib/net9.0/Umbraco.Tests.Integration.dll</Right>
184+
<IsBaselineSuppression>true</IsBaselineSuppression>
185+
</Suppression>
186+
<Suppression>
187+
<DiagnosticId>CP0012</DiagnosticId>
188+
<Target>M:Umbraco.Cms.Tests.Integration.ManagementApi.ManagementApiTest`1.get_Url</Target>
189+
<Left>lib/net9.0/Umbraco.Tests.Integration.dll</Left>
190+
<Right>lib/net9.0/Umbraco.Tests.Integration.dll</Right>
191+
<IsBaselineSuppression>true</IsBaselineSuppression>
192+
</Suppression>
193+
<Suppression>
194+
<DiagnosticId>CP0012</DiagnosticId>
195+
<Target>M:Umbraco.Cms.Tests.Integration.TestServerTest.UmbracoTestServerTestBase.get_Services</Target>
196+
<Left>lib/net9.0/Umbraco.Tests.Integration.dll</Left>
197+
<Right>lib/net9.0/Umbraco.Tests.Integration.dll</Right>
198+
<IsBaselineSuppression>true</IsBaselineSuppression>
199+
</Suppression>
200+
<Suppression>
201+
<DiagnosticId>CP0012</DiagnosticId>
202+
<Target>P:Umbraco.Cms.Tests.Integration.ManagementApi.ManagementApiTest`1.Url</Target>
203+
<Left>lib/net9.0/Umbraco.Tests.Integration.dll</Left>
204+
<Right>lib/net9.0/Umbraco.Tests.Integration.dll</Right>
205+
<IsBaselineSuppression>true</IsBaselineSuppression>
206+
</Suppression>
207+
<Suppression>
208+
<DiagnosticId>CP0012</DiagnosticId>
209+
<Target>P:Umbraco.Cms.Tests.Integration.TestServerTest.UmbracoTestServerTestBase.Services</Target>
210+
<Left>lib/net9.0/Umbraco.Tests.Integration.dll</Left>
211+
<Right>lib/net9.0/Umbraco.Tests.Integration.dll</Right>
212+
<IsBaselineSuppression>true</IsBaselineSuppression>
213+
</Suppression>
214+
<Suppression>
215+
<DiagnosticId>CP0012</DiagnosticId>
216+
<Target>M:Umbraco.Cms.Tests.Integration.TestServerTest.UmbracoTestServerTestBase.CustomMvcSetup(Microsoft.Extensions.DependencyInjection.IMvcBuilder)</Target>
217+
<Left>lib/net9.0/Umbraco.Tests.Integration.dll</Left>
218+
<Right>lib/net9.0/Umbraco.Tests.Integration.dll</Right>
219+
<IsBaselineSuppression>true</IsBaselineSuppression>
220+
</Suppression>
221+
</Suppressions>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System.Linq.Expressions;
2+
using System.Net;
3+
using NUnit.Framework;
4+
using Umbraco.Cms.Api.Management.Controllers.Culture;
5+
using Umbraco.Cms.Core;
6+
using Umbraco.Cms.Core.Services;
7+
using Umbraco.Cms.Tests.Common.Builders;
8+
using Umbraco.Cms.Tests.Common.Builders.Extensions;
9+
10+
namespace Umbraco.Cms.Tests.Integration.ManagementApi.Culture;
11+
12+
public class AllCultureControllerTests : ManagementApiUserGroupTestBase<AllCultureController>
13+
{
14+
ILanguageService LanguageService => GetRequiredService<ILanguageService>();
15+
16+
[SetUp]
17+
public async Task Setup()
18+
{
19+
var langDa = new LanguageBuilder()
20+
.WithCultureInfo("da-DK")
21+
.Build();
22+
await LanguageService.CreateAsync(langDa, Constants.Security.SuperUserKey);
23+
}
24+
25+
protected override Expression<Func<AllCultureController, object>> MethodSelector =>
26+
x => x.GetAll(CancellationToken.None, 0, 100);
27+
28+
protected override UserGroupAssertionModel AdminUserGroupAssertionModel => new()
29+
{
30+
ExpectedStatusCode = HttpStatusCode.OK
31+
};
32+
33+
protected override UserGroupAssertionModel EditorUserGroupAssertionModel => new()
34+
{
35+
ExpectedStatusCode = HttpStatusCode.OK
36+
};
37+
38+
protected override UserGroupAssertionModel SensitiveDataUserGroupAssertionModel => new()
39+
{
40+
ExpectedStatusCode = HttpStatusCode.OK
41+
};
42+
43+
protected override UserGroupAssertionModel TranslatorUserGroupAssertionModel => new()
44+
{
45+
ExpectedStatusCode = HttpStatusCode.OK
46+
};
47+
48+
protected override UserGroupAssertionModel WriterUserGroupAssertionModel => new()
49+
{
50+
ExpectedStatusCode = HttpStatusCode.OK
51+
};
52+
53+
protected override UserGroupAssertionModel UnauthorizedUserGroupAssertionModel => new()
54+
{
55+
ExpectedStatusCode = HttpStatusCode.Unauthorized
56+
};
57+
}

0 commit comments

Comments
 (0)