Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1198: Stop using fake non existing from email addresses #1228

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -185,10 +185,7 @@ private EmailAddress getAuthorAddress(CensusInstance censusInstance, HostUser or

var contributor = censusInstance.namespace().get(originalAuthor.id());
if (contributor == null) {
return EmailAddress.from(originalAuthor.fullName(),
censusInstance.namespace().name() + "+" +
originalAuthor.id() + "+" + originalAuthor.username() + "@" +
censusInstance.configuration().census().domain());
return EmailAddress.from(originalAuthor.fullName(), bot.emailAddress().address());
} else {
return EmailAddress.from(contributor.fullName().orElse(originalAuthor.fullName()),
contributor.username() + "@" + censusInstance.configuration().census().domain());
@@ -106,12 +106,6 @@ private long countSubstrings(String string, String substring) {
return Pattern.compile(substring).matcher(string).results().count();
}

private String noreplyAddress(HostedRepository repository) {
return "test+" + repository.forge().currentUser().id() + "+" +
repository.forge().currentUser().username() +
"@openjdk.java.net";
}

@Test
void simpleArchive(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo);
@@ -220,7 +214,7 @@ void simpleArchive(TestInfo testInfo) throws IOException {
var mail = conversations.get(0).first();
assertEquals("RFR: 1234: This is a pull request", mail.subject());
assertEquals(pr.author().fullName(), mail.author().fullName().orElseThrow());
assertEquals(noreplyAddress(archive), mail.author().address());
assertEquals(from.address(), mail.author().address());
assertEquals(listAddress, mail.sender());
assertEquals("val1", mail.headerValue("Extra1"));
assertEquals("val2", mail.headerValue("Extra2"));
@@ -273,7 +267,7 @@ void simpleArchive(TestInfo testInfo) throws IOException {
assertEquals(1, conversations.size());
assertEquals(3, conversations.get(0).allMessages().size());
for (var newMail : conversations.get(0).allMessages()) {
assertEquals(noreplyAddress(archive), newMail.author().address());
assertEquals(from.address(), newMail.author().address());
assertEquals(listAddress, newMail.sender());
}
assertTrue(conversations.get(0).allMessages().get(2).body().contains("This is a comment 😄"));
@@ -675,9 +669,9 @@ void archiveClosed(TestInfo testInfo) throws IOException {
assertEquals(1, archiveContainsCount(archiveFolder.path(), "Subject: Re: RFR: 1234: This is a pull request"));

// The closer should be the bot account - not the PR creator nor the closer
assertEquals(2, archiveContainsCount(archiveFolder.path(), Pattern.quote("From: test+2+user2 at openjdk.java.net (User Number 2)")));
assertEquals(2, archiveContainsCount(archiveFolder.path(), Pattern.quote("From: test at test.mail (User Number 2)")));
assertEquals(1, archiveContainsCount(archiveFolder.path(), Pattern.quote("From: test at test.mail (test)")));
assertEquals(0, archiveContainsCount(archiveFolder.path(), Pattern.quote("From: test+3+user3 at openjdk.java.net (User Number 3)")));
assertEquals(0, archiveContainsCount(archiveFolder.path(), Pattern.quote("From: test at test.mail (User Number 3)")));
}
}

@@ -826,7 +820,7 @@ void reviewComment(TestInfo testInfo) throws IOException {
assertEquals(1, conversations.size());
assertEquals(3, conversations.get(0).allMessages().size());
for (var newMail : conversations.get(0).allMessages()) {
assertEquals(noreplyAddress(archive), newMail.author().address());
assertEquals(from.address(), newMail.author().address());
assertEquals(listAddress, newMail.sender());
}

@@ -1035,7 +1029,7 @@ void commentThreading(TestInfo testInfo) throws IOException {
assertFalse(thread1.body().contains("Another review comment"), thread1.body());
var thread1reply1 = conversations.get(0).replies(thread1).get(0);
assertTrue(thread1reply1.body().contains("I agree"));
assertEquals(noreplyAddress(archive), thread1reply1.author().address());
assertEquals(from.address(), thread1reply1.author().address());
assertEquals(archive.forge().currentUser().fullName(), thread1reply1.author().fullName().orElseThrow());
var thread1reply2 = conversations.get(0).replies(thread1reply1).get(0);
assertTrue(thread1reply2.body().contains("Great"));
@@ -1641,7 +1635,7 @@ void incrementalChanges(TestInfo testInfo) throws IOException {
var conversations = mailmanList.conversations(Duration.ofDays(1));
assertEquals(1, conversations.size());
for (var newMail : conversations.get(0).allMessages()) {
assertEquals(noreplyAddress(archive), newMail.author().address());
assertEquals(from.address(), newMail.author().address());
assertEquals(listAddress, newMail.sender());
}

@@ -1768,7 +1762,7 @@ void rebased(TestInfo testInfo) throws IOException {
var conversations = mailmanList.conversations(Duration.ofDays(1));
assertEquals(1, conversations.size());
for (var newMail : conversations.get(0).allMessages()) {
assertEquals(noreplyAddress(archive), newMail.author().address());
assertEquals(sender.address(), newMail.author().address());
assertEquals(listAddress, newMail.sender());
assertFalse(newMail.hasHeader("PR-Head-Hash"));
}
@@ -2935,7 +2929,7 @@ void multipleRecipients(TestInfo testInfo) throws IOException {
var mail = conversations.get(0).first();
assertEquals("RFR: 1234: This is a pull request", mail.subject());
assertEquals(pr.author().fullName(), mail.author().fullName().orElseThrow());
assertEquals(noreplyAddress(archive), mail.author().address());
assertEquals(from.address(), mail.author().address());
assertEquals(listAddress1, mail.sender());
assertEquals(List.of(listAddress1), mail.recipients());

@@ -2951,7 +2945,7 @@ void multipleRecipients(TestInfo testInfo) throws IOException {
var reply = conversations.get(0).replies(conversations.get(0).first()).get(0);
assertEquals("RFR: 1234: This is a pull request", reply.subject());
assertEquals(pr.author().fullName(), reply.author().fullName().orElseThrow());
assertEquals(noreplyAddress(archive), reply.author().address());
assertEquals(from.address(), reply.author().address());
assertEquals(listAddress1, reply.sender());
assertEquals(List.of(listAddress1, listAddress2), reply.recipients());
}
@@ -3067,7 +3061,7 @@ void jsonArchive(TestInfo testInfo) throws IOException {
var mail = conversations.get(0).first();
assertEquals("RFR: 1234: This is a pull request", mail.subject());
assertEquals(pr.author().fullName(), mail.author().fullName().orElseThrow());
assertEquals(noreplyAddress(archive), mail.author().address());
assertEquals(from.address(), mail.author().address());
assertEquals(listAddress, mail.sender());
assertEquals("val1", mail.headerValue("Extra1"));
assertEquals("val2", mail.headerValue("Extra2"));
@@ -3151,7 +3145,7 @@ void jsonArchive(TestInfo testInfo) throws IOException {
assertEquals(1, conversations.size());
assertEquals(3, conversations.get(0).allMessages().size());
for (var newMail : conversations.get(0).allMessages()) {
assertEquals(noreplyAddress(archive), newMail.author().address());
assertEquals(from.address(), newMail.author().address());
assertEquals(listAddress, newMail.sender());
}
assertTrue(conversations.get(0).allMessages().get(2).body().contains("This is a comment 😄"));