borepin/FabAccessAPI_Test/Connection_Test.cs
2022-03-12 22:52:28 +01:00

35 lines
1.2 KiB
C#

using Capnp.Rpc;
using FabAccessAPI;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace FabAccessAPI_Test
{
public class Connection_Test
{
[TestCase("test.fab-access.org", 59661)]
public async Task Connect(string host, int port)
{
TcpRpcClient tcpRpcClient = new TcpRpcClient();
tcpRpcClient.Connect(host, port);
await tcpRpcClient.WhenConnected;
Connection connection = new Connection(tcpRpcClient);
}
[TestCase("test.fab-access.org", 59661, "Testuser", "secret")]
public async Task Authenticate_PLAIN(string host, int port, string username, string password)
{
TcpRpcClient tcpRpcClient = new TcpRpcClient();
tcpRpcClient.Connect(host, port);
await tcpRpcClient.WhenConnected;
Connection connection = new Connection(tcpRpcClient);
await connection.Auth("PLAIN", new Dictionary<string, object>(StringComparer.Ordinal) { { "Username", username }, { "Password", password } });
Assert.IsNotNull(connection.Session);
}
}
}