-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SendValidationTakingTooLongNotice method with tests (#5402)
* Added SendValidationTakingTooLongNotice method and tests. * Updated with the new message * Removed the signature from the validation taking too long message. Removed the unused argument from the `SendValidationTakingTooLongNotice` method
- Loading branch information
Showing
3 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1069,6 +1069,95 @@ public void WillSendEmailToOwnersRegardlessOfSettings(bool user1PushAllowed, boo | |
} | ||
} | ||
|
||
public class TheSendValidationTakingTooLongNoticeMethod | ||
: TestContainer | ||
{ | ||
[Theory] | ||
[InlineData("1.2.3")] | ||
[InlineData("1.2.3-alpha")] | ||
[InlineData("1.2.3-alpha.1")] | ||
[InlineData("1.2.3+metadata")] | ||
[InlineData("1.2.3-alpha+metadata")] | ||
[InlineData("1.2.3-alpha.1+metadata")] | ||
public void WillSendEmailToAllOwners(string version) | ||
{ | ||
// Arrange | ||
var nugetVersion = new NuGetVersion(version); | ||
var packageRegistration = new PackageRegistration | ||
{ | ||
Id = "smangit", | ||
Owners = new[] | ||
{ | ||
new User { EmailAddress = "[email protected]", NotifyPackagePushed = true }, | ||
new User { EmailAddress = "[email protected]", NotifyPackagePushed = true } | ||
} | ||
}; | ||
var package = new Package | ||
{ | ||
Version = version, | ||
PackageRegistration = packageRegistration | ||
}; | ||
packageRegistration.Packages.Add(package); | ||
|
||
// Act | ||
var messageService = TestableMessageService.Create(GetConfigurationService()); | ||
var packageUrl = $"https://localhost/packages/{packageRegistration.Id}/{nugetVersion.ToNormalizedString()}"; | ||
messageService.SendValidationTakingTooLongNotice(package, packageUrl); | ||
|
||
// Assert | ||
var message = messageService.MockMailSender.Sent.Last(); | ||
|
||
Assert.Equal("[email protected]", message.To[0].Address); | ||
Assert.Equal("[email protected]", message.To[1].Address); | ||
Assert.Equal(TestGalleryNoReplyAddress, message.From); | ||
Assert.Contains($"[Joe Shmoe] Package validation taking longer than expected - {packageRegistration.Id} {nugetVersion.ToNormalizedString()}", message.Subject); | ||
Assert.Contains( | ||
$"It is taking longer than expected for your package [{packageRegistration.Id} {nugetVersion.ToFullString()}]({packageUrl}) to get published.\n\n" + | ||
$"We are looking into it and there is no action on you at this time. We’ll send you an email notification when your package has been published.\n\n" + | ||
$"Thank you for your patience.", message.Body); | ||
} | ||
|
||
public static IEnumerable<object[]> EmailSettingsCombinations | ||
=> from u1pa in new[] { true, false } | ||
from u2pa in new[] { true, false } | ||
from u1ea in new[] { true, false } | ||
from u2ea in new[] { true, false } | ||
select new object[] { u1pa, u2pa, u1ea, u2ea }; | ||
|
||
[Theory] | ||
[MemberData(nameof(EmailSettingsCombinations))] | ||
public void WillSendEmailToOwnersRegardlessOfSettings(bool user1PushAllowed, bool user2PushAllowed, bool user1EmailAllowed, bool user2EmailAllowed) | ||
{ | ||
// Arrange | ||
var packageRegistration = new PackageRegistration | ||
{ | ||
Id = "smangit", | ||
Owners = new[] | ||
{ | ||
new User { EmailAddress = "[email protected]", NotifyPackagePushed = user1PushAllowed, EmailAllowed = user1EmailAllowed }, | ||
new User { EmailAddress = "[email protected]", NotifyPackagePushed = user2PushAllowed, EmailAllowed = user2EmailAllowed } | ||
} | ||
}; | ||
var package = new Package | ||
{ | ||
Version = "1.2.3", | ||
PackageRegistration = packageRegistration | ||
}; | ||
packageRegistration.Packages.Add(package); | ||
|
||
// Act | ||
var messageService = TestableMessageService.Create(GetConfigurationService()); | ||
messageService.SendValidationTakingTooLongNotice(package, "http://dummy1"); | ||
|
||
// Assert | ||
var message = messageService.MockMailSender.Sent.Last(); | ||
|
||
Assert.Equal("[email protected]", message.To[0].Address); | ||
Assert.Equal("[email protected]", message.To[1].Address); | ||
Assert.Equal(2, message.To.Count); | ||
} | ||
} | ||
|
||
public class TheSendPackageUploadedNoticeMethod | ||
: TestContainer | ||
{ | ||
|