diff options
author | Rory& <root@rory.gay> | 2024-09-17 13:54:51 +0200 |
---|---|---|
committer | Rory& <root@rory.gay> | 2024-09-17 13:54:51 +0200 |
commit | 1713936ce7a0811de8b2c3022cf08a63fc62b966 (patch) | |
tree | 49d9cfe2f0abadb7508b07cb2b2f7e3a7796f626 /Tests/LibMatrix.Tests/Abstractions/HomeserverAbstraction.cs | |
parent | Fix room joining, power levels (diff) | |
download | LibMatrix-dev/authenticated-media.tar.xz |
Fix unit tests, add authenticated media github/dev/authenticated-media dev/authenticated-media
Diffstat (limited to 'Tests/LibMatrix.Tests/Abstractions/HomeserverAbstraction.cs')
-rw-r--r-- | Tests/LibMatrix.Tests/Abstractions/HomeserverAbstraction.cs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Tests/LibMatrix.Tests/Abstractions/HomeserverAbstraction.cs b/Tests/LibMatrix.Tests/Abstractions/HomeserverAbstraction.cs index c9727d6..13b5c1b 100644 --- a/Tests/LibMatrix.Tests/Abstractions/HomeserverAbstraction.cs +++ b/Tests/LibMatrix.Tests/Abstractions/HomeserverAbstraction.cs @@ -1,14 +1,17 @@ using ArcaneLibs.Extensions; using LibMatrix.Homeservers; using LibMatrix.Responses; +using LibMatrix.Services; +using Microsoft.Extensions.Logging.Abstractions; namespace LibMatrix.Tests.Abstractions; public static class HomeserverAbstraction { + private static HomeserverResolverService _hsResolver = new HomeserverResolverService(NullLogger<HomeserverResolverService>.Instance); + private static HomeserverProviderService _hsProvider = new HomeserverProviderService(NullLogger<HomeserverProviderService>.Instance, _hsResolver); + public static async Task<AuthenticatedHomeserverGeneric> GetHomeserver() { - var rhs = await RemoteHomeserver.Create("https://matrixunittests.rory.gay"); - // string username = Guid.NewGuid().ToString(); - // string password = Guid.NewGuid().ToString(); + var rhs = await _hsProvider.GetRemoteHomeserver("matrixunittests.rory.gay"); var username = "@f1a2d2d6-1924-421b-91d0-893b347b2a49:matrixunittests.rory.gay"; var password = "d6d782d6-8bc9-4fac-9cd8-78e101b4298b"; LoginResponse reg; @@ -23,8 +26,7 @@ public static class HomeserverAbstraction { else throw new Exception("Failed to register", e); } - var hs = await reg.GetAuthenticatedHomeserver("https://matrixunittests.rory.gay"); - + var hs = await _hsProvider.GetAuthenticatedWithToken(reg.Homeserver, reg.AccessToken); //var rooms = await hs.GetJoinedRooms(); // var disbandRoomTasks = rooms.Select(async room => { @@ -45,9 +47,9 @@ public static class HomeserverAbstraction { } public static async Task<AuthenticatedHomeserverGeneric> GetRandomHomeserver() { - var rhs = await RemoteHomeserver.Create("https://matrixunittests.rory.gay"); + var rhs = await _hsProvider.GetRemoteHomeserver("matrixunittests.rory.gay"); var reg = await rhs.RegisterAsync(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "Unit tests!"); - var hs = await reg.GetAuthenticatedHomeserver("https://matrixunittests.rory.gay"); + var hs = await _hsProvider.GetAuthenticatedWithToken(reg.Homeserver, reg.AccessToken); // var rooms = await hs.GetJoinedRooms(); // |