From 1f265d1505835fdf2bf5b79f5b332a88debe1a8b Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Fri, 28 Sep 2018 15:57:59 -0400 Subject: [PATCH] Add integration test for restoring lost instance user permissions --- tests/Tgstation.Server.Tests/InstanceManagerTest.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Tgstation.Server.Tests/InstanceManagerTest.cs b/tests/Tgstation.Server.Tests/InstanceManagerTest.cs index 3464217fd6..0c9efe68b9 100644 --- a/tests/Tgstation.Server.Tests/InstanceManagerTest.cs +++ b/tests/Tgstation.Server.Tests/InstanceManagerTest.cs @@ -93,6 +93,19 @@ namespace Tgstation.Server.Tests var testSuite1 = new InstanceTest(instanceManagerClient.CreateClient(firstTest)); await testSuite1.RunTests(cancellationToken).ConfigureAwait(false); + //can regain permissions on instance without instance user + var instanceClient = instanceManagerClient.CreateClient(firstTest); + var ourInstanceUser = await instanceClient.Users.Read(cancellationToken).ConfigureAwait(false); + await instanceClient.Users.Delete(ourInstanceUser, cancellationToken).ConfigureAwait(false); + + await Assert.ThrowsExceptionAsync(() => instanceClient.Users.Read(cancellationToken)).ConfigureAwait(false); + + await instanceManagerClient.Update(new Api.Models.Instance + { + Id = firstTest.Id + }, cancellationToken).ConfigureAwait(false); + ourInstanceUser = await instanceClient.Users.Read(cancellationToken).ConfigureAwait(false); + //can't detach online instance await Assert.ThrowsExceptionAsync(() => instanceManagerClient.Detach(firstTest, cancellationToken)).ConfigureAwait(false);