use of com.google.gerrit.acceptance.TestAccount in project gerrit by GerritCodeReview.
the class AccountIT method getEmailsOfOtherAccount.
@Test
public void getEmailsOfOtherAccount() throws Exception {
String email = "preferred3@example.com";
String secondaryEmail = "secondary3@example.com";
TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
EmailInput input = newEmailInput(secondaryEmail);
gApi.accounts().id(foo.id().get()).addEmail(input);
assertThat(gApi.accounts().id(foo.id().get()).getEmails().stream().map(e -> e.email).collect(toSet())).containsExactly(email, secondaryEmail);
}
use of com.google.gerrit.acceptance.TestAccount in project gerrit by GerritCodeReview.
the class AccountIT method cannotAddNonConfirmedEmailWithoutModifyAccountPermission.
@Test
public void cannotAddNonConfirmedEmailWithoutModifyAccountPermission() throws Exception {
TestAccount account = accountCreator.create(name("user"));
EmailInput input = newEmailInput("test@example.com");
requestScopeOperations.setApiUser(user.id());
assertThrows(AuthException.class, () -> gApi.accounts().id(account.username()).addEmail(input));
}
use of com.google.gerrit.acceptance.TestAccount in project gerrit by GerritCodeReview.
the class AccountIT method cannotAddEmailToBeConfirmedToOtherAccountWithoutModifyAccountPermission.
@Test
public void cannotAddEmailToBeConfirmedToOtherAccountWithoutModifyAccountPermission() throws Exception {
TestAccount user = accountCreator.create();
requestScopeOperations.setApiUser(user.id());
AuthException thrown = assertThrows(AuthException.class, () -> gApi.accounts().id(admin.id().get()).addEmail(newEmailInput("foo@example.com", false)));
assertThat(thrown).hasMessageThat().contains("modify account not permitted");
}
use of com.google.gerrit.acceptance.TestAccount in project gerrit by GerritCodeReview.
the class AccountIT method addExistingReviewersUsingPostReview.
@Test
public void addExistingReviewersUsingPostReview() throws Exception {
PushOneCommit.Result r = createChange();
// First reviewer added to the change
ReviewInput input = new ReviewInput();
input.reviewers = new ArrayList<>(1);
ReviewerInput reviewerInput = new ReviewerInput();
reviewerInput.reviewer = user.email();
input.reviewers.add(reviewerInput);
gApi.changes().id(r.getChangeId()).current().review(input);
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message message = messages.get(0);
assertThat(message.rcpt()).containsExactly(user.getNameEmail());
assertMailReplyTo(message, admin.email());
sender.clear();
// Second reviewer and existing reviewer added to the change
ReviewInput input2 = new ReviewInput();
input2.reviewers = new ArrayList<>(2);
ReviewerInput reviewerInput2 = new ReviewerInput();
reviewerInput2.reviewer = user.email();
input2.reviewers.add(reviewerInput2);
ReviewerInput reviewerInput3 = new ReviewerInput();
TestAccount user2 = accountCreator.user2();
reviewerInput3.reviewer = user2.email();
input2.reviewers.add(reviewerInput3);
gApi.changes().id(r.getChangeId()).current().review(input2);
List<Message> messages2 = sender.getMessages();
assertThat(messages2).hasSize(1);
Message message2 = messages2.get(0);
assertThat(message2.rcpt()).containsExactly(user.getNameEmail(), user2.getNameEmail());
assertMailReplyTo(message, admin.email());
sender.clear();
// Existing reviewers re-added to the change: no notifications
ReviewInput input3 = new ReviewInput();
input3.reviewers = new ArrayList<>(2);
ReviewerInput reviewerInput4 = new ReviewerInput();
reviewerInput4.reviewer = user.email();
input3.reviewers.add(reviewerInput4);
ReviewerInput reviewerInput5 = new ReviewerInput();
reviewerInput5.reviewer = user2.email();
input3.reviewers.add(reviewerInput5);
gApi.changes().id(r.getChangeId()).current().review(input3);
List<Message> messages3 = sender.getMessages();
assertThat(messages3).isEmpty();
}
use of com.google.gerrit.acceptance.TestAccount in project gerrit by GerritCodeReview.
the class AccountIT method getOwnEmails.
@Test
public void getOwnEmails() throws Exception {
String email = "preferred@example.com";
TestAccount foo = accountCreator.create(name("foo"), email, "Foo", null);
requestScopeOperations.setApiUser(foo.id());
assertThat(getEmails()).containsExactly(email);
requestScopeOperations.setApiUser(admin.id());
String secondaryEmail = "secondary@example.com";
EmailInput input = newEmailInput(secondaryEmail);
gApi.accounts().id(foo.id().get()).addEmail(input);
requestScopeOperations.setApiUser(foo.id());
assertThat(getEmails()).containsExactly(email, secondaryEmail);
}
Aggregations