diff --git a/src/Tgstation.Server.Api/Rights/ChatBotRights.cs b/src/Tgstation.Server.Api/Rights/ChatBotRights.cs index d9a8c61ff1..b993335c3c 100644 --- a/src/Tgstation.Server.Api/Rights/ChatBotRights.cs +++ b/src/Tgstation.Server.Api/Rights/ChatBotRights.cs @@ -37,16 +37,16 @@ namespace Tgstation.Server.Api.Rights /// Read = 32, /// - /// User can change - /// - WriteName = 32, - /// /// User can create new /// Create = 64, /// /// User can delete /// - Delete = 128 + Delete = 128, + /// + /// User can change + /// + WriteName = 256, } } diff --git a/src/Tgstation.Server.Api/Rights/ConfigurationRights.cs b/src/Tgstation.Server.Api/Rights/ConfigurationRights.cs index 3efc5dae0f..45b02e528f 100644 --- a/src/Tgstation.Server.Api/Rights/ConfigurationRights.cs +++ b/src/Tgstation.Server.Api/Rights/ConfigurationRights.cs @@ -23,6 +23,6 @@ namespace Tgstation.Server.Api.Rights /// /// User may list files /// - List = 3 + List = 4 } } diff --git a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj index 235cd27951..fc51067823 100644 --- a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj +++ b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj @@ -17,7 +17,7 @@ 4.0.0.0 json web api tgstation-server tgstation ss13 byond Prototype release - 4.0.0.0-preview4 + 4.0.0.0-preview5 diff --git a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj index 3ac3042fca..1ee1b5a291 100644 --- a/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj +++ b/src/Tgstation.Server.Client/Tgstation.Server.Client.csproj @@ -3,7 +3,7 @@ netstandard2.0 Full - 4.0.0.0-preview9 + 4.0.0.0-preview10 true Cyberboss /tg/station 13 diff --git a/tests/Tgstation.Server.Api.Tests/Rights/TestRights.cs b/tests/Tgstation.Server.Api.Tests/Rights/TestRights.cs new file mode 100644 index 0000000000..afa8774bae --- /dev/null +++ b/tests/Tgstation.Server.Api.Tests/Rights/TestRights.cs @@ -0,0 +1,40 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Linq; + +namespace Tgstation.Server.Api.Rights.Tests +{ + /// + /// Tests for + /// + [TestClass] + public sealed class TestRights + { + [TestMethod] + public void TestAllPowerOfTwo() + { + var ulongType = typeof(ulong); + foreach (var I in Enum.GetValues(typeof(RightsType)).Cast()) + { + var expectedLog = -1; + var rightType = RightsHelper.RightToType(I); + foreach (var J in Enum.GetValues(rightType)) + { + Assert.AreEqual(ulongType, Enum.GetUnderlyingType(rightType)); + var asUlong = (ulong)J; + var isOne = asUlong == 1; + if(!isOne) + Assert.AreEqual(0U, asUlong % 2, String.Format("Enum {0} of {1} is not a power of 2!", Enum.GetName(rightType, asUlong), rightType)); + + if (expectedLog > -1) + { + var log = Math.Log(asUlong, 2); + if (log != expectedLog) + Assert.Fail(String.Format("Expected Log2({1}) == {0} to come next for {2}, got {3} instead!", expectedLog, Enum.GetName(rightType, asUlong), rightType, log)); + } + ++expectedLog; + } + } + } + } +}