Revize 578c842e
Přidáno uživatelem Tomáš Orlovský před téměř 4 roky(ů)
tests/Core/Leuze.Tests.Core/Leuze.Tests.Core.csproj | ||
---|---|---|
1 |
<Project Sdk="Microsoft.NET.Sdk"> |
|
1 |
<Project Sdk="Microsoft.NET.Sdk">
|
|
2 | 2 |
|
3 | 3 |
<PropertyGroup> |
4 | 4 |
<TargetFramework>net5.0</TargetFramework> |
... | ... | |
7 | 7 |
</PropertyGroup> |
8 | 8 |
|
9 | 9 |
<ItemGroup> |
10 |
<PackageReference Include="FluentAssertions" Version="5.10.3" /> |
|
10 | 11 |
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" /> |
11 | 12 |
<PackageReference Include="xunit" Version="2.4.1" /> |
12 | 13 |
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> |
tests/Core/Leuze.Tests.Core/LoginTests.cs | ||
---|---|---|
1 | 1 |
using System; |
2 | 2 |
using System.Threading.Tasks; |
3 |
using FluentAssertions; |
|
4 |
using Leuze.Core.Application.CQRS.Auth.Commads; |
|
5 |
using Leuze.Core.Application.Identity; |
|
6 |
using Leuze.Core.Domain.Repositories; |
|
7 |
using Leuze.Core.Infrastructure.Persistence.Repository; |
|
3 | 8 |
using Leuze.Tests.Configuration; |
9 |
using MediatR; |
|
10 |
using Microsoft.AspNetCore.Http; |
|
11 |
using Microsoft.AspNetCore.Identity.UI.V4.Pages.Internal.Account.Manage; |
|
12 |
using Microsoft.Extensions.DependencyInjection; |
|
4 | 13 |
using Xunit; |
5 | 14 |
|
6 | 15 |
namespace Leuze.Tests.Core |
... | ... | |
10 | 19 |
{ |
11 | 20 |
public LoginTests() |
12 | 21 |
{ |
22 |
var services = new ServiceCollection(); |
|
23 |
//services.AddTransient<IPermissionRepository, PermissionRepository>(); |
|
13 | 24 |
|
25 |
Initialize(services); |
|
26 |
|
|
27 |
ApplicationUser user1 = new ApplicationUser("user1", "user@test.com", false); |
|
28 |
DatabaseFixture.UserManager.CreateAsync(user1, "kappa123").Wait(); |
|
29 |
//DatabaseFixture.UserManager.AddPasswordAsync(user1, "kappa123").Wait(); |
|
14 | 30 |
} |
15 | 31 |
|
16 | 32 |
[Fact] |
... | ... | |
18 | 34 |
{ |
19 | 35 |
await _semaphore.WaitAsync(); |
20 | 36 |
|
37 |
IMediator mediator = DatabaseFixture.Services.GetRequiredService<IMediator>(); |
|
38 |
var response = await mediator.Send(new VerifyLocalUser.Command("user@test.com", "kappa123")); |
|
39 |
response.IsSuccess.Should().BeTrue(); |
|
40 |
//HttpContext context = DatabaseFixture.Services.GetRequiredService<IHttpContextAccessor>().HttpContext; |
|
41 |
//Assert.True(context.User.Identity.IsAuthenticated); |
|
42 |
//context.User.Identity.IsAuthenticated.Should().Be(true); |
|
43 |
|
|
44 |
_semaphore.Release(); |
|
45 |
} |
|
46 |
|
|
47 |
[Fact] |
|
48 |
public async Task ADLoginTest() |
|
49 |
{ |
|
50 |
//TODO: AD login implementation |
|
51 |
} |
|
21 | 52 |
|
53 |
[Fact] |
|
54 |
public async Task WrongNameLoginTest() |
|
55 |
{ |
|
56 |
//TODO: AD login implementation |
|
57 |
} |
|
22 | 58 |
|
23 |
_semaphore.Release(); |
|
59 |
[Fact] |
|
60 |
public async Task WrongPassLoginTest() |
|
61 |
{ |
|
62 |
//TODO: AD login implementation |
|
63 |
} |
|
64 |
|
|
65 |
[Fact] |
|
66 |
public async Task AdminRoleTest() |
|
67 |
{ |
|
68 |
//TODO: AD login implementation |
|
69 |
} |
|
70 |
|
|
71 |
[Fact] |
|
72 |
public async Task NonAdminRoleTest() |
|
73 |
{ |
|
74 |
//TODO: AD login implementation |
|
75 |
} |
|
76 |
|
|
77 |
[Fact] |
|
78 |
public async Task AdminAddRoleTest() |
|
79 |
{ |
|
80 |
//TODO: AD login implementation |
|
81 |
} |
|
82 |
|
|
83 |
[Fact] |
|
84 |
public async Task AdminRemoveRoleTest() |
|
85 |
{ |
|
86 |
//TODO: AD login implementation |
|
87 |
} |
|
88 |
|
|
89 |
[Fact] |
|
90 |
public async Task AdminRemoveAdminRoleTest() |
|
91 |
{ |
|
92 |
//TODO: AD login implementation |
|
93 |
} |
|
94 |
|
|
95 |
[Fact] |
|
96 |
public async Task AdminRemoveAdminSelfRoleTest() |
|
97 |
{ |
|
98 |
//TODO: AD login implementation |
|
99 |
} |
|
100 |
|
|
101 |
[Fact] |
|
102 |
public async Task CreateAccTest() |
|
103 |
{ |
|
104 |
//TODO: AD login implementation |
|
105 |
} |
|
106 |
|
|
107 |
[Fact] |
|
108 |
public async Task CreateADAccTest() |
|
109 |
{ |
|
110 |
//TODO: AD login implementation |
|
24 | 111 |
} |
25 | 112 |
} |
26 | 113 |
} |
tests/Leuze.Tests.Configuration/DatabaseInMemoryFixture.cs | ||
---|---|---|
43 | 43 |
/// </summary> |
44 | 44 |
public RoleManager<ApplicationRole> RoleManager { get; private set; } |
45 | 45 |
|
46 |
/// <summary> |
|
47 |
/// Instance of role manager |
|
48 |
/// </summary> |
|
49 |
public SignInManager<ApplicationUser> SignInManager { get; private set; } |
|
50 |
|
|
46 | 51 |
/// <summary> |
47 | 52 |
/// |
48 | 53 |
/// </summary> |
... | ... | |
60 | 65 |
// Assign shortcuts accessors to registered components |
61 | 66 |
UserManager = Services.GetRequiredService<UserManager<ApplicationUser>>(); |
62 | 67 |
RoleManager = Services.GetRequiredService<RoleManager<ApplicationRole>>(); |
68 |
SignInManager = Services.GetRequiredService<SignInManager<ApplicationUser>>(); |
|
63 | 69 |
|
64 | 70 |
// Storage: create using registered db context / storage context |
65 | 71 |
Storage = (TestingStorageContext)Services.GetRequiredService<IStorageContext>(); |
... | ... | |
101 | 107 |
// Register database-specific storage context implementation. |
102 | 108 |
services.AddScoped<IStorageContext, TestingStorageContext>(); |
103 | 109 |
|
110 |
|
|
111 |
|
|
104 | 112 |
} |
105 | 113 |
|
106 | 114 |
/// <summary> |
Také k dispozici: Unified diff
Implemented first test and added test methods for rest of the tests