mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-07-12 00:25:03 +01:00
@@ -287,9 +287,7 @@ namespace Tgstation.Server.Api
|
||||
|
||||
try
|
||||
{
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
Token.ExpiresAt = Token.ParseJwt().ValidTo;
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
Token.ParseJwt();
|
||||
}
|
||||
catch (ArgumentException ex) when (ex is not ArgumentNullException)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
|
||||
@@ -11,28 +10,12 @@ namespace Tgstation.Server.Api.Models
|
||||
public class ChatChannel : ChatChannelBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The channel identifier. Supercedes <see cref="IrcChannel"/> and <see cref="DiscordChannelId"/>.
|
||||
/// The channel identifier.
|
||||
/// For <see cref="ChatProvider.Irc"/>, it's the IRC channel name and optional password colon separated.
|
||||
/// For <see cref="ChatProvider.Discord"/>, it's the stringified Discord channel snowflake.
|
||||
/// </summary>
|
||||
[Required]
|
||||
[StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
|
||||
public string? ChannelData { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The IRC channel name. Also potentially contains the channel passsword (if separated by a colon).
|
||||
/// If multiple copies of the same channel with different keys are added to the server, the one that will be used is undefined.
|
||||
/// </summary>
|
||||
[ResponseOptions]
|
||||
[StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
|
||||
[Obsolete($"Use {nameof(ChannelData)}")]
|
||||
public string? IrcChannel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The Discord channel ID.
|
||||
/// </summary>
|
||||
[Obsolete($"Use {nameof(ChannelData)}")]
|
||||
[ResponseOptions]
|
||||
public ulong? DiscordChannelId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,8 @@ namespace Tgstation.Server.Api.Models.Internal
|
||||
return true;
|
||||
return Provider.Value switch
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
ChatProvider.Discord => Channels?.Select(x => (x.DiscordChannelId.HasValue || ulong.TryParse(x.ChannelData, out _)) && x.IrcChannel == null).All(x => x) ?? true,
|
||||
ChatProvider.Irc => Channels?.Select(x => !x.DiscordChannelId.HasValue && (x.IrcChannel != null || x.ChannelData != null)).All(x => x) ?? true,
|
||||
#pragma warning restore CS0618
|
||||
ChatProvider.Discord => Channels?.All(x => UInt64.TryParse(x.ChannelData, out _)) ?? true,
|
||||
ChatProvider.Irc => Channels?.All(x => x.ChannelData != null && x.ChannelData[0] == '#') ?? true,
|
||||
_ => throw new InvalidOperationException("Invalid provider type!"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Tgstation.Server.Api.Models.Internal
|
||||
namespace Tgstation.Server.Api.Models.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for DreamDaemon API models.
|
||||
@@ -19,21 +16,5 @@ namespace Tgstation.Server.Api.Models.Internal
|
||||
/// </summary>
|
||||
[ResponseOptions]
|
||||
public bool? SoftShutdown { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Deprecated, use <see cref="DreamDaemonLaunchParameters.HealthCheckSeconds"/>.
|
||||
/// </summary>
|
||||
[Required]
|
||||
[ResponseOptions]
|
||||
[Obsolete("Use HealthCheckSeconds")]
|
||||
public uint? HeartbeatSeconds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Deprecated, use <see cref="DreamDaemonLaunchParameters.DumpOnHealthCheckRestart"/>.
|
||||
/// </summary>
|
||||
[Required]
|
||||
[ResponseOptions]
|
||||
[Obsolete("Use DumpOnHealthCheckRestart")]
|
||||
public bool? DumpOnHeartbeatRestart { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,5 @@ namespace Tgstation.Server.Api.Models.Request
|
||||
/// </summary>
|
||||
[RequestOptions(FieldPresence.Required)]
|
||||
public Uri? Origin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If submodules should be recursively cloned. Note that further updates are not recursive.
|
||||
/// </summary>
|
||||
[Obsolete("Use updateSubmodules instead.")]
|
||||
public bool? RecurseSubmodules { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
using Microsoft.IdentityModel.JsonWebTokens;
|
||||
using Microsoft.IdentityModel.JsonWebTokens;
|
||||
|
||||
namespace Tgstation.Server.Api.Models.Response
|
||||
{
|
||||
@@ -14,12 +12,6 @@ namespace Tgstation.Server.Api.Models.Response
|
||||
/// </summary>
|
||||
public string? Bearer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When the <see cref="TokenResponse"/> expires.
|
||||
/// </summary>
|
||||
[Obsolete("Will be removed in a future API version")]
|
||||
public DateTimeOffset? ExpiresAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Parses the <see cref="Bearer"/> as a <see cref="JsonWebToken"/>.
|
||||
/// </summary>
|
||||
|
||||
@@ -69,10 +69,6 @@ namespace Tgstation.Server.Host.Controllers
|
||||
{
|
||||
var result = new Models.ChatChannel
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
DiscordChannelId = api.DiscordChannelId,
|
||||
IrcChannel = api.IrcChannel,
|
||||
#pragma warning restore CS0618
|
||||
IsAdminChannel = api.IsAdminChannel ?? false,
|
||||
IsWatchdogChannel = api.IsWatchdogChannel ?? false,
|
||||
IsUpdatesChannel = api.IsUpdatesChannel ?? false,
|
||||
|
||||
@@ -184,14 +184,6 @@ namespace Tgstation.Server.Host.Controllers
|
||||
return Conflict(new ErrorMessageResponse(ErrorCode.PortNotAvailable));
|
||||
}
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
if (model.HeartbeatSeconds.HasValue && !model.HealthCheckSeconds.HasValue)
|
||||
model.HealthCheckSeconds = model.HeartbeatSeconds;
|
||||
|
||||
if (model.DumpOnHeartbeatRestart.HasValue && !model.DumpOnHealthCheckRestart.HasValue)
|
||||
model.DumpOnHealthCheckRestart = model.DumpOnHeartbeatRestart;
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
var userRights = (DreamDaemonRights)AuthenticationContext.GetRight(RightsType.DreamDaemon);
|
||||
|
||||
bool CheckModified<T>(Expression<Func<Api.Models.Internal.DreamDaemonSettings, T>> expression, DreamDaemonRights requiredRight)
|
||||
@@ -356,10 +348,6 @@ namespace Tgstation.Server.Host.Controllers
|
||||
result.StartupTimeout = settings.StartupTimeout.Value;
|
||||
result.HealthCheckSeconds = settings.HealthCheckSeconds.Value;
|
||||
result.DumpOnHealthCheckRestart = settings.DumpOnHealthCheckRestart.Value;
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
result.HeartbeatSeconds = settings.HealthCheckSeconds.Value;
|
||||
result.DumpOnHeartbeatRestart = settings.DumpOnHealthCheckRestart.Value;
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
result.TopicRequestTimeout = settings.TopicRequestTimeout.Value;
|
||||
result.AdditionalParameters = settings.AdditionalParameters;
|
||||
result.StartProfiler = settings.StartProfiler;
|
||||
|
||||
@@ -99,10 +99,6 @@ namespace Tgstation.Server.Host.Controllers
|
||||
|| ((model.CommitterEmail ?? model.CommitterName) != null && !userRights.HasFlag(RepositoryRights.ChangeCommitter)))
|
||||
return Forbid();
|
||||
|
||||
#pragma warning disable CS0618 // Support for obsolete API field
|
||||
model.UpdateSubmodules ??= model.RecurseSubmodules;
|
||||
#pragma warning restore CS0618
|
||||
|
||||
var currentModel = await DatabaseContext
|
||||
.RepositorySettings
|
||||
.AsQueryable()
|
||||
|
||||
@@ -20,13 +20,13 @@ namespace Tgstation.Server.Host.Models
|
||||
public long ChatSettingsId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="Api.Models.ChatChannel.IrcChannel"/>.
|
||||
/// The IRC channel name.
|
||||
/// </summary>
|
||||
[StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
|
||||
public string IrcChannel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// See <see cref="Api.Models.ChatChannel.DiscordChannelId"/>.
|
||||
/// The Discord channel snowflake.
|
||||
/// </summary>
|
||||
public ulong? DiscordChannelId { get; set; }
|
||||
|
||||
@@ -43,10 +43,6 @@ namespace Tgstation.Server.Host.Models
|
||||
public Api.Models.ChatChannel ToApi(ChatProvider chatProvider) => new Api.Models.ChatChannel
|
||||
{
|
||||
ChannelData = chatProvider == ChatProvider.Discord ? DiscordChannelId.Value.ToString(CultureInfo.InvariantCulture) : IrcChannel,
|
||||
#pragma warning disable CS0618
|
||||
IrcChannel = IrcChannel,
|
||||
DiscordChannelId = DiscordChannelId,
|
||||
#pragma warning restore CS0618
|
||||
IsAdminChannel = IsAdminChannel,
|
||||
IsWatchdogChannel = IsWatchdogChannel,
|
||||
IsUpdatesChannel = IsUpdatesChannel,
|
||||
|
||||
@@ -119,13 +119,10 @@ namespace Tgstation.Server.Host.Security
|
||||
expiry.UtcDateTime,
|
||||
now.UtcDateTime));
|
||||
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var tokenResponse = new TokenResponse
|
||||
{
|
||||
Bearer = tokenHandler.WriteToken(securityToken),
|
||||
ExpiresAt = expiry,
|
||||
};
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
return tokenResponse;
|
||||
}
|
||||
|
||||
@@ -122,9 +122,6 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
IsSystemChannel = true,
|
||||
Tag = "butt2",
|
||||
ChannelData = channelId,
|
||||
#pragma warning disable CS0618
|
||||
IrcChannel = "should_not_be_this!!!JHF*WW(#*(*$&(#*@))("
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
}
|
||||
}, cancellationToken);
|
||||
@@ -137,10 +134,6 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
Assert.AreEqual(true, updatedBot.Channels.First().IsUpdatesChannel);
|
||||
Assert.AreEqual(true, updatedBot.Channels.First().IsWatchdogChannel);
|
||||
Assert.AreEqual("butt2", updatedBot.Channels.First().Tag);
|
||||
#pragma warning disable CS0618
|
||||
Assert.AreEqual(channelId, updatedBot.Channels.First().IrcChannel);
|
||||
Assert.IsNull(updatedBot.Channels.First().DiscordChannelId);
|
||||
#pragma warning restore CS0618
|
||||
Assert.AreEqual(channelId, updatedBot.Channels.First().ChannelData);
|
||||
}
|
||||
|
||||
@@ -224,9 +217,6 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
IsSystemChannel = true,
|
||||
Tag = "butt",
|
||||
ChannelData = channelId.ToString(),
|
||||
#pragma warning disable CS0618
|
||||
DiscordChannelId = 1234,
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
}
|
||||
}, cancellationToken);
|
||||
@@ -239,10 +229,6 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
Assert.AreEqual(true, updatedBot.Channels.First().IsUpdatesChannel);
|
||||
Assert.AreEqual(true, updatedBot.Channels.First().IsWatchdogChannel);
|
||||
Assert.AreEqual("butt", updatedBot.Channels.First().Tag);
|
||||
#pragma warning disable CS0618
|
||||
Assert.AreEqual(channelId, updatedBot.Channels.First().DiscordChannelId);
|
||||
Assert.IsNull(updatedBot.Channels.First().IrcChannel);
|
||||
#pragma warning restore CS0618
|
||||
Assert.AreEqual(channelId.ToString(), updatedBot.Channels.First().ChannelData);
|
||||
}
|
||||
|
||||
|
||||
@@ -617,24 +617,20 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
async Task RunHealthCheckTest(bool checkDump, CancellationToken cancellationToken)
|
||||
{
|
||||
System.Console.WriteLine("TEST: WATCHDOG HEALTH CHECK TEST");
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
|
||||
// Check reverse mapping
|
||||
var status = await instanceClient.DreamDaemon.Update(new DreamDaemonRequest
|
||||
{
|
||||
DumpOnHealthCheckRestart = !checkDump,
|
||||
}, cancellationToken);
|
||||
|
||||
Assert.AreEqual(!checkDump, status.DumpOnHeartbeatRestart);
|
||||
|
||||
// enable health checks
|
||||
status = await instanceClient.DreamDaemon.Update(new DreamDaemonRequest
|
||||
{
|
||||
HealthCheckSeconds = 1,
|
||||
DumpOnHeartbeatRestart = checkDump,
|
||||
DumpOnHealthCheckRestart = checkDump,
|
||||
}, cancellationToken);
|
||||
|
||||
Assert.AreEqual(checkDump, status.DumpOnHeartbeatRestart);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
Assert.AreEqual(checkDump, status.DumpOnHealthCheckRestart);
|
||||
|
||||
var startJob = await StartDD(cancellationToken);
|
||||
@@ -692,8 +688,6 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
|
||||
ddStatus = await instanceClient.DreamDaemon.Read(cancellationToken);
|
||||
Assert.AreEqual(1U, ddStatus.HealthCheckSeconds.Value);
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
Assert.AreEqual(1U, ddStatus.HeartbeatSeconds.Value);
|
||||
if (ddStatus.Status.Value == WatchdogStatus.Offline)
|
||||
{
|
||||
await CheckDMApiFail(ddStatus.ActiveCompileJob, cancellationToken);
|
||||
@@ -708,11 +702,9 @@ namespace Tgstation.Server.Tests.Live.Instance
|
||||
// disable health checks
|
||||
ddStatus = await instanceClient.DreamDaemon.Update(new DreamDaemonRequest
|
||||
{
|
||||
HeartbeatSeconds = 0,
|
||||
HealthCheckSeconds = 0,
|
||||
}, cancellationToken);
|
||||
Assert.AreEqual(0U, ddStatus.HealthCheckSeconds.Value);
|
||||
Assert.AreEqual(0U, ddStatus.HeartbeatSeconds.Value);
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
if (checkDump)
|
||||
{
|
||||
|
||||
@@ -210,13 +210,10 @@ namespace Tgstation.Server.Tests.Live
|
||||
Assert.AreEqual(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), serverInfo.WindowsHost);
|
||||
|
||||
//check that modifying the token even slightly fucks up the auth
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
var newToken = new TokenResponse
|
||||
{
|
||||
ExpiresAt = serverClient.Token.ExpiresAt,
|
||||
Bearer = serverClient.Token.Bearer + '0'
|
||||
};
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
var badClient = clientFactory.CreateFromToken(serverClient.Url, newToken);
|
||||
await ApiAssert.ThrowsException<UnauthorizedException, AdministrationResponse>(() => badClient.Administration.Read(cancellationToken));
|
||||
|
||||
Reference in New Issue
Block a user