use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.
the class OutgoingEmailIT method messageIdHeaderFromAccountUpdate.
@Test
@GerritConfig(name = "auth.registerEmailPrivateKey", value = "HsOc6l_2lhS9G7sE_RsnS7Z6GJjdRDX14co=")
public void messageIdHeaderFromAccountUpdate() throws Exception {
Repository allUsersRepo = repoManager.openRepository(allUsers);
String email = "new.email@example.com";
EmailInput input = new EmailInput();
input.email = email;
sender.clear();
gApi.accounts().self().addEmail(input);
assertThat(sender.getMessages()).hasSize(1);
FakeEmailSender.Message m = sender.getMessages().get(0);
assertThat(m.rcpt()).containsExactly(Address.create(email));
assertThat(getMessageId(sender)).isEqualTo(withPrefixAndSuffixForMessageId(allUsersRepo.getRefDatabase().exactRef(RefNames.refsUsers(admin.id())).getObjectId().getName() + "-HTML"));
}
use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.
the class AbstractSubmit method submitSchedulesOpenChangesOfSameBranchForReindexing.
@Test
@GerritConfig(name = "change.mergeabilityComputationBehavior", value = "API_REF_UPDATED_AND_CHANGE_REINDEX")
public void submitSchedulesOpenChangesOfSameBranchForReindexing() throws Throwable {
// Create a merged change.
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo, "Merged Change", "foo.txt", "foo");
PushOneCommit.Result mergedChange = push.to("refs/for/master");
mergedChange.assertOkStatus();
approve(mergedChange.getChangeId());
submit(mergedChange.getChangeId());
// Create some open changes.
PushOneCommit.Result change1 = createChange();
PushOneCommit.Result change2 = createChange();
PushOneCommit.Result change3 = createChange();
// Create a branch with one open change.
BranchInput in = new BranchInput();
in.revision = projectOperations.project(project).getHead("master").name();
gApi.projects().name(project.get()).branch("dev").create(in);
PushOneCommit.Result changeOtherBranch = createChange("refs/for/dev");
ChangeIndexedListener changeIndexedListener = mock(ChangeIndexedListener.class);
try (Registration registration = extensionRegistry.newRegistration().add(changeIndexedListener)) {
// submit a change, this should trigger asynchronous reindexing of the open changes on the
// same branch
approve(change1.getChangeId());
submit(change1.getChangeId());
assertThat(gApi.changes().id(change1.getChangeId()).get().status).isEqualTo(ChangeStatus.MERGED);
// on submit the change that is submitted gets reindexed synchronously
verify(changeIndexedListener, atLeast(1)).onChangeScheduledForIndexing(project.get(), change1.getChange().getId().get());
verify(changeIndexedListener, atLeast(1)).onChangeIndexed(project.get(), change1.getChange().getId().get());
// the open changes on the same branch get reindexed asynchronously
verify(changeIndexedListener, times(1)).onChangeScheduledForIndexing(project.get(), change2.getChange().getId().get());
verify(changeIndexedListener, times(1)).onChangeScheduledForIndexing(project.get(), change3.getChange().getId().get());
// merged changes don't get reindexed
verify(changeIndexedListener, times(0)).onChangeScheduledForIndexing(project.get(), mergedChange.getChange().getId().get());
// open changes on other branches don't get reindexed
verify(changeIndexedListener, times(0)).onChangeScheduledForIndexing(project.get(), changeOtherBranch.getChange().getId().get());
}
}
use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.
the class AttentionSetIT method canModifyAttentionSetForInvisibleUsersOnVisibleChanges.
@Test
@GerritConfig(name = "accounts.visibility", value = "NONE")
public void canModifyAttentionSetForInvisibleUsersOnVisibleChanges() throws Exception {
PushOneCommit.Result r = createChange();
requestScopeOperations.setApiUser(user.id());
// admin is invisible to the user, but they can still add them to the attention set since they
// see the change.
change(r).addToAttentionSet(new AttentionSetInput(admin.email(), "reason"));
assertThat(Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, admin)).operation()).isEqualTo(Operation.ADD);
// admin is invisible to the user, but they can still remove them to the attention set since
// they see the change.
change(r).attention(admin.id().toString()).remove(new AttentionSetInput("removed"));
assertThat(Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, admin)).operation()).isEqualTo(Operation.REMOVE);
}
use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.
the class AccountManagerIT method activateAccountOnAuthenticationWhenAutoUpdateAccountActiveStatusIsEnabled.
@Test
@GerritConfig(name = "auth.autoUpdateAccountActiveStatus", value = "true")
public void activateAccountOnAuthenticationWhenAutoUpdateAccountActiveStatusIsEnabled() throws Exception {
String username = "foo";
Account.Id accountId = Account.id(seq.nextAccountId());
ExternalId.Key gerritExtIdKey = externalIdKeyFactory.create(ExternalId.SCHEME_GERRIT, username);
accountsUpdate.insert("Create Test Account", accountId, u -> u.setActive(false).addExternalId(externalIdFactory.create(gerritExtIdKey, accountId)));
AuthRequest who = authRequestFactory.createForUser(username);
who.setActive(true);
who.setAuthProvidesAccountActiveStatus(true);
AuthResult authResult = accountManager.authenticate(who);
assertAuthResultForExistingAccount(authResult, accountId, gerritExtIdKey);
Optional<AccountState> accountState = accounts.get(accountId);
assertThat(accountState).isPresent();
assertThat(accountState.get().account().isActive()).isTrue();
}
use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.
the class ChangeIT method strictLabelWithInvalidLabel.
@Test
@GerritConfig(name = "change.strictLabels", value = "true")
public void strictLabelWithInvalidLabel() throws Exception {
String changeId = createChange().getChangeId();
ReviewInput in = new ReviewInput().label("Code-Style", 1);
BadRequestException thrown = assertThrows(BadRequestException.class, () -> gApi.changes().id(changeId).current().review(in));
assertThat(thrown).hasMessageThat().contains("label \"Code-Style\" is not a configured label");
}
Aggregations