internal static async Task RegisterUser(User user, string token) { List <PureRight> pureRights = new List <PureRight>(); pureRights.Add(new PureRight { Authorized = true, Operation = "StartServer", RecourceModule = "ServerHandler" }); string otherToken = await RightControl.Register(user.Uuid, pureRights, token); }
public async Task CheckRegisterGivenAuthorizationsDataBaseOnly() { RightControl rightControl = new RightControl("CheckRegister"); string token = await rightControl.Register("1"); if (!rightControl.IsGranted(token, "Add", "Authorizations")) { Assert.Fail(); } if (rightControl.IsGranted(token, "Delete", "Authorizations")) { Assert.Fail(); } if (rightControl.IsGranted(token, "Anything", "SometingElse")) { Assert.Fail(); } }
public async Task CheckRegisterGivenAuthorizationsWithAdditionalAutorizations() { RightControl rightControl = new RightControl("CheckRegister"); List <PureRight> pureRights = new List <PureRight>(); pureRights.Add(new PureRight { Authorized = false, Operation = "Add", RecourceModule = "Authorizations" }); pureRights.Add(new PureRight { Authorized = true, Operation = "Modify", RecourceModule = "Authorizations" }); pureRights.Add(new PureRight { Authorized = true, Operation = "Any", RecourceModule = "SomethingElse" }); string token = await rightControl.Register("1", pureRights); if (rightControl.IsGranted(token, "Add", "Authorizations")) { Assert.Fail(); } if (rightControl.IsGranted(token, "Delete", "Authorizations")) { Assert.Fail(); } if (!rightControl.IsGranted(token, "Modify", "Authorizations")) { Assert.Fail(); } if (!rightControl.IsGranted(token, "Any", "SomethingElse")) { Assert.Fail(); } }
public async Task CheckGrandManually() { RightControl rightControl = new RightControl("CheckRegisterAnotherNamespace"); string token = "SomeToken"; List <PureRight> pureRights = new List <PureRight>(); pureRights.Add(new PureRight { Authorized = true, Operation = "AddServerSettings_" + "SomeUser", RecourceModule = "ServerSetting" }); string otherToken = await rightControl.Register("1337", pureRights, token); if (!rightControl.IsGranted(token, "AddServerSettings_" + "SomeUser", "ServerSetting")) { Assert.Fail(); } }
public async Task CheckRegisterGivenAuthorizationsWithAdditionalAutorization() { RightControl rightControl = new RightControl("CheckRegister"); PureRight pureRight = new PureRight(); pureRight.Authorized = true; pureRight.Operation = "Edit"; pureRight.RecourceModule = "Authorizations"; string token = await rightControl.Register("1", pureRight); if (!rightControl.IsGranted(token, "Add", "Authorizations")) { Assert.Fail(); } if (rightControl.IsGranted(token, "Delete", "Authorizations")) { Assert.Fail(); } if (!rightControl.IsGranted(token, "Edit", "Authorizations")) { Assert.Fail(); } }