-
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
8198bd2
commit 8c962c0
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() | ||
.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> | ||
{ | ||
|
||
} |