-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dotnet] Experimental platform-specific token provider with dependenc…
…y injection support (#492) * Experimental token provider implementation * Host tests * Add extension methods * Remove Browser project * Cleanup * Update default tests to staging
- Loading branch information
1 parent
34d38b5
commit 95ac9c2
Showing
29 changed files
with
554 additions
and
324 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
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 |
---|---|---|
@@ -1,25 +1,25 @@ | ||
<Project> | ||
<!-- Set common properties regarding assembly information and nuget packages --> | ||
<PropertyGroup> | ||
<Authors>Trinsic Engineering Team</Authors> | ||
<Company>Trinsic</Company> | ||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> | ||
<PackageProjectUrl>https://github.com/trinsic-id/sdk</PackageProjectUrl> | ||
<PackageTags>Trinsic</PackageTags> | ||
<Product>Trinsic SDK for NET</Product> | ||
<RepositoryUrl>https://github.com/trinsic-id/sdk.git</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<Version>1.0.0</Version> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
</PropertyGroup> | ||
<!-- Common compile parameters --> | ||
<PropertyGroup> | ||
<!-- We use full (Windows PDBs) until cross platform support for source link will get better --> | ||
<DebugType>full</DebugType> | ||
<LangVersion>latest</LangVersion> | ||
<NoWarn>$(NoWarn);1591</NoWarn> | ||
<Nullable>enable</Nullable> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
</PropertyGroup> | ||
<!-- Set common properties regarding assembly information and nuget packages --> | ||
<PropertyGroup> | ||
<Authors>Trinsic Engineering Team</Authors> | ||
<Company>Trinsic</Company> | ||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> | ||
<PackageProjectUrl>https://github.com/trinsic-id/sdk</PackageProjectUrl> | ||
<PackageTags>Trinsic</PackageTags> | ||
<Product>Trinsic SDK for NET</Product> | ||
<RepositoryUrl>https://github.com/trinsic-id/sdk.git</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<Version>1.0.0</Version> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
<SymbolPackageFormat>snupkg</SymbolPackageFormat> | ||
</PropertyGroup> | ||
<!-- Common compile parameters --> | ||
<PropertyGroup> | ||
<!-- We use full (Windows PDBs) until cross platform support for source link will get better --> | ||
<DebugType>full</DebugType> | ||
<LangVersion>latest</LangVersion> | ||
<NoWarn>$(NoWarn);1591</NoWarn> | ||
<Nullable>enable</Nullable> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
</PropertyGroup> | ||
</Project> |
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,69 @@ | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Trinsic; | ||
using Trinsic.Services.Common.V1; | ||
using Xunit; | ||
|
||
namespace Tests; | ||
|
||
public class HostTests | ||
{ | ||
[Fact(DisplayName = "Test default service host")] | ||
public async Task TestGenericHost() { | ||
var host = Host | ||
.CreateDefaultBuilder() | ||
.ConfigureServices(services => { | ||
services.AddTrinsic(); | ||
}).Build(); | ||
|
||
await host.StartAsync(); | ||
|
||
var providerService = host.Services.GetService<ProviderService>(); | ||
var accountService = host.Services.GetRequiredService<AccountService>(); | ||
|
||
providerService.Should().NotBeNull(); | ||
accountService.Should().NotBeNull(); | ||
|
||
accountService.Options.ServerEndpoint.Should().Be(ServiceBase.DefaultServerEndpoint); | ||
accountService.Options.ServerPort.Should().Be(ServiceBase.DefaultServerPort); | ||
accountService.Options.ServerUseTls.Should().Be(ServiceBase.DefaultServerUseTls); | ||
accountService.Options.DefaultEcosystem.Should().Be(ServiceBase.DefaultEcosystem); | ||
accountService.Options.AuthToken.Should().Be(string.Empty); | ||
accountService.TokenProvider.Should().BeOfType<FileTokenProvider>(); | ||
|
||
await host.StopAsync(); | ||
} | ||
|
||
[Fact(DisplayName = "Test configured service host")] | ||
public async Task TestConfiguredGenericHost() { | ||
var host = Host | ||
.CreateDefaultBuilder() | ||
.ConfigureServices(services => { | ||
services.AddTrinsic(options => { | ||
options.AuthToken = "auth"; | ||
options.DefaultEcosystem = "eco"; | ||
options.ServerEndpoint = "example.com"; | ||
options.ServerPort = 42; | ||
options.ServerUseTls = true; | ||
}); | ||
}).Build(); | ||
|
||
await host.StartAsync(); | ||
|
||
var providerService = host.Services.GetService<ProviderService>(); | ||
var accountService = host.Services.GetRequiredService<AccountService>(); | ||
|
||
providerService.Should().NotBeNull(); | ||
accountService.Should().NotBeNull(); | ||
|
||
accountService.Options.ServerEndpoint.Should().Be("example.com"); | ||
accountService.Options.ServerPort.Should().Be(42); | ||
accountService.Options.ServerUseTls.Should().BeTrue(); | ||
accountService.Options.DefaultEcosystem.Should().Be("eco"); | ||
accountService.Options.AuthToken.Should().Be("auth"); | ||
|
||
await host.StopAsync(); | ||
} | ||
} |
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
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
Oops, something went wrong.