AbstractDaemonTest: Inline setApiUser methods
Mark the methods @Deprecated, to avoid breaking non-core plugins with this change. Keep RequestScopeOperations in AbstractDaemonTest private. A long-term goal is to eliminate test inheritance, so having specific tests inject this field will be required eventually anyway. Change-Id: Ic33e644094c28604e0f2c8d6d0f8612845b9edcb
This commit is contained in:
parent
4ab3bb4e9c
commit
fccf2b543a
@ -789,20 +789,17 @@ public abstract class AbstractDaemonTest {
|
||||
return atrScope.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enforce a new request context for the current API user.
|
||||
*
|
||||
* <p>This recreates the IdentifiedUser, hence everything which is cached in the IdentifiedUser is
|
||||
* reloaded (e.g. the email addresses of the user).
|
||||
*/
|
||||
@Deprecated // Tests should inject and use their own RequestScopeOperations.
|
||||
protected Context resetCurrentApiUser() {
|
||||
return requestScopeOperations.resetCurrentApiUser();
|
||||
}
|
||||
|
||||
@Deprecated // Tests should inject and use their own RequestScopeOperations.
|
||||
protected Context setApiUser(TestAccount account) {
|
||||
return requestScopeOperations.setApiUser(account.getId());
|
||||
}
|
||||
|
||||
@Deprecated // Tests should inject and use their own RequestScopeOperations.
|
||||
protected Context setApiUserAnonymous() {
|
||||
return requestScopeOperations.setApiUserAnonymous();
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.truth.FailureMetadata;
|
||||
import com.google.common.truth.Subject;
|
||||
import com.google.common.truth.Truth;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
@ -41,6 +42,7 @@ import com.google.gerrit.mail.EmailHeader.AddressList;
|
||||
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
|
||||
import com.google.gerrit.testing.FakeEmailSender;
|
||||
import com.google.gerrit.testing.FakeEmailSender.Message;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -54,9 +56,11 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
public abstract class AbstractNotificationTest extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Before
|
||||
public void enableReviewerByEmail() throws Exception {
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
ConfigInput conf = new ConfigInput();
|
||||
conf.enableReviewerByEmail = InheritableBoolean.TRUE;
|
||||
gApi.projects().name(project.get()).config(conf);
|
||||
@ -82,7 +86,7 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
|
||||
if (record) {
|
||||
accountsModifyingEmailStrategy.add(account);
|
||||
}
|
||||
setApiUser(account);
|
||||
requestScopeOperations.setApiUser(account.getId());
|
||||
GeneralPreferencesInfo prefs = gApi.accounts().self().getPreferences();
|
||||
prefs.emailStrategy = strategy;
|
||||
gApi.accounts().self().setPreferences(prefs);
|
||||
@ -356,7 +360,7 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
|
||||
assignee = testAccount("assignee");
|
||||
|
||||
watchingProjectOwner = testAccount("watchingProjectOwner", "Administrators");
|
||||
setApiUser(watchingProjectOwner);
|
||||
requestScopeOperations.setApiUser(watchingProjectOwner.getId());
|
||||
watch(allProjects.get(), pwi -> pwi.notifyNewChanges = true);
|
||||
|
||||
for (NotifyType watch : NotifyType.values()) {
|
||||
@ -364,7 +368,7 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
|
||||
continue;
|
||||
}
|
||||
TestAccount watcher = testAccount(watch.toString());
|
||||
setApiUser(watcher);
|
||||
requestScopeOperations.setApiUser(watcher.getId());
|
||||
watch(
|
||||
allProjects.get(),
|
||||
pwi -> {
|
||||
@ -457,7 +461,7 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
|
||||
if (pushOptions != null) {
|
||||
ref = ref + '%' + Joiner.on(',').join(pushOptions);
|
||||
}
|
||||
setApiUser(owner);
|
||||
requestScopeOperations.setApiUser(owner.getId());
|
||||
repo = cloneProject(project, owner);
|
||||
PushOneCommit push = pushFactory.create(owner.getIdent(), repo);
|
||||
result = push.to(ref);
|
||||
@ -479,10 +483,10 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
|
||||
StagedChange(String ref) throws Exception {
|
||||
super(ref);
|
||||
|
||||
setApiUser(starrer);
|
||||
requestScopeOperations.setApiUser(starrer.getId());
|
||||
gApi.accounts().self().starChange(result.getChangeId());
|
||||
|
||||
setApiUser(owner);
|
||||
requestScopeOperations.setApiUser(owner.getId());
|
||||
addReviewers(result);
|
||||
sender.clear();
|
||||
}
|
||||
@ -498,14 +502,14 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
|
||||
|
||||
protected StagedChange stageReviewableWipChange() throws Exception {
|
||||
StagedChange sc = stageReviewableChange();
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
gApi.changes().id(sc.changeId).setWorkInProgress();
|
||||
return sc;
|
||||
}
|
||||
|
||||
protected StagedChange stageAbandonedReviewableChange() throws Exception {
|
||||
StagedChange sc = stageReviewableChange();
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
gApi.changes().id(sc.changeId).abandon();
|
||||
sender.clear();
|
||||
return sc;
|
||||
@ -513,7 +517,7 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
|
||||
|
||||
protected StagedChange stageAbandonedReviewableWipChange() throws Exception {
|
||||
StagedChange sc = stageReviewableWipChange();
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
gApi.changes().id(sc.changeId).abandon();
|
||||
sender.clear();
|
||||
return sc;
|
||||
@ -521,7 +525,7 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
|
||||
|
||||
protected StagedChange stageAbandonedWipChange() throws Exception {
|
||||
StagedChange sc = stageWipChange();
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
gApi.changes().id(sc.changeId).abandon();
|
||||
sender.clear();
|
||||
return sc;
|
||||
|
@ -59,6 +59,7 @@ import com.google.gerrit.acceptance.testsuite.account.AccountOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.account.TestSshKeys;
|
||||
import com.google.gerrit.acceptance.testsuite.group.GroupOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.AccessSection;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
@ -195,21 +196,22 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
return cfg;
|
||||
}
|
||||
|
||||
@Inject private Provider<PublicKeyStore> publicKeyStoreProvider;
|
||||
@Inject private @ServerInitiated Provider<AccountsUpdate> accountsUpdateProvider;
|
||||
@Inject private ExternalIds externalIds;
|
||||
@Inject private AccountIndexer accountIndexer;
|
||||
@Inject private DynamicSet<AccountIndexedListener> accountIndexedListeners;
|
||||
@Inject private DynamicSet<GitReferenceUpdatedListener> refUpdateListeners;
|
||||
@Inject private Sequences seq;
|
||||
@Inject private Provider<InternalAccountQuery> accountQueryProvider;
|
||||
@Inject private StalenessChecker stalenessChecker;
|
||||
@Inject private AccountIndexer accountIndexer;
|
||||
@Inject private GitReferenceUpdated gitReferenceUpdated;
|
||||
@Inject private RetryHelper.Metrics retryMetrics;
|
||||
@Inject private Provider<MetaDataUpdate.InternalFactory> metaDataUpdateInternalFactory;
|
||||
@Inject private ExternalIdNotes.Factory extIdNotesFactory;
|
||||
@Inject private VersionedAuthorizedKeys.Accessor authorizedKeys;
|
||||
@Inject private ExternalIds externalIds;
|
||||
@Inject private GitReferenceUpdated gitReferenceUpdated;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private Provider<InternalAccountQuery> accountQueryProvider;
|
||||
@Inject private Provider<MetaDataUpdate.InternalFactory> metaDataUpdateInternalFactory;
|
||||
@Inject private Provider<PublicKeyStore> publicKeyStoreProvider;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
@Inject private RetryHelper.Metrics retryMetrics;
|
||||
@Inject private Sequences seq;
|
||||
@Inject private StalenessChecker stalenessChecker;
|
||||
@Inject private VersionedAuthorizedKeys.Accessor authorizedKeys;
|
||||
|
||||
@Inject protected Emails emails;
|
||||
|
||||
@ -708,7 +710,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
|
||||
accountIndexedCounter.assertNoReindex();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("not allowed to get stars of another account");
|
||||
gApi.accounts().id(Integer.toString((admin.id.get()))).getStars(triplet);
|
||||
@ -771,11 +773,11 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
in.reviewer = user2.email;
|
||||
gApi.changes().id(r.getChangeId()).addReviewer(in);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.accounts().self().setStars(r.getChangeId(), new StarsInput(ImmutableSet.of(IGNORE_LABEL)));
|
||||
|
||||
sender.clear();
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(r.getChangeId()).abandon();
|
||||
List<Message> messages = sender.getMessages();
|
||||
assertThat(messages).hasSize(1);
|
||||
@ -787,11 +789,11 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
public void addReviewerToIgnoredChange() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.accounts().self().setStars(r.getChangeId(), new StarsInput(ImmutableSet.of(IGNORE_LABEL)));
|
||||
|
||||
sender.clear();
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
|
||||
AddReviewerInput in = new AddReviewerInput();
|
||||
in.reviewer = user.email;
|
||||
@ -832,7 +834,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
String status = "OOO";
|
||||
gApi.accounts().id(foo.id.get()).setStatus(status);
|
||||
|
||||
setApiUser(foo);
|
||||
requestScopeOperations.setApiUser(foo.getId());
|
||||
AccountDetailInfo detail = gApi.accounts().id(foo.id.get()).detail();
|
||||
assertThat(detail._accountId).isEqualTo(foo.id.get());
|
||||
assertThat(detail.name).isEqualTo(name);
|
||||
@ -854,7 +856,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
EmailInput input = newEmailInput(secondaryEmail);
|
||||
gApi.accounts().id(foo.id.get()).addEmail(input);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
AccountDetailInfo detail = gApi.accounts().id(foo.id.get()).detail();
|
||||
assertThat(detail.secondaryEmails).isNull();
|
||||
}
|
||||
@ -876,15 +878,15 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
String email = "preferred@example.com";
|
||||
TestAccount foo = accountCreator.create(name("foo"), email, "Foo");
|
||||
|
||||
setApiUser(foo);
|
||||
requestScopeOperations.setApiUser(foo.getId());
|
||||
assertThat(getEmails()).containsExactly(email);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
String secondaryEmail = "secondary@example.com";
|
||||
EmailInput input = newEmailInput(secondaryEmail);
|
||||
gApi.accounts().id(foo.id.hashCode()).addEmail(input);
|
||||
|
||||
setApiUser(foo);
|
||||
requestScopeOperations.setApiUser(foo.getId());
|
||||
assertThat(getEmails()).containsExactly(email, secondaryEmail);
|
||||
}
|
||||
|
||||
@ -893,7 +895,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
String email = "preferred2@example.com";
|
||||
TestAccount foo = accountCreator.create(name("foo"), email, "Foo");
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("modify account not permitted");
|
||||
gApi.accounts().id(foo.id.get()).getEmails();
|
||||
@ -928,7 +930,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
accountIndexedCounter.assertReindexOf(admin);
|
||||
}
|
||||
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
assertThat(getEmails()).containsAllIn(emails);
|
||||
}
|
||||
|
||||
@ -963,7 +965,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
public void cannotAddNonConfirmedEmailWithoutModifyAccountPermission() throws Exception {
|
||||
TestAccount account = accountCreator.create(name("user"));
|
||||
EmailInput input = newEmailInput("test@test.com");
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
gApi.accounts().id(account.username).addEmail(input);
|
||||
}
|
||||
@ -998,7 +1000,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
value = "HsOc6l+2lhS9G7sE/RsnS7Z6GJjdRDX14co=")
|
||||
public void addEmailToBeConfirmedToOwnAccount() throws Exception {
|
||||
TestAccount user = accountCreator.create();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
String email = "self@example.com";
|
||||
EmailInput input = newEmailInput(email, false);
|
||||
@ -1009,7 +1011,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
public void cannotAddEmailToBeConfirmedToOtherAccountWithoutModifyAccountPermission()
|
||||
throws Exception {
|
||||
TestAccount user = accountCreator.create();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("modify account not permitted");
|
||||
@ -1032,14 +1034,14 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
EmailInput input = newEmailInput(email);
|
||||
gApi.accounts().self().addEmail(input);
|
||||
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
assertThat(getEmails()).contains(email);
|
||||
|
||||
accountIndexedCounter.clear();
|
||||
gApi.accounts().self().deleteEmail(input.email);
|
||||
accountIndexedCounter.assertReindexOf(admin);
|
||||
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
assertThat(getEmails()).doesNotContain(email);
|
||||
}
|
||||
|
||||
@ -1063,13 +1065,13 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
gApi.accounts().self().getExternalIds().stream().map(e -> e.identity).collect(toSet()))
|
||||
.containsAllOf(extId1, extId2);
|
||||
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
assertThat(getEmails()).contains(email);
|
||||
|
||||
gApi.accounts().self().deleteEmail(email);
|
||||
accountIndexedCounter.assertReindexOf(admin);
|
||||
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
assertThat(getEmails()).doesNotContain(email);
|
||||
assertThat(
|
||||
gApi.accounts().self().getExternalIds().stream().map(e -> e.identity).collect(toSet()))
|
||||
@ -1085,15 +1087,15 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
gApi.accounts().id(user.id.get()).addEmail(input);
|
||||
accountIndexedCounter.assertReindexOf(user);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertThat(getEmails()).contains(email);
|
||||
|
||||
// admin can delete email of user
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.accounts().id(user.id.get()).deleteEmail(email);
|
||||
accountIndexedCounter.assertReindexOf(user);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertThat(getEmails()).doesNotContain(email);
|
||||
|
||||
// user cannot delete email of admin
|
||||
@ -1190,7 +1192,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void userCannotSetNameOfOtherUser() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
gApi.accounts().id(admin.username).setName("Admin McAdminface");
|
||||
}
|
||||
@ -1205,7 +1207,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void fetchUserBranch() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers, user);
|
||||
String userRefName = RefNames.refsUsers(user.id);
|
||||
@ -1357,7 +1359,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
accountIndexedCounter.assertNoReindex();
|
||||
assertThat(r.getChange().change().getDest().get()).isEqualTo(userRef);
|
||||
|
||||
setApiUser(foo);
|
||||
requestScopeOperations.setApiUser(foo.getId());
|
||||
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.approve());
|
||||
gApi.changes().id(r.getChangeId()).current().submit();
|
||||
|
||||
@ -1550,7 +1552,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void pushAccountConfigToUserBranch() throws Exception {
|
||||
TestAccount oooUser = accountCreator.create("away", "away@mail.invalid", "Ambrose Way");
|
||||
setApiUser(oooUser);
|
||||
requestScopeOperations.setApiUser(oooUser.getId());
|
||||
|
||||
// Must clone as oooUser to ensure the push is allowed.
|
||||
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers, oooUser);
|
||||
@ -1879,7 +1881,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
assertKeyMapContains(key, addGpgKey(key.getPublicKeyArmored()));
|
||||
assertKeys(key);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(ResourceNotFoundException.class);
|
||||
exception.expectMessage(id);
|
||||
gApi.accounts().self().gpgKey(id).get();
|
||||
@ -1916,7 +1918,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
|
||||
TestKey key = validKeyWithSecondUserId();
|
||||
addGpgKey(key.getPublicKeyArmored());
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
exception.expect(ResourceConflictException.class);
|
||||
exception.expectMessage("GPG key already associated with another account");
|
||||
@ -2059,12 +2061,12 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void reindexPermissions() throws Exception {
|
||||
// admin can reindex any account
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.accounts().id(user.username).index();
|
||||
accountIndexedCounter.assertReindexOf(user);
|
||||
|
||||
// user can reindex own account
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.accounts().self().index();
|
||||
accountIndexedCounter.assertReindexOf(user);
|
||||
|
||||
@ -2077,7 +2079,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void checkConsistency() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
|
||||
// Create an account with a preferred email.
|
||||
String username = name("foo");
|
||||
@ -2600,7 +2602,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
null);
|
||||
|
||||
// Create 2 drafts each on both changes for user.
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
createDraft(r1, PushOneCommit.FILE_NAME, "draft 1a");
|
||||
createDraft(r1, PushOneCommit.FILE_NAME, "draft 1b");
|
||||
createDraft(r2, PushOneCommit.FILE_NAME, "draft 2a");
|
||||
@ -2609,12 +2611,12 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
assertThat(gApi.changes().id(r2.getChangeId()).current().draftsAsList()).hasSize(2);
|
||||
|
||||
// Create 1 draft on first change for admin.
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
createDraft(r1, PushOneCommit.FILE_NAME, "admin draft");
|
||||
assertThat(gApi.changes().id(r1.getChangeId()).current().draftsAsList()).hasSize(1);
|
||||
|
||||
// Delete user's draft comments; leave admin's alone.
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
List<DeletedDraftCommentInfo> result =
|
||||
gApi.accounts().self().deleteDraftComments(new DeleteDraftCommentsInput());
|
||||
|
||||
@ -2630,7 +2632,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
assertThat(gApi.changes().id(r1.getChangeId()).current().draftsAsList()).isEmpty();
|
||||
assertThat(gApi.changes().id(r2.getChangeId()).current().draftsAsList()).isEmpty();
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
assertThat(gApi.changes().id(r1.getChangeId()).current().draftsAsList()).hasSize(1);
|
||||
} finally {
|
||||
cleanUpDrafts();
|
||||
@ -2667,9 +2669,9 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
public void deleteOtherUsersDraftCommentsDisallowed() throws Exception {
|
||||
try {
|
||||
PushOneCommit.Result r = createChange();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
createDraft(r, PushOneCommit.FILE_NAME, "draft");
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
try {
|
||||
gApi.accounts().id(user.id.get()).deleteDraftComments(new DeleteDraftCommentsInput());
|
||||
assert_().fail("expected AuthException");
|
||||
@ -2688,7 +2690,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r1 = createChange();
|
||||
PushOneCommit.Result r2 = createChange("refs/for/secret");
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
createDraft(r1, PushOneCommit.FILE_NAME, "draft a");
|
||||
createDraft(r2, PushOneCommit.FILE_NAME, "draft b");
|
||||
assertThat(gApi.changes().id(r1.getChangeId()).current().draftsAsList()).hasSize(1);
|
||||
@ -2732,7 +2734,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
|
||||
private void cleanUpDrafts() throws Exception {
|
||||
for (TestAccount testAccount : accountCreator.getAll()) {
|
||||
setApiUser(testAccount);
|
||||
requestScopeOperations.setApiUser(testAccount.getId());
|
||||
for (ChangeInfo changeInfo : gApi.changes().query("has:draft").get()) {
|
||||
for (CommentInfo c :
|
||||
gApi.changes()
|
||||
@ -2864,7 +2866,7 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
u.addExternalId(
|
||||
ExternalId.createWithEmail(name("test"), email, account.getId(), email)));
|
||||
accountIndexedCounter.assertReindexOf(account);
|
||||
setApiUser(account);
|
||||
requestScopeOperations.setApiUser(account.getId());
|
||||
}
|
||||
|
||||
private Map<String, GpgKeyInfo> addGpgKey(String armored) throws Exception {
|
||||
|
@ -24,6 +24,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.group.GroupOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.RawInputUtil;
|
||||
import com.google.gerrit.common.data.ContributorAgreement;
|
||||
import com.google.gerrit.common.data.GroupReference;
|
||||
@ -62,6 +63,7 @@ public class AgreementsIT extends AbstractDaemonTest {
|
||||
private ContributorAgreement caAutoVerify;
|
||||
private ContributorAgreement caNoAutoVerify;
|
||||
@Inject private GroupOperations groupOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
protected void setUseContributorAgreements(InheritableBoolean value) throws Exception {
|
||||
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
|
||||
@ -123,7 +125,7 @@ public class AgreementsIT extends AbstractDaemonTest {
|
||||
public void setUp() throws Exception {
|
||||
caAutoVerify = configureContributorAgreement(true);
|
||||
caNoAutoVerify = configureContributorAgreement(false);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -168,7 +170,7 @@ public class AgreementsIT extends AbstractDaemonTest {
|
||||
gApi.accounts().self().signAgreement(caAutoVerify.getName());
|
||||
|
||||
// Explicitly reset the user to force a new request context
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
// Verify that the agreement was signed
|
||||
result = gApi.accounts().self().listAgreements();
|
||||
@ -193,7 +195,7 @@ public class AgreementsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void signAgreementAnonymous() throws Exception {
|
||||
setApiUserAnonymous();
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("Authentication required");
|
||||
gApi.accounts().self().signAgreement(caAutoVerify.getName());
|
||||
@ -224,12 +226,12 @@ public class AgreementsIT extends AbstractDaemonTest {
|
||||
ChangeInfo change = gApi.changes().create(newChangeInput()).get();
|
||||
|
||||
// Approve and submit it
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(change.changeId).current().review(ReviewInput.approve());
|
||||
gApi.changes().id(change.changeId).current().submit(new SubmitInput());
|
||||
|
||||
// Revert is not allowed when CLA is required but not signed
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
setUseContributorAgreements(InheritableBoolean.TRUE);
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("Contributor Agreement");
|
||||
@ -248,12 +250,12 @@ public class AgreementsIT extends AbstractDaemonTest {
|
||||
ChangeInfo change = gApi.changes().create(newChangeInput()).get();
|
||||
|
||||
// Approve and submit it
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(change.changeId).current().review(ReviewInput.approve());
|
||||
gApi.changes().id(change.changeId).current().submit(new SubmitInput());
|
||||
|
||||
// Revert in excluded project is allowed even when CLA is required but not signed
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
setUseContributorAgreements(InheritableBoolean.TRUE);
|
||||
gApi.changes().id(change.changeId).revert();
|
||||
}
|
||||
@ -263,7 +265,7 @@ public class AgreementsIT extends AbstractDaemonTest {
|
||||
assume().that(isContributorAgreementsEnabled()).isTrue();
|
||||
|
||||
// Create a new branch
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
BranchInfo dest =
|
||||
gApi.projects()
|
||||
.name(project.get())
|
||||
@ -280,7 +282,7 @@ public class AgreementsIT extends AbstractDaemonTest {
|
||||
gApi.changes().id(change.changeId).current().submit(new SubmitInput());
|
||||
|
||||
// Cherry-pick is not allowed when CLA is required but not signed
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
setUseContributorAgreements(InheritableBoolean.TRUE);
|
||||
CherryPickInput in = new CherryPickInput();
|
||||
in.destination = dest.ref;
|
||||
@ -311,7 +313,7 @@ public class AgreementsIT extends AbstractDaemonTest {
|
||||
gApi.accounts().self().signAgreement(caAutoVerify.getName());
|
||||
|
||||
// Explicitly reset the user to force a new request context
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
// Create a change succeeds after signing the agreement
|
||||
gApi.changes().create(newChangeInput());
|
||||
@ -350,7 +352,7 @@ public class AgreementsIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
@GerritConfig(name = "auth.contributorAgreements", value = "true")
|
||||
public void anonymousAccessServerInfoEvenWithCLAs() throws Exception {
|
||||
setApiUserAnonymous();
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
gApi.config().server().getInfo();
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.client.ChangeStatus;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@ -44,6 +45,7 @@ import org.junit.Test;
|
||||
|
||||
public class AbandonIT extends AbstractDaemonTest {
|
||||
@Inject private AbandonUtil abandonUtil;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void abandon() throws Exception {
|
||||
@ -127,7 +129,7 @@ public class AbandonIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r = createChange();
|
||||
String changeId = r.getChangeId();
|
||||
assertThat(info(changeId).status).isEqualTo(ChangeStatus.NEW);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("abandon not permitted");
|
||||
gApi.changes().id(changeId).abandon();
|
||||
@ -139,7 +141,7 @@ public class AbandonIT extends AbstractDaemonTest {
|
||||
String changeId = r.getChangeId();
|
||||
assertThat(info(changeId).status).isEqualTo(ChangeStatus.NEW);
|
||||
grant(project, "refs/heads/master", Permission.ABANDON, false, REGISTERED_USERS);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(changeId).abandon();
|
||||
assertThat(info(changeId).status).isEqualTo(ChangeStatus.ABANDONED);
|
||||
gApi.changes().id(changeId).restore();
|
||||
@ -170,7 +172,7 @@ public class AbandonIT extends AbstractDaemonTest {
|
||||
String changeId = r.getChangeId();
|
||||
assertThat(info(changeId).status).isEqualTo(ChangeStatus.NEW);
|
||||
gApi.changes().id(changeId).abandon();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertThat(info(changeId).status).isEqualTo(ChangeStatus.ABANDONED);
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("restore not permitted");
|
||||
|
@ -68,6 +68,7 @@ import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.account.AccountOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.group.GroupOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.FooterConstants;
|
||||
import com.google.gerrit.common.data.LabelFunction;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
@ -181,17 +182,14 @@ import org.junit.Test;
|
||||
public class ChangeIT extends AbstractDaemonTest {
|
||||
private String systemTimeZone;
|
||||
|
||||
@Inject private DynamicSet<ChangeMessageModifier> changeMessageModifiers;
|
||||
|
||||
@Inject private DynamicSet<ChangeIndexedListener> changeIndexedListeners;
|
||||
|
||||
@Inject private AccountOperations accountOperations;
|
||||
|
||||
@Inject private ChangeIndexCollection changeIndexCollection;
|
||||
@Inject private DynamicSet<ChangeIndexedListener> changeIndexedListeners;
|
||||
@Inject private DynamicSet<ChangeMessageModifier> changeMessageModifiers;
|
||||
@Inject private GroupOperations groupOperations;
|
||||
@Inject private IndexConfig indexConfig;
|
||||
|
||||
@Inject protected GroupOperations groupOperations;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private ChangeIndexedCounter changeIndexedCounter;
|
||||
private RegistrationHandle changeIndexedCounterHandle;
|
||||
@ -261,7 +259,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result result =
|
||||
pushFactory.create(user.getIdent(), userRepo).to("refs/for/master");
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
String changeId = result.getChangeId();
|
||||
assertThat(gApi.changes().id(changeId).get().isPrivate).isNull();
|
||||
|
||||
@ -302,7 +300,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
assertThat(gApi.changes().id(changeId).get().isPrivate).isNull();
|
||||
|
||||
gApi.changes().id(changeId).setPrivate(true, null);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
ChangeInfo info = gApi.changes().id(changeId).get();
|
||||
assertThat(info.isPrivate).isTrue();
|
||||
}
|
||||
@ -310,7 +308,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void cannotSetOtherUsersChangePrivate() throws Exception {
|
||||
PushOneCommit.Result result = createChange();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("not allowed to mark private");
|
||||
gApi.changes().id(result.getChangeId()).setPrivate(true, null);
|
||||
@ -322,7 +320,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result result =
|
||||
pushFactory.create(user.getIdent(), userRepo).to("refs/for/master");
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(result.getChangeId()).setPrivate(true, null);
|
||||
// Owner can always access its private changes.
|
||||
assertThat(gApi.changes().id(result.getChangeId()).get().isPrivate).isTrue();
|
||||
@ -331,7 +329,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
gApi.changes().id(result.getChangeId()).addReviewer(admin.getId().toString());
|
||||
|
||||
// This change should be visible for admin as a reviewer.
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
assertThat(gApi.changes().id(result.getChangeId()).get().isPrivate).isTrue();
|
||||
|
||||
// Remove admin from reviewers.
|
||||
@ -349,7 +347,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
gApi.changes().id(result.getChangeId()).setPrivate(true, null);
|
||||
|
||||
allow("refs/*", Permission.VIEW_PRIVATE_CHANGES, REGISTERED_USERS);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertThat(gApi.changes().id(result.getChangeId()).get().isPrivate).isTrue();
|
||||
}
|
||||
|
||||
@ -385,7 +383,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
merge(result);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("not allowed to mark private");
|
||||
gApi.changes().id(changeId).setPrivate(true, null);
|
||||
@ -405,7 +403,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
merge(result);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(changeId).setPrivate(false, null);
|
||||
assertThat(gApi.changes().id(changeId).get().isPrivate).isNull();
|
||||
}
|
||||
@ -415,7 +413,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result rwip = createChange();
|
||||
String changeId = rwip.getChangeId();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("not allowed to toggle work in progress");
|
||||
gApi.changes().id(changeId).setWorkInProgress();
|
||||
@ -423,24 +421,24 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void setWorkInProgressAllowedAsAdmin() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
String changeId =
|
||||
gApi.changes().create(new ChangeInput(project.get(), "master", "Test Change")).get().id;
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(changeId).setWorkInProgress();
|
||||
assertThat(gApi.changes().id(changeId).get().workInProgress).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setWorkInProgressAllowedAsProjectOwner() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
String changeId =
|
||||
gApi.changes().create(new ChangeInput(project.get(), "master", "Test Change")).get().id;
|
||||
|
||||
com.google.gerrit.acceptance.TestAccount user2 = accountCreator.user2();
|
||||
grant(project, "refs/*", Permission.OWNER, false, REGISTERED_USERS);
|
||||
setApiUser(user2);
|
||||
requestScopeOperations.setApiUser(user2.getId());
|
||||
gApi.changes().id(changeId).setWorkInProgress();
|
||||
assertThat(gApi.changes().id(changeId).get().workInProgress).isTrue();
|
||||
}
|
||||
@ -461,7 +459,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
String changeId = rready.getChangeId();
|
||||
gApi.changes().id(changeId).setWorkInProgress();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("not allowed to toggle work in progress");
|
||||
gApi.changes().id(changeId).setReadyForReview();
|
||||
@ -469,26 +467,26 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void setReadyForReviewAllowedAsAdmin() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
String changeId =
|
||||
gApi.changes().create(new ChangeInput(project.get(), "master", "Test Change")).get().id;
|
||||
gApi.changes().id(changeId).setWorkInProgress();
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(changeId).setReadyForReview();
|
||||
assertThat(gApi.changes().id(changeId).get().workInProgress).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setReadyForReviewAllowedAsProjectOwner() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
String changeId =
|
||||
gApi.changes().create(new ChangeInput(project.get(), "master", "Test Change")).get().id;
|
||||
gApi.changes().id(changeId).setWorkInProgress();
|
||||
|
||||
com.google.gerrit.acceptance.TestAccount user2 = accountCreator.user2();
|
||||
grant(project, "refs/*", Permission.OWNER, false, REGISTERED_USERS);
|
||||
setApiUser(user2);
|
||||
requestScopeOperations.setApiUser(user2.getId());
|
||||
gApi.changes().id(changeId).setReadyForReview();
|
||||
assertThat(gApi.changes().id(changeId).get().workInProgress).isNull();
|
||||
}
|
||||
@ -700,7 +698,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
r.assertOkStatus();
|
||||
assertThat(r.getChange().change().getOwner()).isEqualTo(user.id);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
ReviewInput in = ReviewInput.noScore().setWorkInProgress(true);
|
||||
gApi.changes().id(r.getChangeId()).current().review(in);
|
||||
ChangeInfo info = gApi.changes().id(r.getChangeId()).get();
|
||||
@ -715,7 +713,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
r.assertOkStatus();
|
||||
assertThat(r.getChange().change().getOwner()).isEqualTo(user.id);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
ReviewInput in = ReviewInput.noScore().setWorkInProgress(true);
|
||||
gApi.changes().id(r.getChangeId()).current().review(in);
|
||||
ChangeInfo info = gApi.changes().id(r.getChangeId()).get();
|
||||
@ -726,7 +724,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
public void reviewWithWorkInProgressByNonOwnerReturnsError() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
ReviewInput in = ReviewInput.noScore().setWorkInProgress(true);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("not allowed to toggle work in progress");
|
||||
gApi.changes().id(r.getChangeId()).current().review(in);
|
||||
@ -736,7 +734,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
public void reviewWithReadyByNonOwnerReturnsError() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
ReviewInput in = ReviewInput.noScore().setReady(true);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("not allowed to toggle work in progress");
|
||||
gApi.changes().id(r.getChangeId()).current().review(in);
|
||||
@ -838,7 +836,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
// expect both the original reviewers and CCs to be preserved
|
||||
// original owner should be added as reviewer, user requesting the revert (new owner) removed
|
||||
setApiUser(accountCreator.admin2());
|
||||
requestScopeOperations.setApiUser(accountCreator.admin2().getId());
|
||||
Map<ReviewerState, Collection<AccountInfo>> result =
|
||||
gApi.changes().id(r.getChangeId()).revert().get().reviewers;
|
||||
assertThat(result).containsKey(ReviewerState.REVIEWER);
|
||||
@ -1020,7 +1018,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
// Rebase the second
|
||||
String changeId = r2.getChangeId();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("rebase not permitted");
|
||||
gApi.changes().id(changeId).rebase();
|
||||
@ -1042,7 +1040,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
// Rebase the second
|
||||
String changeId = r2.getChangeId();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(changeId).rebase();
|
||||
}
|
||||
|
||||
@ -1063,7 +1061,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
// Rebase the second
|
||||
String changeId = r2.getChangeId();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("rebase not permitted");
|
||||
gApi.changes().id(changeId).rebase();
|
||||
@ -1102,7 +1100,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
pushFactory.create(user.getIdent(), testRepo).to("refs/for/master");
|
||||
String changeId = changeResult.getChangeId();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("delete not permitted");
|
||||
gApi.changes().id(changeId).delete();
|
||||
@ -1161,7 +1159,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
com.google.gerrit.acceptance.TestAccount deleteAs)
|
||||
throws Exception {
|
||||
try {
|
||||
setApiUser(owner);
|
||||
requestScopeOperations.setApiUser(owner.getId());
|
||||
ChangeInput in = new ChangeInput();
|
||||
in.project = projectName.get();
|
||||
in.branch = "refs/heads/master";
|
||||
@ -1173,7 +1171,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
assertThat(gApi.changes().id(changeId).info().owner._accountId).isEqualTo(owner.id.get());
|
||||
|
||||
setApiUser(deleteAs);
|
||||
requestScopeOperations.setApiUser(deleteAs.getId());
|
||||
gApi.changes().id(changeId).delete();
|
||||
|
||||
assertThat(query(changeId)).isEmpty();
|
||||
@ -1200,7 +1198,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result changeResult = createChange();
|
||||
String changeId = changeResult.getChangeId();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("delete not permitted");
|
||||
gApi.changes().id(changeId).delete();
|
||||
@ -1227,7 +1225,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
pushFactory.create(user.getIdent(), testRepo).to("refs/for/master");
|
||||
String changeId = changeResult.getChangeId();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(changeId).abandon();
|
||||
|
||||
exception.expect(AuthException.class);
|
||||
@ -1273,7 +1271,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
merge(changeResult);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(MethodNotAllowedException.class);
|
||||
exception.expectMessage("delete not permitted");
|
||||
gApi.changes().id(changeId).delete();
|
||||
@ -1536,7 +1534,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
assertThat(commit.committer.email).isEqualTo(user.email);
|
||||
|
||||
// check the user cannot see the change
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
try {
|
||||
gApi.changes().id(result.getChangeId()).get();
|
||||
fail("Expected ResourceNotFoundException");
|
||||
@ -1613,7 +1611,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
result.assertOkStatus();
|
||||
|
||||
// check that 'user' cannot see the change
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
try {
|
||||
gApi.changes().id(result.getChangeId()).get();
|
||||
fail("Expected ResourceNotFoundException");
|
||||
@ -1622,7 +1620,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
// check that 'user' was NOT added as cc ('user' can't see the change)
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
ChangeInfo change = gApi.changes().id(result.getChangeId()).get();
|
||||
assertThat(change.reviewers.get(REVIEWER)).isNull();
|
||||
assertThat(change.reviewers.get(CC)).isNull();
|
||||
@ -1646,7 +1644,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
result.assertOkStatus();
|
||||
|
||||
// check the user cannot see the change
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
try {
|
||||
gApi.changes().id(result.getChangeId()).get();
|
||||
fail("Expected ResourceNotFoundException");
|
||||
@ -1655,7 +1653,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
// try to add user as reviewer
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
AddReviewerInput in = new AddReviewerInput();
|
||||
in.reviewer = user.email;
|
||||
AddReviewerResult r = gApi.changes().id(result.getChangeId()).addReviewer(in);
|
||||
@ -1907,7 +1905,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
AddReviewerInput in = new AddReviewerInput();
|
||||
in.reviewer = user.email;
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(r.getChangeId()).addReviewer(in);
|
||||
|
||||
// There should be no email notification when adding self
|
||||
@ -1944,7 +1942,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
private void testImplicitlyCcOnNonVotingReviewPgStyle(
|
||||
com.google.gerrit.acceptance.TestAccount testAccount) throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
setApiUser(testAccount);
|
||||
requestScopeOperations.setApiUser(testAccount.getId());
|
||||
assertThat(getReviewerState(r.getChangeId(), testAccount.id)).isEmpty();
|
||||
|
||||
// Exact request format made by PG UI at ddc6b7160fe416fed9e7e3180489d44c82fd64f8.
|
||||
@ -1961,7 +1959,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void implicitlyAddReviewerOnVotingReview() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes()
|
||||
.id(r.getChangeId())
|
||||
.revision(r.getCommit().name())
|
||||
@ -1973,12 +1971,12 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
// Further test: remove the vote, then comment again. The user should be
|
||||
// implicitly re-added to the ReviewerSet, as a CC if we're using NoteDb.
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).remove();
|
||||
c = gApi.changes().id(r.getChangeId()).get();
|
||||
assertThat(c.reviewers.values()).isEmpty();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes()
|
||||
.id(r.getChangeId())
|
||||
.revision(r.getCommit().name())
|
||||
@ -2080,7 +2078,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
assertThat(m).hasSize(1);
|
||||
assertThat(m).containsEntry("Code-Review", Short.valueOf((short) 2));
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.dislike());
|
||||
|
||||
m = gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).votes();
|
||||
@ -2152,7 +2150,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
String changeId = r.getChangeId();
|
||||
gApi.changes().id(changeId).revision(r.getCommit().name()).review(ReviewInput.approve());
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(changeId).revision(r.getCommit().name()).review(ReviewInput.recommend());
|
||||
|
||||
Collection<AccountInfo> reviewers = gApi.changes().id(changeId).get().reviewers.get(REVIEWER);
|
||||
@ -2163,7 +2161,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
assertThat(reviewerIt.next()._accountId).isEqualTo(user.getId().get());
|
||||
|
||||
sender.clear();
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
DeleteReviewerInput input = new DeleteReviewerInput();
|
||||
if (!notify) {
|
||||
input.notify = NotifyHandling.NONE;
|
||||
@ -2194,7 +2192,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
String changeId = r.getChangeId();
|
||||
gApi.changes().id(changeId).revision(r.getCommit().name()).review(ReviewInput.approve());
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("remove reviewer not permitted");
|
||||
gApi.changes().id(r.getChangeId()).reviewer(admin.getId().toString()).remove();
|
||||
@ -2205,14 +2203,14 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r = createChange();
|
||||
String changeId = r.getChangeId();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
recommend(changeId);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
approve(changeId);
|
||||
gApi.changes().id(changeId).revision(r.getCommit().name()).submit();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("remove reviewer not permitted");
|
||||
gApi.changes().id(r.getChangeId()).reviewer("self").remove();
|
||||
@ -2223,13 +2221,13 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r = createChange();
|
||||
String changeId = r.getChangeId();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
recommend(changeId);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(changeId).abandon();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(r.getChangeId()).reviewer("self").remove();
|
||||
eventRecorder.assertReviewerDeletedEvents(changeId, user.email);
|
||||
}
|
||||
@ -2239,14 +2237,14 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r = createChange();
|
||||
String changeId = r.getChangeId();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
recommend(changeId);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
approve(changeId);
|
||||
gApi.changes().id(changeId).abandon();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("remove reviewer not permitted");
|
||||
gApi.changes().id(r.getChangeId()).reviewer(admin.getId().toString()).remove();
|
||||
@ -2257,10 +2255,10 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r = createChange();
|
||||
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
recommend(r.getChangeId());
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
sender.clear();
|
||||
gApi.changes().id(r.getChangeId()).reviewer(user.getId().toString()).deleteVote("Code-Review");
|
||||
|
||||
@ -2292,10 +2290,10 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r = createChange();
|
||||
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
recommend(r.getChangeId());
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
sender.clear();
|
||||
DeleteVoteInput in = new DeleteVoteInput();
|
||||
in.label = "Code-Review";
|
||||
@ -2321,9 +2319,9 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
.preferredEmail(email)
|
||||
.fullname("User2")
|
||||
.create();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
recommend(r.getChangeId());
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
sender.clear();
|
||||
in.notifyDetails = new HashMap<>();
|
||||
in.notifyDetails.put(RecipientType.TO, new NotifyInfo(ImmutableList.of(email)));
|
||||
@ -2331,9 +2329,9 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
assertNotifyTo(email, "User2");
|
||||
|
||||
// notify unrelated account as CC
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
recommend(r.getChangeId());
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
sender.clear();
|
||||
in.notifyDetails = new HashMap<>();
|
||||
in.notifyDetails.put(RecipientType.CC, new NotifyInfo(ImmutableList.of(email)));
|
||||
@ -2341,9 +2339,9 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
assertNotifyCc(email, "User2");
|
||||
|
||||
// notify unrelated account as BCC
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
recommend(r.getChangeId());
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
sender.clear();
|
||||
in.notifyDetails = new HashMap<>();
|
||||
in.notifyDetails.put(RecipientType.BCC, new NotifyInfo(ImmutableList.of(email)));
|
||||
@ -2356,7 +2354,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r = createChange();
|
||||
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("delete vote not permitted");
|
||||
gApi.changes().id(r.getChangeId()).reviewer(admin.getId().toString()).deleteVote("Code-Review");
|
||||
@ -2400,12 +2398,12 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
// Approve the change as user, then remove the approval
|
||||
// (only to confirm that the user does have Code-Review+2 permission)
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(changeId).revision(commit).review(ReviewInput.approve());
|
||||
gApi.changes().id(changeId).revision(commit).review(ReviewInput.noScore());
|
||||
|
||||
// Submit the change
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(changeId).revision(commit).submit();
|
||||
|
||||
// User should still be on the change
|
||||
@ -2522,7 +2520,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
assertThat(
|
||||
Iterables.getOnlyElement(query("project:{" + project.get() + "} owner:self")).changeId)
|
||||
.isEqualTo(r.getChangeId());
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertThat(query("owner:self project:{" + project.get() + "}")).isEmpty();
|
||||
}
|
||||
|
||||
@ -2533,7 +2531,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
in.reviewer = user.email;
|
||||
gApi.changes().id(r.getChangeId()).addReviewer(in);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertThat(get(r.getChangeId(), REVIEWED).reviewed).isNull();
|
||||
|
||||
revision(r).review(ReviewInput.recommend());
|
||||
@ -2554,7 +2552,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
public void editTopicWithoutPermissionNotAllowed() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
assertThat(gApi.changes().id(r.getChangeId()).topic()).isEqualTo("");
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("edit topic name not permitted");
|
||||
gApi.changes().id(r.getChangeId()).topic("mytopic");
|
||||
@ -2565,7 +2563,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r = createChange();
|
||||
assertThat(gApi.changes().id(r.getChangeId()).topic()).isEqualTo("");
|
||||
grant(project, "refs/heads/master", Permission.EDIT_TOPIC_NAME, false, REGISTERED_USERS);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(r.getChangeId()).topic("mytopic");
|
||||
assertThat(gApi.changes().id(r.getChangeId()).topic()).isEqualTo("mytopic");
|
||||
}
|
||||
@ -2609,7 +2607,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
public void submitNotAllowedWithoutPermission() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("submit not permitted");
|
||||
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).submit();
|
||||
@ -2620,7 +2618,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r = createChange();
|
||||
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
|
||||
grant(project, "refs/heads/master", Permission.SUBMIT, false, REGISTERED_USERS);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).submit();
|
||||
assertThat(gApi.changes().id(r.getChangeId()).info().status).isEqualTo(ChangeStatus.MERGED);
|
||||
}
|
||||
@ -2726,7 +2724,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void defaultSearchDoesNotTouchDatabase() throws Exception {
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
PushOneCommit.Result r1 = createChange();
|
||||
gApi.changes()
|
||||
.id(r1.getChangeId())
|
||||
@ -2736,7 +2734,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
createChange();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
AcceptanceTestRequestScope.Context ctx = disableDb();
|
||||
try {
|
||||
assertThat(
|
||||
@ -2803,7 +2801,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void anonymousRestApi() throws Exception {
|
||||
setApiUserAnonymous();
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
PushOneCommit.Result r = createChange();
|
||||
|
||||
ChangeInfo info = gApi.changes().id(r.getChangeId()).get();
|
||||
@ -3038,7 +3036,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
gApi.changes().id(baseChange).setPrivate(true, "set private");
|
||||
|
||||
// Create the destination change on 'master' branch.
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
testRepo.reset(initialHead);
|
||||
String changeId = createChange().getChangeId();
|
||||
|
||||
@ -3259,10 +3257,10 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
PushOneCommit.Result r = createChange();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).review(ReviewInput.approve());
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).submit();
|
||||
|
||||
ChangeInfo change = gApi.changes().id(r.getChangeId()).get();
|
||||
@ -3482,7 +3480,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
.isEqualTo("test commit\n\nChange-Id: " + r.getChangeId() + "\n");
|
||||
|
||||
for (com.google.gerrit.acceptance.TestAccount acc : ImmutableList.of(admin, user)) {
|
||||
setApiUser(acc);
|
||||
requestScopeOperations.setApiUser(acc.getId());
|
||||
String newMessage =
|
||||
"modified commit by " + acc.username + "\n\nChange-Id: " + r.getChangeId() + "\n";
|
||||
gApi.changes().id(r.getChangeId()).setMessage(newMessage);
|
||||
@ -3501,7 +3499,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
// Move the change to WIP and edit the commit message again, to observe a
|
||||
// different tag. Must switch to change owner to move into WIP.
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(r.getChangeId()).setWorkInProgress();
|
||||
String newMessage = "modified commit in WIP change\n\nChange-Id: " + r.getChangeId() + "\n";
|
||||
gApi.changes().id(r.getChangeId()).setMessage(newMessage);
|
||||
@ -3747,7 +3745,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
u.save();
|
||||
}
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
PushOneCommit.Result r = createChange();
|
||||
String changeId = r.getChangeId();
|
||||
|
||||
@ -3767,7 +3765,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
.containsExactly((short) 2, (short) 1);
|
||||
assertThat(gApi.changes().id(changeId).get().submittable).isTrue();
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
// Remove user's permission for 'Label'.
|
||||
try (ProjectConfigUpdate u = updateProject(project)) {
|
||||
Util.remove(u.getConfig(), Permission.forLabel(label), registered, "refs/heads/*");
|
||||
@ -3779,7 +3777,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
// Verify user's new permitted range.
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
change = gApi.changes().id(changeId).get();
|
||||
assertPermitted(change, label);
|
||||
assertPermitted(change, codeReviewLabel, -1, 0, 1);
|
||||
@ -3788,7 +3786,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
.containsExactly((short) 2, (short) 1);
|
||||
assertThat(gApi.changes().id(changeId).get().submittable).isTrue();
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(changeId).current().submit();
|
||||
}
|
||||
|
||||
@ -3964,18 +3962,18 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
in.reviewer = email;
|
||||
gApi.changes().id(r.getChangeId()).addReviewer(in);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(r.getChangeId()).ignore(true);
|
||||
assertThat(gApi.changes().id(r.getChangeId()).ignored()).isTrue();
|
||||
|
||||
sender.clear();
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(r.getChangeId()).abandon();
|
||||
List<Message> messages = sender.getMessages();
|
||||
assertThat(messages).hasSize(1);
|
||||
assertThat(messages.get(0).rcpt()).containsExactly(new Address(fullname, email));
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(r.getChangeId()).ignore(false);
|
||||
assertThat(gApi.changes().id(r.getChangeId()).ignored()).isFalse();
|
||||
}
|
||||
@ -3993,7 +3991,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
public void cannotIgnoreStarredChange() throws Exception {
|
||||
String changeId = createChange().getChangeId();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.accounts().self().starChange(changeId);
|
||||
assertThat(gApi.changes().id(changeId).get().starred).isTrue();
|
||||
|
||||
@ -4011,7 +4009,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
public void cannotStarIgnoredChange() throws Exception {
|
||||
String changeId = createChange().getChangeId();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(changeId).ignore(true);
|
||||
assertThat(gApi.changes().id(changeId).ignored()).isTrue();
|
||||
|
||||
@ -4035,16 +4033,16 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
in.reviewer = user.email;
|
||||
gApi.changes().id(r.getChangeId()).addReviewer(in);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertThat(gApi.changes().id(r.getChangeId()).get().reviewed).isNull();
|
||||
gApi.changes().id(r.getChangeId()).markAsReviewed(true);
|
||||
assertThat(gApi.changes().id(r.getChangeId()).get().reviewed).isTrue();
|
||||
|
||||
setApiUser(user2);
|
||||
requestScopeOperations.setApiUser(user2.getId());
|
||||
sender.clear();
|
||||
amendChange(r.getChangeId());
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertThat(gApi.changes().id(r.getChangeId()).get().reviewed).isNull();
|
||||
|
||||
List<Message> messages = sender.getMessages();
|
||||
@ -4056,7 +4054,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
public void cannotSetUnreviewedLabelForPatchSetThatAlreadyHasReviewedLabel() throws Exception {
|
||||
String changeId = createChange().getChangeId();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(changeId).markAsReviewed(true);
|
||||
assertThat(gApi.changes().id(changeId).get().reviewed).isTrue();
|
||||
|
||||
@ -4081,7 +4079,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
public void cannotSetReviewedLabelForPatchSetThatAlreadyHasUnreviewedLabel() throws Exception {
|
||||
String changeId = createChange().getChangeId();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(changeId).markAsReviewed(false);
|
||||
assertThat(gApi.changes().id(changeId).get().reviewed).isNull();
|
||||
|
||||
@ -4106,7 +4104,7 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
public void setReviewedAndUnreviewedLabelsForDifferentPatchSets() throws Exception {
|
||||
String changeId = createChange().getChangeId();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(changeId).markAsReviewed(true);
|
||||
assertThat(gApi.changes().id(changeId).get().reviewed).isTrue();
|
||||
|
||||
|
@ -34,6 +34,7 @@ import com.google.gerrit.acceptance.GitUtil;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.CherryPickInput;
|
||||
@ -46,6 +47,7 @@ import com.google.gerrit.extensions.common.CommitInfo;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.server.project.testing.Util;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -58,6 +60,7 @@ import org.junit.Test;
|
||||
|
||||
@NoHttpd
|
||||
public class StickyApprovalsIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
@ -455,7 +458,7 @@ public class StickyApprovalsIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
private void trivialRebase(String changeId) throws Exception {
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
testRepo.reset(getRemoteHead());
|
||||
PushOneCommit push =
|
||||
pushFactory.create(
|
||||
@ -553,20 +556,20 @@ public class StickyApprovalsIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
private void vote(TestAccount user, String changeId, String label, int vote) throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(changeId).current().review(new ReviewInput().label(label, vote));
|
||||
}
|
||||
|
||||
private void vote(TestAccount user, String changeId, int codeReviewVote, int verifiedVote)
|
||||
throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
ReviewInput in =
|
||||
new ReviewInput().label("Code-Review", codeReviewVote).label("Verified", verifiedVote);
|
||||
gApi.changes().id(changeId).current().review(in);
|
||||
}
|
||||
|
||||
private void deleteVote(TestAccount user, String changeId, String label) throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(changeId).reviewer(user.getId().toString()).deleteVote(label);
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ import com.google.gerrit.acceptance.Sandboxed;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.testsuite.account.AccountOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.group.GroupOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.common.data.GroupReference;
|
||||
@ -118,17 +119,18 @@ import org.junit.Test;
|
||||
|
||||
@NoHttpd
|
||||
public class GroupsIT extends AbstractDaemonTest {
|
||||
@Inject private Groups groups;
|
||||
@Inject @ServerInitiated private GroupsUpdate groupsUpdate;
|
||||
@Inject private AccountOperations accountOperations;
|
||||
@Inject private DynamicSet<GroupIndexedListener> groupIndexedListeners;
|
||||
@Inject private GroupIncludeCache groupIncludeCache;
|
||||
@Inject private StalenessChecker stalenessChecker;
|
||||
@Inject private GroupIndexer groupIndexer;
|
||||
@Inject private GroupOperations groupOperations;
|
||||
@Inject private Groups groups;
|
||||
@Inject private GroupsConsistencyChecker consistencyChecker;
|
||||
@Inject private PeriodicGroupIndexer slaveGroupIndexer;
|
||||
@Inject private DynamicSet<GroupIndexedListener> groupIndexedListeners;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
@Inject private Sequences seq;
|
||||
@Inject private AccountOperations accountOperations;
|
||||
@Inject private GroupOperations groupOperations;
|
||||
@Inject private StalenessChecker stalenessChecker;
|
||||
|
||||
@Before
|
||||
public void setTimeForTesting() {
|
||||
@ -408,7 +410,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void createGroupWithoutCapability_Forbidden() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
gApi.groups().create(name("newGroup"));
|
||||
}
|
||||
@ -730,7 +732,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
AccountGroup.UUID group = groupOperations.newGroup().create();
|
||||
gApi.groups().id(group.get()).addMembers(user.username);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertMembers(gApi.groups().id(group.get()).members(true), user.fullName);
|
||||
}
|
||||
|
||||
@ -741,7 +743,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
gApi.groups().id(group1.get()).addGroups(group2.get());
|
||||
gApi.groups().id(group2.get()).addMembers(user.username);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
List<AccountInfo> listedMembers = gApi.groups().id(group1.get()).members(true);
|
||||
|
||||
assertMembers(listedMembers);
|
||||
@ -769,7 +771,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
gApi.groups().id(ownerGroup.get()).addMembers(user.username);
|
||||
gApi.groups().id(group2.get()).addMembers(user.username);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
List<AccountInfo> listedMembers = gApi.groups().id(group1.get()).members(true);
|
||||
|
||||
assertMembers(listedMembers, user.fullName);
|
||||
@ -830,13 +832,13 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
in.ownerId = adminGroupUuid().get();
|
||||
gApi.groups().create(in);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertThat(gApi.groups().list().getAsMap()).doesNotContainKey(newGroupName);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.groups().id(newGroupName).addMembers(user.username);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertThat(gApi.groups().list().getAsMap()).containsKey(newGroupName);
|
||||
}
|
||||
|
||||
@ -1009,15 +1011,15 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
GroupInfo group = gApi.groups().create(in).get();
|
||||
|
||||
// admin can reindex any group
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.groups().id(group.id).index();
|
||||
|
||||
// group owner can reindex own group (group is owned by itself)
|
||||
setApiUser(groupOwner);
|
||||
requestScopeOperations.setApiUser(groupOwner.getId());
|
||||
gApi.groups().id(group.id).index();
|
||||
|
||||
// user cannot reindex any group
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("not allowed to index group");
|
||||
gApi.groups().id(group.id).index();
|
||||
@ -1291,7 +1293,7 @@ public class GroupsIT extends AbstractDaemonTest {
|
||||
gApi.groups().create(groupInput).get();
|
||||
restartAsSlave();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
List<GroupInfo> groups = gApi.groups().list().withUser(user.username).get();
|
||||
ImmutableList<String> groupNames =
|
||||
groups.stream().map(group -> group.name).collect(toImmutableList());
|
||||
|
@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.RawInputUtil;
|
||||
import com.google.gerrit.extensions.api.plugins.InstallPluginInput;
|
||||
import com.google.gerrit.extensions.api.plugins.PluginApi;
|
||||
@ -33,6 +34,7 @@ import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.RawInput;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.List;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -49,6 +51,8 @@ public class PluginIT extends AbstractDaemonTest {
|
||||
ImmutableList.of(
|
||||
"plugin-a.js", "plugin-b.html", "plugin-c.js", "plugin-d.html", "plugin_e.js");
|
||||
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
@GerritConfig(name = "plugins.allowRemoteAdmin", value = "true")
|
||||
public void pluginManagement() throws Exception {
|
||||
@ -112,7 +116,7 @@ public class PluginIT extends AbstractDaemonTest {
|
||||
deprecatedInput();
|
||||
|
||||
// Non-admin cannot disable
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
try {
|
||||
gApi.plugins().name("plugin-a").disable();
|
||||
fail("Expected AuthException");
|
||||
|
@ -32,6 +32,7 @@ import com.google.gerrit.acceptance.GitUtil;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.projects.BranchInput;
|
||||
@ -76,6 +77,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
|
||||
@Inject private DynamicSet<ProjectIndexedListener> projectIndexedListeners;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Inject
|
||||
@IndexExecutor(BATCH)
|
||||
@ -351,7 +353,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void nonOwnerCannotSetConfig() throws Exception {
|
||||
ConfigInput input = createTestConfigInput();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("write refs/meta/config not permitted");
|
||||
gApi.projects().name(project.get()).config(input);
|
||||
@ -386,7 +388,7 @@ public class ProjectIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void setHeadNotAllowed() throws Exception {
|
||||
gApi.projects().name(project.get()).branch("test").create(new BranchInput());
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("not permitted: set HEAD on refs/heads/test");
|
||||
gApi.projects().name(project.get()).head("test");
|
||||
|
@ -20,6 +20,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
@ -35,11 +36,12 @@ import org.junit.Test;
|
||||
public class SetParentIT extends AbstractDaemonTest {
|
||||
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void setParentNotAllowed() throws Exception {
|
||||
String parent = projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
gApi.projects().name(project.get()).parent(parent);
|
||||
}
|
||||
@ -48,7 +50,7 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
@GerritConfig(name = "receive.allowProjectOwnersToChangeParent", value = "true")
|
||||
public void setParentNotAllowedForNonOwners() throws Exception {
|
||||
String parent = projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
gApi.projects().name(project.get()).parent(parent);
|
||||
}
|
||||
@ -72,7 +74,7 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
@GerritConfig(name = "receive.allowProjectOwnersToChangeParent", value = "true")
|
||||
public void setParentAllowedForOwners() throws Exception {
|
||||
String parent = projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
grant(project, "refs/*", Permission.OWNER, false, SystemGroupBackend.REGISTERED_USERS);
|
||||
gApi.projects().name(project.get()).parent(parent);
|
||||
assertThat(gApi.projects().name(project.get()).parent()).isEqualTo(parent);
|
||||
|
@ -40,6 +40,7 @@ import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.ChangeApi;
|
||||
import com.google.gerrit.extensions.api.changes.CherryPickInput;
|
||||
@ -112,9 +113,10 @@ import org.junit.Test;
|
||||
|
||||
public class RevisionIT extends AbstractDaemonTest {
|
||||
|
||||
@Inject private GetRevisionActions getRevisionActions;
|
||||
@Inject private DynamicSet<PatchSetWebLink> patchSetLinks;
|
||||
@Inject private DynamicSet<ChangeIndexedListener> changeIndexedListeners;
|
||||
@Inject private DynamicSet<PatchSetWebLink> patchSetLinks;
|
||||
@Inject private GetRevisionActions getRevisionActions;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void reviewTriplet() throws Exception {
|
||||
@ -215,13 +217,13 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r = createChange();
|
||||
String changeId = project.get() + "~master~" + r.getChangeId();
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
revision(r).review(ReviewInput.approve());
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
revision(r).review(ReviewInput.recommend());
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(changeId).reviewer(user.username).deleteVote("Code-Review");
|
||||
Optional<ApprovalInfo> crUser =
|
||||
get(changeId, DETAILED_LABELS)
|
||||
@ -236,7 +238,7 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
|
||||
revision(r).submit();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
ReviewInput in = new ReviewInput();
|
||||
in.label("Code-Review", 1);
|
||||
in.message = "Still LGTM";
|
||||
@ -302,7 +304,7 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void voteNotAllowedWithoutPermission() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("is restricted");
|
||||
gApi.changes().id(r.getChange().getId().get()).current().review(ReviewInput.approve());
|
||||
@ -736,7 +738,7 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
|
||||
// 'user' cherry-picks the change to a new branch, the source change's author/committer('admin')
|
||||
// will be added as a reviewer of the newly created change.
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
CherryPickInput input = new CherryPickInput();
|
||||
input.message = "it goes to a new branch";
|
||||
|
||||
@ -772,13 +774,13 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
// Change is created by 'admin'.
|
||||
PushOneCommit.Result r = createChange();
|
||||
// Change is approved by 'admin2'. Change is CC'd to 'user'.
|
||||
setApiUser(accountCreator.admin2());
|
||||
requestScopeOperations.setApiUser(accountCreator.admin2().getId());
|
||||
ReviewInput in = ReviewInput.approve();
|
||||
in.reviewer(user.email, ReviewerState.CC, true);
|
||||
gApi.changes().id(r.getChangeId()).current().review(in);
|
||||
|
||||
// Change is cherrypicked by 'user2'.
|
||||
setApiUser(accountCreator.user2());
|
||||
requestScopeOperations.setApiUser(accountCreator.user2().getId());
|
||||
CherryPickInput cin = new CherryPickInput();
|
||||
cin.message = "this need to go to stable";
|
||||
cin.destination = "stable";
|
||||
@ -857,7 +859,7 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
input.base = dstChange.getCommit().name();
|
||||
input.message = srcChange.getCommit().getFullMessage();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(UnprocessableEntityException.class);
|
||||
exception.expectMessage(
|
||||
String.format("Commit %s does not exist on branch refs/heads/foo", input.base));
|
||||
@ -1123,7 +1125,7 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
public void setDescriptionNotAllowedWithoutPermission() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
assertDescription(r, "");
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("edit description not permitted");
|
||||
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).description("test");
|
||||
@ -1134,7 +1136,7 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r = createChange();
|
||||
assertDescription(r, "");
|
||||
grant(project, "refs/heads/master", Permission.OWNER, false, REGISTERED_USERS);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).description("test");
|
||||
assertDescription(r, "test");
|
||||
}
|
||||
@ -1397,11 +1399,11 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
amendChange(r.getChangeId());
|
||||
|
||||
// code-review
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
recommend(r.getChangeId());
|
||||
|
||||
// check if it's blocked to delete a vote on a non-current patch set.
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
exception.expect(MethodNotAllowedException.class);
|
||||
exception.expectMessage("Cannot access on non-current patch set");
|
||||
gApi.changes()
|
||||
@ -1420,10 +1422,10 @@ public class RevisionIT extends AbstractDaemonTest {
|
||||
amendChange(r.getChangeId());
|
||||
|
||||
// code-review
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
recommend(r.getChangeId());
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes()
|
||||
.id(r.getChangeId())
|
||||
.current()
|
||||
|
@ -35,6 +35,7 @@ import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.RawInputUtil;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
@ -91,6 +92,7 @@ public class ChangeEditIT extends AbstractDaemonTest {
|
||||
private static final byte[] CONTENT_NEW2 = CONTENT_NEW2_STR.getBytes(UTF_8);
|
||||
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private String changeId;
|
||||
private String changeId2;
|
||||
@ -625,11 +627,11 @@ public class ChangeEditIT extends AbstractDaemonTest {
|
||||
gApi.changes().id(changeId2).edit().publish(publishInput);
|
||||
assertThat(queryEdits()).isEmpty();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
createEmptyEditFor(changeId);
|
||||
assertThat(queryEdits()).hasSize(1);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
assertThat(queryEdits()).isEmpty();
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,7 @@ import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.Sandboxed;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
@ -94,6 +95,7 @@ import com.google.gerrit.server.project.testing.Util;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.testing.FakeEmailSender.Message;
|
||||
import com.google.gerrit.testing.TestTimeUtil;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
@ -130,6 +132,8 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
||||
HTTP
|
||||
}
|
||||
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private LabelType patchSetLock;
|
||||
|
||||
@BeforeClass
|
||||
@ -162,7 +166,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
||||
|
||||
@After
|
||||
public void resetPublishCommentOnPushOption() throws Exception {
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
GeneralPreferencesInfo prefs = gApi.accounts().id(admin.id.get()).getPreferences();
|
||||
prefs.publishCommentsOnPush = false;
|
||||
gApi.accounts().id(admin.id.get()).setPreferences(prefs);
|
||||
@ -520,7 +524,7 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
||||
pwi.filter = "*";
|
||||
pwi.notifyNewChanges = true;
|
||||
projectsToWatch.add(pwi);
|
||||
setApiUser(user3);
|
||||
requestScopeOperations.setApiUser(user3.getId());
|
||||
gApi.accounts().self().setWatchedProjects(projectsToWatch);
|
||||
|
||||
TestAccount user2 = accountCreator.user2();
|
||||
|
@ -24,6 +24,7 @@ import static java.util.stream.Collectors.toList;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.AccessSection;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
@ -36,6 +37,7 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.server.project.ProjectConfig;
|
||||
import com.google.gerrit.server.project.testing.Util;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
import org.eclipse.jgit.api.PushCommand;
|
||||
@ -52,6 +54,8 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PushPermissionsIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
try (ProjectConfigUpdate u = updateProject(allProjects)) {
|
||||
@ -264,14 +268,14 @@ public class PushPermissionsIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void addPatchSetDenied() throws Exception {
|
||||
grant(project, "refs/for/refs/heads/*", Permission.PUSH, false, REGISTERED_USERS);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
ChangeInput ci = new ChangeInput();
|
||||
ci.project = project.get();
|
||||
ci.branch = "master";
|
||||
ci.subject = "A change";
|
||||
Change.Id id = new Change.Id(gApi.changes().create(ci).get()._number);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
ObjectId ps1Id = forceFetch(new PatchSet.Id(id, 1).toRefName());
|
||||
ObjectId ps2Id = testRepo.amend(ps1Id).add("file", "content").create();
|
||||
PushResult r = push(ps2Id.name() + ":refs/for/master");
|
||||
|
@ -30,6 +30,7 @@ import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.AccessSection;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
@ -75,9 +76,10 @@ import org.junit.Test;
|
||||
|
||||
@NoHttpd
|
||||
public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
@Inject private PermissionBackend permissionBackend;
|
||||
@Inject private ChangeNoteUtil noteUtil;
|
||||
@Inject private AllUsersName allUsersName;
|
||||
@Inject private ChangeNoteUtil noteUtil;
|
||||
@Inject private PermissionBackend permissionBackend;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private AccountGroup.UUID admins;
|
||||
private AccountGroup.UUID nonInteractiveUsers;
|
||||
@ -188,7 +190,7 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
u.save();
|
||||
}
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertUploadPackRefs(
|
||||
"HEAD",
|
||||
psRef1,
|
||||
@ -232,7 +234,7 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
allow("refs/heads/master", Permission.READ, REGISTERED_USERS);
|
||||
deny("refs/heads/branch", Permission.READ, REGISTERED_USERS);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertUploadPackRefs(
|
||||
"HEAD", psRef1, metaRef1, psRef3, metaRef3, "refs/heads/master", "refs/tags/master-tag");
|
||||
}
|
||||
@ -242,7 +244,7 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
deny("refs/heads/master", Permission.READ, REGISTERED_USERS);
|
||||
allow("refs/heads/branch", Permission.READ, REGISTERED_USERS);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertUploadPackRefs(
|
||||
psRef2,
|
||||
metaRef2,
|
||||
@ -260,11 +262,11 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
allow("refs/heads/master", Permission.READ, REGISTERED_USERS);
|
||||
|
||||
// Admin's edit is not visible.
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(cd3.getId().get()).edit().create();
|
||||
|
||||
// User's edit is visible.
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(cd3.getId().get()).edit().create();
|
||||
|
||||
assertUploadPackRefs(
|
||||
@ -285,14 +287,14 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
allow("refs/*", Permission.VIEW_PRIVATE_CHANGES, REGISTERED_USERS);
|
||||
|
||||
// Admin's edit on change3 is visible.
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(cd3.getId().get()).edit().create();
|
||||
|
||||
// Admin's edit on change4 is not visible since user cannot see the change.
|
||||
gApi.changes().id(cd4.getId().get()).edit().create();
|
||||
|
||||
// User's edit is visible.
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(cd3.getId().get()).edit().create();
|
||||
|
||||
assertUploadPackRefs(
|
||||
@ -314,9 +316,9 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
deny("refs/heads/master", Permission.READ, REGISTERED_USERS);
|
||||
allow("refs/heads/branch", Permission.READ, REGISTERED_USERS);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(cd3.getId().get()).edit().create();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
assertUploadPackRefs(
|
||||
// Change 1 is visible due to accessDatabase capability, even though
|
||||
@ -351,7 +353,7 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
private void uploadPackNoSearchingChangeCacheImpl() throws Exception {
|
||||
allow("refs/heads/*", Permission.READ, REGISTERED_USERS);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
try (Repository repo = repoManager.openRepository(project)) {
|
||||
assertRefs(
|
||||
repo,
|
||||
@ -391,7 +393,7 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
gApi.changes().id(cd4.getId().id).delete();
|
||||
gApi.projects().name(project.get()).branch("refs/heads/branch").delete();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertUploadPackRefs(
|
||||
"HEAD",
|
||||
"refs/meta/config",
|
||||
@ -425,7 +427,7 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
public void receivePackRespectsVisibilityOfOpenChanges() throws Exception {
|
||||
allow("refs/heads/master", Permission.READ, REGISTERED_USERS);
|
||||
deny("refs/heads/branch", Permission.READ, REGISTERED_USERS);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
assertThat(getReceivePackRefs().additionalHaves()).containsExactly(obj(cd3, 1));
|
||||
}
|
||||
@ -618,7 +620,7 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
allow(project, "refs/*", Permission.READ, REGISTERED_USERS);
|
||||
allow(allUsersName, "refs/*", Permission.READ, REGISTERED_USERS);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
DraftInput draftInput = new DraftInput();
|
||||
draftInput.line = 1;
|
||||
draftInput.message = "nit: trailing whitespace";
|
||||
@ -638,7 +640,7 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
||||
allow(project, "refs/*", Permission.READ, REGISTERED_USERS);
|
||||
allow(allUsersName, "refs/*", Permission.READ, REGISTERED_USERS);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.accounts().self().starChange(cd3.getId().toString());
|
||||
String starredChangesRef = RefNames.refsStarredChanges(cd3.getId(), user.id);
|
||||
|
||||
|
@ -23,6 +23,7 @@ import com.google.common.collect.Multimap;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.AcceptanceTestRequestScope.Context;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.accounts.EmailApi;
|
||||
import com.google.gerrit.extensions.api.accounts.EmailInput;
|
||||
import com.google.gerrit.extensions.common.EmailInfo;
|
||||
@ -52,14 +53,15 @@ import java.util.Set;
|
||||
import org.junit.Test;
|
||||
|
||||
public class EmailIT extends AbstractDaemonTest {
|
||||
@Inject private @ServerInitiated Provider<AccountsUpdate> accountsUpdateProvider;
|
||||
@Inject private ExternalIds externalIds;
|
||||
@Inject private AuthConfig authConfig;
|
||||
@Inject private @AnonymousCowardName String anonymousCowardName;
|
||||
@Inject private @CanonicalWebUrl Provider<String> canonicalUrl;
|
||||
@Inject private @DisableReverseDnsLookup Boolean disableReverseDnsLookup;
|
||||
@Inject private @ServerInitiated Provider<AccountsUpdate> accountsUpdateProvider;
|
||||
@Inject private AuthConfig authConfig;
|
||||
@Inject private EmailExpander emailExpander;
|
||||
@Inject private ExternalIds externalIds;
|
||||
@Inject private Provider<Emails> emails;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void addEmail() throws Exception {
|
||||
@ -120,7 +122,7 @@ public class EmailIT extends AbstractDaemonTest {
|
||||
createEmail(email);
|
||||
assertThat(gApi.accounts().self().get().email).isNotEqualTo(email);
|
||||
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
gApi.accounts().self().email(email).setPreferred();
|
||||
assertThat(gApi.accounts().self().get().email).isEqualTo(email);
|
||||
}
|
||||
@ -139,7 +141,7 @@ public class EmailIT extends AbstractDaemonTest {
|
||||
ExternalId.SCHEME_EXTERNAL, "foo", admin.id, email)));
|
||||
assertThat(gApi.accounts().self().get().email).isNotEqualTo(email);
|
||||
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
gApi.accounts().self().email(email).setPreferred();
|
||||
assertThat(gApi.accounts().self().get().email).isEqualTo(email);
|
||||
}
|
||||
@ -165,7 +167,7 @@ public class EmailIT extends AbstractDaemonTest {
|
||||
createEmail(email);
|
||||
assertThat(gApi.accounts().self().get().email).isNotEqualTo(email);
|
||||
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
String emailOtherCase = email.toUpperCase();
|
||||
gApi.accounts().self().email(emailOtherCase).setPreferred();
|
||||
assertThat(gApi.accounts().self().get().email).isEqualTo(email);
|
||||
@ -221,7 +223,7 @@ public class EmailIT extends AbstractDaemonTest {
|
||||
assertThat(gApi.accounts().self().get().email).isNotEqualTo(email);
|
||||
|
||||
// Get email
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
EmailApi emailApi = gApi.accounts().self().email(email);
|
||||
EmailInfo emailInfo = emailApi.get();
|
||||
assertThat(emailInfo.email).isEqualTo(email);
|
||||
@ -233,7 +235,7 @@ public class EmailIT extends AbstractDaemonTest {
|
||||
assertThat(gApi.accounts().self().get().email).isEqualTo(email);
|
||||
|
||||
// Get email again (now it's the preferred email)
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
emailApi = gApi.accounts().self().email(email);
|
||||
emailInfo = emailApi.get();
|
||||
assertThat(emailInfo.email).isEqualTo(email);
|
||||
@ -245,7 +247,7 @@ public class EmailIT extends AbstractDaemonTest {
|
||||
assertThat(getEmails()).doesNotContain(email);
|
||||
|
||||
// Now the email is no longer found
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
emailApi = gApi.accounts().self().email(email);
|
||||
exception.expect(ResourceNotFoundException.class);
|
||||
emailApi.get();
|
||||
|
@ -33,6 +33,7 @@ import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.config.ConsistencyCheckInfo;
|
||||
@ -90,6 +91,7 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
@Inject private ExternalIds externalIds;
|
||||
@Inject private ExternalIdReader externalIdReader;
|
||||
@Inject private ExternalIdNotes.Factory externalIdNotesFactory;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void getExternalIds() throws Exception {
|
||||
@ -109,7 +111,7 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void getExternalIdsOfOtherUserNotAllowed() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("access database not permitted");
|
||||
gApi.accounts().id(admin.id.get()).getExternalIds();
|
||||
@ -135,7 +137,7 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void deleteExternalIds() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
List<AccountExternalIdInfo> externalIds = gApi.accounts().self().getExternalIds();
|
||||
|
||||
List<String> toDelete = new ArrayList<>();
|
||||
@ -162,7 +164,7 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void deleteExternalIdsOfOtherUserNotAllowed() throws Exception {
|
||||
List<AccountExternalIdInfo> extIds = gApi.accounts().self().getExternalIds();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("access database not permitted");
|
||||
gApi.accounts()
|
||||
@ -173,7 +175,7 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void deleteExternalIdOfOtherUserUnderOwnAccount_UnprocessableEntity() throws Exception {
|
||||
List<AccountExternalIdInfo> extIds = gApi.accounts().self().getExternalIds();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(UnprocessableEntityException.class);
|
||||
exception.expectMessage(String.format("External id %s does not exist", extIds.get(0).identity));
|
||||
gApi.accounts()
|
||||
@ -199,7 +201,7 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
|
||||
assertThat(toDelete).hasSize(1);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
RestResponse response =
|
||||
userRestSession.post("/accounts/" + admin.id + "/external.ids:delete", toDelete);
|
||||
response.assertNoContent();
|
||||
@ -402,7 +404,7 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void readExternalIdsWhenInvalidExternalIdsExist() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
|
||||
insertValidExternalIds();
|
||||
insertInvalidButParsableExternalIds();
|
||||
@ -423,7 +425,7 @@ public class ExternalIdIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void checkConsistency() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ACCESS_DATABASE);
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
|
||||
insertValidExternalIds();
|
||||
|
||||
|
@ -28,6 +28,7 @@ import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.RestSession;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
@ -70,12 +71,10 @@ import org.junit.Test;
|
||||
|
||||
public class ImpersonationIT extends AbstractDaemonTest {
|
||||
@Inject private AccountControl.Factory accountControlFactory;
|
||||
|
||||
@Inject private ApprovalsUtil approvalsUtil;
|
||||
|
||||
@Inject private ChangeMessagesUtil cmUtil;
|
||||
|
||||
@Inject private CommentsUtil commentsUtil;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private RestSession anonRestSession;
|
||||
private TestAccount admin2;
|
||||
@ -254,7 +253,7 @@ public class ImpersonationIT extends AbstractDaemonTest {
|
||||
allowCodeReviewOnBehalfOf();
|
||||
PushOneCommit.Result r = createChange();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
DraftInput di = new DraftInput();
|
||||
di.path = Patch.COMMIT_MSG;
|
||||
di.side = Side.REVISION;
|
||||
@ -262,7 +261,7 @@ public class ImpersonationIT extends AbstractDaemonTest {
|
||||
di.message = "message";
|
||||
gApi.changes().id(r.getChangeId()).current().createDraft(di);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
ReviewInput in = new ReviewInput();
|
||||
in.onBehalfOf = user.id.toString();
|
||||
in.label("Code-Review", 1);
|
||||
@ -310,7 +309,7 @@ public class ImpersonationIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void voteOnBehalfOfInvisibleUserNotAllowed() throws Exception {
|
||||
allowCodeReviewOnBehalfOf();
|
||||
setApiUser(accountCreator.user2());
|
||||
requestScopeOperations.setApiUser(accountCreator.user2().getId());
|
||||
assertThat(accountControlFactory.get().canSee(user.id)).isFalse();
|
||||
|
||||
PushOneCommit.Result r = createChange();
|
||||
@ -391,7 +390,7 @@ public class ImpersonationIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void submitOnBehalfOfInvisibleUserNotAllowed() throws Exception {
|
||||
allowSubmitOnBehalfOf();
|
||||
setApiUser(accountCreator.user2());
|
||||
requestScopeOperations.setApiUser(accountCreator.user2().getId());
|
||||
assertThat(accountControlFactory.get().canSee(user.id)).isFalse();
|
||||
|
||||
PushOneCommit.Result r = createChange();
|
||||
@ -452,14 +451,14 @@ public class ImpersonationIT extends AbstractDaemonTest {
|
||||
allowRunAs();
|
||||
PushOneCommit.Result r = createChange();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
DraftInput di = new DraftInput();
|
||||
di.path = Patch.COMMIT_MSG;
|
||||
di.side = Side.REVISION;
|
||||
di.line = 1;
|
||||
di.message = "inline comment";
|
||||
gApi.changes().id(r.getChangeId()).current().createDraft(di);
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
|
||||
// Things that aren't allowed with on_behalf_of:
|
||||
// - no labels.
|
||||
@ -481,7 +480,7 @@ public class ImpersonationIT extends AbstractDaemonTest {
|
||||
assertThat(c.author._accountId).isEqualTo(user.id.get());
|
||||
assertThat(c.message).isEqualTo(di.message);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertThat(gApi.changes().id(r.getChangeId()).drafts()).isEmpty();
|
||||
}
|
||||
|
||||
@ -533,7 +532,7 @@ public class ImpersonationIT extends AbstractDaemonTest {
|
||||
in.message = "Message on behalf of";
|
||||
in.label("Code-Review", 1);
|
||||
|
||||
setApiUser(accountCreator.user2());
|
||||
requestScopeOperations.setApiUser(accountCreator.user2().getId());
|
||||
gApi.changes().id(r.getChangeId()).revision(r.getPatchSetId().getId()).review(in);
|
||||
|
||||
ChangeInfo info = gApi.changes().id(r.getChangeId()).get(MESSAGES);
|
||||
|
@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.client.ProjectWatchInfo;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
@ -29,6 +30,7 @@ import org.junit.Test;
|
||||
|
||||
public class WatchedProjectsIT extends AbstractDaemonTest {
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private static final String NEW_PROJECT_NAME = "newProjectAccess";
|
||||
|
||||
@ -154,7 +156,7 @@ public class WatchedProjectsIT extends AbstractDaemonTest {
|
||||
String projectName = project.get();
|
||||
|
||||
// Let another user watch a project
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
List<ProjectWatchInfo> projectsToWatch = new ArrayList<>();
|
||||
|
||||
ProjectWatchInfo pwi = new ProjectWatchInfo();
|
||||
@ -171,7 +173,7 @@ public class WatchedProjectsIT extends AbstractDaemonTest {
|
||||
gApi.accounts().self().deleteWatchedProjects(d);
|
||||
|
||||
// Check that trying to delete a non-existing watch doesn't fail
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.accounts().self().deleteWatchedProjects(d);
|
||||
}
|
||||
|
||||
@ -180,7 +182,7 @@ public class WatchedProjectsIT extends AbstractDaemonTest {
|
||||
String projectName = project.get();
|
||||
|
||||
// Let another user watch a project
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
List<ProjectWatchInfo> projectsToWatch = new ArrayList<>();
|
||||
|
||||
ProjectWatchInfo pwi = new ProjectWatchInfo();
|
||||
|
@ -24,6 +24,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.acceptance.UseSsh;
|
||||
import com.google.gerrit.acceptance.rest.util.RestCall;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.common.ChangeInput;
|
||||
import com.google.gerrit.gpg.testing.TestKey;
|
||||
import com.google.gerrit.server.ServerInitiated;
|
||||
@ -41,6 +42,7 @@ import org.junit.Test;
|
||||
*/
|
||||
public class AccountsRestApiBindingsIT extends AbstractDaemonTest {
|
||||
@Inject private @ServerInitiated Provider<AccountsUpdate> accountsUpdateProvider;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
/**
|
||||
* Account REST endpoints to be tested, each URL contains a placeholder for the account
|
||||
@ -169,7 +171,7 @@ public class AccountsRestApiBindingsIT extends AbstractDaemonTest {
|
||||
u.addExternalId(
|
||||
ExternalId.createWithEmail(name("test"), email, admin.getId(), email)));
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.accounts()
|
||||
.self()
|
||||
.putGpgKeys(ImmutableList.of(key.getPublicKeyArmored()), ImmutableList.of());
|
||||
|
@ -38,6 +38,7 @@ import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.ChangeApi;
|
||||
import com.google.gerrit.extensions.api.changes.SubmitInput;
|
||||
@ -116,15 +117,13 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
@Inject private ApprovalsUtil approvalsUtil;
|
||||
|
||||
@Inject private Submit submitHandler;
|
||||
|
||||
@Inject private DynamicSet<OnSubmitValidationListener> onSubmitValidationListeners;
|
||||
@Inject private IdentifiedUser.GenericFactory userFactory;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
@Inject private Submit submitHandler;
|
||||
|
||||
@Inject private DynamicSet<OnSubmitValidationListener> onSubmitValidationListeners;
|
||||
private RegistrationHandle onSubmitValidatorHandle;
|
||||
|
||||
private String systemTimeZone;
|
||||
|
||||
@Before
|
||||
@ -343,7 +342,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
||||
|
||||
submit(result.getChangeId(), new SubmitInput(), AuthException.class, "submit not permitted");
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
submit(result.getChangeId());
|
||||
}
|
||||
|
||||
@ -367,10 +366,10 @@ public abstract class AbstractSubmit extends AbstractDaemonTest {
|
||||
ChangeInfo change = gApi.changes().id(result.getChangeId()).get();
|
||||
assertThat(change.owner._accountId).isEqualTo(admin.id.get());
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
submit(result.getChangeId(), new SubmitInput(), AuthException.class, "submit not permitted");
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
submit(result.getChangeId());
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.client.ChangeStatus;
|
||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||
@ -31,6 +32,7 @@ import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.project.testing.Util;
|
||||
import com.google.inject.Inject;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
@ -38,6 +40,7 @@ import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.junit.Test;
|
||||
|
||||
public abstract class AbstractSubmitByRebase extends AbstractSubmit {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Override
|
||||
protected abstract SubmitType getSubmitType();
|
||||
@ -68,7 +71,7 @@ public abstract class AbstractSubmitByRebase extends AbstractSubmit {
|
||||
}
|
||||
|
||||
private void submitWithRebase(TestAccount submitter) throws Exception {
|
||||
setApiUser(submitter);
|
||||
requestScopeOperations.setApiUser(submitter.getId());
|
||||
RevCommit initialHead = getRemoteHead();
|
||||
PushOneCommit.Result change = createChange("Change 1", "a.txt", "content");
|
||||
submit(change.getChangeId());
|
||||
|
@ -24,6 +24,7 @@ import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.changes.ActionVisitor;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
@ -54,9 +55,9 @@ public class ActionsIT extends AbstractDaemonTest {
|
||||
return submitWholeTopicEnabledConfig();
|
||||
}
|
||||
|
||||
@Inject private RevisionJson.Factory revisionJsonFactory;
|
||||
|
||||
@Inject private DynamicSet<ActionVisitor> actionVisitors;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
@Inject private RevisionJson.Factory revisionJsonFactory;
|
||||
|
||||
private RegistrationHandle visitorHandle;
|
||||
|
||||
@ -156,25 +157,25 @@ public class ActionsIT extends AbstractDaemonTest {
|
||||
String change = createChangeWithTopic().getChangeId();
|
||||
approve(change);
|
||||
|
||||
setApiUserAnonymous();
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
String etag1 = getETag(change);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
approve(parent);
|
||||
|
||||
setApiUserAnonymous();
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
String etag2 = getETag(change);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
String changeWithSameTopic = createChangeWithTopic().getChangeId();
|
||||
|
||||
setApiUserAnonymous();
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
String etag3 = getETag(change);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
approve(changeWithSameTopic);
|
||||
|
||||
setApiUserAnonymous();
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
String etag4 = getETag(change);
|
||||
|
||||
if (isSubmitWholeTopicEnabled()) {
|
||||
@ -193,13 +194,13 @@ public class ActionsIT extends AbstractDaemonTest {
|
||||
String change = createChange().getChangeId();
|
||||
approve(change);
|
||||
|
||||
setApiUserAnonymous();
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
String etag1 = getETag(change);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
approve(parent);
|
||||
|
||||
setApiUserAnonymous();
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
String etag2 = getETag(change);
|
||||
assertThat(etag2).isEqualTo(etag1);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.AssigneeInput;
|
||||
import com.google.gerrit.extensions.client.ReviewerState;
|
||||
@ -32,6 +33,7 @@ import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.testing.FakeEmailSender.Message;
|
||||
import com.google.gerrit.testing.TestTimeUtil;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.eclipse.jgit.transport.RefSpec;
|
||||
@ -41,6 +43,7 @@ import org.junit.Test;
|
||||
|
||||
@NoHttpd
|
||||
public class AssigneeIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@BeforeClass
|
||||
public static void setTimeForTesting() {
|
||||
@ -144,7 +147,7 @@ public class AssigneeIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void setAssigneeNotAllowedWithoutPermission() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("not permitted");
|
||||
setAssignee(r, user.email);
|
||||
@ -154,7 +157,7 @@ public class AssigneeIT extends AbstractDaemonTest {
|
||||
public void setAssigneeAllowedWithPermission() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
grant(project, "refs/heads/master", Permission.EDIT_ASSIGNEE, false, REGISTERED_USERS);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertThat(setAssignee(r, user.email)._accountId).isEqualTo(user.getId().get());
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.extensions.api.changes.DeleteChangeMessageInput;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
@ -40,6 +41,7 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.notedb.ChangeNoteUtil;
|
||||
import com.google.gerrit.testing.ConfigSuite;
|
||||
import com.google.gerrit.testing.TestTimeUtil;
|
||||
import com.google.inject.Inject;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
@ -54,6 +56,8 @@ import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(ConfigSuite.class)
|
||||
public class ChangeMessagesIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private String systemTimeZone;
|
||||
|
||||
@Before
|
||||
@ -139,7 +143,7 @@ public class ChangeMessagesIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void deleteCannotBeAppliedWithoutAdministrateServerCapability() throws Exception {
|
||||
int changeNum = createOneChangeWithMultipleChangeMessagesInHistory();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
try {
|
||||
deleteOneChangeMessage(changeNum, 0, user, "spam");
|
||||
@ -153,7 +157,7 @@ public class ChangeMessagesIT extends AbstractDaemonTest {
|
||||
public void deleteCanBeAppliedWithAdministrateServerCapability() throws Exception {
|
||||
allowGlobalCapabilities(REGISTERED_USERS, GlobalCapability.ADMINISTRATE_SERVER);
|
||||
int changeNum = createOneChangeWithMultipleChangeMessagesInHistory();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
deleteOneChangeMessage(changeNum, 0, user, "spam");
|
||||
}
|
||||
|
||||
@ -209,22 +213,22 @@ public class ChangeMessagesIT extends AbstractDaemonTest {
|
||||
private int createOneChangeWithMultipleChangeMessagesInHistory() throws Exception {
|
||||
// Creates the following commit history on the meta branch of the test change.
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
// Commit 1: create a change.
|
||||
PushOneCommit.Result result = createChange();
|
||||
String changeId = result.getChangeId();
|
||||
// Commit 2: post a review with message "message 1".
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
addOneReview(changeId, "message 1");
|
||||
// Commit 3: amend a new patch set.
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
amendChange(changeId);
|
||||
// Commit 4: post a review with message "message 2".
|
||||
addOneReview(changeId, "message 2");
|
||||
// Commit 5: amend a new patch set.
|
||||
amendChange(changeId);
|
||||
// Commit 6: approve the change.
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(changeId).current().review(ReviewInput.approve());
|
||||
// commit 7: submit the change.
|
||||
gApi.changes().id(changeId).current().submit();
|
||||
|
@ -20,6 +20,7 @@ import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
@ -32,13 +33,14 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ChangeOwnerIT extends AbstractDaemonTest {
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private TestAccount user2;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
user2 = accountCreator.user2();
|
||||
}
|
||||
|
||||
@ -64,22 +66,22 @@ public class ChangeOwnerIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void testChangeOwner_OwnerACLGrantedOnParentProject() throws Exception {
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
grantApproveToChangeOwner(project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
TestRepository<InMemoryRepository> childRepo = cloneProject(child, user);
|
||||
approve(user, createMyChange(childRepo));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeOwner_BlockedOnParentProject() throws Exception {
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
blockApproveForChangeOwner(project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
grantApproveToAll(child);
|
||||
TestRepository<InMemoryRepository> childRepo = cloneProject(child, user);
|
||||
String changeId = createMyChange(childRepo);
|
||||
@ -93,11 +95,11 @@ public class ChangeOwnerIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void testChangeOwner_BlockedOnParentProjectAndExclusiveAllowOnChild() throws Exception {
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
blockApproveForChangeOwner(project);
|
||||
Project.NameKey child = projectOperations.newProject().parent(project).create();
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
grantExclusiveApproveToAll(child);
|
||||
TestRepository<InMemoryRepository> childRepo = cloneProject(child, user);
|
||||
String changeId = createMyChange(childRepo);
|
||||
@ -110,7 +112,7 @@ public class ChangeOwnerIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
private void approve(TestAccount a, String changeId) throws Exception {
|
||||
Context old = setApiUser(a);
|
||||
Context old = requestScopeOperations.setApiUser(a.getId());
|
||||
try {
|
||||
gApi.changes().id(changeId).current().review(ReviewInput.approve());
|
||||
} finally {
|
||||
|
@ -24,6 +24,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.AcceptanceTestRequestScope.Context;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
||||
import com.google.gerrit.extensions.api.changes.AddReviewerResult;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
@ -36,12 +37,14 @@ import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.mail.Address;
|
||||
import com.google.gerrit.testing.FakeEmailSender.Message;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.inject.Inject;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ChangeReviewersByEmailIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@ -195,9 +198,9 @@ public class ChangeReviewersByEmailIT extends AbstractDaemonTest {
|
||||
// Review change as user
|
||||
ReviewInput reviewInput = new ReviewInput();
|
||||
reviewInput.message = "I have a comment";
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
revision(r).review(reviewInput);
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
|
||||
sender.clear();
|
||||
|
||||
|
@ -31,6 +31,7 @@ import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.Sandboxed;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.testsuite.group.GroupOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
||||
import com.google.gerrit.extensions.api.changes.AddReviewerResult;
|
||||
@ -64,7 +65,8 @@ import org.junit.Test;
|
||||
|
||||
public class ChangeReviewersIT extends AbstractDaemonTest {
|
||||
|
||||
@Inject protected GroupOperations groupOperations;
|
||||
@Inject private GroupOperations groupOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void addGroupAsReviewer() throws Exception {
|
||||
@ -499,7 +501,7 @@ public class ChangeReviewersIT extends AbstractDaemonTest {
|
||||
|
||||
gApi.changes().id(changeId).current().review(ReviewInput.dislike());
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
// NoteDb adds reviewer to a change on every review.
|
||||
gApi.changes().id(changeId).current().review(ReviewInput.dislike());
|
||||
|
||||
@ -657,9 +659,9 @@ public class ChangeReviewersIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r = createChange();
|
||||
TestAccount newUser = createAccounts(1, name("foo")).get(0);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(r.getChangeId()).current().review(new ReviewInput().label("Code-Review", 1));
|
||||
setApiUser(newUser);
|
||||
requestScopeOperations.setApiUser(newUser.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("remove reviewer not permitted");
|
||||
gApi.changes().id(r.getChangeId()).reviewer(user.email).remove();
|
||||
@ -676,7 +678,7 @@ public class ChangeReviewersIT extends AbstractDaemonTest {
|
||||
|
||||
gApi.changes().id(r.getChangeId()).addReviewer(user.email);
|
||||
assertThatUserIsOnlyReviewer(r.getChangeId());
|
||||
setApiUser(newUser);
|
||||
requestScopeOperations.setApiUser(newUser.getId());
|
||||
gApi.changes().id(r.getChangeId()).reviewer(user.email).remove();
|
||||
assertThat(gApi.changes().id(r.getChangeId()).get().reviewers).isEmpty();
|
||||
}
|
||||
@ -687,7 +689,7 @@ public class ChangeReviewersIT extends AbstractDaemonTest {
|
||||
TestAccount newUser = createAccounts(1, name("foo")).get(0);
|
||||
|
||||
gApi.changes().id(r.getChangeId()).addReviewer(user.email);
|
||||
setApiUser(newUser);
|
||||
requestScopeOperations.setApiUser(newUser.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("remove reviewer not permitted");
|
||||
gApi.changes().id(r.getChangeId()).reviewer(user.email).remove();
|
||||
@ -702,7 +704,7 @@ public class ChangeReviewersIT extends AbstractDaemonTest {
|
||||
input.reviewer = user.email;
|
||||
input.state = ReviewerState.CC;
|
||||
gApi.changes().id(r.getChangeId()).addReviewer(input);
|
||||
setApiUser(newUser);
|
||||
requestScopeOperations.setApiUser(newUser.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("remove reviewer not permitted");
|
||||
gApi.changes().id(r.getChangeId()).reviewer(user.email).remove();
|
||||
|
@ -22,6 +22,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GitUtil;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectInput;
|
||||
@ -31,6 +32,7 @@ import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.server.project.testing.Util;
|
||||
import com.google.inject.Inject;
|
||||
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
@ -43,6 +45,8 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ConfigChangeIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
try (ProjectConfigUpdate u = updateProject(project)) {
|
||||
@ -52,7 +56,7 @@ public class ConfigChangeIT extends AbstractDaemonTest {
|
||||
u.save();
|
||||
}
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
fetchRefsMetaConfig();
|
||||
}
|
||||
|
||||
@ -96,13 +100,13 @@ public class ConfigChangeIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
@TestProjectInput(cloneAs = "user")
|
||||
public void onlyAdminMayUpdateProjectParent() throws Exception {
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
ProjectInput parent = new ProjectInput();
|
||||
parent.name = name("parent");
|
||||
parent.permissionsOnly = true;
|
||||
gApi.projects().create(parent);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
Config cfg = readProjectConfig();
|
||||
assertThat(cfg.getString("access", null, "inheritFrom")).isAnyOf(null, allProjects.get());
|
||||
cfg.setString("access", null, "inheritFrom", parent.name);
|
||||
@ -132,7 +136,7 @@ public class ConfigChangeIT extends AbstractDaemonTest {
|
||||
assertThat(readProjectConfig().getString("access", null, "inheritFrom"))
|
||||
.isAnyOf(null, allProjects.get());
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(id).current().submit();
|
||||
assertThat(gApi.changes().id(id).info().status).isEqualTo(ChangeStatus.MERGED);
|
||||
assertThat(gApi.projects().name(project.get()).get().parent).isEqualTo(parent.name);
|
||||
@ -142,7 +146,7 @@ public class ConfigChangeIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void rejectDoubleInheritance() throws Exception {
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
// Create separate projects to test the config
|
||||
Project.NameKey parent = createProjectOverAPI("projectToInheritFrom", null, true, null);
|
||||
Project.NameKey child = createProjectOverAPI("projectWithMalformedConfig", null, true, null);
|
||||
|
@ -27,6 +27,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.PushOneCommit.Result;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.changes.ChangeApi;
|
||||
import com.google.gerrit.extensions.api.changes.CherryPickInput;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
@ -50,6 +51,7 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.submit.ChangeAlreadyMergedException;
|
||||
import com.google.gerrit.testing.FakeEmailSender.Message;
|
||||
import com.google.gerrit.testing.TestTimeUtil;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -64,6 +66,8 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CreateChangeIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@BeforeClass
|
||||
public static void setTimeForTesting() {
|
||||
TestTimeUtil.resetWithClockStep(1, SECONDS);
|
||||
@ -149,11 +153,11 @@ public class CreateChangeIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void notificationsOnChangeCreation() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
watch(project.get());
|
||||
|
||||
// check that watcher is notified
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
assertCreateSucceeds(newChangeInput(ChangeStatus.NEW));
|
||||
|
||||
List<Message> messages = sender.getMessages();
|
||||
@ -502,7 +506,7 @@ public class CreateChangeIT extends AbstractDaemonTest {
|
||||
assertThat(o.signedOffBy).isNull();
|
||||
}
|
||||
|
||||
resetCurrentApiUser();
|
||||
requestScopeOperations.resetCurrentApiUser();
|
||||
}
|
||||
|
||||
private ChangeInput newMergeChangeInput(String targetBranch, String sourceRef, String strategy) {
|
||||
|
@ -22,6 +22,7 @@ import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@ -29,12 +30,15 @@ import com.google.gerrit.extensions.common.ChangeMessageInfo;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.testing.FakeEmailSender;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DeleteVoteIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void deleteVoteOnChange() throws Exception {
|
||||
deleteVote(false);
|
||||
@ -51,7 +55,7 @@ public class DeleteVoteIT extends AbstractDaemonTest {
|
||||
|
||||
PushOneCommit.Result r2 = amendChange(r.getChangeId());
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
recommend(r.getChangeId());
|
||||
|
||||
sender.clear();
|
||||
|
@ -25,12 +25,14 @@ import com.google.common.truth.IterableSubject;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.HashtagsInput;
|
||||
import com.google.gerrit.extensions.common.ChangeMessageInfo;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.testing.TestTimeUtil;
|
||||
import com.google.inject.Inject;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@ -47,6 +49,8 @@ public class HashtagsIT extends AbstractDaemonTest {
|
||||
TestTimeUtil.useSystemTime();
|
||||
}
|
||||
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void getNoHashtags() throws Exception {
|
||||
// Get on a change with no hashtags returns an empty list.
|
||||
@ -253,7 +257,7 @@ public class HashtagsIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void addHashtagWithoutPermissionNotAllowed() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("edit hashtags not permitted");
|
||||
addHashtags(r, "MyHashtag");
|
||||
@ -263,7 +267,7 @@ public class HashtagsIT extends AbstractDaemonTest {
|
||||
public void addHashtagWithPermissionAllowed() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
grant(project, "refs/heads/master", Permission.EDIT_HASHTAGS, false, REGISTERED_USERS);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
addHashtags(r, "MyHashtag");
|
||||
assertThatGet(r).containsExactly("MyHashtag");
|
||||
assertMessage(r, "Hashtag added: MyHashtag");
|
||||
|
@ -22,6 +22,7 @@ import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.testsuite.group.GroupOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
@ -34,9 +35,9 @@ import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.junit.Test;
|
||||
|
||||
public class IndexChangeIT extends AbstractDaemonTest {
|
||||
|
||||
@Inject protected GroupOperations groupOperations;
|
||||
@Inject private GroupOperations groupOperations;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void indexChange() throws Exception {
|
||||
@ -80,32 +81,32 @@ public class IndexChangeIT extends AbstractDaemonTest {
|
||||
String changeId = result.getChangeId();
|
||||
|
||||
// User can see the change and it is mergeable
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
List<ChangeInfo> changes = gApi.changes().query(changeId).get();
|
||||
assertThat(changes).hasSize(1);
|
||||
assertThat(changes.get(0).mergeable).isNotNull();
|
||||
|
||||
// Other user can see the change and it is mergeable
|
||||
setApiUser(user2);
|
||||
requestScopeOperations.setApiUser(user2.getId());
|
||||
changes = gApi.changes().query(changeId).get();
|
||||
assertThat(changes).hasSize(1);
|
||||
assertThat(changes.get(0).mergeable).isTrue();
|
||||
|
||||
// Remove the user from the group so they can no longer see the project
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.groups().id(group).removeMembers("user");
|
||||
|
||||
// User can no longer see the change
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
changes = gApi.changes().query(changeId).get();
|
||||
assertThat(changes).isEmpty();
|
||||
|
||||
// Reindex the change
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(changeId).index();
|
||||
|
||||
// Other user can still see the change and it is still mergeable
|
||||
setApiUser(user2);
|
||||
requestScopeOperations.setApiUser(user2.getId());
|
||||
changes = gApi.changes().query(changeId).get();
|
||||
assertThat(changes).hasSize(1);
|
||||
assertThat(changes.get(0).mergeable).isTrue();
|
||||
|
@ -23,6 +23,7 @@ import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.acceptance.GitUtil;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.LabelFunction;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
@ -38,6 +39,7 @@ import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.server.group.SystemGroupBackend;
|
||||
import com.google.gerrit.server.project.testing.Util;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
@ -46,6 +48,8 @@ import org.junit.Test;
|
||||
|
||||
@NoHttpd
|
||||
public class MoveChangeIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void moveChangeWithShortRef() throws Exception {
|
||||
// Move change to a different branch using short ref name
|
||||
@ -182,7 +186,7 @@ public class MoveChangeIT extends AbstractDaemonTest {
|
||||
r.getChange().change().getDest().get(),
|
||||
Permission.ABANDON,
|
||||
systemGroupBackend.getGroup(REGISTERED_USERS).getUUID());
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("move not permitted");
|
||||
move(r.getChangeId(), newBranch.get());
|
||||
|
@ -22,6 +22,7 @@ import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS
|
||||
import com.google.gerrit.acceptance.GitUtil;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.ChangeApi;
|
||||
import com.google.gerrit.extensions.api.changes.CherryPickInput;
|
||||
@ -54,6 +55,7 @@ import org.junit.Test;
|
||||
|
||||
public class SubmitByMergeIfNecessaryIT extends AbstractSubmitByMerge {
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Override
|
||||
protected SubmitType getSubmitType() {
|
||||
@ -628,7 +630,7 @@ public class SubmitByMergeIfNecessaryIT extends AbstractSubmitByMerge {
|
||||
gApi.changes().id(changeResult.getChangeId()).move(secretBranch.get());
|
||||
block(secretBranch.get(), "read", ANONYMOUS_USERS);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
// Verify that user cannot see the first change.
|
||||
try {
|
||||
@ -675,7 +677,7 @@ public class SubmitByMergeIfNecessaryIT extends AbstractSubmitByMerge {
|
||||
// Mark the first change private so that it's not visible to user.
|
||||
gApi.changes().id(changeResult.getChangeId()).setPrivate(true, "nobody should see this");
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
// Verify that user cannot see the first change.
|
||||
try {
|
||||
@ -735,7 +737,7 @@ public class SubmitByMergeIfNecessaryIT extends AbstractSubmitByMerge {
|
||||
// Mark change2a private so that it's not visible to user.
|
||||
gApi.changes().id(change2a.getChangeId()).setPrivate(true, "nobody should see this");
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
// Verify that user cannot see change2a
|
||||
try {
|
||||
|
@ -27,6 +27,7 @@ import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.testsuite.account.AccountOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.group.GroupOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.extensions.api.accounts.EmailInput;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
@ -44,9 +45,10 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private AccountOperations accountOperations;
|
||||
@Inject private GroupOperations groupOperations;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private AccountGroup.UUID group1;
|
||||
private AccountGroup.UUID group2;
|
||||
@ -133,16 +135,16 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
assertThat(reviewers).hasSize(1);
|
||||
assertThat(Iterables.getOnlyElement(reviewers).account.name).isEqualTo(user2.fullName);
|
||||
|
||||
setApiUser(user1);
|
||||
requestScopeOperations.setApiUser(user1.getId());
|
||||
reviewers = suggestReviewers(changeId, user2.fullName, 2);
|
||||
assertThat(reviewers).isEmpty();
|
||||
|
||||
setApiUser(user2);
|
||||
requestScopeOperations.setApiUser(user2.getId());
|
||||
reviewers = suggestReviewers(changeId, user2.username, 2);
|
||||
assertThat(reviewers).hasSize(1);
|
||||
assertThat(Iterables.getOnlyElement(reviewers).account.name).isEqualTo(user2.fullName);
|
||||
|
||||
setApiUser(user3);
|
||||
requestScopeOperations.setApiUser(user3.getId());
|
||||
reviewers = suggestReviewers(changeId, user2.username, 2);
|
||||
assertThat(reviewers).hasSize(1);
|
||||
assertThat(Iterables.getOnlyElement(reviewers).account.name).isEqualTo(user2.fullName);
|
||||
@ -153,7 +155,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
String changeId = createChange().getChangeId();
|
||||
List<SuggestedReviewerInfo> reviewers;
|
||||
|
||||
setApiUser(user3);
|
||||
requestScopeOperations.setApiUser(user3.getId());
|
||||
block("refs/*", "read", ANONYMOUS_USERS);
|
||||
allow("refs/*", "read", group1);
|
||||
reviewers = suggestReviewers(changeId, user2.username, 2);
|
||||
@ -166,11 +168,12 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
String changeId = createChange().getChangeId();
|
||||
List<SuggestedReviewerInfo> reviewers;
|
||||
|
||||
setApiUser(user1);
|
||||
requestScopeOperations.setApiUser(user1.getId());
|
||||
reviewers = suggestReviewers(changeId, user2.username, 2);
|
||||
assertThat(reviewers).isEmpty();
|
||||
|
||||
setApiUser(user1); // Clear cached group info.
|
||||
// Clear cached group info.
|
||||
requestScopeOperations.setApiUser(user1.getId());
|
||||
allowGlobalCapabilities(group1, GlobalCapability.VIEW_ALL_ACCOUNTS);
|
||||
reviewers = suggestReviewers(changeId, user2.username, 2);
|
||||
assertThat(reviewers).hasSize(1);
|
||||
@ -330,22 +333,22 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
TestAccount reviewer1 = user("customuser2", "User2");
|
||||
TestAccount reviewer2 = user("customuser3", "User3");
|
||||
|
||||
setApiUser(user1);
|
||||
requestScopeOperations.setApiUser(user1.getId());
|
||||
String changeId1 = createChangeFromApi();
|
||||
|
||||
setApiUser(reviewer1);
|
||||
requestScopeOperations.setApiUser(reviewer1.getId());
|
||||
reviewChange(changeId1);
|
||||
|
||||
setApiUser(user1);
|
||||
requestScopeOperations.setApiUser(user1.getId());
|
||||
String changeId2 = createChangeFromApi();
|
||||
|
||||
setApiUser(reviewer1);
|
||||
requestScopeOperations.setApiUser(reviewer1.getId());
|
||||
reviewChange(changeId2);
|
||||
|
||||
setApiUser(reviewer2);
|
||||
requestScopeOperations.setApiUser(reviewer2.getId());
|
||||
reviewChange(changeId2);
|
||||
|
||||
setApiUser(user1);
|
||||
requestScopeOperations.setApiUser(user1.getId());
|
||||
String changeId3 = createChangeFromApi();
|
||||
List<SuggestedReviewerInfo> reviewers = suggestReviewers(changeId3, null, 4);
|
||||
assertThat(reviewers.stream().map(r -> r.account._accountId).collect(toList()))
|
||||
@ -363,7 +366,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void defaultReviewerSuggestionOnFirstChange() throws Exception {
|
||||
TestAccount user1 = user("customuser1", "User1");
|
||||
setApiUser(user1);
|
||||
requestScopeOperations.setApiUser(user1.getId());
|
||||
List<SuggestedReviewerInfo> reviewers = suggestReviewers(createChange().getChangeId(), "", 4);
|
||||
assertThat(reviewers).isEmpty();
|
||||
}
|
||||
@ -382,23 +385,23 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
TestAccount userWhoLooksForSuggestions = user("customuser5", fullName);
|
||||
|
||||
// Create a change as userWhoOwns and add some reviews
|
||||
setApiUser(userWhoOwns);
|
||||
requestScopeOperations.setApiUser(userWhoOwns.getId());
|
||||
String changeId1 = createChangeFromApi();
|
||||
|
||||
setApiUser(reviewer1);
|
||||
requestScopeOperations.setApiUser(reviewer1.getId());
|
||||
reviewChange(changeId1);
|
||||
|
||||
setApiUser(user1);
|
||||
requestScopeOperations.setApiUser(user1.getId());
|
||||
String changeId2 = createChangeFromApi();
|
||||
|
||||
setApiUser(reviewer1);
|
||||
requestScopeOperations.setApiUser(reviewer1.getId());
|
||||
reviewChange(changeId2);
|
||||
|
||||
setApiUser(reviewer2);
|
||||
requestScopeOperations.setApiUser(reviewer2.getId());
|
||||
reviewChange(changeId2);
|
||||
|
||||
// Create a comment as a different user
|
||||
setApiUser(userWhoComments);
|
||||
requestScopeOperations.setApiUser(userWhoComments.getId());
|
||||
ReviewInput ri = new ReviewInput();
|
||||
ri.message = "Test";
|
||||
gApi.changes().id(changeId1).revision(1).review(ri);
|
||||
@ -406,7 +409,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
// Create a change as a new user to assert that we receive the correct
|
||||
// ranking
|
||||
|
||||
setApiUser(userWhoLooksForSuggestions);
|
||||
requestScopeOperations.setApiUser(userWhoLooksForSuggestions.getId());
|
||||
List<SuggestedReviewerInfo> reviewers = suggestReviewers(createChangeFromApi(), "Pri", 4);
|
||||
assertThat(reviewers.stream().map(r -> r.account._accountId).collect(toList()))
|
||||
.containsExactly(
|
||||
@ -425,25 +428,25 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
TestAccount reviewer1 = user("customuser2", fullName);
|
||||
TestAccount reviewer2 = user("customuser3", fullName);
|
||||
|
||||
setApiUser(userWhoOwns);
|
||||
requestScopeOperations.setApiUser(userWhoOwns.getId());
|
||||
String changeId1 = createChangeFromApi();
|
||||
|
||||
setApiUser(reviewer1);
|
||||
requestScopeOperations.setApiUser(reviewer1.getId());
|
||||
reviewChange(changeId1);
|
||||
|
||||
setApiUser(userWhoOwns);
|
||||
requestScopeOperations.setApiUser(userWhoOwns.getId());
|
||||
String changeId2 = createChangeFromApi(newProject);
|
||||
|
||||
setApiUser(reviewer2);
|
||||
requestScopeOperations.setApiUser(reviewer2.getId());
|
||||
reviewChange(changeId2);
|
||||
|
||||
setApiUser(userWhoOwns);
|
||||
requestScopeOperations.setApiUser(userWhoOwns.getId());
|
||||
String changeId3 = createChangeFromApi(newProject);
|
||||
|
||||
setApiUser(reviewer2);
|
||||
requestScopeOperations.setApiUser(reviewer2.getId());
|
||||
reviewChange(changeId3);
|
||||
|
||||
setApiUser(userWhoOwns);
|
||||
requestScopeOperations.setApiUser(userWhoOwns.getId());
|
||||
List<SuggestedReviewerInfo> reviewers = suggestReviewers(createChangeFromApi(), "Prim", 4);
|
||||
|
||||
// Assert that reviewer1 is on top, even though reviewer2 has more reviews
|
||||
@ -489,7 +492,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
String secondaryEmail = "foo.secondary@example.com";
|
||||
createAccountWithSecondaryEmail("foo", secondaryEmail);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
List<SuggestedReviewerInfo> reviewers =
|
||||
suggestReviewers(createChange().getChangeId(), secondaryEmail, 4);
|
||||
assertThat(reviewers).isEmpty();
|
||||
@ -509,7 +512,7 @@ public class SuggestReviewersIT extends AbstractDaemonTest {
|
||||
assertThat(Iterables.getOnlyElement(reviewers).account.secondaryEmails)
|
||||
.containsExactly(secondaryEmail);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
reviewers = suggestReviewers(createChange().getChangeId(), "foo", 4);
|
||||
assertReviewers(reviewers, ImmutableList.of(foo), ImmutableList.of());
|
||||
assertThat(Iterables.getOnlyElement(reviewers).account.secondaryEmails).isNull();
|
||||
|
@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
|
||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||
@ -33,9 +34,11 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class WorkInProgressByDefaultIT extends AbstractDaemonTest {
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private Project.NameKey project1;
|
||||
private Project.NameKey project2;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@ -45,7 +48,7 @@ public class WorkInProgressByDefaultIT extends AbstractDaemonTest {
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
GeneralPreferencesInfo prefs = gApi.accounts().id(admin.id.get()).getPreferences();
|
||||
prefs.workInProgressByDefault = false;
|
||||
gApi.accounts().id(admin.id.get()).setPreferences(prefs);
|
||||
|
@ -22,6 +22,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GitUtil;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.AccessSection;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
@ -69,10 +70,11 @@ public class AccessIT extends AbstractDaemonTest {
|
||||
|
||||
private static final String LABEL_CODE_REVIEW = "Code-Review";
|
||||
|
||||
private Project.NameKey newProjectName;
|
||||
|
||||
@Inject private DynamicSet<FileHistoryWebLink> fileHistoryWebLinkDynamicSet;
|
||||
@Inject protected ProjectOperations projectOperations;
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private Project.NameKey newProjectName;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@ -169,7 +171,7 @@ public class AccessIT extends AbstractDaemonTest {
|
||||
public void createAccessChange() throws Exception {
|
||||
allow(newProjectName, RefNames.REFS_CONFIG, Permission.READ, REGISTERED_USERS);
|
||||
// User can see the branch
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
pApi().branch("refs/heads/master").get();
|
||||
|
||||
ProjectAccessInput accessInput = newProjectAccessInput();
|
||||
@ -184,7 +186,7 @@ public class AccessIT extends AbstractDaemonTest {
|
||||
accessSection.permissions.put(Permission.READ, read);
|
||||
accessInput.add.put(REFS_HEADS, accessSection);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
ChangeInfo out = pApi().accessChange(accessInput);
|
||||
|
||||
assertThat(out.project).isEqualTo(newProjectName.get());
|
||||
@ -192,7 +194,7 @@ public class AccessIT extends AbstractDaemonTest {
|
||||
assertThat(out.status).isEqualTo(ChangeStatus.NEW);
|
||||
assertThat(out.submitted).isNull();
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
|
||||
ChangeInfo c = gApi.changes().id(out._number).get(MESSAGES);
|
||||
assertThat(c.messages.stream().map(m -> m.message)).containsExactly("Uploaded patch set 1");
|
||||
@ -203,7 +205,7 @@ public class AccessIT extends AbstractDaemonTest {
|
||||
gApi.changes().id(out._number).current().submit();
|
||||
|
||||
// check that the change took effect.
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
try {
|
||||
BranchInfo info = pApi().branch("refs/heads/master").get();
|
||||
fail("wanted failure, got " + newGson().toJson(info));
|
||||
@ -214,16 +216,16 @@ public class AccessIT extends AbstractDaemonTest {
|
||||
// Restore.
|
||||
accessInput.add.clear();
|
||||
accessInput.remove.put(REFS_HEADS, accessSection);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
out = pApi().accessChange(accessInput);
|
||||
|
||||
gApi.changes().id(out._number).current().review(reviewIn);
|
||||
gApi.changes().id(out._number).current().submit();
|
||||
|
||||
// Now it works again.
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
pApi().branch("refs/heads/master").get();
|
||||
}
|
||||
|
||||
@ -323,7 +325,7 @@ public class AccessIT extends AbstractDaemonTest {
|
||||
accessInput.add.put(REFS_ALL, accessSectionInfo);
|
||||
pApi().access(accessInput);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(ResourceNotFoundException.class);
|
||||
pApi().access();
|
||||
}
|
||||
@ -343,7 +345,7 @@ public class AccessIT extends AbstractDaemonTest {
|
||||
AccessSectionInfo accessSectionInfoToApply = createDefaultAccessSectionInfo();
|
||||
accessInfoToApply.add.put(REFS_HEADS, accessSectionInfoToApply);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(ResourceNotFoundException.class);
|
||||
pApi().access();
|
||||
}
|
||||
@ -390,7 +392,7 @@ public class AccessIT extends AbstractDaemonTest {
|
||||
assertThat(owners.includes).isNull();
|
||||
|
||||
// PROJECT_OWNERS is invisible to anonymous user, but GetAccess disregards visibility.
|
||||
setApiUserAnonymous();
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
ProjectAccessInfo anonResult = pApi().access();
|
||||
assertThat(anonResult.groups.keySet())
|
||||
.containsExactly(
|
||||
@ -406,7 +408,7 @@ public class AccessIT extends AbstractDaemonTest {
|
||||
ProjectAccessInput accessInput = newProjectAccessInput();
|
||||
accessInput.parent = newParentProjectName;
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("administrate server not permitted");
|
||||
pApi().access(accessInput);
|
||||
@ -433,7 +435,7 @@ public class AccessIT extends AbstractDaemonTest {
|
||||
|
||||
accessInput.add.put(AccessSection.GLOBAL_CAPABILITIES, accessSectionInfo);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
gApi.projects().name(allProjects.get()).access(accessInput);
|
||||
}
|
||||
@ -489,7 +491,7 @@ public class AccessIT extends AbstractDaemonTest {
|
||||
|
||||
accessInput.remove.put(AccessSection.GLOBAL_CAPABILITIES, accessSectionInfo);
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
gApi.projects().name(allProjects.get()).access(accessInput);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.projects.BranchApi;
|
||||
import com.google.gerrit.extensions.api.projects.BranchInfo;
|
||||
@ -33,10 +34,13 @@ import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.inject.Inject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CreateBranchIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private Branch.NameKey testBranch;
|
||||
|
||||
@Before
|
||||
@ -59,7 +63,7 @@ public class CreateBranchIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void createBranch_Forbidden() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertCreateFails(testBranch, AuthException.class, "not permitted: create on refs/heads/test");
|
||||
}
|
||||
|
||||
@ -77,7 +81,7 @@ public class CreateBranchIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void createBranchByProjectOwner() throws Exception {
|
||||
grantOwner();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertCreateSucceeds(testBranch);
|
||||
}
|
||||
|
||||
@ -91,7 +95,7 @@ public class CreateBranchIT extends AbstractDaemonTest {
|
||||
public void createBranchByProjectOwnerCreateReferenceBlocked_Forbidden() throws Exception {
|
||||
grantOwner();
|
||||
blockCreateReference();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertCreateFails(testBranch, AuthException.class, "not permitted: create on refs/heads/test");
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.UseLocalDisk;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInfo;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
||||
@ -48,6 +49,7 @@ import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.server.group.SystemGroupBackend;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@ -70,6 +72,8 @@ import org.eclipse.jgit.treewalk.TreeWalk;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CreateProjectIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void createProjectHttp() throws Exception {
|
||||
String newProjectName = name("newProject");
|
||||
@ -299,7 +303,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
public void createProjectWithCapability() throws Exception {
|
||||
allowGlobalCapabilities(SystemGroupBackend.REGISTERED_USERS, GlobalCapability.CREATE_PROJECT);
|
||||
try {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
ProjectInput in = new ProjectInput();
|
||||
in.name = name("newProject");
|
||||
ProjectInfo p = gApi.projects().create(in).get();
|
||||
@ -312,7 +316,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void createProjectWithoutCapability_Forbidden() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
ProjectInput in = new ProjectInput();
|
||||
in.name = name("newProject");
|
||||
assertCreateFails(in, AuthException.class);
|
||||
@ -331,7 +335,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
parent.setState(com.google.gerrit.extensions.client.ProjectState.HIDDEN);
|
||||
allowGlobalCapabilities(SystemGroupBackend.REGISTERED_USERS, GlobalCapability.CREATE_PROJECT);
|
||||
try {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
ProjectInput in = new ProjectInput();
|
||||
in.name = name("newProject");
|
||||
ProjectInfo p = gApi.projects().create(in).get();
|
||||
|
@ -22,6 +22,7 @@ import static org.eclipse.jgit.lib.Constants.R_HEADS;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.projects.BranchApi;
|
||||
import com.google.gerrit.extensions.api.projects.BranchInput;
|
||||
@ -37,6 +38,7 @@ import org.junit.Test;
|
||||
|
||||
public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private Branch.NameKey testBranch;
|
||||
|
||||
@ -49,7 +51,7 @@ public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void deleteBranch_Forbidden() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertDeleteForbidden(testBranch);
|
||||
}
|
||||
|
||||
@ -61,7 +63,7 @@ public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void deleteBranchByProjectOwner() throws Exception {
|
||||
grantOwner();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertDeleteSucceeds(testBranch);
|
||||
}
|
||||
|
||||
@ -75,21 +77,21 @@ public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
public void deleteBranchByProjectOwnerForcePushBlocked_Forbidden() throws Exception {
|
||||
grantOwner();
|
||||
blockForcePush();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertDeleteForbidden(testBranch);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteBranchByUserWithForcePushPermission() throws Exception {
|
||||
grantForcePush();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertDeleteSucceeds(testBranch);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteBranchByUserWithDeletePermission() throws Exception {
|
||||
grantDelete();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertDeleteSucceeds(testBranch);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.projects.BranchInput;
|
||||
import com.google.gerrit.extensions.api.projects.DeleteBranchesInput;
|
||||
@ -32,6 +33,7 @@ import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
@ -44,6 +46,8 @@ public class DeleteBranchesIT extends AbstractDaemonTest {
|
||||
private static final ImmutableList<String> BRANCHES =
|
||||
ImmutableList.of("refs/heads/test-1", "refs/heads/test-2", "test-3", "refs/meta/foo");
|
||||
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
allow("refs/*", Permission.CREATE, REGISTERED_USERS);
|
||||
@ -70,14 +74,14 @@ public class DeleteBranchesIT extends AbstractDaemonTest {
|
||||
|
||||
DeleteBranchesInput input = new DeleteBranchesInput();
|
||||
input.branches = branchToDelete;
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
try {
|
||||
project().deleteBranches(input);
|
||||
fail("Expected AuthException");
|
||||
} catch (AuthException e) {
|
||||
assertThat(e).hasMessageThat().isEqualTo("not permitted: delete on refs/heads/test-1");
|
||||
}
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
assertBranches(BRANCHES);
|
||||
}
|
||||
|
||||
@ -85,14 +89,14 @@ public class DeleteBranchesIT extends AbstractDaemonTest {
|
||||
public void deleteMultiBranchesWithoutPermissionForbidden() throws Exception {
|
||||
DeleteBranchesInput input = new DeleteBranchesInput();
|
||||
input.branches = BRANCHES;
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
try {
|
||||
project().deleteBranches(input);
|
||||
fail("Expected ResourceConflictException");
|
||||
} catch (ResourceConflictException e) {
|
||||
assertThat(e).hasMessageThat().isEqualTo(errorMessageForBranches(BRANCHES));
|
||||
}
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
assertBranches(BRANCHES);
|
||||
}
|
||||
|
||||
|
@ -21,18 +21,22 @@ import static org.eclipse.jgit.lib.Constants.R_TAGS;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.projects.TagApi;
|
||||
import com.google.gerrit.extensions.api.projects.TagInfo;
|
||||
import com.google.gerrit.extensions.api.projects.TagInput;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.inject.Inject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DeleteTagIT extends AbstractDaemonTest {
|
||||
private static final String TAG = "refs/tags/test";
|
||||
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
tag().create(new TagInput());
|
||||
@ -40,7 +44,7 @@ public class DeleteTagIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void deleteTag_Forbidden() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertDeleteForbidden();
|
||||
}
|
||||
|
||||
@ -52,7 +56,7 @@ public class DeleteTagIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void deleteTagByProjectOwner() throws Exception {
|
||||
grantOwner();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertDeleteSucceeds();
|
||||
}
|
||||
|
||||
@ -66,21 +70,21 @@ public class DeleteTagIT extends AbstractDaemonTest {
|
||||
public void deleteTagByProjectOwnerForcePushBlocked_Forbidden() throws Exception {
|
||||
grantOwner();
|
||||
blockForcePush();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertDeleteForbidden();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteTagByUserWithForcePushPermission() throws Exception {
|
||||
grantForcePush();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertDeleteSucceeds();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteTagByUserWithDeletePermission() throws Exception {
|
||||
grantDelete();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertDeleteSucceeds();
|
||||
}
|
||||
|
||||
|
@ -23,11 +23,13 @@ import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.projects.DeleteTagsInput;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectApi;
|
||||
import com.google.gerrit.extensions.api.projects.TagInfo;
|
||||
import com.google.gerrit.extensions.api.projects.TagInput;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.inject.Inject;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
@ -39,6 +41,8 @@ public class DeleteTagsIT extends AbstractDaemonTest {
|
||||
private static final ImmutableList<String> TAGS =
|
||||
ImmutableList.of("refs/tags/test-1", "refs/tags/test-2", "refs/tags/test-3", "test-4");
|
||||
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
for (String name : TAGS) {
|
||||
@ -61,14 +65,14 @@ public class DeleteTagsIT extends AbstractDaemonTest {
|
||||
public void deleteTagsForbidden() throws Exception {
|
||||
DeleteTagsInput input = new DeleteTagsInput();
|
||||
input.tags = TAGS;
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
try {
|
||||
project().deleteTags(input);
|
||||
fail("Expected ResourceConflictException");
|
||||
} catch (ResourceConflictException e) {
|
||||
assertThat(e).hasMessageThat().isEqualTo(errorMessageForTags(TAGS));
|
||||
}
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
assertTags(TAGS);
|
||||
}
|
||||
|
||||
|
@ -20,15 +20,19 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.projects.BranchInfo;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectApi.ListRefsRequest;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.inject.Inject;
|
||||
import org.junit.Test;
|
||||
|
||||
@NoHttpd
|
||||
public class ListBranchesIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void listBranchesOfNonExistingProject_NotFound() throws Exception {
|
||||
exception.expect(ResourceNotFoundException.class);
|
||||
@ -38,7 +42,7 @@ public class ListBranchesIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void listBranchesOfNonVisibleProject_NotFound() throws Exception {
|
||||
blockRead("refs/*");
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(ResourceNotFoundException.class);
|
||||
gApi.projects().name(project.get()).branches().get();
|
||||
}
|
||||
@ -70,7 +74,7 @@ public class ListBranchesIT extends AbstractDaemonTest {
|
||||
blockRead("refs/heads/dev");
|
||||
String master = pushTo("refs/heads/master").getCommit().name();
|
||||
pushTo("refs/heads/dev");
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
// refs/meta/config is hidden since user is no project owner
|
||||
assertRefs(
|
||||
ImmutableList.of(
|
||||
@ -83,7 +87,7 @@ public class ListBranchesIT extends AbstractDaemonTest {
|
||||
blockRead("refs/heads/master");
|
||||
pushTo("refs/heads/master");
|
||||
String dev = pushTo("refs/heads/dev").getCommit().name();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
// refs/meta/config is hidden since user is no project owner
|
||||
assertRefs(ImmutableList.of(branch("refs/heads/dev", dev, false)), list().get());
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.Sandboxed;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInfo;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
||||
@ -43,6 +44,7 @@ import org.junit.Test;
|
||||
@Sandboxed
|
||||
public class ListProjectsIT extends AbstractDaemonTest {
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void listProjects() throws Exception {
|
||||
@ -54,7 +56,7 @@ public class ListProjectsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void listProjectsFiltersInvisibleProjects() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
assertThatNameList(gApi.projects().list().get()).contains(project);
|
||||
|
||||
try (ProjectConfigUpdate u = updateProject(project)) {
|
||||
|
@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectApi.ListRefsRequest;
|
||||
import com.google.gerrit.extensions.api.projects.TagApi;
|
||||
@ -33,6 +34,7 @@ import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.inject.Inject;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import org.junit.Test;
|
||||
@ -56,6 +58,8 @@ public class TagsIT extends AbstractDaemonTest {
|
||||
+ "=XFeC\n"
|
||||
+ "-----END PGP SIGNATURE-----";
|
||||
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void listTagsOfNonExistingProject() throws Exception {
|
||||
exception.expect(ResourceNotFoundException.class);
|
||||
@ -71,7 +75,7 @@ public class TagsIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void listTagsOfNonVisibleProject() throws Exception {
|
||||
blockRead("refs/*");
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(ResourceNotFoundException.class);
|
||||
gApi.projects().name(project.get()).tags().get();
|
||||
}
|
||||
@ -187,7 +191,7 @@ public class TagsIT extends AbstractDaemonTest {
|
||||
assertThat(result.canDelete).isTrue();
|
||||
assertThat(result.created).isEqualTo(timestamp(r));
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
result = tag(input.ref).get();
|
||||
assertThat(result.canDelete).isNull();
|
||||
|
||||
|
@ -30,6 +30,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.AcceptanceTestRequestScope;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.changes.DeleteCommentInput;
|
||||
import com.google.gerrit.extensions.api.changes.DraftInput;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
@ -76,20 +77,17 @@ import org.junit.Test;
|
||||
|
||||
@NoHttpd
|
||||
public class CommentsIT extends AbstractDaemonTest {
|
||||
|
||||
@Inject private Provider<ChangesCollection> changes;
|
||||
|
||||
@Inject private Provider<PostReview> postReview;
|
||||
|
||||
@Inject private FakeEmailSender email;
|
||||
|
||||
@Inject private ChangeNoteUtil noteUtil;
|
||||
@Inject private FakeEmailSender email;
|
||||
@Inject private Provider<ChangesCollection> changes;
|
||||
@Inject private Provider<PostReview> postReview;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private final Integer[] lines = {0, 1};
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -445,7 +443,7 @@ public class CommentsIT extends AbstractDaemonTest {
|
||||
.create(admin.getIdent(), testRepo, SUBJECT, FILE_NAME, "new content", r1.getChangeId())
|
||||
.to("refs/for/master");
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
addDraft(
|
||||
r1.getChangeId(),
|
||||
r1.getCommit().getName(),
|
||||
@ -455,13 +453,13 @@ public class CommentsIT extends AbstractDaemonTest {
|
||||
r2.getCommit().getName(),
|
||||
newDraft(FILE_NAME, Side.REVISION, 1, "typo: content"));
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
addDraft(
|
||||
r2.getChangeId(),
|
||||
r2.getCommit().getName(),
|
||||
newDraft(FILE_NAME, Side.REVISION, 1, "+1, please fix"));
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
Map<String, List<CommentInfo>> actual = gApi.changes().id(r1.getChangeId()).drafts();
|
||||
assertThat(actual.keySet()).containsExactly(FILE_NAME);
|
||||
List<CommentInfo> comments = actual.get(FILE_NAME);
|
||||
@ -569,11 +567,11 @@ public class CommentsIT extends AbstractDaemonTest {
|
||||
other.getCommit().getName(),
|
||||
newDraft(FILE_NAME, Side.REVISION, 1, "unrelated comment"));
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
// Drafts by other users aren't returned.
|
||||
addDraft(
|
||||
r2.getChangeId(), r2.getCommit().getName(), newDraft(FILE_NAME, Side.REVISION, 2, "oops"));
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
ReviewInput reviewInput = new ReviewInput();
|
||||
reviewInput.drafts = DraftHandling.PUBLISH_ALL_REVISIONS;
|
||||
@ -766,7 +764,7 @@ public class CommentsIT extends AbstractDaemonTest {
|
||||
String uuid = commentsMap.get(targetComment.path).get(0).id;
|
||||
DeleteCommentInput input = new DeleteCommentInput("contains confidential information");
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
gApi.changes().id(result.getChangeId()).current().comment(uuid).delete(input);
|
||||
}
|
||||
@ -837,7 +835,7 @@ public class CommentsIT extends AbstractDaemonTest {
|
||||
// PS4 has comments [c7, c8].
|
||||
assertThat(getRevisionComments(changeId, ps4)).hasSize(2);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
for (int i = 0; i < commentsBeforeDelete.size(); i++) {
|
||||
List<RevCommit> commitsBeforeDelete = getChangeMetaCommitsInReverseOrder(id);
|
||||
|
||||
@ -907,7 +905,7 @@ public class CommentsIT extends AbstractDaemonTest {
|
||||
|
||||
List<RevCommit> commitsBeforeDelete = getChangeMetaCommitsInReverseOrder(id);
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
for (int i = 0; i < 3; i++) {
|
||||
DeleteCommentInput input = new DeleteCommentInput("delete comment 2, iteration: " + i);
|
||||
gApi.changes().id(changeId).revision(ps1).comment(uuid).delete(input);
|
||||
|
@ -22,6 +22,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GitUtil;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.changes.SubmittedTogetherInfo;
|
||||
import com.google.gerrit.extensions.client.ChangeStatus;
|
||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
@ -44,6 +45,7 @@ public class SubmittedTogetherIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void doesNotIncludeCurrentFiles() throws Exception {
|
||||
@ -104,7 +106,7 @@ public class SubmittedTogetherIT extends AbstractDaemonTest {
|
||||
RevCommit b = commitBuilder().add("b", "1").message("change 2").create();
|
||||
pushHead(testRepo, "refs/for/master", false);
|
||||
|
||||
setApiUserAnonymous();
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
assertSubmittedTogether(getChangeId(a));
|
||||
assertSubmittedTogether(getChangeId(b), getChangeId(b), getChangeId(a));
|
||||
}
|
||||
@ -143,7 +145,7 @@ public class SubmittedTogetherIT extends AbstractDaemonTest {
|
||||
pushHead(testRepo, "refs/for/master/" + name("topic"), false);
|
||||
String id2 = getChangeId(b);
|
||||
|
||||
setApiUserAnonymous();
|
||||
requestScopeOperations.setApiUserAnonymous();
|
||||
if (isSubmitWholeTopicEnabled()) {
|
||||
assertSubmittedTogether(id1, id2, id1);
|
||||
assertSubmittedTogether(id2, id2, id1);
|
||||
|
@ -18,17 +18,20 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput;
|
||||
import com.google.gerrit.extensions.client.Comment;
|
||||
import com.google.gerrit.extensions.client.Side;
|
||||
import com.google.gerrit.mail.MailMessage;
|
||||
import com.google.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import org.junit.Ignore;
|
||||
|
||||
@Ignore
|
||||
public class AbstractMailIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
protected MailMessage.Builder messageBuilderWithDefaultFields() {
|
||||
MailMessage.Builder b = MailMessage.builder();
|
||||
@ -54,7 +57,7 @@ public class AbstractMailIT extends AbstractDaemonTest {
|
||||
String changeId = r.getChangeId();
|
||||
|
||||
// Review it
|
||||
setApiUser(reviewer);
|
||||
requestScopeOperations.setApiUser(reviewer.getId());
|
||||
ReviewInput input = new ReviewInput();
|
||||
input.message = "I have two comments";
|
||||
input.comments = new HashMap<>();
|
||||
|
@ -31,6 +31,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.truth.Truth;
|
||||
import com.google.gerrit.acceptance.AbstractNotificationTest;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.AbandonInput;
|
||||
@ -52,10 +53,13 @@ import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.project.ProjectConfig;
|
||||
import com.google.gerrit.server.project.testing.Util;
|
||||
import com.google.gerrit.server.restapi.change.PostReview;
|
||||
import com.google.inject.Inject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
/*
|
||||
* Set up for extra standard test accounts and permissions.
|
||||
*/
|
||||
@ -242,7 +246,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
String changeId, TestAccount by, EmailStrategy emailStrategy, @Nullable NotifyHandling notify)
|
||||
throws Exception {
|
||||
setEmailStrategy(by, emailStrategy);
|
||||
setApiUser(by);
|
||||
requestScopeOperations.setApiUser(by.getId());
|
||||
AbandonInput in = new AbandonInput();
|
||||
if (notify != null) {
|
||||
in.notify = notify;
|
||||
@ -585,7 +589,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
@Nullable NotifyHandling notify)
|
||||
throws Exception {
|
||||
setEmailStrategy(by, emailStrategy);
|
||||
setApiUser(by);
|
||||
requestScopeOperations.setApiUser(by.getId());
|
||||
adder.addReviewer(changeId, reviewer, notify);
|
||||
}
|
||||
|
||||
@ -1017,7 +1021,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
@Test
|
||||
public void deleteReviewerFromReviewableChange() throws Exception {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
removeReviewer(sc, extraReviewer);
|
||||
assertThat(sender)
|
||||
.sent("deleteReviewer", sc)
|
||||
@ -1047,7 +1051,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
@Test
|
||||
public void deleteReviewerFromReviewableChangeByAdmin() throws Exception {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
removeReviewer(sc, extraReviewer);
|
||||
assertThat(sender)
|
||||
.sent("deleteReviewer", sc)
|
||||
@ -1063,7 +1067,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
public void deleteReviewerFromReviewableChangeByAdminCcingSelf() throws Exception {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
setEmailStrategy(admin, EmailStrategy.CC_ON_OWN_COMMENTS);
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
removeReviewer(sc, extraReviewer);
|
||||
assertThat(sender)
|
||||
.sent("deleteReviewer", sc)
|
||||
@ -1078,7 +1082,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
@Test
|
||||
public void deleteCcerFromReviewableChange() throws Exception {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
removeReviewer(sc, extraCcer);
|
||||
assertThat(sender)
|
||||
.sent("deleteReviewer", sc)
|
||||
@ -1093,7 +1097,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
@Test
|
||||
public void deleteReviewerFromReviewableChangeNotifyOwnerReviewers() throws Exception {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
removeReviewer(sc, extraReviewer, NotifyHandling.OWNER_REVIEWERS);
|
||||
assertThat(sender)
|
||||
.sent("deleteReviewer", sc)
|
||||
@ -1150,7 +1154,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
@Test
|
||||
public void deleteReviewerFromWipChangeNotifyAll() throws Exception {
|
||||
StagedChange sc = stageWipChangeWithExtraReviewer();
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
removeReviewer(sc, extraReviewer, NotifyHandling.ALL);
|
||||
assertThat(sender)
|
||||
.sent("deleteReviewer", sc)
|
||||
@ -1166,7 +1170,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
public void deleteReviewerWithApprovalFromWipChange() throws Exception {
|
||||
StagedChange sc = stageWipChangeWithExtraReviewer();
|
||||
recommend(sc, extraReviewer);
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
removeReviewer(sc, extraReviewer);
|
||||
assertThat(sender).sent("deleteReviewer", sc).to(extraReviewer).noOneElse();
|
||||
}
|
||||
@ -1187,7 +1191,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
}
|
||||
|
||||
private void recommend(StagedChange sc, TestAccount by) throws Exception {
|
||||
setApiUser(by);
|
||||
requestScopeOperations.setApiUser(by.getId());
|
||||
gApi.changes().id(sc.changeId).revision("current").review(ReviewInput.recommend());
|
||||
}
|
||||
|
||||
@ -1201,7 +1205,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
ReviewInput.noScore()
|
||||
.reviewer(extraReviewer.email)
|
||||
.reviewer(extraCcer.email, ReviewerState.CC, false);
|
||||
setApiUser(extraReviewer);
|
||||
requestScopeOperations.setApiUser(extraReviewer.getId());
|
||||
gApi.changes().id(sc.changeId).revision("current").review(in);
|
||||
return sc;
|
||||
}
|
||||
@ -1239,7 +1243,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
public void deleteVoteFromReviewableChange() throws Exception {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
recommend(sc, extraReviewer);
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
deleteVote(sc, extraReviewer);
|
||||
assertThat(sender)
|
||||
.sent("deleteVote", sc)
|
||||
@ -1255,7 +1259,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
recommend(sc, extraReviewer);
|
||||
setEmailStrategy(sc.owner, CC_ON_OWN_COMMENTS);
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
deleteVote(sc, extraReviewer);
|
||||
assertThat(sender)
|
||||
.sent("deleteVote", sc)
|
||||
@ -1271,7 +1275,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
public void deleteVoteFromReviewableChangeByAdmin() throws Exception {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
recommend(sc, extraReviewer);
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
deleteVote(sc, extraReviewer);
|
||||
assertThat(sender)
|
||||
.sent("deleteVote", sc)
|
||||
@ -1288,7 +1292,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
recommend(sc, extraReviewer);
|
||||
setEmailStrategy(admin, EmailStrategy.CC_ON_OWN_COMMENTS);
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
deleteVote(sc, extraReviewer);
|
||||
assertThat(sender)
|
||||
.sent("deleteVote", sc)
|
||||
@ -1304,7 +1308,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
public void deleteVoteFromReviewableChangeNotifyOwnerReviewers() throws Exception {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
recommend(sc, extraReviewer);
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
deleteVote(sc, extraReviewer, NotifyHandling.OWNER_REVIEWERS);
|
||||
assertThat(sender)
|
||||
.sent("deleteVote", sc)
|
||||
@ -1318,7 +1322,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
recommend(sc, extraReviewer);
|
||||
setEmailStrategy(sc.owner, CC_ON_OWN_COMMENTS);
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
deleteVote(sc, extraReviewer, NotifyHandling.OWNER_REVIEWERS);
|
||||
assertThat(sender)
|
||||
.sent("deleteVote", sc)
|
||||
@ -1332,7 +1336,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
public void deleteVoteFromReviewableChangeNotifyOwner() throws Exception {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
recommend(sc, extraReviewer);
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
deleteVote(sc, extraReviewer, NotifyHandling.OWNER);
|
||||
assertThat(sender).sent("deleteVote", sc).to(sc.owner).noOneElse();
|
||||
}
|
||||
@ -1341,7 +1345,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
public void deleteVoteFromReviewableChangeNotifyNone() throws Exception {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
recommend(sc, extraReviewer);
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
deleteVote(sc, extraReviewer, NotifyHandling.NONE);
|
||||
assertThat(sender).notSent();
|
||||
}
|
||||
@ -1351,7 +1355,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
StagedChange sc = stageReviewableChangeWithExtraReviewer();
|
||||
recommend(sc, extraReviewer);
|
||||
setEmailStrategy(sc.owner, CC_ON_OWN_COMMENTS);
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
deleteVote(sc, extraReviewer, NotifyHandling.NONE);
|
||||
assertThat(sender).notSent();
|
||||
}
|
||||
@ -1360,7 +1364,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
public void deleteVoteFromReviewableWipChange() throws Exception {
|
||||
StagedChange sc = stageReviewableWipChangeWithExtraReviewer();
|
||||
recommend(sc, extraReviewer);
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
deleteVote(sc, extraReviewer);
|
||||
assertThat(sender)
|
||||
.sent("deleteVote", sc)
|
||||
@ -1375,7 +1379,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
public void deleteVoteFromWipChange() throws Exception {
|
||||
StagedChange sc = stageWipChangeWithExtraReviewer();
|
||||
recommend(sc, extraReviewer);
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
deleteVote(sc, extraReviewer);
|
||||
assertThat(sender)
|
||||
.sent("deleteVote", sc)
|
||||
@ -1508,7 +1512,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
private void merge(String changeId, TestAccount by, EmailStrategy emailStrategy)
|
||||
throws Exception {
|
||||
setEmailStrategy(by, emailStrategy);
|
||||
setApiUser(by);
|
||||
requestScopeOperations.setApiUser(by.getId());
|
||||
gApi.changes().id(changeId).revision("current").submit();
|
||||
}
|
||||
|
||||
@ -1520,7 +1524,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
String changeId, TestAccount by, EmailStrategy emailStrategy, NotifyHandling notify)
|
||||
throws Exception {
|
||||
setEmailStrategy(by, emailStrategy);
|
||||
setApiUser(by);
|
||||
requestScopeOperations.setApiUser(by.getId());
|
||||
SubmitInput in = new SubmitInput();
|
||||
in.notify = notify;
|
||||
gApi.changes().id(changeId).revision("current").submit(in);
|
||||
@ -1528,7 +1532,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
|
||||
private StagedChange stageChangeReadyForMerge() throws Exception {
|
||||
StagedChange sc = stageReviewableChange();
|
||||
setApiUser(sc.reviewer);
|
||||
requestScopeOperations.setApiUser(sc.reviewer.getId());
|
||||
gApi.changes().id(sc.changeId).revision("current").review(ReviewInput.approve());
|
||||
sender.clear();
|
||||
return sc;
|
||||
@ -2004,7 +2008,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
private void restore(String changeId, TestAccount by, EmailStrategy emailStrategy)
|
||||
throws Exception {
|
||||
setEmailStrategy(by, emailStrategy);
|
||||
setApiUser(by);
|
||||
requestScopeOperations.setApiUser(by.getId());
|
||||
gApi.changes().id(changeId).restore();
|
||||
}
|
||||
|
||||
@ -2109,7 +2113,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
|
||||
private StagedChange stageChange() throws Exception {
|
||||
StagedChange sc = stageReviewableChange();
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.changes().id(sc.changeId).revision("current").review(ReviewInput.approve());
|
||||
gApi.changes().id(sc.changeId).revision("current").submit();
|
||||
sender.clear();
|
||||
@ -2123,7 +2127,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
private void revert(StagedChange sc, TestAccount by, EmailStrategy emailStrategy)
|
||||
throws Exception {
|
||||
setEmailStrategy(by, emailStrategy);
|
||||
setApiUser(by);
|
||||
requestScopeOperations.setApiUser(by.getId());
|
||||
gApi.changes().id(sc.changeId).revert();
|
||||
}
|
||||
|
||||
@ -2242,7 +2246,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
private void assign(StagedChange sc, TestAccount by, TestAccount to, EmailStrategy emailStrategy)
|
||||
throws Exception {
|
||||
setEmailStrategy(by, emailStrategy);
|
||||
setApiUser(by);
|
||||
requestScopeOperations.setApiUser(by.getId());
|
||||
AssigneeInput in = new AssigneeInput();
|
||||
in.assignee = to.email;
|
||||
gApi.changes().id(sc.changeId).setAssignee(in);
|
||||
@ -2288,7 +2292,7 @@ public class ChangeNotificationsIT extends AbstractNotificationTest {
|
||||
}
|
||||
|
||||
private void startReview(StagedChange sc) throws Exception {
|
||||
setApiUser(sc.owner);
|
||||
requestScopeOperations.setApiUser(sc.owner.getId());
|
||||
gApi.changes().id(sc.changeId).setReadyForReview();
|
||||
// PolyGerrit current immediately follows up with a review.
|
||||
gApi.changes().id(sc.changeId).revision("current").review(ReviewInput.noScore());
|
||||
|
@ -20,6 +20,7 @@ import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.common.ChangeMessageInfo;
|
||||
import com.google.gerrit.mail.EmailHeader;
|
||||
@ -27,6 +28,7 @@ import com.google.gerrit.mail.MailProcessingUtil;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.testing.FakeEmailSender;
|
||||
import com.google.gerrit.testing.TestTimeUtil;
|
||||
import com.google.inject.Inject;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
@ -41,6 +43,8 @@ import org.junit.Test;
|
||||
|
||||
/** Tests the presence of required metadata in email headers, text and html. */
|
||||
public class MailMetadataIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
private String systemTimeZone;
|
||||
|
||||
@Before
|
||||
@ -92,7 +96,7 @@ public class MailMetadataIT extends AbstractDaemonTest {
|
||||
ReviewInput input = new ReviewInput();
|
||||
input.message = "Test";
|
||||
revision(newChange).review(input);
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
Collection<ChangeMessageInfo> result =
|
||||
gApi.changes().id(newChange.getChangeId()).get().messages;
|
||||
assertThat(result).isNotEmpty();
|
||||
|
@ -18,13 +18,16 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailFormat;
|
||||
import com.google.gerrit.testing.FakeEmailSender;
|
||||
import com.google.inject.Inject;
|
||||
import org.junit.Test;
|
||||
|
||||
public class NotificationMailFormatIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void userReceivesPlaintextEmail() throws Exception {
|
||||
@ -35,7 +38,7 @@ public class NotificationMailFormatIT extends AbstractDaemonTest {
|
||||
|
||||
// Create change as admin and review as user
|
||||
PushOneCommit.Result r = createChange();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.recommend());
|
||||
|
||||
// Check that admin has received only plaintext content
|
||||
@ -47,7 +50,7 @@ public class NotificationMailFormatIT extends AbstractDaemonTest {
|
||||
assertMailReplyTo(m, user.email);
|
||||
|
||||
// Reset user preference
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
i.emailFormat = EmailFormat.HTML_PLAINTEXT;
|
||||
gApi.accounts().id(admin.getId().toString()).setPreferences(i);
|
||||
}
|
||||
@ -56,7 +59,7 @@ public class NotificationMailFormatIT extends AbstractDaemonTest {
|
||||
public void userReceivesHtmlAndPlaintextEmail() throws Exception {
|
||||
// Create change as admin and review as user
|
||||
PushOneCommit.Result r = createChange();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.changes().id(r.getChangeId()).current().review(ReviewInput.recommend());
|
||||
|
||||
// Check that admin has received both HTML and plaintext content
|
||||
|
@ -23,6 +23,7 @@ import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.api.changes.StarsInput;
|
||||
@ -43,6 +44,7 @@ import org.junit.Test;
|
||||
@NoHttpd
|
||||
public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
@Inject private ProjectOperations projectOperations;
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void newPatchSetsNotifyConfig() throws Exception {
|
||||
@ -108,7 +110,7 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
|
||||
assertThat(sender.getMessages()).isEmpty();
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
ReviewInput in = new ReviewInput();
|
||||
in.message = "comment";
|
||||
gApi.changes().id(r.getChangeId()).current().review(in);
|
||||
@ -169,7 +171,7 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
|
||||
assertThat(sender.getMessages()).isEmpty();
|
||||
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
ReviewInput in = new ReviewInput();
|
||||
in.message = "comment";
|
||||
gApi.changes().id(r.getChangeId()).current().review(in);
|
||||
@ -210,11 +212,11 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
public void watchProject() throws Exception {
|
||||
// watch project
|
||||
String watchedProject = projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
watch(watchedProject);
|
||||
|
||||
// push a change to watched project -> should trigger email notification
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
TestRepository<InMemoryRepository> watchedRepo =
|
||||
cloneProject(new Project.NameKey(watchedProject), admin);
|
||||
PushOneCommit.Result r =
|
||||
@ -247,7 +249,7 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
public void watchFile() throws Exception {
|
||||
String watchedProject = projectOperations.newProject().create().get();
|
||||
String otherWatchedProject = projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
// watch file in project as user
|
||||
watch(watchedProject, "file:a.txt");
|
||||
@ -257,7 +259,7 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
|
||||
// push a change to watched file -> should trigger email notification for
|
||||
// user
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
TestRepository<InMemoryRepository> watchedRepo =
|
||||
cloneProject(new Project.NameKey(watchedProject), admin);
|
||||
PushOneCommit.Result r =
|
||||
@ -277,7 +279,7 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
|
||||
// watch project as user2
|
||||
TestAccount user2 = accountCreator.create("user2", "user2@test.com", "User2");
|
||||
setApiUser(user2);
|
||||
requestScopeOperations.setApiUser(user2.getId());
|
||||
watch(watchedProject);
|
||||
|
||||
// push a change to non-watched file -> should not trigger email
|
||||
@ -300,13 +302,13 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void watchKeyword() throws Exception {
|
||||
String watchedProject = projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
// watch keyword in project as user
|
||||
watch(watchedProject, "multimaster");
|
||||
|
||||
// push a change with keyword -> should trigger email notification
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
TestRepository<InMemoryRepository> watchedRepo =
|
||||
cloneProject(new Project.NameKey(watchedProject), admin);
|
||||
PushOneCommit.Result r =
|
||||
@ -338,13 +340,13 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void watchAllProjects() throws Exception {
|
||||
String anyProject = projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
// watch the All-Projects project to watch all projects
|
||||
watch(allProjects.get());
|
||||
|
||||
// push a change to any project -> should trigger email notification
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
TestRepository<InMemoryRepository> anyRepo =
|
||||
cloneProject(new Project.NameKey(anyProject), admin);
|
||||
PushOneCommit.Result r =
|
||||
@ -363,7 +365,7 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void watchFileAllProjects() throws Exception {
|
||||
String anyProject = projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
// watch file in All-Projects project as user to watch the file in all
|
||||
// projects
|
||||
@ -371,7 +373,7 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
|
||||
// push a change to watched file in any project -> should trigger email
|
||||
// notification for user
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
TestRepository<InMemoryRepository> anyRepo =
|
||||
cloneProject(new Project.NameKey(anyProject), admin);
|
||||
PushOneCommit.Result r =
|
||||
@ -391,7 +393,7 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
|
||||
// watch project as user2
|
||||
TestAccount user2 = accountCreator.create("user2", "user2@test.com", "User2");
|
||||
setApiUser(user2);
|
||||
requestScopeOperations.setApiUser(user2.getId());
|
||||
watch(anyProject);
|
||||
|
||||
// push a change to non-watched file in any project -> should not trigger
|
||||
@ -414,14 +416,14 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void watchKeywordAllProjects() throws Exception {
|
||||
String anyProject = projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
|
||||
// watch keyword in project as user
|
||||
watch(allProjects.get(), "multimaster");
|
||||
|
||||
// push a change with keyword to any project -> should trigger email
|
||||
// notification
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
TestRepository<InMemoryRepository> anyRepo =
|
||||
cloneProject(new Project.NameKey(anyProject), admin);
|
||||
PushOneCommit.Result r =
|
||||
@ -455,11 +457,11 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
public void watchProjectNoNotificationForIgnoredChange() throws Exception {
|
||||
// watch project
|
||||
String watchedProject = projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
watch(watchedProject);
|
||||
|
||||
// push a change to watched project
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
TestRepository<InMemoryRepository> watchedRepo =
|
||||
cloneProject(new Project.NameKey(watchedProject), admin);
|
||||
PushOneCommit.Result r =
|
||||
@ -469,13 +471,13 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
r.assertOkStatus();
|
||||
|
||||
// ignore the change
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.accounts().self().setStars(r.getChangeId(), new StarsInput(ImmutableSet.of(IGNORE_LABEL)));
|
||||
|
||||
sender.clear();
|
||||
|
||||
// post a comment -> should not trigger email notification since user ignored the change
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
ReviewInput in = new ReviewInput();
|
||||
in.message = "comment";
|
||||
gApi.changes().id(r.getChangeId()).current().review(in);
|
||||
@ -488,11 +490,11 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
public void watchProjectNoNotificationForPrivateChange() throws Exception {
|
||||
// watch project
|
||||
String watchedProject = projectOperations.newProject().create().get();
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
watch(watchedProject);
|
||||
|
||||
// push a private change to watched project -> should not trigger email notification
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
TestRepository<InMemoryRepository> watchedRepo =
|
||||
cloneProject(new Project.NameKey(watchedProject), admin);
|
||||
PushOneCommit.Result r =
|
||||
@ -520,19 +522,19 @@ public class ProjectWatchIT extends AbstractDaemonTest {
|
||||
new AccountGroup.UUID(groupThatCanViewPrivateChanges.id));
|
||||
|
||||
// watch project as user that can't view private changes
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
watch(watchedProject);
|
||||
|
||||
// watch project as user that can view all private change
|
||||
TestAccount userThatCanViewPrivateChanges =
|
||||
accountCreator.create(
|
||||
"user2", "user2@test.com", "User2", groupThatCanViewPrivateChanges.name);
|
||||
setApiUser(userThatCanViewPrivateChanges);
|
||||
requestScopeOperations.setApiUser(userThatCanViewPrivateChanges.getId());
|
||||
watch(watchedProject);
|
||||
|
||||
// push a private change to watched project -> should trigger email notification for
|
||||
// userThatCanViewPrivateChanges, but not for user
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
TestRepository<InMemoryRepository> watchedRepo =
|
||||
cloneProject(new Project.NameKey(watchedProject), admin);
|
||||
PushOneCommit.Result r =
|
||||
|
@ -20,6 +20,7 @@ import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.UseLocalDisk;
|
||||
import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.api.groups.GroupApi;
|
||||
@ -29,6 +30,7 @@ import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.project.testing.Util;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import org.eclipse.jgit.lib.ReflogEntry;
|
||||
@ -37,6 +39,8 @@ import org.junit.Test;
|
||||
|
||||
@UseLocalDisk
|
||||
public class ReflogIT extends AbstractDaemonTest {
|
||||
@Inject private RequestScopeOperations requestScopeOperations;
|
||||
|
||||
@Test
|
||||
public void guessRestApiInReflog() throws Exception {
|
||||
PushOneCommit.Result r = createChange();
|
||||
@ -80,7 +84,7 @@ public class ReflogIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void regularUserIsNotAllowedToGetReflog() throws Exception {
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
exception.expect(AuthException.class);
|
||||
gApi.projects().name(project.get()).branch("master").reflog();
|
||||
}
|
||||
@ -96,13 +100,13 @@ public class ReflogIT extends AbstractDaemonTest {
|
||||
u.save();
|
||||
}
|
||||
|
||||
setApiUser(user);
|
||||
requestScopeOperations.setApiUser(user.getId());
|
||||
gApi.projects().name(project.get()).branch("master").reflog();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adminUserIsAllowedToGetReflog() throws Exception {
|
||||
setApiUser(admin);
|
||||
requestScopeOperations.setApiUser(admin.getId());
|
||||
gApi.projects().name(project.get()).branch("master").reflog();
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit bde9bc6db227bf799ec35d6c1667fedb49b1c0a7
|
||||
Subproject commit 09269fd13109ef6771803fd0560a78e34dd5281e
|
@ -1 +1 @@
|
||||
Subproject commit 0f798f61c0c598c1499cbaacc1c609078c8bf0d5
|
||||
Subproject commit 17f5d016b8c9e76cdbf467a004ba22d4c46311fa
|
Loading…
x
Reference in New Issue
Block a user