-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64299fa
commit d9d6814
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Options; | ||
using Passwordless.AspNetCore.Services; | ||
|
||
namespace Passwordless.AspNetCore.Tests; | ||
|
||
public class RegistrationTests | ||
{ | ||
[Fact] | ||
public void AllExpectedServicesAndOptionsResolve() | ||
{ | ||
var configuration = new ConfigurationBuilder() | ||
Check failure on line 15 in tests/Passwordless.AspNetCore.Tests/RegistrationTests.cs GitHub Actions / test (ubuntu-latest)Passwordless.AspNetCore.Tests.RegistrationTests.AllExpectedServicesAndOptionsResolve
Check failure on line 15 in tests/Passwordless.AspNetCore.Tests/RegistrationTests.cs GitHub Actions / test (windows-latest)Passwordless.AspNetCore.Tests.RegistrationTests.AllExpectedServicesAndOptionsResolve
|
||
.AddInMemoryCollection(new Dictionary<string, string?> | ||
{ | ||
["ApiSecret"] = "FakeApiSecret", | ||
["ApiUrl"] = "https://example.org", | ||
["SignInScheme"] = "Cookies", | ||
["Register:Discoverable"] = "false" | ||
}) | ||
.Build(); | ||
|
||
var serviceCollection = new ServiceCollection(); | ||
|
||
serviceCollection.AddDbContext<TestDbContext>(); | ||
|
||
serviceCollection | ||
.AddIdentity<IdentityUser, IdentityRole>() | ||
.AddEntityFrameworkStores<TestDbContext>() | ||
.AddPasswordless(configuration); | ||
|
||
var provider = serviceCollection.BuildServiceProvider(); | ||
|
||
_ = provider.GetRequiredService<PasswordlessClient>(); | ||
_ = provider.GetRequiredService<IPasswordlessService<PasswordlessRegisterRequest>>(); | ||
var optionsAccessor = provider.GetRequiredService<IOptions<PasswordlessAspNetCoreOptions>>(); | ||
var options = optionsAccessor.Value; | ||
Assert.Equal("FakeApiSecret", options.ApiSecret); | ||
Assert.Equal("https://example.org", options.ApiUrl); | ||
Assert.Equal("Cookies", options.SignInScheme); | ||
Assert.False(options.Register.Discoverable); | ||
} | ||
} | ||
|
||
public class TestDbContext : IdentityDbContext<IdentityUser> | ||
{ | ||
|
||
} |