mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-07-20 20:43:47 +01:00
+1
-1
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<!-- This is the authorative version list -->
|
||||
<!-- Integration tests will ensure they match across the board -->
|
||||
<TgsCoreVersion>4.1.0</TgsCoreVersion>
|
||||
<TgsCoreVersion>4.1.1</TgsCoreVersion>
|
||||
<TgsApiVersion>6.1.0</TgsApiVersion>
|
||||
<TgsClientVersion>6.0.0</TgsClientVersion>
|
||||
<TgsDmapiVersion>5.0.0</TgsDmapiVersion>
|
||||
|
||||
@@ -87,8 +87,8 @@ namespace Tgstation.Server.Host.Controllers
|
||||
if (countOfExistingBotsInInstance >= Instance.ChatBotLimit.Value)
|
||||
return Conflict(new ErrorMessage(ErrorCode.ChatBotMax));
|
||||
|
||||
model.Enabled = model.Enabled ?? false;
|
||||
model.ReconnectionInterval = model.ReconnectionInterval ?? 1;
|
||||
model.Enabled ??= false;
|
||||
model.ReconnectionInterval ??= 1;
|
||||
|
||||
// try to update das db first
|
||||
var dbModel = new Models.ChatBot
|
||||
@@ -264,6 +264,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
|| CheckModified(x => x.Name, ChatBotRights.WriteName)
|
||||
|| CheckModified(x => x.Provider, ChatBotRights.WriteProvider)
|
||||
|| CheckModified(x => x.ReconnectionInterval, ChatBotRights.WriteReconnectionInterval)
|
||||
|| CheckModified(x => x.ChannelLimit, ChatBotRights.WriteChannelLimit)
|
||||
|| (model.Channels != null && !userRights.HasFlag(ChatBotRights.WriteChannels)))
|
||||
return Forbid();
|
||||
|
||||
@@ -329,7 +330,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
return BadRequest(new ErrorMessage(ErrorCode.ChatBotMaxChannels));
|
||||
|
||||
if (forCreation)
|
||||
model.ChannelLimit = model.ChannelLimit ?? (ushort)defaultMaxChannels;
|
||||
model.ChannelLimit ??= (ushort)defaultMaxChannels;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
/// <response code="200">Instance updated successfully.</response>
|
||||
/// <response code="202">Instance updated successfully and relocation job created.</response>
|
||||
[HttpPost]
|
||||
[TgsAuthorize(InstanceManagerRights.Relocate | InstanceManagerRights.Rename | InstanceManagerRights.SetAutoUpdate | InstanceManagerRights.SetConfiguration | InstanceManagerRights.SetOnline)]
|
||||
[TgsAuthorize(InstanceManagerRights.Relocate | InstanceManagerRights.Rename | InstanceManagerRights.SetAutoUpdate | InstanceManagerRights.SetConfiguration | InstanceManagerRights.SetOnline | InstanceManagerRights.SetChatBotLimit)]
|
||||
[ProducesResponseType(typeof(Api.Models.Instance), 200)]
|
||||
[ProducesResponseType(typeof(Api.Models.Instance), 202)]
|
||||
[ProducesResponseType(410)]
|
||||
|
||||
@@ -196,6 +196,10 @@ namespace Tgstation.Server.Tests.Instance
|
||||
var instance = metadata.CloneMetadata();
|
||||
instance.ChatBotLimit = 0;
|
||||
await ApiAssert.ThrowsException<ConflictException>(() => instanceClient.Update(instance, cancellationToken), ErrorCode.ChatBotMax);
|
||||
|
||||
discordBot.ChannelLimit = 20;
|
||||
discordBot.Channels = null;
|
||||
await chatClient.Update(discordBot, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Api.Rights;
|
||||
using Tgstation.Server.Client;
|
||||
using Tgstation.Server.Host.Controllers;
|
||||
using Tgstation.Server.Tests.Instance;
|
||||
@@ -14,13 +15,15 @@ namespace Tgstation.Server.Tests
|
||||
sealed class InstanceManagerTest
|
||||
{
|
||||
readonly IInstanceManagerClient instanceManagerClient;
|
||||
readonly IUsersClient usersClient;
|
||||
readonly string testRootPath;
|
||||
|
||||
long counter;
|
||||
|
||||
public InstanceManagerTest(IInstanceManagerClient instanceManagerClient, string testRootPath)
|
||||
public InstanceManagerTest(IInstanceManagerClient instanceManagerClient, IUsersClient usersClient, string testRootPath)
|
||||
{
|
||||
this.instanceManagerClient = instanceManagerClient ?? throw new ArgumentNullException(nameof(instanceManagerClient));
|
||||
this.usersClient = usersClient ?? throw new ArgumentNullException(nameof(usersClient));
|
||||
this.testRootPath = testRootPath ?? throw new ArgumentNullException(nameof(testRootPath));
|
||||
|
||||
counter = 0;
|
||||
@@ -110,7 +113,7 @@ namespace Tgstation.Server.Tests
|
||||
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken).ConfigureAwait(false);
|
||||
} while (firstTest.MoveJob != null);
|
||||
|
||||
|
||||
|
||||
//online it for real for component tests
|
||||
firstTest.Online = true;
|
||||
firstTest.ConfigurationType = ConfigurationType.HostWrite;
|
||||
@@ -152,10 +155,28 @@ namespace Tgstation.Server.Tests
|
||||
var instanceAttachFileName = (string)typeof(InstanceController).GetField("InstanceAttachFileName", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
|
||||
var attachPath = Path.Combine(firstTest.Path, instanceAttachFileName);
|
||||
Assert.IsTrue(File.Exists(attachPath));
|
||||
|
||||
|
||||
//can recreate detached instance
|
||||
firstTest = await instanceManagerClient.CreateOrAttach(firstTest, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// Test updating only with SetChatBotLimit works
|
||||
var current = await usersClient.Read(cancellationToken);
|
||||
var update = new UserUpdate
|
||||
{
|
||||
Id = current.Id,
|
||||
InstanceManagerRights = InstanceManagerRights.SetChatBotLimit
|
||||
};
|
||||
await usersClient.Update(update, cancellationToken);
|
||||
var update2 = new Api.Models.Instance
|
||||
{
|
||||
Id = firstTest.Id,
|
||||
ChatBotLimit = 77
|
||||
};
|
||||
var newThing = await instanceManagerClient.Update(update2, cancellationToken);
|
||||
|
||||
update.InstanceManagerRights |= InstanceManagerRights.Delete | InstanceManagerRights.Create;
|
||||
await usersClient.Update(update, cancellationToken);
|
||||
|
||||
//but only if the attach file exists
|
||||
await instanceManagerClient.Detach(firstTest, cancellationToken).ConfigureAwait(false);
|
||||
File.Delete(attachPath);
|
||||
|
||||
@@ -78,8 +78,6 @@ namespace Tgstation.Server.Tests
|
||||
Assert.IsTrue(discordProvider.Connected, "Discord provider not connected!");
|
||||
}
|
||||
|
||||
// Disabled until 4.1.0 due to changes in version handling
|
||||
[Ignore]
|
||||
[TestMethod]
|
||||
public async Task TestServerUpdate()
|
||||
{
|
||||
@@ -125,7 +123,7 @@ namespace Tgstation.Server.Tests
|
||||
}
|
||||
} while (true);
|
||||
|
||||
var testUpdateVersion = new Version(4, 0, 0, 6);
|
||||
var testUpdateVersion = new Version(4, 1, 0);
|
||||
using (adminClient)
|
||||
//attempt to update to stable
|
||||
await adminClient.Administration.Update(new Administration
|
||||
@@ -144,7 +142,7 @@ namespace Tgstation.Server.Tests
|
||||
Assert.IsTrue(File.Exists(updatedAssemblyPath), "Updated assembly missing!");
|
||||
|
||||
var updatedAssemblyVersion = FileVersionInfo.GetVersionInfo(updatedAssemblyPath);
|
||||
Assert.AreEqual(testUpdateVersion, Version.Parse(updatedAssemblyVersion.FileVersion));
|
||||
Assert.AreEqual(testUpdateVersion, Version.Parse(updatedAssemblyVersion.FileVersion).Semver());
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -222,7 +220,7 @@ namespace Tgstation.Server.Tests
|
||||
|
||||
var adminTest = new AdministrationTest(adminClient.Administration).Run(cancellationToken);
|
||||
var usersTest = new UsersTest(adminClient.Users).Run(cancellationToken);
|
||||
await new InstanceManagerTest(adminClient.Instances, server.Directory).Run(cancellationToken).ConfigureAwait(false);
|
||||
await new InstanceManagerTest(adminClient.Instances, adminClient.Users, server.Directory).Run(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
await adminTest.ConfigureAwait(false);
|
||||
await usersTest.ConfigureAwait(false);
|
||||
|
||||
Reference in New Issue
Block a user