public async Task CreateComment_Anon() { string userName = "******"; var user = TestHelper.SetPrincipal(userName); var cmd = new CreateCommentCommand(2, null, "This is my data").SetUserContext(user); var c = cmd.Execute().Result; VoatAssert.IsValid(c); Assert.AreNotEqual(0, c.Response.ID); Assert.AreEqual(true, c.Response.IsAnonymized); Assert.AreNotEqual(cmd.Content, c.Response.FormattedContent); //verify in db using (var db = new Voat.Data.Repository(user)) { var comment = await db.GetComment(c.Response.ID); Assert.IsNotNull(comment, "Couldn't find comment in db", c.Response.ID); Assert.AreEqual(c.Response.ID, comment.ID); Assert.AreEqual(comment.ID.ToString(), comment.UserName); Assert.AreEqual(c.Response.Content, comment.Content); Assert.IsTrue(comment.IsAnonymized); Assert.AreEqual(c.Response.IsAnonymized, comment.IsAnonymized); } base.VerifyCommentIsProtected(c.Response.SubmissionID.Value, c.Response.ID, userName); }
private Submission GetSubmission() { using (var repo = new Voat.Data.Repository()) { return(repo.GetSubmission(submissionID)); } }
public async Task Block_Subverse_Toggle() { string userName = "******"; var user = TestHelper.SetPrincipal(userName); using (var db = new Voat.Data.Repository(user)) { string name = "whatever"; await db.Block(DomainType.Subverse, name, SubscriptionAction.Toggle); var blocks = await db.GetBlockedSubverses(userName); Assert.IsNotNull(blocks); Assert.IsTrue(blocks.Any(x => x.Name == name && x.Type == DomainType.Subverse)); await db.Block(DomainType.Subverse, name, SubscriptionAction.Toggle); blocks = await db.GetBlockedSubverses(userName); Assert.IsNotNull(blocks); Assert.IsFalse(blocks.Any(x => x.Name == name && x.Type == DomainType.Subverse)); } }
public void BannedDomainTest() { var domain = "paydayloansforeverybody.com"; var reason = "Total Rip off!"; var createdBy = "AntiSpamcist"; var createdDate = DateTime.UtcNow.AddDays(-10); using (var db = new VoatDataContext()) { db.BannedDomain.Add(new BannedDomain() { Domain = domain, Reason = reason, CreatedBy = createdBy, CreationDate = createdDate }); db.SaveChanges(); } using (var repo = new Voat.Data.Repository()) { var result = repo.BannedDomains(new string[] { "yahoo.com", "google.com", domain, domain.ToUpper(), "testuri.org" }); Assert.IsNotNull(result, "Result was null"); Assert.IsTrue(result.Any(), "Result expected"); Assert.AreEqual(1, result.Count(), "Count off"); var bd = result.First(); Assert.AreEqual(domain, bd.Domain); Assert.AreEqual(reason, bd.Reason); Assert.AreEqual(createdBy, bd.CreatedBy); Assert.AreEqual(createdDate.ToString(), bd.CreationDate.ToString()); result = repo.BannedDomains(new string[] { "subdomain." + domain }); Assert.IsNotNull(result, "subdomain failure"); Assert.IsTrue(result.Any(), "Subdomain Result expected"); } }
public void Block_Subverse_SubverseDoesNotExist() { using (var db = new Voat.Data.Repository()) { TestHelper.SetPrincipal("TestUser1"); db.Block(DomainType.Subverse, "happyhappyjoyjoy"); } }
public void SubverseRetrieval() { using (var db = new Voat.Data.Repository()) { var info = db.GetSubverseInfo("unit"); Assert.IsTrue(info.Title == "v/unit"); } }
public void Block_Subverse_NoAuthentication() { TestHelper.SetPrincipal(null); using (var db = new Voat.Data.Repository()) { db.Block(DomainType.Subverse, "test"); } }
public void GetAnonymousSubmission() { using (var db = new Voat.Data.Repository()) { var anon_sub = db.GetSubmission(2); Assert.IsTrue(anon_sub.UserName == anon_sub.ID.ToString()); } }
public void Get_SubversesUser_Moderates() { using (var db = new Voat.Data.Repository()) { var result = db.GetSubversesUserModerates("unit"); Assert.IsNotNull(result, "Result was null"); Assert.IsTrue(result.Any(x => x.Subverse == "AuthorizedOnly"), "Result expected to see subverse AuthorizedOnly for user unit"); } }
public async Task GetUserPrefernces_UserNotExists() { using (var db = new Voat.Data.Repository()) { var p = await db.GetUserPreferences("asrtastarstarstarstart343"); Assert.AreNotEqual(null, p); } }
public async Task GetSubmission() { using (var db = new Voat.Data.Repository()) { var s = await db.GetSubmissionsDapper("unit", new SearchOptions()).ConfigureAwait(false); Assert.IsTrue(s.Any()); } }
public async Task SaveComment() { using (var db = new Voat.Data.Repository()) { var result = await db.Save(ContentType.Comment, 1); Assert.AreEqual(Status.Success, result.Status); Assert.AreEqual(true, result.Response.Value); } }
public void GetAnonymousSubmission() { var user = TestHelper.SetPrincipal(null); using (var db = new Voat.Data.Repository(user)) { var anon_sub = db.GetSubmission(2); Assert.IsTrue(anon_sub.UserName == anon_sub.ID.ToString()); } }
public void SubverseRetrieval() { var user = TestHelper.SetPrincipal(null); using (var db = new Voat.Data.Repository(user)) { var info = db.GetSubverseInfo(SUBVERSES.Unit); Assert.IsTrue(info.Title == "v/unit"); } }
public async Task Block_Subverse_NoAuthentication() { await VoatAssert.ThrowsAsync <VoatSecurityException>(() => { var user = TestHelper.SetPrincipal(null); using (var db = new Voat.Data.Repository(user)) { return(db.Block(DomainType.Subverse, "test")); } }); }
public void Get_SubversesUser_Moderates() { var user = TestHelper.SetPrincipal(null); using (var db = new Voat.Data.Repository(user)) { var result = db.GetSubversesUserModerates(USERNAMES.Unit); Assert.IsNotNull(result, "Result was null"); Assert.IsTrue(result.Any(x => x.Subverse == "AuthorizedOnly"), "Result expected to see subverse AuthorizedOnly for user unit"); } }
public async Task EnsureLogVisitWorks() { using (var repo = new Voat.Data.Repository()) { await repo.LogVisit(null, 1, "127.0.0.1"); await repo.LogVisit(SUBVERSES.Whatever, null, "127.0.0.2"); await repo.LogVisit(SUBVERSES.Anon, 2, "127.0.0.3"); } }
public async Task GetUserPrefernces_UserNotExists() { var user = TestHelper.SetPrincipal(null); using (var db = new Voat.Data.Repository(user)) { var p = await db.GetUserPreferences("asrtastarstarstarstart343"); Assert.AreNotEqual(null, p); } }
public async Task Block_Subverse_SubverseDoesNotExist() { string userName = "******"; var user = TestHelper.SetPrincipal(userName); await VoatAssert.ThrowsAsync <VoatNotFoundException>(() => { using (var db = new Voat.Data.Repository(user)) { return(db.Block(DomainType.Subverse, "happyhappyjoyjoy")); } }); }
public async Task GetSubmission() { var user = TestHelper.SetPrincipal(null); using (var db = new Voat.Data.Repository(user)) { var s = await db.GetSubmissionsDapper(new DomainReference(DomainType.Subverse, SUBVERSES.Unit), new SearchOptions()).ConfigureAwait(Utilities.CONSTANTS.AWAIT_CAPTURE_CONTEXT); Assert.IsTrue(s.Any()); } }
public void GetAnonymousComments() { using (var db = new Voat.Data.Repository()) { var comments = db.GetCommentTree(2, null, null); foreach (var c in comments) { Assert.IsTrue(c.IsAnonymized); } } }
public async Task SaveComment() { var user = TestHelper.SetPrincipal(null); using (var db = new Voat.Data.Repository(user)) { var result = await db.Save(ContentType.Comment, 1); Assert.AreEqual(Status.Success, result.Status); Assert.AreEqual(true, result.Response); } }
public async Task GetUserPrefernces() { using (var db = new Voat.Data.Repository()) { var p = await db.GetUserPreferences("unit"); Assert.IsTrue(p != null); Assert.IsTrue(p.UserName == "unit"); Assert.IsTrue(p.Bio == "User unit's short bio"); Assert.IsTrue(!p.DisableCSS); } }
public async Task GetSubmissionsFilterAnonymous() { using (var db = new Voat.Data.Repository()) { var anon_sub = await db.GetSubmissionsDapper("anon", SearchOptions.Default).ConfigureAwait(false); var first = anon_sub.OrderBy(x => x.CreationDate).First(); Assert.IsNotNull(first, "no anon submissions found"); Assert.AreEqual("First Anon Post", first.Title); Assert.AreEqual(first.UserName, first.ID.ToString()); } }
public async Task PostComment_BannedDomain() { using (var db = new Voat.Data.Repository()) { TestHelper.SetPrincipal("TestUser10"); var result = await db.PostComment(1, null, "Check out my new post: http://www.fleddit.com/r/something/hen9s87r9/How-I-Made-a-million-virtual-cat-pics"); Assert.IsNotNull(result, "Result was null"); Assert.IsFalse(result.Success, "Submitting content with banned domain did not get rejected"); Assert.AreEqual(Status.Denied, result.Status, "Expecting a denied status"); } }
public void GetAnonymousComments() { var user = TestHelper.SetPrincipal(null); using (var db = new Voat.Data.Repository(user)) { var comments = db.GetCommentTree(2, null, null); foreach (var c in comments) { Assert.IsTrue(c.IsAnonymized); } } }
public async Task GetUserPrefernces() { var user = TestHelper.SetPrincipal(null); using (var db = new Voat.Data.Repository(user)) { var p = await db.GetUserPreferences(USERNAMES.Unit); Assert.IsTrue(p != null); Assert.IsTrue(p.UserName == USERNAMES.Unit); Assert.IsTrue(p.Bio == "User unit's short bio"); Assert.IsTrue(!p.DisableCSS); } }
public async Task GetSubmissionsFilterAnonymous() { var user = TestHelper.SetPrincipal(null); using (var db = new Voat.Data.Repository(user)) { var anon_sub = await db.GetSubmissionsDapper(new DomainReference(DomainType.Subverse, SUBVERSES.Anon), SearchOptions.Default).ConfigureAwait(Utilities.CONSTANTS.AWAIT_CAPTURE_CONTEXT); var first = anon_sub.OrderBy(x => x.CreationDate).First(); Assert.IsNotNull(first, "no anon submissions found"); Assert.AreEqual("First Anon Post", first.Title); Assert.AreEqual(first.UserName, first.ID.ToString()); } }
public async Task PostSubmission_AuthorizedOnly_Denied() { using (var db = new Voat.Data.Repository()) { TestHelper.SetPrincipal("TestUser11"); var result = await db.PostSubmission(new UserSubmission() { Subverse = "AuthorizedOnly", Title = "Ha ha, you can't stop me", Content = "Cookies for you my friend" }); Assert.IsNotNull(result, "Result was null"); Assert.IsFalse(result.Success, "Submitting to authorized only subverse was allowed by non admin"); Assert.AreEqual(Status.Denied, result.Status, "Expecting a denied status"); } }
public async Task PostSubmission_AuthorizedOnly_Allow() { var user = TestHelper.SetPrincipal(USERNAMES.Unit); using (var db = new Voat.Data.Repository(user)) { var result = await db.PostSubmission(new UserSubmission() { Subverse = SUBVERSES.AuthorizedOnly, Title = "Ha ha, you can't stop me", Content = "Cookies for you my friend" }); Assert.IsNotNull(result, "Result was null"); Assert.IsTrue(result.Success, "Submitting to authorized only subverse was not allowed by admin"); Assert.AreEqual(Status.Success, result.Status, "Expecting a success status"); } }