Add tests and fixes to .well-known/openid-configuration and create realm
This commit is contained in:
parent
e07d6e3ea5
commit
d440979451
17 changed files with 642 additions and 45 deletions
|
|
@ -0,0 +1,70 @@
|
|||
using System.Text.Json.Nodes;
|
||||
using IdentityShroud.TestUtils.Asserts;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace IdentityShroud.TestUtils.Tests.Asserts;
|
||||
|
||||
public class JsonObjectAssertTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("foo", new string[] { "foo" })]
|
||||
[InlineData("foo.bar", new string[] { "foo", "bar" })]
|
||||
[InlineData("foo[1].bar", new string[] { "foo", "1", "bar" })]
|
||||
public void ParsePath(string path, string[] expected)
|
||||
{
|
||||
var result = JsonObjectAssert.ParsePath(path);
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NavigateToPath_Success()
|
||||
{
|
||||
JsonObject foo = new();
|
||||
foo["bar"] = 1;
|
||||
JsonObject obj = new();
|
||||
obj["foo"] = foo;
|
||||
|
||||
JsonNode? node = JsonObjectAssert.NavigateToPath(obj, ["foo", "bar"]);
|
||||
Assert.NotNull(node);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NavigateToPath_PathDoesNotExist()
|
||||
{
|
||||
JsonObject obj = new();
|
||||
Assert.Throws<XunitException>(
|
||||
() => JsonObjectAssert.NavigateToPath(obj, ["test"]),
|
||||
ex => ex.Message.StartsWith("Path 'test' does not exist") ? null : ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NavigateToPath_MemberOfNullObject()
|
||||
{
|
||||
JsonObject obj = new();
|
||||
obj["foo"] = null;
|
||||
|
||||
Assert.Throws<XunitException>(
|
||||
() => JsonObjectAssert.NavigateToPath(obj, ["foo", "bar"]),
|
||||
ex => ex.Message.StartsWith("Path 'foo.bar' does not exist") ? null : ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equal_WrongType()
|
||||
{
|
||||
JsonObject obj = new();
|
||||
obj["test"] = new JsonObject();
|
||||
|
||||
Assert.Throws<XunitException>(
|
||||
() => JsonObjectAssert.Equal("str", obj, ["test"]),
|
||||
ex => ex.Message.StartsWith("Type mismatch") ? null : ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Equal_Match()
|
||||
{
|
||||
JsonObject obj = new();
|
||||
obj["test"] = "str";
|
||||
|
||||
JsonObjectAssert.Equal("str", obj, ["test"]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue