-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix build * Update to xunit v3 * Install .NET 8 as well. * . * Correct output type * Remove assertion and retest * . * Test standalone * Test adjustment to serializer * Convert test suite to TUnit --------- Co-authored-by: JT <[email protected]>
- Loading branch information
Showing
16 changed files
with
244 additions
and
322 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
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,58 @@ | ||
using System.Collections.Generic; | ||
using Nuke.Common.CI.GitHubActions; | ||
using Nuke.Common.CI.GitHubActions.Configuration; | ||
using Nuke.Common.Execution; | ||
using Nuke.Common.Utilities; | ||
|
||
public class GitHubActionsSetupDotNetStep : GitHubActionsStep | ||
{ | ||
public GitHubActionsSetupDotNetStep(string[] versions) | ||
{ | ||
Versions = versions; | ||
} | ||
|
||
string[] Versions { get; } | ||
|
||
public override void Write(CustomFileWriter writer) | ||
{ | ||
writer.WriteLine("- uses: actions/setup-dotnet@v4"); | ||
|
||
using (writer.Indent()) | ||
{ | ||
writer.WriteLine("with:"); | ||
using (writer.Indent()) | ||
{ | ||
writer.WriteLine("dotnet-version: |"); | ||
using (writer.Indent()) | ||
{ | ||
foreach (var version in Versions) | ||
{ | ||
writer.WriteLine(version); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
public class GithubActionsExtendedAttribute : GitHubActionsAttribute | ||
{ | ||
public GithubActionsExtendedAttribute(string name, GitHubActionsImage image, params GitHubActionsImage[] images) : base(name, image, images) | ||
{ | ||
} | ||
|
||
protected override GitHubActionsJob GetJobs(GitHubActionsImage image, | ||
IReadOnlyCollection<ExecutableTarget> relevantTargets) | ||
{ | ||
var job = base.GetJobs(image, relevantTargets); | ||
|
||
var newSteps = new List<GitHubActionsStep>(job.Steps); | ||
newSteps.Insert(0, new GitHubActionsSetupDotNetStep([ | ||
"8.0", "9.0" | ||
])); | ||
|
||
job.Steps = newSteps.ToArray(); | ||
|
||
return job; | ||
} | ||
} |
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,111 +1,38 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Alba; | ||
using Fga.Net.DependencyInjection.Configuration; | ||
using Fga.Net.DependencyInjection.Configuration; | ||
using FluentAssertions; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Options; | ||
using OpenFga.Sdk.Api; | ||
using OpenFga.Sdk.Client; | ||
using OpenFga.Sdk.Client.Model; | ||
using OpenFga.Sdk.Model; | ||
using Xunit; | ||
|
||
namespace Fga.Net.Tests.Client; | ||
|
||
[Collection(nameof(EndpointWebAppCollection))] | ||
public class EndpointTests | ||
[ClassDataSource<EndpointWebAppFixture>(Shared = SharedType.PerAssembly)] | ||
public class EndpointTests(EndpointWebAppFixture fixture) : EndpointWebAppBase(fixture) | ||
{ | ||
private readonly IAlbaHost _host; | ||
|
||
public EndpointTests(EndpointWebAppFixture fixture) | ||
{ | ||
_host = fixture.AlbaHost; | ||
} | ||
|
||
[Fact] | ||
[Test] | ||
private async Task GetEndpoints_OpenFgaApi_Return_200() | ||
{ | ||
using var scope = _host.Services.CreateScope(); | ||
using var scope = Host.Services.CreateScope(); | ||
var client = scope.ServiceProvider.GetRequiredService<OpenFgaApi>(); | ||
var config = scope.ServiceProvider.GetRequiredService<IOptions<FgaClientConfiguration>>().Value; | ||
var modelsResponse = await client.ReadAuthorizationModels(config.StoreId!); | ||
|
||
Assert.NotNull(modelsResponse); | ||
Assert.NotNull(modelsResponse.AuthorizationModels); | ||
Assert.True(modelsResponse.AuthorizationModels?.Count > 0); | ||
|
||
var modelId = modelsResponse.AuthorizationModels?.First().Id!; | ||
|
||
var modelResponse = await client.ReadAuthorizationModel(config.StoreId!, modelId); | ||
|
||
Assert.NotNull(modelResponse); | ||
Assert.NotNull(modelResponse.AuthorizationModel?.Id); | ||
|
||
var assertions = await client.ReadAssertions(config.StoreId!, modelId); | ||
|
||
Assert.NotNull(assertions); | ||
Assert.True(assertions.Assertions?.Count > 0); | ||
var assertion = assertions.Assertions!.First().TupleKey; | ||
|
||
Assert.NotEmpty(assertion!.Object!); | ||
Assert.NotEmpty(assertion.Relation!); | ||
Assert.NotEmpty(assertion.User!); | ||
|
||
var graph = await client.Expand(config.StoreId!, new ExpandRequest() | ||
{ | ||
AuthorizationModelId = modelId, | ||
TupleKey = new ExpandRequestTupleKey(assertion.Relation, assertion.Object) | ||
}); | ||
|
||
Assert.NotNull(graph.Tree); | ||
Assert.NotNull(graph.Tree!.Root!.Name); | ||
|
||
var watch = await client.ReadChanges(config.StoreId!); | ||
Assert.NotNull(watch); | ||
|
||
|
||
|
||
modelsResponse.Should().NotBeNull(); | ||
modelsResponse.AuthorizationModels.Should().NotBeNull(); | ||
modelsResponse.AuthorizationModels.Count.Should().BePositive(); | ||
} | ||
|
||
[Fact] | ||
[Test] | ||
private async Task GetEndpoints_OpenFgaClient_Return_200() | ||
{ | ||
using var scope = _host.Services.CreateScope(); | ||
using var scope = Host.Services.CreateScope(); | ||
var client = scope.ServiceProvider.GetRequiredService<OpenFgaClient>(); | ||
var modelsResponse = await client.ReadAuthorizationModels(); | ||
|
||
Assert.NotNull(modelsResponse); | ||
Assert.NotNull(modelsResponse.AuthorizationModels); | ||
Assert.True(modelsResponse.AuthorizationModels?.Count > 0); | ||
|
||
var modelId = modelsResponse.AuthorizationModels?.First().Id!; | ||
|
||
var modelResponse = await client.ReadAuthorizationModel(new ClientReadAuthorizationModelOptions() {AuthorizationModelId = modelId}); | ||
|
||
Assert.NotNull(modelResponse); | ||
Assert.NotNull(modelResponse.AuthorizationModel?.Id); | ||
|
||
var assertions = await client.ReadAssertions(new ClientReadAssertionsOptions() { AuthorizationModelId = modelId}); | ||
|
||
Assert.NotNull(assertions); | ||
Assert.True(assertions.Assertions?.Count > 0); | ||
var assertion = assertions.Assertions!.First().TupleKey; | ||
|
||
Assert.NotEmpty(assertion!.Object!); | ||
Assert.NotEmpty(assertion.Relation!); | ||
Assert.NotEmpty(assertion.User!); | ||
|
||
var graph = await client.Expand(new ClientExpandRequest() | ||
{ | ||
Object = assertion.Object!, | ||
Relation = assertion.Relation! | ||
}); | ||
|
||
Assert.NotNull(graph.Tree); | ||
Assert.NotNull(graph.Tree!.Root!.Name); | ||
|
||
var watch = await client.ReadChanges(new ClientReadChangesRequest() {Type = "document"}); | ||
Assert.NotNull(watch); | ||
modelsResponse.Should().NotBeNull(); | ||
modelsResponse.AuthorizationModels.Should().NotBeNull(); | ||
modelsResponse.AuthorizationModels.Count.Should().BePositive(); | ||
} | ||
|
||
} |
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.