Skip to content

Commit

Permalink
Remove assertion and retest
Browse files Browse the repository at this point in the history
  • Loading branch information
Hawxy committed Jan 6, 2025
1 parent fcccdec commit 1d2b8c4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion tests/Fga.Net.Tests/Fga.Net.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
Expand Down
48 changes: 25 additions & 23 deletions tests/Fga.Net.Tests/Unit/ExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,39 @@ namespace Fga.Net.Tests.Unit;
public class ExtensionTests
{
public static TheoryData<ExtensionScenario> BadExtensions =>
new()
[
new ExtensionScenario("Empty Extension Config - Auth0 FGA",
config => config.ConfigureAuth0Fga(x => { })),

new ExtensionScenario("Empty Schema",
config => config.ConfigureOpenFga(x => { x.SetConnection("localhost"); })),

new ExtensionScenario("Empty API Key", config => config.ConfigureOpenFga(x =>
{
new ExtensionScenario("Empty Extension Config - Auth0 FGA",
config => config.ConfigureAuth0Fga(x => { })),
new ExtensionScenario("Empty Schema",
config => config.ConfigureOpenFga(x => { x.SetConnection("localhost"); })),
new ExtensionScenario("Empty API Key", config => config.ConfigureOpenFga(x =>
{
x.SetConnection("http://localhost")
.WithApiKeyAuthentication("");
})),
new ExtensionScenario("Empty OIDC configuration", config => config.ConfigureOpenFga(x =>
{
x.SetConnection("http://localhost")
.WithOidcAuthentication("clientId", "", "issuer", "audience");
})),
};
x.SetConnection("http://localhost")
.WithApiKeyAuthentication("");
})),

new ExtensionScenario("Empty OIDC configuration", config => config.ConfigureOpenFga(x =>
{
x.SetConnection("http://localhost")
.WithOidcAuthentication("clientId", "", "issuer", "audience");
}))

];

[Theory]
[MemberData(nameof(BadExtensions))]
public void InvalidConfiguration_ThrowsException(ExtensionScenario scenario)
{
var collection = new ServiceCollection();

Assert.Throws<InvalidOperationException>(() =>
collection.AddOpenFgaClient(config =>
{
config.SetStoreId(Guid.NewGuid().ToString());

scenario.Configuration(config);
}));
collection.AddOpenFgaClient(config =>
{
config.SetStoreId(Guid.NewGuid().ToString());

scenario.Configuration(config);
})
}


Expand Down

0 comments on commit 1d2b8c4

Please sign in to comment.