public virtual ActionResult ReportAbuse(string id, string version, ReportAbuseViewModel reportForm) { if (!ModelState.IsValid) { return(ReportAbuse(id, version)); } var package = packageSvc.FindPackageByIdAndVersion(id, version); if (package == null) { return(PackageNotFound(id, version)); } MailAddress from = null; if (Request.IsAuthenticated) { var user = userSvc.FindByUsername(HttpContext.User.Identity.Name); from = user.ToMailAddress(); } else { from = new MailAddress(reportForm.Email); } messageService.ReportAbuse(from, package, reportForm.Message); TempData["Message"] = "Your abuse report has been sent to the gallery operators."; return(RedirectToAction(MVC.Packages.DisplayPackage(id, version))); }
// NOTE: Intentionally NOT requiring authentication public virtual ActionResult ReportAbuse(string id, string version) { var package = packageSvc.FindPackageByIdAndVersion(id, version); if (package == null) { return(PackageNotFound(id, version)); } var model = new ReportAbuseViewModel { PackageId = id, PackageVersion = package.Version, }; if (Request.IsAuthenticated) { var user = userSvc.FindByUsername(HttpContext.User.Identity.Name); if (user.Confirmed) { model.ConfirmedUser = true; } } return(View(model)); }
public virtual ActionResult ReportAbuse(string id, string version, ReportAbuseViewModel reportForm) { // Html Encode the message reportForm.Message = System.Web.HttpUtility.HtmlEncode(reportForm.Message); if (!ModelState.IsValid) { return(ReportAbuse(id, version)); } var package = _packageService.FindPackageByIdAndVersion(id, version); if (package == null) { return(HttpNotFound()); } User user = null; MailAddress from; if (Request.IsAuthenticated) { user = GetCurrentUser(); from = user.ToMailAddress(); } else { from = new MailAddress(reportForm.Email); } var request = new ReportPackageRequest { AlreadyContactedOwners = reportForm.AlreadyContactedOwner, FromAddress = from, Message = reportForm.Message, Package = package, Reason = EnumHelper.GetDescription(reportForm.Reason.Value), RequestingUser = user, Url = Url, CopySender = reportForm.CopySender }; _messageService.ReportAbuse(request ); TempData["Message"] = "Your abuse report has been sent to the gallery operators."; return(Redirect(Url.Package(id, version))); }
public virtual ActionResult ReportAbuse(string id, string version, ReportAbuseViewModel reportForm) { if (!ModelState.IsValid) { return(ReportAbuse(id, version)); } var package = _packageService.FindPackageByIdAndVersion(id, version); if (package == null) { return(HttpNotFound()); } User user = null; MailAddress from; if (Request.IsAuthenticated) { user = _userService.FindByUsername(HttpContext.User.Identity.Name); from = user.ToMailAddress(); } else { from = new MailAddress(reportForm.Email); } var request = new ReportPackageRequest { AlreadyContactedOwners = reportForm.AlreadyContactedOwner, FromAddress = from, Message = reportForm.Message, Package = package, Reason = reportForm.Reason, RequestingUser = user, Url = Url }; _messageService.ReportAbuse(request ); TempData["Message"] = "Your abuse report has been sent to the gallery operators."; return(Redirect(Url.Package(id, version))); }
// NOTE: Intentionally NOT requiring authentication public virtual ActionResult ReportAbuse(string id, string version) { var package = _packageService.FindPackageByIdAndVersion(id, version); if (package == null) { return(HttpNotFound()); } var model = new ReportAbuseViewModel { ReasonChoices = { ReportPackageReason.IsFraudulent, ReportPackageReason.ViolatesALicenseIOwn, ReportPackageReason.ContainsMaliciousCode, ReportPackageReason.HasABug, ReportPackageReason.Other }, PackageId = id, PackageVersion = package.Version, }; if (Request.IsAuthenticated) { var user = _userService.FindByUsername(HttpContext.User.Identity.Name); // If user logged on in as owner a different tab, then clicked the link, we can redirect them to ReportMyPackage if (package.IsOwner(user)) { return(RedirectToAction(ActionNames.ReportMyPackage, new { id, version })); } if (user.Confirmed) { model.ConfirmedUser = true; } } ViewData[Constants.ReturnUrlViewDataKey] = Url.Action(ActionNames.ReportMyPackage, new { id, version }); return(View(model)); }
// NOTE: Intentionally NOT requiring authentication public virtual ActionResult ContactAdmins(string id, string version) { var package = packageSvc.FindPackageByIdAndVersion(id, version); if (package == null) return PackageNotFound(id, version); var model = new ReportAbuseViewModel { PackageId = id, PackageVersion = package.Version, }; if (Request.IsAuthenticated) { var user = userSvc.FindByUsername(HttpContext.User.Identity.Name); if (user.Confirmed) model.ConfirmedUser = true; } return View("~/Views/Packages/ContactAdmins.cshtml", model); }
public virtual ActionResult ContactAdmins(string id, string version, ReportAbuseViewModel reportForm) { if (!ModelState.IsValid) return ContactAdmins(id, version); var package = packageSvc.FindPackageByIdAndVersion(id, version); if (package == null) return PackageNotFound(id, version); MailAddress from = null; if (Request.IsAuthenticated) { var user = userSvc.FindByUsername(HttpContext.User.Identity.Name); from = user.ToMailAddress(); } else from = new MailAddress(reportForm.Email); var packageUrl = EnsureTrailingSlash(Configuration.GetSiteRoot(UseHttps())) + RemoveStartingSlash(Url.Package(package)); messageService.ContactSiteAdmins(from, package, reportForm.Message.clean_html(), packageUrl, reportForm.CopySender); TempData["Message"] = "Your message has been sent to the site admins."; return RedirectToAction(MVC.Packages.DisplayPackage(id, version)); }
public virtual ActionResult ReportAbuse(string id, string version) { var package = _packageService.FindPackageByIdAndVersion(id, version); if (package == null) { return(HttpNotFound()); } var model = new ReportAbuseViewModel { ReasonChoices = ReportOtherPackageReasons, PackageId = id, PackageVersion = package.Version, CopySender = true, }; if (Request.IsAuthenticated) { var user = GetCurrentUser(); // If user logged on in as owner a different tab, then clicked the link, we can redirect them to ReportMyPackage if (package.IsOwner(user)) { return(RedirectToAction("ReportMyPackage", new { id, version })); } if (user.Confirmed) { model.ConfirmedUser = true; } } ViewData[Constants.ReturnUrlViewDataKey] = Url.Action("ReportMyPackage", new { id, version }); return(View(model)); }
public virtual ActionResult ReportAbuse(string id, string version) { var package = _packageService.FindPackageByIdAndVersion(id, version); if (package == null) { return HttpNotFound(); } var model = new ReportAbuseViewModel { ReasonChoices = ReportOtherPackageReasons, PackageId = id, PackageVersion = package.Version, }; if (Request.IsAuthenticated) { var user = _userService.FindByUsername(HttpContext.User.Identity.Name); // If user logged on in as owner a different tab, then clicked the link, we can redirect them to ReportMyPackage if (package.IsOwner(user)) { return RedirectToAction(ActionNames.ReportMyPackage, new {id, version}); } if (user.Confirmed) { model.ConfirmedUser = true; } } ViewData[Constants.ReturnUrlViewDataKey] = Url.Action(ActionNames.ReportMyPackage, new {id, version}); return View(model); }
public virtual ActionResult ReportMyPackage(string id, string version) { var user = _userService.FindByUsername(HttpContext.User.Identity.Name); var package = _packageService.FindPackageByIdAndVersion(id, version); if (package == null) { return HttpNotFound(); } // If user hit this url by constructing it manually but is not the owner, redirect them to ReportAbuse if (!(HttpContext.User.IsInRole(Constants.AdminRoleName) || package.IsOwner(user))) { return RedirectToAction(ActionNames.ReportAbuse, new { id, version }); } var model = new ReportAbuseViewModel { ReasonChoices = ReportMyPackageReasons, ConfirmedUser = user.Confirmed, PackageId = id, PackageVersion = package.Version, }; return View(model); }
public virtual ActionResult ReportAbuse(string id, string version, ReportAbuseViewModel reportForm) { // Html Encode the message reportForm.Message = System.Web.HttpUtility.HtmlEncode(reportForm.Message); if (!ModelState.IsValid) { return ReportAbuse(id, version); } var package = _packageService.FindPackageByIdAndVersion(id, version); if (package == null) { return HttpNotFound(); } User user = null; MailAddress from; if (Request.IsAuthenticated) { user = GetCurrentUser(); from = user.ToMailAddress(); } else { from = new MailAddress(reportForm.Email); } var request = new ReportPackageRequest { AlreadyContactedOwners = reportForm.AlreadyContactedOwner, FromAddress = from, Message = reportForm.Message, Package = package, Reason = EnumHelper.GetDescription(reportForm.Reason.Value), RequestingUser = user, Url = Url, CopySender = reportForm.CopySender, Signature = reportForm.Signature }; _messageService.ReportAbuse(request); TempData["Message"] = "Your abuse report has been sent to the gallery operators."; return Redirect(Url.Package(id, version)); }
public virtual ActionResult ReportMyPackage(string id, string version, ReportAbuseViewModel reportForm) { // Html Encode the message reportForm.Message = System.Web.HttpUtility.HtmlEncode(reportForm.Message); if (!ModelState.IsValid) { return ReportMyPackage(id, version); } var package = _packageService.FindPackageByIdAndVersion(id, version); if (package == null) { return HttpNotFound(); } var user = GetCurrentUser(); MailAddress from = user.ToMailAddress(); _messageService.ReportMyPackage( new ReportPackageRequest { FromAddress = from, Message = reportForm.Message, Package = package, Reason = EnumHelper.GetDescription(reportForm.Reason.Value), RequestingUser = user, Url = Url, CopySender = reportForm.CopySender }); TempData["Message"] = "Your support request has been sent to the gallery operators."; return Redirect(Url.Package(id, version)); }
public void SendsMessageToGalleryOwnerWithEmailOnlyWhenUnauthenticated() { var messageService = new Mock<IMessageService>(); messageService.Setup( s => s.ReportAbuse(It.Is<ReportPackageRequest>(r => r.Message == "Mordor took my finger"))); var package = new Package { PackageRegistration = new PackageRegistration { Id = "mordor" }, Version = "2.0.1" }; var packageService = new Mock<IPackageService>(); packageService.Setup(p => p.FindPackageByIdAndVersion("mordor", "2.0.1", true)).Returns(package); var httpContext = new Mock<HttpContextBase>(); httpContext.Setup(h => h.Request.IsAuthenticated).Returns(false); var controller = CreateController( packageService: packageService, messageService: messageService, httpContext: httpContext); var model = new ReportAbuseViewModel { Email = "*****@*****.**", Message = "Mordor took my finger.", Reason = ReportPackageReason.IsFraudulent, AlreadyContactedOwner = true, }; TestUtility.SetupUrlHelper(controller, httpContext); var result = controller.ReportAbuse("mordor", "2.0.1", model) as RedirectResult; Assert.NotNull(result); messageService.Verify( s => s.ReportAbuse( It.Is<ReportPackageRequest>( r => r.FromAddress.Address == "*****@*****.**" && r.Package == package && r.Reason == EnumHelper.GetDescription(ReportPackageReason.IsFraudulent) && r.Message == "Mordor took my finger." && r.AlreadyContactedOwners))); }
public void SendsMessageToGalleryOwnerWithUserInfoWhenAuthenticated() { var messageService = new Mock<IMessageService>(); messageService.Setup( s => s.ReportAbuse(It.Is<ReportPackageRequest>(r => r.Message == "Mordor took my finger"))); var package = new Package { PackageRegistration = new PackageRegistration { Id = "mordor" }, Version = "2.0.1" }; var packageService = new Mock<IPackageService>(); packageService.Setup(p => p.FindPackageByIdAndVersion("mordor", It.IsAny<string>(), true)).Returns(package); var httpContext = new Mock<HttpContextBase>(); httpContext.Setup(h => h.Request.IsAuthenticated).Returns(true); httpContext.Setup(h => h.User.Identity.Name).Returns("Frodo"); var userService = new Mock<IUserService>(); userService.Setup(u => u.FindByUsername("Frodo")).Returns(new User { EmailAddress = "*****@*****.**", Username = "******", Key = 1 }); var controller = CreateController( packageService: packageService, messageService: messageService, userService: userService, httpContext: httpContext); var model = new ReportAbuseViewModel { Message = "Mordor took my finger", Reason = ReportPackageReason.IsFraudulent, }; TestUtility.SetupUrlHelper(controller, httpContext); ActionResult result = controller.ReportAbuse("mordor", "2.0.1", model) as RedirectResult; Assert.NotNull(result); userService.VerifyAll(); messageService.Verify( s => s.ReportAbuse( It.Is<ReportPackageRequest>( r => r.Message == "Mordor took my finger" && r.FromAddress.Address == "*****@*****.**" && r.FromAddress.DisplayName == "Frodo" && r.Reason == EnumHelper.GetDescription(ReportPackageReason.IsFraudulent)))); }
public virtual async Task<ActionResult> ReportMyPackage(string id, string version, ReportAbuseViewModel reportForm) { // Html Encode the message reportForm.Message = System.Web.HttpUtility.HtmlEncode(reportForm.Message); if (!ModelState.IsValid) { return ReportMyPackage(id, version); } var package = _packageService.FindPackageByIdAndVersion(id, version); if (package == null) { return HttpNotFound(); } var user = GetCurrentUser(); MailAddress from = user.ToMailAddress(); var request = new ReportPackageRequest { FromAddress = from, Message = reportForm.Message, Package = package, Reason = EnumHelper.GetDescription(reportForm.Reason.Value), RequestingUser = user, Url = Url, CopySender = reportForm.CopySender }; var subject = $"Owner Support Request for '{package.PackageRegistration.Id}' version {package.Version}"; var requestorEmailAddress = user != null ? user.EmailAddress : reportForm.Email; var reason = EnumHelper.GetDescription(reportForm.Reason.Value); await _supportRequestService.AddNewSupportRequestAsync(subject, reportForm.Message, requestorEmailAddress, reason, user, package); _messageService.ReportMyPackage(request); TempData["Message"] = "Your support request has been sent to the gallery operators."; return Redirect(Url.Package(id, version)); }
public virtual ActionResult ReportAbuse(string id, string version, ReportAbuseViewModel reportForm) { if (!ModelState.IsValid) { return ReportAbuse(id, version); } var package = packageSvc.FindPackageByIdAndVersion(id, version); if (package == null) { return PackageNotFound(id, version); } MailAddress from = null; if (Request.IsAuthenticated) { var user = userSvc.FindByUsername(HttpContext.User.Identity.Name); from = user.ToMailAddress(); } else { from = new MailAddress(reportForm.Email); } messageService.ReportAbuse(from, package, reportForm.Message); TempData["Message"] = "Your abuse report has been sent to the gallery operators."; return RedirectToAction(MVC.Packages.DisplayPackage(id, version)); }
public virtual ActionResult ReportAbuse(string id, string version, ReportAbuseViewModel reportForm) { if (!ModelState.IsValid) { return ReportAbuse(id, version); } var package = _packageService.FindPackageByIdAndVersion(id, version); if (package == null) { return HttpNotFound(); } User user = null; MailAddress from; if (Request.IsAuthenticated) { user = _userService.FindByUsername(HttpContext.User.Identity.Name); from = user.ToMailAddress(); } else { from = new MailAddress(reportForm.Email); } var request = new ReportPackageRequest { AlreadyContactedOwners = reportForm.AlreadyContactedOwner, FromAddress = from, Message = reportForm.Message, Package = package, Reason = EnumHelper.GetDescription(reportForm.Reason.Value), RequestingUser = user, Url = Url }; _messageService.ReportAbuse(request ); TempData["Message"] = "Your abuse report has been sent to the gallery operators."; return Redirect(Url.Package(id, version)); }
public void SendsMessageToGalleryOwnerWithEmailOnlyWhenUnauthenticated() { var messageService = new Mock<IMessageService>(); messageService.Setup( s => s.ReportAbuse( It.IsAny<MailAddress>(), It.IsAny<Package>(), "Mordor took my finger")); var package = new Package { PackageRegistration = new PackageRegistration { Id = "mordor" }, Version = "2.0.1" }; var packageSvc = new Mock<IPackageService>(); packageSvc.Setup(p => p.FindPackageByIdAndVersion("mordor", "2.0.1", true)).Returns(package); var httpContext = new Mock<HttpContextBase>(); httpContext.Setup(h => h.Request.IsAuthenticated).Returns(false); var controller = CreateController( packageSvc: packageSvc, messageSvc: messageService, httpContext: httpContext); var model = new ReportAbuseViewModel { Email = "*****@*****.**", Message = "Mordor took my finger." }; var result = controller.ReportAbuse("mordor", "2.0.1", model) as RedirectToRouteResult; Assert.NotNull(result); messageService.Verify( s => s.ReportAbuse( It.Is<MailAddress>(m => m.Address == "*****@*****.**"), package, "Mordor took my finger." )); }
public virtual ActionResult ContactAdmins(string id, string version, ReportAbuseViewModel reportForm) { if (!ModelState.IsValid) return ContactAdmins(id, version); var package = packageSvc.FindPackageByIdAndVersion(id, version); if (package == null) return PackageNotFound(id, version); MailAddress from = null; if (Request.IsAuthenticated) { var user = userSvc.FindByUsername(HttpContext.User.Identity.Name); from = user.ToMailAddress(); } else from = new MailAddress(reportForm.Email); var packageUrl = EnsureTrailingSlash(Configuration.GetSiteRoot(useHttps: false)) + RemoveStartingSlash(Url.Package(package)); messageService.ContactSiteAdmins(from, package, reportForm.Message, packageUrl, reportForm.CopySender); TempData["Message"] = "Your message has been sent to the site admins."; return RedirectToAction(MVC.Packages.DisplayPackage(id, version)); }
// NOTE: Intentionally NOT requiring authentication public virtual ActionResult ContactAdmins(string id, string version) { var package = packageSvc.FindPackageByIdAndVersion(id, version); if (package == null) return PackageNotFound(id, version); var model = new ReportAbuseViewModel { PackageId = id, PackageVersion = package.Version, }; if (Request.IsAuthenticated) { var user = userSvc.FindByUsername(HttpContext.User.Identity.Name); if (user.Confirmed) model.ConfirmedUser = true; } return View("~/Views/Packages/ContactAdmins.cshtml", model); }
public virtual async Task <ActionResult> ReportMyPackage(string id, string version, ReportAbuseViewModel reportForm) { // Html Encode the message reportForm.Message = System.Web.HttpUtility.HtmlEncode(reportForm.Message); if (!ModelState.IsValid) { return(ReportMyPackage(id, version)); } var package = _packageService.FindPackageByIdAndVersion(id, version); if (package == null) { return(HttpNotFound()); } var user = GetCurrentUser(); MailAddress from = user.ToMailAddress(); var request = new ReportPackageRequest { FromAddress = from, Message = reportForm.Message, Package = package, Reason = EnumHelper.GetDescription(reportForm.Reason.Value), RequestingUser = user, Url = Url, CopySender = reportForm.CopySender }; var subject = $"Owner Support Request for '{package.PackageRegistration.Id}' version {package.Version}"; var requestorEmailAddress = user != null ? user.EmailAddress : reportForm.Email; var reason = EnumHelper.GetDescription(reportForm.Reason.Value); await _supportRequestService.AddNewSupportRequestAsync(subject, reportForm.Message, requestorEmailAddress, reason, user, package); _messageService.ReportMyPackage(request); TempData["Message"] = "Your support request has been sent to the gallery operators."; return(Redirect(Url.Package(id, version))); }
public virtual ActionResult ReportMyPackage(string id, string version) { var user = GetCurrentUser(); var package = _packageService.FindPackageByIdAndVersion(id, version); if (package == null) { return HttpNotFound(); } // If user hit this url by constructing it manually but is not the owner, redirect them to ReportAbuse if (!(User.IsInRole(Constants.AdminRoleName) || package.IsOwner(user))) { return RedirectToAction("ReportAbuse", new { id, version }); } var model = new ReportAbuseViewModel { ReasonChoices = ReportMyPackageReasons, ConfirmedUser = user.Confirmed, PackageId = id, PackageVersion = package.Version, CopySender = true, Signature = user.Username }; return View(model); }
public void SendsMessageToGalleryOwnerWithUserInfoWhenAuthenticated() { var messageService = new Mock<IMessageService>(); messageService.Setup( s => s.ReportAbuse( It.IsAny<MailAddress>(), It.IsAny<Package>(), "Mordor took my finger")); var package = new Package { PackageRegistration = new PackageRegistration { Id = "mordor" }, Version = "2.0.1" }; var packageSvc = new Mock<IPackageService>(); packageSvc.Setup(p => p.FindPackageByIdAndVersion("mordor", It.IsAny<string>(), true)).Returns(package); var httpContext = new Mock<HttpContextBase>(); httpContext.Setup(h => h.Request.IsAuthenticated).Returns(true); httpContext.Setup(h => h.User.Identity.Name).Returns("Frodo"); var userSvc = new Mock<IUserService>(); userSvc.Setup(u => u.FindByUsername("Frodo")).Returns(new User { EmailAddress = "*****@*****.**", Username = "******" }); var controller = CreateController( packageSvc: packageSvc, messageSvc: messageService, userSvc: userSvc, httpContext: httpContext); var model = new ReportAbuseViewModel { Message = "Mordor took my finger." }; var result = controller.ReportAbuse("mordor", "2.0.1", model) as RedirectToRouteResult; Assert.NotNull(result); userSvc.VerifyAll(); messageService.Verify( s => s.ReportAbuse( It.Is<MailAddress>( m => m.Address == "*****@*****.**" && m.DisplayName == "Frodo"), package, "Mordor took my finger." )); }
public virtual ActionResult ReportMyPackage(string id, string version, ReportAbuseViewModel reportForm) { if (!ModelState.IsValid) { return ReportMyPackage(id, version); } var package = _packageService.FindPackageByIdAndVersion(id, version); if (package == null) { return HttpNotFound(); } var user = _userService.FindByUsername(HttpContext.User.Identity.Name); MailAddress from = user.ToMailAddress(); _messageService.ReportMyPackage( new ReportPackageRequest { FromAddress = from, Message = reportForm.Message, Package = package, Reason = EnumHelper.GetDescription(reportForm.Reason.Value), RequestingUser = user, Url = Url }); TempData["Message"] = "Your support request has been sent to the gallery operators."; return Redirect(Url.Package(id, version)); }
public async void HtmlEncodesMessageContent() { var user = new User { Username = "******", Key = 1, EmailAddress = "*****@*****.**" }; var package = new Package { PackageRegistration = new PackageRegistration { Id = "mordor", Owners = { user } }, Version = "2.0.1" }; var packageService = new Mock<IPackageService>(); packageService.Setup(p => p.FindPackageByIdAndVersion("mordor", "2.0.1", true)).Returns(package); ReportPackageRequest reportRequest = null; var messageService = new Mock<IMessageService>(); messageService .Setup(s => s.ReportMyPackage(It.IsAny<ReportPackageRequest>())) .Callback<ReportPackageRequest>(r => reportRequest = r); var httpContext = new Mock<HttpContextBase>(); var controller = CreateController( packageService: packageService, messageService: messageService, httpContext: httpContext); controller.SetCurrentUser(user); var model = new ReportAbuseViewModel { Email = "*****@*****.**", Message = "I like the cut of your jib. It's <b>bold</b>.", Reason = ReportPackageReason.IsFraudulent, AlreadyContactedOwner = true, }; TestUtility.SetupUrlHelper(controller, httpContext); await controller.ReportMyPackage("mordor", "2.0.1", model); Assert.NotNull(reportRequest); Assert.Equal(user.EmailAddress, reportRequest.FromAddress.Address); Assert.Same(package, reportRequest.Package); Assert.Equal(EnumHelper.GetDescription(ReportPackageReason.IsFraudulent), reportRequest.Reason); Assert.Equal("I like the cut of your jib. It's <b>bold</b>.", reportRequest.Message); }
public async Task HtmlEncodesMessageContent() { var messageService = new Mock<IMessageService>(); messageService.Setup( s => s.ReportAbuse(It.Is<ReportPackageRequest>(r => r.Message == "Mordor took my finger"))); var package = new Package { PackageRegistration = new PackageRegistration { Id = "mordor" }, Version = "2.0.1" }; var packageService = new Mock<IPackageService>(); packageService.Setup(p => p.FindPackageByIdAndVersion("mordor", "2.0.1", true)).Returns(package); var httpContext = new Mock<HttpContextBase>(); httpContext.Setup(h => h.Request.IsAuthenticated).Returns(false); var controller = CreateController( packageService: packageService, messageService: messageService, httpContext: httpContext); var model = new ReportAbuseViewModel { Email = "*****@*****.**", Message = "I like the cut of your jib. It's <b>bold</b>.", Reason = ReportPackageReason.IsFraudulent, AlreadyContactedOwner = true, }; TestUtility.SetupUrlHelper(controller, httpContext); await controller.ReportAbuse("mordor", "2.0.1", model); messageService.Verify( s => s.ReportAbuse( It.Is<ReportPackageRequest>( r => r.FromAddress.Address == "*****@*****.**" && r.Package == package && r.Reason == EnumHelper.GetDescription(ReportPackageReason.IsFraudulent) && r.Message == "I like the cut of your jib. It's <b>bold</b>." && r.AlreadyContactedOwners))); }
// NOTE: Intentionally NOT requiring authentication public virtual ActionResult ReportAbuse(string id, string version) { var package = _packageSvc.FindPackageByIdAndVersion(id, version); if (package == null) { return PackageNotFound(id, version); } var model = new ReportAbuseViewModel { PackageId = id, PackageVersion = package.Version, }; if (Request.IsAuthenticated) { var user = _userSvc.FindByUsername(HttpContext.User.Identity.Name); if (user.Confirmed) { model.ConfirmedUser = true; } } return View(model); }