Revize e0b070f4
Přidáno uživatelem Tomáš Orlovský před téměř 4 roky(ů)
Leuze.sln | ||
---|---|---|
37 | 37 |
EndProject |
38 | 38 |
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Leuze.Tests.Core", "tests\Core\Leuze.Tests.Core\Leuze.Tests.Core.csproj", "{D271989D-921D-486B-929C-6BBF1EC0EED4}" |
39 | 39 |
EndProject |
40 |
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Leuze.Tests.Core.Infrastructure.ActiveDirectory", "tests\Core\Leuze.Tests.Core.Infrastructure.ActiveDirectory\Leuze.Tests.Core.Infrastructure.ActiveDirectory.csproj", "{C1813611-5FF2-4E70-B7E5-A4E8553F0B66}" |
|
41 |
EndProject |
|
42 | 40 |
Global |
43 | 41 |
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
44 | 42 |
Debug|Any CPU = Debug|Any CPU |
... | ... | |
81 | 79 |
{D271989D-921D-486B-929C-6BBF1EC0EED4}.Debug|Any CPU.Build.0 = Debug|Any CPU |
82 | 80 |
{D271989D-921D-486B-929C-6BBF1EC0EED4}.Release|Any CPU.ActiveCfg = Release|Any CPU |
83 | 81 |
{D271989D-921D-486B-929C-6BBF1EC0EED4}.Release|Any CPU.Build.0 = Release|Any CPU |
84 |
{C1813611-5FF2-4E70-B7E5-A4E8553F0B66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|
85 |
{C1813611-5FF2-4E70-B7E5-A4E8553F0B66}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|
86 |
{C1813611-5FF2-4E70-B7E5-A4E8553F0B66}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|
87 |
{C1813611-5FF2-4E70-B7E5-A4E8553F0B66}.Release|Any CPU.Build.0 = Release|Any CPU |
|
88 | 82 |
EndGlobalSection |
89 | 83 |
GlobalSection(SolutionProperties) = preSolution |
90 | 84 |
HideSolutionNode = FALSE |
... | ... | |
103 | 97 |
{B74BED5E-F175-4A6E-B4AC-8625E0E4E287} = {C5588326-929D-42B3-912B-9D838373B48E} |
104 | 98 |
{8ECAEA01-61F3-402D-B94E-E54FC0C94C8E} = {B74BED5E-F175-4A6E-B4AC-8625E0E4E287} |
105 | 99 |
{D271989D-921D-486B-929C-6BBF1EC0EED4} = {B74BED5E-F175-4A6E-B4AC-8625E0E4E287} |
106 |
{C1813611-5FF2-4E70-B7E5-A4E8553F0B66} = {B74BED5E-F175-4A6E-B4AC-8625E0E4E287} |
|
107 | 100 |
EndGlobalSection |
108 | 101 |
GlobalSection(ExtensibilityGlobals) = postSolution |
109 | 102 |
SolutionGuid = {849C3668-1CB9-4F98-ADFA-A71F5629384C} |
tests/Core/Leuze.Tests.Core.Infrastructure.ActiveDirectory/Leuze.Tests.Core.Infrastructure.ActiveDirectory.csproj | ||
---|---|---|
1 |
<Project Sdk="Microsoft.NET.Sdk"> |
|
2 |
|
|
3 |
<PropertyGroup> |
|
4 |
<AssemblyName>Leuze.Tests.Core.Infrastructure.ActiveDirectory</AssemblyName> |
|
5 |
<RootNamespace>Leuze.Tests.Core.Infrastructure.ActiveDirectory</RootNamespace> |
|
6 |
<Product></Product> |
|
7 |
<Description></Description> |
|
8 |
</PropertyGroup> |
|
9 |
|
|
10 |
<PropertyGroup> |
|
11 |
<TargetFramework>net5.0</TargetFramework> |
|
12 |
<Nullable>enable</Nullable> |
|
13 |
<IsPackable>false</IsPackable> |
|
14 |
<GenerateDocumentationFile>true</GenerateDocumentationFile> |
|
15 |
</PropertyGroup> |
|
16 |
|
|
17 |
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|
18 |
<DocumentationFile>..\..\..\docs\Leuze.Tests.Core.Infrastructure.ActiveDirectory.xml</DocumentationFile> |
|
19 |
</PropertyGroup> |
|
20 |
|
|
21 |
<ItemGroup> |
|
22 |
<PackageReference Include="FluentAssertions" Version="5.10.3" /> |
|
23 |
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" /> |
|
24 |
<PackageReference Include="xunit" Version="2.4.1" /> |
|
25 |
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> |
|
26 |
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
|
27 |
<PrivateAssets>all</PrivateAssets> |
|
28 |
</PackageReference> |
|
29 |
<PackageReference Include="coverlet.collector" Version="3.0.3"> |
|
30 |
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
|
31 |
<PrivateAssets>all</PrivateAssets> |
|
32 |
</PackageReference> |
|
33 |
</ItemGroup> |
|
34 |
|
|
35 |
</Project> |
tests/Core/Leuze.Tests.Core/AccountManipulationTests.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 |
using FluentAssertions; |
|
7 |
using Leuze.Core.Application.Identity; |
|
8 |
using Leuze.Tests.Configuration; |
|
9 |
using Microsoft.Extensions.DependencyInjection; |
|
10 |
using Xunit; |
|
11 |
|
|
12 |
namespace Leuze.Tests.Core |
|
13 |
{ |
|
14 |
[Trait("Category", "Core")] |
|
15 |
public class AccountManipulationTests : TestWithDatabase |
|
16 |
{ |
|
17 |
|
|
18 |
private static (string name, string mail, string pass) USER1 = ("user1", "user@test.com", "kappa123"); |
|
19 |
public AccountManipulationTests() |
|
20 |
{ |
|
21 |
var services = new ServiceCollection(); |
|
22 |
|
|
23 |
Initialize(services); |
|
24 |
} |
|
25 |
|
|
26 |
[Fact] |
|
27 |
[Trait("Category", "AccTests")] |
|
28 |
public async Task CreateAccTest() |
|
29 |
{ |
|
30 |
ApplicationUser user1 = new ApplicationUser(USER1.name, USER1.mail, false); |
|
31 |
//TODO: fix create user with password |
|
32 |
//DatabaseFixture.UserManager.CreateAsync(user1, USER1.pass).Wait(); |
|
33 |
DatabaseFixture.UserManager.CreateAsync(user1).Wait(); |
|
34 |
DatabaseFixture.UserManager.Users.Contains(user1).Should().BeTrue(); |
|
35 |
} |
|
36 |
|
|
37 |
[Fact] |
|
38 |
public async Task CreateADAccTest() |
|
39 |
{ |
|
40 |
//TODO: Account create through AD login implementation |
|
41 |
} |
|
42 |
} |
|
43 |
} |
tests/Core/Leuze.Tests.Core/LoginTests.cs | ||
---|---|---|
2 | 2 |
using System.Threading.Tasks; |
3 | 3 |
using FluentAssertions; |
4 | 4 |
using Leuze.Core.Application.CQRS.Auth.Commads; |
5 |
using Leuze.Core.Application.CQRS.Auth.Commands; |
|
5 | 6 |
using Leuze.Core.Application.Identity; |
6 | 7 |
using Leuze.Core.Domain.Repositories; |
7 | 8 |
using Leuze.Core.Infrastructure.Persistence.Repository; |
... | ... | |
35 | 36 |
[Fact] |
36 | 37 |
public async Task SimpleLoginTest() |
37 | 38 |
{ |
38 |
//TODO: FIX THIS T.O. |
|
39 |
///await _semaphore.WaitAsync(); |
|
39 |
await _semaphore.WaitAsync(); |
|
40 | 40 |
|
41 |
///IMediator mediator = DatabaseFixture.Services.GetRequiredService<IMediator>(); |
|
42 |
///var response = await mediator.Send(new VerifyLocalUser.Command("user@test.com", "kappa123")); |
|
43 |
///response.IsSuccess.Should().BeTrue(); |
|
41 |
IMediator mediator = DatabaseFixture.Services.GetRequiredService<IMediator>(); |
|
44 | 42 |
|
43 |
var response = await mediator.Send(new VerifyLocalUser.Command(USER1.mail, USER1.pass)); |
|
44 |
// response.IsSuccess.Should().BeTrue(); |
|
45 | 45 |
|
46 |
|
|
46 | 47 |
//HttpContext context = DatabaseFixture.Services.GetRequiredService<IHttpContextAccessor>().HttpContext; |
48 |
|
|
47 | 49 |
//Assert.True(context.User.Identity.IsAuthenticated); |
48 | 50 |
//context.User.Identity.IsAuthenticated.Should().Be(true); |
49 | 51 |
|
50 |
///_semaphore.Release();
|
|
52 |
_semaphore.Release(); |
|
51 | 53 |
} |
52 | 54 |
|
53 | 55 |
[Fact] |
54 | 56 |
public async Task ADLoginTest() |
55 | 57 |
{ |
56 |
//TODO: AD login implementation |
|
58 |
// IMediator mediator = DatabaseFixture.Services.GetRequiredService<IMediator>(); |
|
59 |
|
|
60 |
// var response = await mediator.Send(new VerifyAdUser.Command(USER1.mail, USER1.name)); |
|
61 |
// response.IsSuccess.Should().BeTrue(); |
|
57 | 62 |
} |
58 | 63 |
|
59 | 64 |
[Fact] |
... | ... | |
79 | 84 |
|
80 | 85 |
_semaphore.Release(); |
81 | 86 |
} |
82 |
|
|
83 |
[Fact] |
|
84 |
public async Task AdminRoleTest() |
|
85 |
{ |
|
86 |
//TODO: AD login implementation |
|
87 |
} |
|
88 |
|
|
89 |
[Fact] |
|
90 |
public async Task NonAdminRoleTest() |
|
91 |
{ |
|
92 |
//TODO: AD login implementation |
|
93 |
} |
|
94 |
|
|
95 |
[Fact] |
|
96 |
public async Task AdminAddRoleTest() |
|
97 |
{ |
|
98 |
//TODO: AD login implementation |
|
99 |
} |
|
100 |
|
|
101 |
[Fact] |
|
102 |
public async Task AdminRemoveRoleTest() |
|
103 |
{ |
|
104 |
//TODO: AD login implementation |
|
105 |
} |
|
106 |
|
|
107 |
[Fact] |
|
108 |
public async Task AdminRemoveAdminRoleTest() |
|
109 |
{ |
|
110 |
//TODO: AD login implementation |
|
111 |
} |
|
112 |
|
|
113 |
[Fact] |
|
114 |
public async Task AdminRemoveAdminSelfRoleTest() |
|
115 |
{ |
|
116 |
//TODO: AD login implementation |
|
117 |
} |
|
118 |
|
|
119 |
[Fact] |
|
120 |
public async Task CreateAccTest() |
|
121 |
{ |
|
122 |
//TODO: AD login implementation |
|
123 |
} |
|
124 |
|
|
125 |
[Fact] |
|
126 |
public async Task CreateADAccTest() |
|
127 |
{ |
|
128 |
//TODO: AD login implementation |
|
129 |
} |
|
130 | 87 |
} |
131 | 88 |
} |
tests/Core/Leuze.Tests.Core/RoleTests.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 |
using Leuze.Tests.Configuration; |
|
7 |
using Microsoft.Extensions.DependencyInjection; |
|
8 |
using Xunit; |
|
9 |
|
|
10 |
namespace Leuze.Tests.Core |
|
11 |
{ |
|
12 |
[Trait("Category", "Core")] |
|
13 |
public class RoleTests : TestWithDatabase |
|
14 |
{ |
|
15 |
public RoleTests() |
|
16 |
{ |
|
17 |
var services = new ServiceCollection(); |
|
18 |
|
|
19 |
Initialize(services); |
|
20 |
} |
|
21 |
|
|
22 |
[Fact] |
|
23 |
public async Task AdminRoleTest() |
|
24 |
{ |
|
25 |
//TODO: implementation |
|
26 |
} |
|
27 |
|
|
28 |
[Fact] |
|
29 |
public async Task NonAdminRoleTest() |
|
30 |
{ |
|
31 |
//TODO: implementation |
|
32 |
} |
|
33 |
|
|
34 |
[Fact] |
|
35 |
public async Task AdminAddRoleTest() |
|
36 |
{ |
|
37 |
//TODO: implementation |
|
38 |
} |
|
39 |
|
|
40 |
[Fact] |
|
41 |
public async Task AdminRemoveRoleTest() |
|
42 |
{ |
|
43 |
//TODO: implementation |
|
44 |
} |
|
45 |
|
|
46 |
[Fact] |
|
47 |
public async Task AdminRemoveAdminRoleTest() |
|
48 |
{ |
|
49 |
//TODO: implementation |
|
50 |
} |
|
51 |
|
|
52 |
[Fact] |
|
53 |
public async Task AdminRemoveAdminSelfRoleTest() |
|
54 |
{ |
|
55 |
//TODO: implementation |
|
56 |
} |
|
57 |
} |
|
58 |
} |
Také k dispozici: Unified diff
Implemented most of login tests, one of two account tests and prepared tests for role testing. Deleted unused project. #8722 @testFull