Ejemplo n.º 1
0
        public async Task AllowSubmittingDeletedLink()
        {
            var user = TestHelper.SetPrincipal("UnitTestUser31");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = "I need to think of better titles but I don't want to get in trouble", Url = "http://i.deleted.this.on/purpose.jpg"
            }).SetUserContext(user);
            var r = await cmd.Execute();

            VoatAssert.IsValid(r);

            var id   = r.Response.ID;
            var cmd2 = new DeleteSubmissionCommand(id).SetUserContext(user);
            var r2   = await cmd2.Execute();

            VoatAssert.IsValid(r);

            cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = "Hello Man - Longer because of Rules", Url = "http://i.deleted.this.on/purpose.jpg"
            }).SetUserContext(user);
            r = await cmd.Execute();

            VoatAssert.IsValid(r);
        }
Ejemplo n.º 2
0
        public void Edit_Submission_Title_Content()
        {
            var user = TestHelper.SetPrincipal("anon");

            var x = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Anon, Title = "xxxxxxxxxxxx", Content = "xxxxxxxxxxxx"
            }).SetUserContext(user);
            var s = x.Execute().Result;

            Assert.IsNotNull(s, "Response is null");
            Assert.IsTrue(s.Success, s.Message);

            var cmd = new EditSubmissionCommand(s.Response.ID, new Domain.Models.UserSubmission()
            {
                Title = "yyyyyyyyyyyy", Content = "yyyyyyyyyyyy"
            }).SetUserContext(user);
            var r = cmd.Execute().Result;

            VoatAssert.IsValid(r, message: "Edit Submission failed to return true: " + r.Message);

            using (var repo = new Voat.Data.Repository())
            {
                var submission = repo.GetSubmission(s.Response.ID);
                Assert.IsNotNull(submission, "Can't find submission from repo");
                Assert.AreEqual("yyyyyyyyyyyy", submission.Title);
                Assert.AreEqual("yyyyyyyyyyyy", submission.Content);
            }

            //Assert.Inconclusive();
        }
Ejemplo n.º 3
0
        public async Task AllowSubmittingDeletedLink()
        {
            TestHelper.SetPrincipal("UnitTestUser31");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = "unit", Title = "I need to think of better titles but I don't want to get in trouble", Url = "http://i.deleted.this.on/purpose.jpg"
            });
            var r = await cmd.Execute();

            Assert.IsNotNull(r, "Response was null");
            Assert.IsTrue(r.Success, r.Message);
            var id = r.Response.ID;

            var cmd2 = new DeleteSubmissionCommand(id);
            var r2   = await cmd2.Execute();

            Assert.IsTrue(r2.Success, r2.Message);

            cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = "unit", Title = "Hello Man - Longer because of Rules", Url = "http://i.deleted.this.on/purpose.jpg"
            });
            r = await cmd.Execute();

            Assert.IsNotNull(r, "Response was null");
            Assert.IsTrue(r.Success, r.Message);
        }
Ejemplo n.º 4
0
        public void PreventBannedDomainPost_MultiPartDomains()
        {
            using (var repo = new VoatDataContext())
            {
                repo.BannedDomain.Add(new BannedDomain()
                {
                    Domain = "one.two.three.com", Reason = "People hate counting", CreatedBy = "UnitTest", CreationDate = DateTime.UtcNow
                });
                repo.SaveChanges();
            }

            var user = TestHelper.SetPrincipal("TestUser02");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = "Hello Man - Longer because of Rules", Url = "http://www.one.two.three.com/images/feelsgoodman.jpg"
            }).SetUserContext(user);
            var r = cmd.Execute().Result;

            Assert.IsNotNull(r, "Response was null");
            Assert.IsFalse(r.Success, r.Message);
            Assert.AreEqual(r.Message, "Submission contains banned domains");

            cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = "Hello Man - Longer because of Rules", Content = "Check out this cool image I found using dogpile.com: HTTP://one.TWO.three.com/images/feelsgoodman.jpg"
            }).SetUserContext(user);
            r = cmd.Execute().Result;
            Assert.IsNotNull(r, "Response was null");
            Assert.IsFalse(r.Success, r.Message);
            Assert.AreEqual(r.Message, "Submission contains banned domains");
        }
Ejemplo n.º 5
0
        public void TestNegativeSCPSubmission()
        {
            var userName = "******";

            //Create user
            TestDataInitializer.CreateUser(userName, DateTime.UtcNow.AddDays(-450));
            //Add submission with negatives directly to db
            using (var context = new VoatDataContext())
            {
                var s = context.Submission.Add(new Submission()
                {
                    CreationDate = DateTime.UtcNow.AddHours(-12),
                    Subverse     = SUBVERSES.Unit,
                    Title        = "Test Negative SCP",
                    Url          = "https://www.youtube.com/watch?v=pnbJEg9r1o8",
                    Type         = 2,
                    UpCount      = 2,
                    DownCount    = 13,
                    UserName     = userName
                });
                context.SaveChanges();
            }



            var user           = TestHelper.SetPrincipal(userName);
            var userSubmission = new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = "Le Censorship!", Content = "Will this work?"
            };
            var cmd = new CreateSubmissionCommand(userSubmission).SetUserContext(user);
            var r   = cmd.Execute().Result;

            VoatAssert.IsValid(r);
        }
Ejemplo n.º 6
0
        public async Task QuerySubmissions_By_Domain()
        {
            var domain = "LearnToGolfLikeCharlesBarkleyOrYourMoneyBack.com";

            var user = TestHelper.SetPrincipal("UnitTestUser48");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Title = "Best Offer Ever!", Url = $"https://www.{domain}/limited-time-offer-{Guid.NewGuid().ToString()}.html", Subverse = SUBVERSES.Unit
            }).SetUserContext(user);
            var r = await cmd.Execute();

            Assert.AreEqual(Status.Success, r.Status, r.Message);


            var q = new QuerySubmissionsByDomain(domain, SearchOptions.Default);
            //q.CachePolicy.Duration = cacheTime; //Cache this request
            var result = q.ExecuteAsync().Result;

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Any(), "Found no results");

            foreach (var s in result)
            {
                Assert.IsTrue(s.Url.ToLower().Contains(domain.ToLower()), $"Couldn't find {domain} in {s.Url}");
            }
        }
Ejemplo n.º 7
0
        public async Task DeleteSubmission_Moderator()
        {
            var user = TestHelper.SetPrincipal("TestUser13");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = "This is a title", Content = "This is content a mod would hate"
            }).SetUserContext(user);

            var r = await cmd.Execute();

            VoatAssert.IsValid(r);
            Assert.IsNotNull(r.Response, "Expecting a non null response");
            Assert.AreNotEqual(0, r.Response.ID);

            user = TestHelper.SetPrincipal(USERNAMES.Unit);
            var d  = new DeleteSubmissionCommand(r.Response.ID, "This is content I hate").SetUserContext(user);
            var r2 = await d.Execute();

            VoatAssert.IsValid(r2);

            //verify
            using (var db = new Voat.Data.Repository(user))
            {
                var s = db.GetSubmission(r.Response.ID);
                Assert.AreEqual(true, s.IsDeleted);

                //Content should remain unchanged in mod deletion
                Assert.AreEqual(s.Content, r.Response.Content);
                Assert.AreEqual(s.FormattedContent, r.Response.FormattedContent);
                //Assert.IsTrue(s.Content.StartsWith("Deleted by"));
                //Assert.AreEqual(s.FormattedContent, Utilities.Formatting.FormatMessage(s.Content));
            }
        }
Ejemplo n.º 8
0
        public async Task GroupedSubmissionReports()
        {
            var userName = USERNAMES.Unit;
            var user     = TestHelper.SetPrincipal(userName);
            var cmd      = new CreateSubmissionCommand(new UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = "This is spammy spam", Content = "http://somespamsite.com"
            }).SetUserContext(user);
            var response = await cmd.Execute();

            Assert.IsTrue(response.Success, response.Message);
            var submission = response.Response;

            userName = USERNAMES.Unit;
            user     = TestHelper.SetPrincipal(userName);
            await SubmitAndVerify(user, ContentType.Submission, submission.ID, 1);

            int index = 0;

            for (int i = 1; i < 20; i++)
            {
                userName = $"TestUser{i.ToString().PadLeft(2, '0')}";
                user     = TestHelper.SetPrincipal(userName);
                await SubmitAndVerify(user, ContentType.Submission, submission.ID, ids[index]);

                index++;
                if (index >= 4)
                {
                    index = 0;
                }
            }
        }
Ejemplo n.º 9
0
        public async Task Submission_Length_Validations()
        {
            var user = TestHelper.SetPrincipal("TestUser20");

            var createCmd = new CreateSubmissionCommand(
                new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit,
                Title    = "Can you hear me now?".RepeatUntil(201),
                Content  = null
            }).SetUserContext(user);
            var r = await createCmd.Execute();

            VoatAssert.IsValid(r, Status.Invalid);

            createCmd = new CreateSubmissionCommand(
                new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit,
                Title    = "Can you hear me now?",
                Content  = "Great!".RepeatUntil(10001)
            }).SetUserContext(user);
            r = await createCmd.Execute();

            VoatAssert.IsValid(r, Status.Invalid);
            Assert.IsTrue(r.ValidationErrors.Any(x => x.MemberNames.Any(m => m.IsEqual("content"))));

            createCmd = new CreateSubmissionCommand(
                new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit,
                Title    = "Can you hear me now?",
                Content  = "Great!"
            }).SetUserContext(user);
            r = await createCmd.Execute();

            VoatAssert.IsValid(r);

            var editCmd = new EditSubmissionCommand(r.Response.ID, new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit,
                Title    = "Can you hear me now?",
                Content  = "Great!".RepeatUntil(10001),
            }).SetUserContext(user);

            r = await editCmd.Execute();

            VoatAssert.IsValid(r, Status.Invalid);

            //editCmd = new EditSubmissionCommand(r.Response.ID, new Domain.Models.UserSubmission()
            //{
            //    Subverse = SUBVERSES.Unit,
            //    Title = "Can you hear me now?",
            //    Content = "Great!".RepeatUntil(10001),
            //}).SetUserContext(user);
            //r = await createCmd.Execute();
            //VoatAssert.IsValid(r, Status.Denied);
        }
Ejemplo n.º 10
0
        public void PreventBannedDomainPost()
        {
            using (var repo = new VoatDataContext())
            {
                repo.BannedDomain.Add(new BannedDomain()
                {
                    Domain = "saiddit.com", Reason = "No one really likes you.", CreatedBy = "UnitTest", CreationDate = DateTime.UtcNow
                });
                repo.SaveChanges();
            }

            var user = TestHelper.SetPrincipal("TestUser02");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = "Hello Man - Longer because of Rules", Url = "http://www.saiddit.com/images/feelsgoodman.jpg"
            }).SetUserContext(user);
            var r = cmd.Execute().Result;

            Assert.IsNotNull(r, "Response was null");
            Assert.IsFalse(r.Success, r.Message);
            Assert.AreEqual(r.Message, "Submission contains banned domains");

            cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = "Hello Man - Longer because of Rules", Content = "Check out this cool image I found using dogpile.com: http://saiddit.com/images/feelsgoodman.jpg"
            }).SetUserContext(user);
            r = cmd.Execute().Result;
            Assert.IsNotNull(r, "Response was null");
            Assert.IsFalse(r.Success, r.Message);
            Assert.AreEqual(r.Message, "Submission contains banned domains");

            cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = "Test Embedded Banned Domain",
                Content  = "http://yahoo.com/index.html Check out this cool image I found using compuserve.com: http://saiddit.com/images/feelsgoodman.jpg. http://www2.home.geocities.com/index.html"
            }).SetUserContext(user);
            r = cmd.Execute().Result;
            Assert.IsNotNull(r, "Response was null");
            Assert.IsFalse(r.Success, r.Message);
            Assert.AreEqual(r.Message, "Submission contains banned domains");

            //Test URLEncoding Markdown Matching
            cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit,
                Title    = "Hello Man - Longer because of Rules",
                Content  = "[https://www.some-fake-domain.com/surl/start](https://www.google.com/url?q=http%3A%2F%2Fww2.saiddit.com%2F%3Flnk%26keyword%3Dsome%2Bkey%2Bword%26charset%3Dutf-8)"
            }).SetUserContext(user);
            r = cmd.Execute().Result;
            Assert.IsNotNull(r, "Response was null");
            Assert.IsFalse(r.Success, r.Message);
            Assert.AreEqual(r.Message, "Submission contains banned domains");
        }
Ejemplo n.º 11
0
            public static Domain.Models.Submission CreateSubmission(string userName, Domain.Models.UserSubmission submission)
            {
                var user = TestHelper.SetPrincipal(userName);

                var cmd = new CreateSubmissionCommand(submission).SetUserContext(user);
                var r   = cmd.Execute().Result;

                VoatAssert.IsValid(r);
                Assert.AreNotEqual(0, r.Response.ID);

                return(r.Response);
            }
Ejemplo n.º 12
0
        public void LongUrl_Bug()
        {
            var user = TestHelper.SetPrincipal("TestUser09");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Whatever, Title = "Long Url Bug", Url = "http://kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk.com/"
            }).SetUserContext(user);
            var r = cmd.Execute().Result;

            VoatAssert.IsValid(r, Status.Success);
            //Assert.AreNotEqual(0, r.Response.ID);
        }
Ejemplo n.º 13
0
        public void PreventPostingToDisabledSub()
        {
            var user           = TestHelper.SetPrincipal("TestUser06");
            var userSubmission = new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Disabled, Title = "I am not paying attention", Content = "Why was this sub disabled?"
            };
            var cmd = new CreateSubmissionCommand(userSubmission).SetUserContext(user);
            var r   = cmd.Execute().Result;

            VoatAssert.IsValid(r, Status.Denied);
            Assert.AreEqual("Subverse is disabled", r.Message);
        }
Ejemplo n.º 14
0
        public void PreventUserFromPostingToAuthorizedOnlySubverses()
        {
            var user           = TestHelper.SetPrincipal("TestUser09");
            var userSubmission = new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.AuthorizedOnly, Title = Guid.NewGuid().ToString(), Url = "http://www.digit.com/images/feelsgoodman.jpg"
            };
            var cmd = new CreateSubmissionCommand(userSubmission).SetUserContext(user);
            var r   = cmd.Execute().Result;

            VoatAssert.IsValid(r, Status.Denied);
            Assert.AreEqual(r.Message, "You are not authorized to submit links or start discussions in this subverse. Please contact subverse moderators for authorization");
        }
Ejemplo n.º 15
0
        public void PreventUserFromPostingCompromisedTitle1()
        {
            var user           = TestHelper.SetPrincipal("TestUser01");
            var userSubmission = new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Whatever, Title = "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000", Content = "cookies"
            };
            var cmd = new CreateSubmissionCommand(userSubmission).SetUserContext(user);
            var r   = cmd.Execute().Result;

            VoatAssert.IsValid(r, Status.Denied);
            Assert.AreEqual(r.Message, "Submission title can not contain Unicode or unprintable characters");
        }
Ejemplo n.º 16
0
        public void PreventShortTitlePosts()
        {
            var user = TestHelper.SetPrincipal("TestUser02");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = "What", Url = "http://www.hellogoodbye.com/images/feelsgoodman.jpg"
            }).SetUserContext(user);
            var r = cmd.Execute().Result;

            VoatAssert.IsValid(r, Status.Invalid);
            Assert.AreEqual(r.Message, $"A title must be between {VoatSettings.Instance.MinimumTitleLength} and {VoatSettings.Instance.MaximumTitleLength} characters");
        }
Ejemplo n.º 17
0
        public void CreateSubmissionTrapJSInUrl()
        {
            var user = TestHelper.SetPrincipal("TestUser06");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Whatever, Title = "This is a title", Url = "javascript:alert('arst');"
            }).SetUserContext(user);
            var r = cmd.Execute().Result;

            VoatAssert.IsValid(r, Status.Invalid);
            Assert.AreEqual(r.Message, "The url you are trying to submit is invalid");
        }
Ejemplo n.º 18
0
        public void PreventGlobalBannedUsers()
        {
            var user           = TestHelper.SetPrincipal("BannedGlobally");
            var userSubmission = new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = Guid.NewGuid().ToString(), Url = "http://www.SendhelpImStuckInUnitTests.com/images/feelsgoodman.jpg"
            };
            var cmd = new CreateSubmissionCommand(userSubmission).SetUserContext(user);
            var r   = cmd.Execute().Result;

            VoatAssert.IsValid(r, Status.Denied);
            Assert.AreEqual(r.Message, "User is globally banned");
        }
Ejemplo n.º 19
0
        public void PreventPartialUrlTitlePosts_Bug()
        {
            var user = TestHelper.SetPrincipal("TestUser09");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Whatever, Title = "speedtesting", Url = "http://beta.speedtesting.net/"
            }).SetUserContext(user);
            var r = cmd.Execute().Result;

            VoatAssert.IsValid(r, Status.Success);
            //Assert.AreNotEqual(0, r.Response.ID);
        }
Ejemplo n.º 20
0
        public void PreventSubverseBannedUsers()
        {
            var user           = TestHelper.SetPrincipal("BannedFromVUnit");
            var userSubmission = new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = Guid.NewGuid().ToString(), Url = "http://www.SuperAwesomeDomainName.com/images/feelsgoodman.jpg"
            };
            var cmd = new CreateSubmissionCommand(userSubmission).SetUserContext(user);
            var r   = cmd.Execute().Result;

            VoatAssert.IsValid(r, Status.Denied);
            Assert.AreEqual(r.Message, $"User is banned from v/{userSubmission.Subverse}");
        }
Ejemplo n.º 21
0
        public void PreventGlobalBannedUsers()
        {
            TestHelper.SetPrincipal("BannedGlobally");
            var userSubmission = new Domain.Models.UserSubmission()
            {
                Subverse = "unit", Title = Guid.NewGuid().ToString(), Url = "http://www.SendhelpImStuckInUnitTests.com/images/feelsgoodman.jpg"
            };
            var cmd = new CreateSubmissionCommand(userSubmission);
            var r   = cmd.Execute().Result;

            Assert.IsNotNull(r, "Response was null");
            Assert.IsFalse(r.Success, r.Message);
            Assert.AreEqual(r.Message, "User is globally banned");
        }
Ejemplo n.º 22
0
        public void PreventSubverseBannedUsers()
        {
            TestHelper.SetPrincipal("BannedFromVUnit");
            var userSubmission = new Domain.Models.UserSubmission()
            {
                Subverse = "unit", Title = Guid.NewGuid().ToString(), Url = "http://www.SuperAwesomeDomainName.com/images/feelsgoodman.jpg"
            };
            var cmd = new CreateSubmissionCommand(userSubmission);
            var r   = cmd.Execute().Result;

            Assert.IsNotNull(r, "Response was null");
            Assert.IsFalse(r.Success, r.Message);
            Assert.AreEqual(r.Message, $"User is banned from v/{userSubmission.Subverse}");
        }
Ejemplo n.º 23
0
        public void PreventPartialUrlTitlePosts()
        {
            var user = TestHelper.SetPrincipal("TestUser02");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Whatever, Title = "www.yahoo.com", Url = "http://www.yahoo.com"
            }).SetUserContext(user);
            var r = cmd.Execute().Result;

            VoatAssert.IsValid(r, Status.Denied);
            Assert.AreEqual(r.Message, "Submission title may not be the same as the URL you are trying to submit. Why would you even think about doing this?! Why?");
            //Assert.AreNotEqual(0, r.Response.ID);
        }
Ejemplo n.º 24
0
        public void PreventUserFromPostingToAuthorizedOnlySubverses()
        {
            TestHelper.SetPrincipal("TestUser9");
            var userSubmission = new Domain.Models.UserSubmission()
            {
                Subverse = "AuthorizedOnly", Title = Guid.NewGuid().ToString(), Url = "http://www.digit.com/images/feelsgoodman.jpg"
            };
            var cmd = new CreateSubmissionCommand(userSubmission);
            var r   = cmd.Execute().Result;

            Assert.IsNotNull(r, "Response was null");
            Assert.IsFalse(r.Success, r.Message);
            Assert.AreEqual(r.Message, "You are not authorized to submit links or start discussions in this subverse. Please contact subverse moderators for authorization");
        }
Ejemplo n.º 25
0
        public void PreventUserFromPostingCompromisedTitle1()
        {
            TestHelper.SetPrincipal("TestUser1");
            var userSubmission = new Domain.Models.UserSubmission()
            {
                Subverse = "whatever", Title = "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000", Content = "cookies"
            };
            var cmd = new CreateSubmissionCommand(userSubmission);
            var r   = cmd.Execute().Result;

            Assert.IsNotNull(r, "Response was null");
            Assert.IsFalse(r.Success, r.Message);
            Assert.AreEqual(r.Message, "Submission title can not contain Unicode or unprintable characters");
        }
Ejemplo n.º 26
0
        public void PreventPostingToDisabledSub()
        {
            TestHelper.SetPrincipal("TestUser6");
            var userSubmission = new Domain.Models.UserSubmission()
            {
                Subverse = "disabled", Title = "I am not paying attention", Content = "Why was this sub disabled?"
            };
            var cmd = new CreateSubmissionCommand(userSubmission);
            var r   = cmd.Execute().Result;

            Assert.IsNotNull(r, "Response was null");
            Assert.IsFalse(r.Success, r.Message);
            Assert.AreEqual(r.Message, "Subverse is disabled");
        }
Ejemplo n.º 27
0
        public void CreateSubmissionTrapJSInUrl()
        {
            TestHelper.SetPrincipal("TestUser6");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = "whatever", Title = "This is a title", Url = "javascript:alert('arst');"
            });
            var r = cmd.Execute().Result;

            Assert.IsNotNull(r, "Response is null");
            Assert.IsFalse(r.Success, r.Message);
            Assert.AreEqual(r.Message, "The url you are trying to submit is invalid");
        }
Ejemplo n.º 28
0
        public void PreventShortTitlePosts()
        {
            TestHelper.SetPrincipal("TestUser2");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = "unit", Title = "What", Url = "http://www.hellogoodbye.com/images/feelsgoodman.jpg"
            });
            var r = cmd.Execute().Result;

            Assert.IsNotNull(r, "Response was null");
            Assert.IsFalse(r.Success, r.Message);
            Assert.AreEqual(r.Message, "A title may not be less than 5 characters");
        }
Ejemplo n.º 29
0
        public void PreventPartialUrlTitlePosts()
        {
            TestHelper.SetPrincipal("TestUser2");

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = "whatever", Title = "www.yahoo.com", Url = "http://www.yahoo.com"
            });
            var r = cmd.Execute().Result;

            Assert.IsFalse(r.Success);
            Assert.AreEqual(r.Message, "Submission title may not be the same as the URL you are trying to submit. Why would you even think about doing this?! Why?");
            //Assert.AreNotEqual(0, r.Response.ID);
        }
Ejemplo n.º 30
0
        public async Task CreateSubmission_Anon_InNonAnonSub()
        {
            string userName = "******";
            var    user     = TestHelper.SetPrincipal(userName);

            var cmd = new CreateSubmissionCommand(new Domain.Models.UserSubmission()
            {
                Subverse = SUBVERSES.Unit, Title = "This is a title", Url = "http://www.yahoo.com", IsAnonymized = true
            }).SetUserContext(user).SetUserContext(user);

            var r = await cmd.Execute();

            VoatAssert.IsValid(r, Status.Denied);
        }