Exemple #1
0
        public async Task ModeratorRemovals_Allowed_Owner()
        {
            string subName = "testAllowedOwner";
            var    mods    = InitializeSubverseModerators(subName);

            RemoveModeratorCommand cmd = null;
            CommandResponse <RemoveModeratorResponse> response = null;

            string baseUserName   = "";
            string originUserName = "";
            string targetUserName = "";


            originUserName = "******";
            targetUserName = "******";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Success, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Success, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");
        }
Exemple #2
0
        public async Task ModeratorRemovals_Denials_System()
        {
            string subName = "testSystemDenials";
            var    mods    = InitializeSubverseModerators(subName);

            RemoveModeratorCommand cmd = null;
            CommandResponse <RemoveModeratorResponse> response = null;

            string originUserName = "";
            string targetUserName = "";

            originUserName = "******";
            targetUserName = "******";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");
        }
Exemple #3
0
        public override async Task <CommandResponse> Execute()
        {
            var m = new Data.Models.SubverseModerator();

            m.UserName = UserName;
            m.Subverse = Subverse;

            var cmd    = new RemoveModeratorCommand(m);
            var result = await cmd.Execute();

            return(result);
        }
Exemple #4
0
        public async Task ModeratorRemovals_Denials_NonOwner()
        {
            string subName = "testDenials";
            var    mods    = InitializeSubverseModerators(subName);

            RemoveModeratorCommand cmd = null;
            CommandResponse <RemoveModeratorResponse> response = null;

            string baseUserName   = "";
            string originUserName = "";
            string targetUserName = "";

            //Test same level drops
            baseUserName   = "******";
            originUserName = $"{baseUserName}.0";
            targetUserName = $"{baseUserName}.1";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            baseUserName   = "******";
            originUserName = $"{baseUserName}.0";
            targetUserName = $"{baseUserName}.1";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            baseUserName   = "******";
            originUserName = $"{baseUserName}.0";
            targetUserName = $"{baseUserName}.1";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            baseUserName   = "******";
            originUserName = $"{baseUserName}.0";
            targetUserName = $"{baseUserName}.1";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            //Test L1 denials
            originUserName = "******";
            targetUserName = "******";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");

            originUserName = "******";
            targetUserName = "******";
            TestHelper.SetPrincipal(originUserName);
            cmd      = new RemoveModeratorCommand(mods[targetUserName].ID, false);
            response = await cmd.Execute();

            Assert.AreEqual(Status.Denied, response.Status, $"Status mismatch on {originUserName} to {targetUserName}");
        }