From eaf079f4676fca5a5d9543e82cf4d5bb5ee4c71e Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 20 Aug 2018 15:38:34 -0400 Subject: [PATCH] Removes ModelAttribute and Permissions Attribute Ancient prototypes gone astray --- src/Tgstation.Server.Api/ModelAttribute.cs | 53 ------------------- .../Models/Administration.cs | 4 -- src/Tgstation.Server.Api/Models/Byond.cs | 3 -- src/Tgstation.Server.Api/Models/ChatBot.cs | 1 - .../Models/ConfigurationFile.cs | 5 -- .../Models/DreamDaemon.cs | 6 --- src/Tgstation.Server.Api/Models/DreamMaker.cs | 1 - src/Tgstation.Server.Api/Models/Instance.cs | 8 --- .../Models/InstanceUser.cs | 2 - .../Models/Internal/ChatBot.cs | 6 --- .../Internal/DreamDaemonLaunchParameters.cs | 6 --- .../Models/Internal/DreamDaemonSettings.cs | 3 -- .../Models/Internal/DreamMakerSettings.cs | 5 +- .../Models/Internal/Job.cs | 9 ---- .../Models/Internal/RepositorySettings.cs | 9 ---- .../Models/Internal/RevisionInformation.cs | 2 - .../Models/Internal/User.cs | 4 -- src/Tgstation.Server.Api/Models/Job.cs | 2 - src/Tgstation.Server.Api/Models/Repository.cs | 8 --- src/Tgstation.Server.Api/Models/User.cs | 1 - .../PermissionsAttribute.cs | 26 --------- .../Controllers/ModelController.cs | 5 -- .../Tgstation.Server.Api.Tests/TestModels.cs | 37 ------------- 23 files changed, 1 insertion(+), 205 deletions(-) delete mode 100644 src/Tgstation.Server.Api/ModelAttribute.cs delete mode 100644 src/Tgstation.Server.Api/PermissionsAttribute.cs delete mode 100644 tests/Tgstation.Server.Api.Tests/TestModels.cs diff --git a/src/Tgstation.Server.Api/ModelAttribute.cs b/src/Tgstation.Server.Api/ModelAttribute.cs deleted file mode 100644 index df50284cf3..0000000000 --- a/src/Tgstation.Server.Api/ModelAttribute.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using Tgstation.Server.Api.Rights; - -namespace Tgstation.Server.Api -{ - /// - /// Indicates the rights for a model - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] - public sealed class ModelAttribute : Attribute - { - /// - /// Right required to read the model - /// - public object ReadRight { get; set; } - - /// - /// Right required to update the model - /// - public object WriteRight { get; set; } - - /// - /// If the Create and Delete actions are available for this model - /// - public bool CanCrud { get; set; } - - /// - /// If the List action is available for this model - /// - public bool CanList { get; set; } - - /// - /// If the actions require an - /// - public bool RequiresInstance { get; set; } - - /// - /// The the model uses - /// - public RightsType RightsType { get; } - - /// - /// Construct a - /// - public ModelAttribute() => CanList = true; - - /// - /// Construct a with a given - /// - /// The value of - public ModelAttribute(RightsType rightsType) => RightsType = rightsType; - } -} diff --git a/src/Tgstation.Server.Api/Models/Administration.cs b/src/Tgstation.Server.Api/Models/Administration.cs index 33f7aa5e5f..d9233de8a4 100644 --- a/src/Tgstation.Server.Api/Models/Administration.cs +++ b/src/Tgstation.Server.Api/Models/Administration.cs @@ -9,25 +9,21 @@ namespace Tgstation.Server.Api.Models /// /// If the server is running on a windows operating system /// - [Permissions(DenyWrite = true)] public bool WindowsHost { get; set; } /// /// The GitHub repository the server is built to recieve updates from /// - [Permissions(DenyWrite = true)] public Uri TrackedRepositoryUrl { get; set; } /// /// The latest available version of the Tgstation.Server.Host assembly from the upstream repository. If is higher than 's the update cannot be applied due to API changes /// - [Permissions(DenyWrite = true)] public Version LatestVersion { get; set; } /// /// Changes the version of Tgstation.Server.Host to the given version from the upstream repository /// - [Permissions(WriteRight = AdministrationRights.ChangeVersion)] public Version NewVersion { get; set; } } } diff --git a/src/Tgstation.Server.Api/Models/Byond.cs b/src/Tgstation.Server.Api/Models/Byond.cs index 9eebf4ddd1..77b69207cb 100644 --- a/src/Tgstation.Server.Api/Models/Byond.cs +++ b/src/Tgstation.Server.Api/Models/Byond.cs @@ -6,19 +6,16 @@ namespace Tgstation.Server.Api.Models /// /// Represents a BYOND installation /// - [Model(RightsType.Byond, RequiresInstance = true)] public sealed class Byond { /// /// The of the installation used for new compiles. Will be if the user does not have permission to view it or there is no BYOND version installed. Only considers the and numbers /// - [Permissions(ReadRight = ByondRights.ReadActive, WriteRight = ByondRights.ChangeVersion)] public Version Version { get; set; } /// /// The being used to install a new /// - [Permissions(DenyWrite = true)] public Job InstallJob { get; set; } } } diff --git a/src/Tgstation.Server.Api/Models/ChatBot.cs b/src/Tgstation.Server.Api/Models/ChatBot.cs index 7c1ee41dd0..5a3c50e5bd 100644 --- a/src/Tgstation.Server.Api/Models/ChatBot.cs +++ b/src/Tgstation.Server.Api/Models/ChatBot.cs @@ -11,7 +11,6 @@ namespace Tgstation.Server.Api.Models /// /// Channels the Discord bot should listen/announce in /// - [Permissions(WriteRight = ChatBotRights.WriteChannels)] public List Channels { get; set; } /// diff --git a/src/Tgstation.Server.Api/Models/ConfigurationFile.cs b/src/Tgstation.Server.Api/Models/ConfigurationFile.cs index 1c27df900c..0d0e9419e3 100644 --- a/src/Tgstation.Server.Api/Models/ConfigurationFile.cs +++ b/src/Tgstation.Server.Api/Models/ConfigurationFile.cs @@ -6,31 +6,26 @@ namespace Tgstation.Server.Api.Models /// /// Represents a game configuration file. Create and delete actions uncerimonuously overwrite/delete files /// - [Model(RightsType.Configuration, CanCrud = true, CanList = true, RequiresInstance = true, ReadRight = ConfigurationRights.Read, WriteRight = ConfigurationRights.Write)] public sealed class ConfigurationFile { /// /// The path to the file /// - [Permissions(DenyWrite = true)] public string Path { get; set; } /// /// If access to the file was denied for the operation /// - [Permissions(DenyWrite = true)] public bool? AccessDenied { get; set; } /// /// If represents a directory /// - [Permissions(DenyWrite = true)] public bool? IsDirectory { get; set; } /// /// The MD5 hash of the file when last read by the user. If this doesn't match during update actions, the write will be denied with /// - [Permissions(DenyWrite = true)] public string LastReadHash { get; set; } /// diff --git a/src/Tgstation.Server.Api/Models/DreamDaemon.cs b/src/Tgstation.Server.Api/Models/DreamDaemon.cs index 3ca0f22d87..b977ff7086 100644 --- a/src/Tgstation.Server.Api/Models/DreamDaemon.cs +++ b/src/Tgstation.Server.Api/Models/DreamDaemon.cs @@ -11,37 +11,31 @@ namespace Tgstation.Server.Api.Models /// /// The live revision /// - [Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadRevision)] public CompileJob ActiveCompileJob { get; set; } /// /// The next revision to go live /// - [Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadRevision)] public CompileJob StagedCompileJob { get; set; } /// /// The current status of /// - [Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadMetadata)] public bool? Running { get; set; } /// /// The current of /// - [Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadMetadata)] public DreamDaemonSecurity? CurrentSecurity { get; set; } /// /// The port the running instance is set to /// - [Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadMetadata)] public ushort? CurrentPort { get; set; } /// /// The webclient status the running instance is set to /// - [Permissions(DenyWrite = true, ReadRight = DreamDaemonRights.ReadMetadata)] public bool? CurrentAllowWebclient { get; set; } } } diff --git a/src/Tgstation.Server.Api/Models/DreamMaker.cs b/src/Tgstation.Server.Api/Models/DreamMaker.cs index 121d4b2d52..ca4d092f7d 100644 --- a/src/Tgstation.Server.Api/Models/DreamMaker.cs +++ b/src/Tgstation.Server.Api/Models/DreamMaker.cs @@ -10,7 +10,6 @@ namespace Tgstation.Server.Api.Models /// /// The of the compiler /// - [Permissions(DenyWrite = true)] public CompilerStatus Status { get; set; } } } diff --git a/src/Tgstation.Server.Api/Models/Instance.cs b/src/Tgstation.Server.Api/Models/Instance.cs index 38abfd9e52..1d89cd1fab 100644 --- a/src/Tgstation.Server.Api/Models/Instance.cs +++ b/src/Tgstation.Server.Api/Models/Instance.cs @@ -7,52 +7,44 @@ namespace Tgstation.Server.Api.Models /// /// Metadata about a server instance /// - [Model(RightsType.InstanceManager, CanCrud = true, CanList = true)] public class Instance { /// /// The id of the . Not modifiable /// - [Permissions(DenyWrite = true)] public long Id { get; set; } /// /// The name of the /// - [Permissions(WriteRight = InstanceManagerRights.Rename)] [Required] public string Name { get; set; } /// /// The path to where the is located. Can only be changed while the is offline. Must not exist when the instance is created /// - [Permissions(WriteRight = InstanceManagerRights.Relocate)] [Required] public string Path { get; set; } /// /// If the is online /// - [Permissions(WriteRight = InstanceManagerRights.SetOnline)] public bool? Online { get; set; } /// /// If can be used on the /// - [Permissions(WriteRight = InstanceManagerRights.SetConfiguration)] [Required] public ConfigurationType? ConfigurationType { get; set; } /// /// The time interval in minutes the repository is automatically pulled and compiles /// - [Permissions(WriteRight = InstanceManagerRights.SetAutoUpdate)] public int? AutoUpdateInterval { get; set; } /// /// The representing a change of /// - [Permissions(DenyWrite = true)] [NotMapped] public Job MoveJob { get; set; } diff --git a/src/Tgstation.Server.Api/Models/InstanceUser.cs b/src/Tgstation.Server.Api/Models/InstanceUser.cs index 14727e9812..a77d6640b8 100644 --- a/src/Tgstation.Server.Api/Models/InstanceUser.cs +++ b/src/Tgstation.Server.Api/Models/InstanceUser.cs @@ -6,13 +6,11 @@ namespace Tgstation.Server.Api.Models /// /// Represents a s permissions in an /// - [Model(RightsType.InstanceUser, WriteRight = Rights.InstanceUserRights.WriteUsers, CanList = true, RequiresInstance = true)] public class InstanceUser { /// /// The of the the belongs to /// - [Permissions(DenyWrite = true)] [Required] public long? UserId { get; set; } diff --git a/src/Tgstation.Server.Api/Models/Internal/ChatBot.cs b/src/Tgstation.Server.Api/Models/Internal/ChatBot.cs index 87e7083b64..c14ec06c53 100644 --- a/src/Tgstation.Server.Api/Models/Internal/ChatBot.cs +++ b/src/Tgstation.Server.Api/Models/Internal/ChatBot.cs @@ -6,38 +6,32 @@ namespace Tgstation.Server.Api.Models.Internal /// /// Manage the server chat bots /// - [Model(RightsType.ChatBots, RequiresInstance = true, CanList = true, CanCrud = true, ReadRight = ChatBotRights.Read)] public class ChatBot { /// /// The settings id /// - [Permissions(DenyWrite = true)] public long Id { get; set; } /// /// The name of the connection /// - [Permissions(WriteRight = ChatBotRights.WriteName)] [Required] public string Name { get; set; } /// /// If the connection is enabled /// - [Permissions(WriteRight = ChatBotRights.WriteEnabled)] public bool? Enabled { get; set; } /// /// The used for the connection /// - [Permissions(WriteRight = ChatBotRights.WriteProvider)] public ChatProvider? Provider { get; set; } /// /// The information used to connect to the /// - [Permissions(ReadRight = ChatBotRights.ReadConnectionString, WriteRight = ChatBotRights.ReadConnectionString)] [Required] public string ConnectionString { get; set; } } diff --git a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs index 093277987d..c3ad8ccca0 100644 --- a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs +++ b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonLaunchParameters.cs @@ -6,41 +6,35 @@ namespace Tgstation.Server.Api.Models.Internal /// /// Launch settings for DreamDaemon /// - [Model(RightsType.DreamDaemon, CanCrud = true, RequiresInstance = true)] public class DreamDaemonLaunchParameters { /// /// If the BYOND web client can be used to connect to the game server /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetWebClient)] [Required] public bool? AllowWebClient { get; set; } /// /// The level of /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetSecurity)] [Required] public DreamDaemonSecurity? SecurityLevel { get; set; } /// /// The first port uses. This should be the publically advertised port /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetPorts)] [Required] public ushort? PrimaryPort { get; set; } /// /// The second port uses /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetPorts)] [Required] public ushort? SecondaryPort { get; set; } /// /// The DreamDaemon startup timeout in seconds /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetStartupTimeout)] [Required] public uint? StartupTimeout { get; set; } } diff --git a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonSettings.cs b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonSettings.cs index 72260ee5fc..dd55b85977 100644 --- a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonSettings.cs +++ b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonSettings.cs @@ -11,21 +11,18 @@ namespace Tgstation.Server.Api.Models.Internal /// /// If starts when it's starts /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetAutoStart)] [Required] public bool? AutoStart { get; set; } /// /// If the server is undergoing a soft reset. This may be automatically set by changes to other fields /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SoftRestart)] [Required] public bool? SoftRestart { get; set; } /// /// If the server is undergoing a soft shutdown /// - [Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SoftShutdown)] [Required] public bool? SoftShutdown { get; set; } } diff --git a/src/Tgstation.Server.Api/Models/Internal/DreamMakerSettings.cs b/src/Tgstation.Server.Api/Models/Internal/DreamMakerSettings.cs index 86ad593915..7867023ebe 100644 --- a/src/Tgstation.Server.Api/Models/Internal/DreamMakerSettings.cs +++ b/src/Tgstation.Server.Api/Models/Internal/DreamMakerSettings.cs @@ -6,19 +6,16 @@ namespace Tgstation.Server.Api.Models.Internal /// /// Configurable settings for /// - [Model(RightsType.DreamMaker, ReadRight = DreamMakerRights.Read, CanCrud = true, RequiresInstance = true)] public class DreamMakerSettings { /// /// The .dme file tries to compile with without the extension /// - [Permissions(WriteRight = DreamMakerRights.SetDme)] public string ProjectName { get; set; } /// - /// The port used during compilation to validate the TGS API + /// The port used during compilation to validate the DMAPI /// - [Permissions(WriteRight = DreamMakerRights.SetApiValidationPort)] [Required] public ushort? ApiValidationPort { get; set; } } diff --git a/src/Tgstation.Server.Api/Models/Internal/Job.cs b/src/Tgstation.Server.Api/Models/Internal/Job.cs index 42c6b071a6..e64bb68115 100644 --- a/src/Tgstation.Server.Api/Models/Internal/Job.cs +++ b/src/Tgstation.Server.Api/Models/Internal/Job.cs @@ -7,58 +7,49 @@ namespace Tgstation.Server.Api.Models.Internal /// /// Represents a long running job /// - [Model(RequiresInstance = true)] public class Job { /// /// The ID /// - [Permissions(DenyWrite = true)] public long Id { get; set; } /// /// English description of the /// - [Permissions(DenyWrite = true)] [Required] public string Description { get; set; } /// /// Details of any exceptions caught during the /// - [Permissions(DenyWrite = true)] public string ExceptionDetails { get; set; } /// /// When the was started /// - [Permissions(DenyWrite = true)] [Required] public DateTimeOffset? StartedAt { get; set; } /// /// When the stopped /// - [Permissions(DenyWrite = true)] public DateTimeOffset? StoppedAt { get; set; } /// /// If the was cancelled /// - [Permissions(DenyWrite = true)] [Required] public bool? Cancelled { get; set; } /// /// The of if it can be cancelled /// - [Permissions(DenyWrite = true)] public RightsType? CancelRightsType { get; set; } /// /// The required to cancel the /// - [Permissions(DenyWrite = true)] public ulong? CancelRight { get; set; } } } \ No newline at end of file diff --git a/src/Tgstation.Server.Api/Models/Internal/RepositorySettings.cs b/src/Tgstation.Server.Api/Models/Internal/RepositorySettings.cs index 14dac247ab..416934f2b2 100644 --- a/src/Tgstation.Server.Api/Models/Internal/RepositorySettings.cs +++ b/src/Tgstation.Server.Api/Models/Internal/RepositorySettings.cs @@ -6,60 +6,51 @@ namespace Tgstation.Server.Api.Models.Internal /// /// Represents configurable settings for a /// - [Model(RightsType.Repository, ReadRight = RepositoryRights.Read, RequiresInstance = true)] public class RepositorySettings { /// /// The name of the committer /// - [Permissions(WriteRight = RepositoryRights.ChangeCommitter)] [Required] public string CommitterName { get; set; } /// /// The e-mail of the committer /// - [Permissions(WriteRight = RepositoryRights.ChangeCommitter)] [Required] public string CommitterEmail { get; set; } /// /// The username to access the git repository with /// - [Permissions(ReadRight = RepositoryRights.ChangeCredentials, WriteRight = RepositoryRights.ChangeCredentials)] public string AccessUser { get; set; } /// /// The token/password to access the git repository with /// - [Permissions(ReadRight = RepositoryRights.ChangeCredentials, WriteRight = RepositoryRights.ChangeCredentials)] public string AccessToken { get; set; } /// /// If commits created from testmerges are pushed to the remote /// - [Permissions(WriteRight = RepositoryRights.ChangeTestMergeCommits)] [Required] public bool? PushTestMergeCommits { get; set; } /// /// If test merge commits are signed with the username of the person who merged it. Note this only affects future commits /// - [Permissions(WriteRight = RepositoryRights.ChangeTestMergeCommits)] [Required] public bool? ShowTestMergeCommitters { get; set; } /// /// If test merge commits should be kept when auto updating. May cause merge conflicts which will block the update /// - [Permissions(WriteRight = RepositoryRights.ChangeTestMergeCommits)] [Required] public bool? AutoUpdatesKeepTestMerges { get; set; } /// /// If synchronization should occur when auto updating /// - [Permissions(WriteRight = RepositoryRights.ChangeTestMergeCommits)] [Required] public bool? AutoUpdatesSynchronize { get; set; } } diff --git a/src/Tgstation.Server.Api/Models/Internal/RevisionInformation.cs b/src/Tgstation.Server.Api/Models/Internal/RevisionInformation.cs index 159201a17d..e1331a1029 100644 --- a/src/Tgstation.Server.Api/Models/Internal/RevisionInformation.cs +++ b/src/Tgstation.Server.Api/Models/Internal/RevisionInformation.cs @@ -10,14 +10,12 @@ namespace Tgstation.Server.Api.Models.Internal /// /// The revision sha /// - [Permissions(DenyWrite = true)] [Required, StringLength(40)] public string CommitSha { get; set; } /// /// The sha of the most recent remote commit /// - [Permissions(DenyWrite = true)] [Required, StringLength(40)] public string OriginCommitSha { get; set; } } diff --git a/src/Tgstation.Server.Api/Models/Internal/User.cs b/src/Tgstation.Server.Api/Models/Internal/User.cs index 1e6ab36b2e..e80d8b0cca 100644 --- a/src/Tgstation.Server.Api/Models/Internal/User.cs +++ b/src/Tgstation.Server.Api/Models/Internal/User.cs @@ -7,13 +7,11 @@ namespace Tgstation.Server.Api.Models.Internal /// /// Represents a server /// - [Model(RightsType.Administration, WriteRight = Rights.AdministrationRights.EditUsers, CanCrud = true)] public class User { /// /// The ID of the /// - [Permissions(DenyWrite = true)] public long Id { get; set; } /// @@ -25,14 +23,12 @@ namespace Tgstation.Server.Api.Models.Internal /// /// When the was created /// - [Permissions(DenyWrite = true)] [Required] public DateTimeOffset? CreatedAt { get; set; } /// /// The SID/UID of the on Windows/POSIX respectively /// - [Permissions(DenyWrite = true)] public string SystemIdentifier { get; set; } /// diff --git a/src/Tgstation.Server.Api/Models/Job.cs b/src/Tgstation.Server.Api/Models/Job.cs index 3ac1549daa..ad4e1372ab 100644 --- a/src/Tgstation.Server.Api/Models/Job.cs +++ b/src/Tgstation.Server.Api/Models/Job.cs @@ -8,13 +8,11 @@ /// /// The that started the job /// - [Permissions(DenyWrite = true)] public User StartedBy { get; set; } /// /// The that cancelled the job /// - [Permissions(DenyWrite = true)] public User CancelledBy { get; set; } /// diff --git a/src/Tgstation.Server.Api/Models/Repository.cs b/src/Tgstation.Server.Api/Models/Repository.cs index 9b65efa513..d6e6a82ab3 100644 --- a/src/Tgstation.Server.Api/Models/Repository.cs +++ b/src/Tgstation.Server.Api/Models/Repository.cs @@ -11,49 +11,41 @@ namespace Tgstation.Server.Api.Models /// /// The origin URL. If , the does not exist /// - [Permissions(WriteRight = RepositoryRights.SetOrigin)] public string Origin { get; set; } /// /// The commit HEAD should point to. Not populated in responses, use instead for retrieval /// - [Permissions(WriteRight = RepositoryRights.SetSha)] public string CheckoutSha { get; set; } /// /// The current for the /// - [Permissions(DenyWrite = true)] public RevisionInformation RevisionInformation { get; set; } /// /// If the repository was cloned from GitHub.com. If this enables test merge functionality /// - [Permissions(DenyWrite = true)] public bool? IsGitHub { get; set; } /// /// The started by the if any /// - [Permissions(DenyWrite = true)] public Job ActiveJob { get; set; } /// /// Do the equivalent of a git pull. Will attempt to merge unless is also specified in which case a hard reset will be performed after checking out /// - [Permissions(WriteRight = RepositoryRights.UpdateBranch)] public bool? UpdateFromOrigin { get; set; } /// /// The branch or tag HEAD points to /// - [Permissions(WriteRight = RepositoryRights.SetReference)] public string Reference { get; set; } /// /// for new s. Note that merges that conflict will not be performed /// - [Permissions(WriteRight = RepositoryRights.MergePullRequest)] public List NewTestMerges { get; set; } } } \ No newline at end of file diff --git a/src/Tgstation.Server.Api/Models/User.cs b/src/Tgstation.Server.Api/Models/User.cs index 1431dd2db9..3382bba8f5 100644 --- a/src/Tgstation.Server.Api/Models/User.cs +++ b/src/Tgstation.Server.Api/Models/User.cs @@ -16,7 +16,6 @@ /// /// The who created this /// - [Permissions(DenyWrite = true)] public User CreatedBy { get; set; } } } \ No newline at end of file diff --git a/src/Tgstation.Server.Api/PermissionsAttribute.cs b/src/Tgstation.Server.Api/PermissionsAttribute.cs deleted file mode 100644 index 7d4962758f..0000000000 --- a/src/Tgstation.Server.Api/PermissionsAttribute.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace Tgstation.Server.Api -{ - /// - /// Indicates permissions for model fields - /// - [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] - public sealed class PermissionsAttribute : Attribute - { - /// - /// Right required to read the field - /// - public object ReadRight { get; set; } - - /// - /// Right required to update the field - /// - public object WriteRight { get; set; } - - /// - /// If the field cannot be written to - /// - public bool DenyWrite { get; set; } - } -} diff --git a/src/Tgstation.Server.Host/Controllers/ModelController.cs b/src/Tgstation.Server.Host/Controllers/ModelController.cs index dbc2c704d4..ba701b57d1 100644 --- a/src/Tgstation.Server.Host/Controllers/ModelController.cs +++ b/src/Tgstation.Server.Host/Controllers/ModelController.cs @@ -15,11 +15,6 @@ namespace Tgstation.Server.Host.Controllers /// The model being represented public abstract class ModelController : ApiController where TModel : class { - /// - /// The of the - /// - protected static readonly ModelAttribute ModelAttribute = (ModelAttribute)typeof(TModel).GetCustomAttributes(typeof(ModelAttribute), true).First(); - /// /// Construct a /// diff --git a/tests/Tgstation.Server.Api.Tests/TestModels.cs b/tests/Tgstation.Server.Api.Tests/TestModels.cs deleted file mode 100644 index c86f7070c6..0000000000 --- a/tests/Tgstation.Server.Api.Tests/TestModels.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Tgstation.Server.Api.Tests -{ - [TestClass] - public sealed class TestModels - { - static IEnumerable> Models() - { - var modelAttributeType = typeof(ModelAttribute); - var targetAssembly = modelAttributeType.Assembly; - foreach(var I in targetAssembly.GetTypes()) - { - var attr = (ModelAttribute)I.GetCustomAttributes(modelAttributeType, false).FirstOrDefault(); - if (attr != default(ModelAttribute)) - yield return new Tuple(I, attr); - } - } - - [TestMethod] - public void TestModelsPropertiesPermissions() - { - var permissionsAttributeType = typeof(PermissionsAttribute); - foreach (var I in Models()) - { - foreach (var J in I.Item1.GetProperties()) - { - var perm = (PermissionsAttribute)J.GetCustomAttributes(permissionsAttributeType, false).FirstOrDefault(); - } - } - } - } -}