200b84f49a
* Add Instances base (#6) * Use Uri for checks in GetAccounts function (#8) * Add integration and perf tests to sln (#9) * Remove perf tests (#10) * remove perf tests * do all unit tests * Code coverage (#11) * code coverage * enable codecov for GA * Update README.md * Update coverage and dependencies (#12) * Update coverage and dependencies * fmt * add codecov config * merge DUI3/Alpha into sdk (#13) * merge DUI3/Alpha into sdk * formatting * Merge Objects dui3/alpha -> dev (#14) * merge DUI3/Alpha into sdk * formatting * Objects changes * Objects tests * Unit test project * update codecov to be less intrusive (#15) * update codecov to be less intrusive * fix codecov yaml * add coverage exclusion * Merge sharp `dui3/alpha` -> sdk `main` (#16) * Merge * csharpier format * Fixed polysharp issues * Integration Tests * Fixes * Some nullability fixes (#17) * add coverage exclusion * fix some tests and fix nullability errors --------- Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com> Co-authored-by: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com>
88 lines
2.5 KiB
C#
88 lines
2.5 KiB
C#
using GraphQL.Client.Http;
|
|
using Speckle.Core.Api.GraphQL.Models;
|
|
using Speckle.Core.Credentials;
|
|
|
|
namespace Speckle.Core.Tests.Integration.Credentials;
|
|
|
|
public class UserServerInfoTests
|
|
{
|
|
private Account acc;
|
|
|
|
[OneTimeSetUp]
|
|
public async Task Setup()
|
|
{
|
|
acc = await Fixtures.SeedUser();
|
|
}
|
|
|
|
[Test]
|
|
public async Task IsFrontEnd2True()
|
|
{
|
|
ServerInfo? result = await AccountManager.GetServerInfo("https://app.speckle.systems/");
|
|
|
|
Assert.That(result, Is.Not.Null);
|
|
Assert.That(result!.frontend2, Is.True);
|
|
}
|
|
|
|
[Test]
|
|
public async Task IsFrontEnd2False()
|
|
{
|
|
ServerInfo? result = await AccountManager.GetServerInfo("https://speckle.xyz/");
|
|
|
|
Assert.That(result, Is.Not.Null);
|
|
Assert.That(result!.frontend2, Is.False);
|
|
}
|
|
|
|
/// <remarks>
|
|
/// We get ServerInfo from "http://localhost:3000/graphql",
|
|
/// Then we mutate the `frontend2` property of ServerInfo by trying to fetch header from "http://localhost:3000/",
|
|
/// This is not doable in local server because there is no end-point on this to ping.
|
|
/// This is a bad sign for mutation.
|
|
/// </remarks>
|
|
[Test]
|
|
public void GetServerInfo_ExpectFail_CantPing()
|
|
{
|
|
Uri serverUrl = new(acc.serverInfo.url);
|
|
|
|
Assert.ThrowsAsync<HttpRequestException>(async () => await AccountManager.GetServerInfo(serverUrl));
|
|
}
|
|
|
|
[Test]
|
|
public void GetServerInfo_ExpectFail_NoServer()
|
|
{
|
|
Uri serverUrl = new("http://invalidserver.local");
|
|
|
|
Assert.ThrowsAsync<HttpRequestException>(async () => await AccountManager.GetServerInfo(serverUrl));
|
|
}
|
|
|
|
[Test]
|
|
public async Task GetUserInfo()
|
|
{
|
|
Uri serverUrl = new(acc.serverInfo.url);
|
|
UserInfo result = await AccountManager.GetUserInfo(acc.token, serverUrl);
|
|
|
|
Assert.That(result.id, Is.EqualTo(acc.userInfo.id));
|
|
Assert.That(result.name, Is.EqualTo(acc.userInfo.name));
|
|
Assert.That(result.email, Is.EqualTo(acc.userInfo.email));
|
|
Assert.That(result.company, Is.EqualTo(acc.userInfo.company));
|
|
Assert.That(result.avatar, Is.EqualTo(acc.userInfo.avatar));
|
|
}
|
|
|
|
[Test]
|
|
public void GetUserInfo_ExpectFail_NoServer()
|
|
{
|
|
Uri serverUrl = new("http://invalidserver.local");
|
|
|
|
Assert.ThrowsAsync<HttpRequestException>(async () => await AccountManager.GetUserInfo("", serverUrl));
|
|
}
|
|
|
|
[Test]
|
|
public void GetUserInfo_ExpectFail_NoUser()
|
|
{
|
|
Uri serverUrl = new(acc.serverInfo.url);
|
|
|
|
Assert.ThrowsAsync<GraphQLHttpRequestException>(
|
|
async () => await AccountManager.GetUserInfo("Bearer 08913c3c1e7ac65d779d1e1f11b942a44ad9672ca9", serverUrl)
|
|
);
|
|
}
|
|
}
|