mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-07-20 12:33:00 +01:00
Fix warnings, test build errors, and disable IDE0290
This commit is contained in:
@@ -668,6 +668,7 @@
|
||||
</Rules>
|
||||
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp.CodeStyle" RuleNamespace="Microsoft.CodeAnalysis.CSharp.CodeStyle">
|
||||
<Rule Id="IDE0028" Action="None" />
|
||||
<Rule Id="IDE0290" Action="None" />
|
||||
<Rule Id="IDE0301" Action="None" />
|
||||
</Rules>
|
||||
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp.EditorFeatures" RuleNamespace="Microsoft.CodeAnalysis.CSharp.EditorFeatures">
|
||||
@@ -754,6 +755,7 @@
|
||||
<Rule Id="IDE0048WithoutSuggestion" Action="Warning" />
|
||||
<Rule Id="IDE0049" Action="None" />
|
||||
<Rule Id="IDE0049WithoutSuggestion" Action="None" />
|
||||
<Rule Id="IDE0290" Action="None" />
|
||||
<Rule Id="IDE0301" Action="None" />
|
||||
<Rule Id="IDE1005" Action="Warning" />
|
||||
<Rule Id="IDE1005WithoutSuggestion" Action="Warning" />
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Tgstation.Server.Host.GraphQL.Types;
|
||||
using System.Linq;
|
||||
|
||||
using Tgstation.Server.Host.GraphQL.Types;
|
||||
|
||||
namespace Tgstation.Server.Host.GraphQL.Interfaces
|
||||
{
|
||||
@@ -12,5 +14,11 @@ namespace Tgstation.Server.Host.GraphQL.Interfaces
|
||||
/// </summary>
|
||||
/// <returns>The <see cref="GatewayInformation"/> for the <see cref="IGateway"/>.</returns>
|
||||
GatewayInformation Information();
|
||||
|
||||
/// <summary>
|
||||
/// Queries all <see cref="Instance"/>s in the <see cref="IGateway"/>.
|
||||
/// </summary>
|
||||
/// <returns>Queryable <see cref="Instance"/>s.</returns>
|
||||
IQueryable<Instance> Instances();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,15 @@ using System.Linq;
|
||||
|
||||
namespace Tgstation.Server.Host.GraphQL.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a game server instance.
|
||||
/// </summary>
|
||||
public sealed class Instance : Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// Queries all <see cref="InstancePermissionSet"/>s in the <see cref="Instance"/>.
|
||||
/// </summary>
|
||||
/// <returns>Queryable <see cref="InstancePermissionSet"/>s.</returns>
|
||||
public IQueryable<InstancePermissionSet> QueryableInstancePermissionSets()
|
||||
=> throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Tgstation.Server.Host.GraphQL.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a set of permissions for an <see cref="Instance"/>.
|
||||
/// </summary>
|
||||
public sealed class InstancePermissionSet
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
|
||||
/// <inheritdoc />
|
||||
public GatewayInformation Information() => new();
|
||||
|
||||
/// <inheritdoc />
|
||||
public IQueryable<Instance> Instances()
|
||||
=> throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using Tgstation.Server.Host.GraphQL.Interfaces;
|
||||
|
||||
@@ -12,5 +13,8 @@ namespace Tgstation.Server.Host.GraphQL.Types
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public GatewayInformation Information() => throw new NotImplementedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public IQueryable<Instance> Instances() => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,9 @@ namespace Tgstation.Server.Host.Security
|
||||
public void Dispose() => currentAuthenticationContext.Dispose();
|
||||
|
||||
/// <inheritdoc />
|
||||
#pragma warning disable CA1506 // TODO: Decomplexify
|
||||
public async Task ValidateToken(TokenValidatedContext tokenValidatedContext, CancellationToken cancellationToken)
|
||||
#pragma warning restore CA1506
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(tokenValidatedContext);
|
||||
|
||||
@@ -190,8 +192,7 @@ namespace Tgstation.Server.Host.Security
|
||||
currentAuthenticationContext.Initialize(
|
||||
user,
|
||||
expires,
|
||||
// signature is enough to uniquely identify the session as it is composite of all the inputs
|
||||
jwt.EncodedSignature,
|
||||
jwt.EncodedSignature, // signature is enough to uniquely identify the session as it is composite of all the inputs
|
||||
instancePermissionSet,
|
||||
systemIdentity);
|
||||
}
|
||||
|
||||
@@ -13,32 +13,6 @@ namespace Tgstation.Server.Host.Security.Tests
|
||||
[TestClass]
|
||||
public sealed class TestAuthenticationContext
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestConstruction()
|
||||
{
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new AuthenticationContext().Initialize(null, null, null));
|
||||
var mockSystemIdentity = new Mock<ISystemIdentity>();
|
||||
|
||||
var user = new User()
|
||||
{
|
||||
PermissionSet = new PermissionSet()
|
||||
};
|
||||
|
||||
var authContext = new AuthenticationContext();
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new AuthenticationContext().Initialize(mockSystemIdentity.Object, null, null));
|
||||
|
||||
var instanceUser = new InstancePermissionSet();
|
||||
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new AuthenticationContext().Initialize(null, null, instanceUser));
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new AuthenticationContext().Initialize(mockSystemIdentity.Object, null, instanceUser));
|
||||
new AuthenticationContext().Initialize(mockSystemIdentity.Object, user, null);
|
||||
new AuthenticationContext().Initialize(null, user, instanceUser);
|
||||
new AuthenticationContext().Initialize(mockSystemIdentity.Object, user, instanceUser);
|
||||
user.SystemIdentifier = "root";
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new AuthenticationContext().Initialize(null, user, null));
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void TestGetRightsGeneric()
|
||||
{
|
||||
@@ -48,7 +22,7 @@ namespace Tgstation.Server.Host.Security.Tests
|
||||
};
|
||||
var instanceUser = new InstancePermissionSet();
|
||||
var authContext = new AuthenticationContext();
|
||||
authContext.Initialize(null, user, instanceUser);
|
||||
authContext.Initialize(user, DateTimeOffset.UtcNow, "asdf", instanceUser, null);
|
||||
|
||||
user.PermissionSet.AdministrationRights = AdministrationRights.WriteUsers;
|
||||
instanceUser.EngineRights = EngineRights.InstallOfficialOrChangeActiveByondVersion | EngineRights.ReadActive;
|
||||
|
||||
Reference in New Issue
Block a user