Revert "submitted_together: Add a dummy change for not visible changes"
This reverts commit e73ebe2dc4. It
broke anonymous access in projects with the CherryPick submit type.
Add a test to prevent the problem from happening again.
Error in GET /changes/24150/revisions/f3d9f239bc26908994eebc8b4ba64e89c634f352/actions
java.lang.IllegalStateException: user already specified: IdentifiedUser[account 5195]
at com.google.gerrit.server.query.change.ChangeData.changeControl(ChangeData.java:691)
at com.google.gerrit.server.git.ChangeSet.<init>(ChangeSet.java:66)
at com.google.gerrit.server.git.MergeSuperSet.completeChangeSetWithoutTopic(MergeSuperSet.java:169)
at com.google.gerrit.server.git.MergeSuperSet.completeChangeSet(MergeSuperSet.java:103)
at com.google.gerrit.server.change.GetRevisionActions.getETag(GetRevisionActions.java:75)
at com.google.gerrit.server.change.GetRevisionActions.getETag(GetRevisionActions.java:39)
at com.google.gerrit.httpd.restapi.RestApiServlet.addResourceStateHeaders(RestApiServlet.java:496)
at com.google.gerrit.httpd.restapi.RestApiServlet.configureCaching(RestApiServlet.java:476)
at com.google.gerrit.httpd.restapi.RestApiServlet.service(RestApiServlet.java:347)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
Change-Id: I143300e7b3a17046559d640bd589ba34aed662f0
This commit is contained in:
@@ -16,38 +16,22 @@ package com.google.gerrit.acceptance.server.change;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.GitUtil.pushHead;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GitUtil;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.client.ChangeStatus;
|
||||
import com.google.gerrit.extensions.client.SubmitType;
|
||||
import com.google.gerrit.extensions.client.SubmittedTogetherOption;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.git.ProjectConfig;
|
||||
import com.google.gerrit.server.project.Util;
|
||||
import com.google.gerrit.testutil.ConfigSuite;
|
||||
|
||||
import org.eclipse.jgit.junit.TestRepository;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class SubmittedTogetherIT extends AbstractDaemonTest {
|
||||
|
||||
@ConfigSuite.Config
|
||||
public static Config submitWholeTopicEnabled() {
|
||||
return submitWholeTopicEnabledConfig();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnsAncestors() throws Exception {
|
||||
// Create two commits and push.
|
||||
@@ -238,115 +222,6 @@ public class SubmittedTogetherIT extends AbstractDaemonTest {
|
||||
assertSubmittedTogether(id2, id2, id1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHiddenDraftChange() throws Exception {
|
||||
setApiUser(admin);
|
||||
RevCommit initialHead = getRemoteHead();
|
||||
// Create two independent commits and push.
|
||||
RevCommit c1_1 = commitBuilder()
|
||||
.add("a.txt", "1")
|
||||
.message("subject: 1")
|
||||
.create();
|
||||
String id1 = getChangeId(c1_1);
|
||||
pushHead(testRepo, "refs/drafts/master/" + name("connectingTopic"), false);
|
||||
|
||||
testRepo.reset(initialHead);
|
||||
setApiUser(user);
|
||||
RevCommit c2_1 = commitBuilder()
|
||||
.add("b.txt", "2")
|
||||
.message("subject: 2")
|
||||
.create();
|
||||
String id2 = getChangeId(c2_1);
|
||||
pushHead(testRepo, "refs/for/master/" + name("connectingTopic"), false);
|
||||
|
||||
String draftId = "Some changes are not visible";
|
||||
EnumSet<SubmittedTogetherOption> o1 = EnumSet.noneOf(
|
||||
SubmittedTogetherOption.class);
|
||||
EnumSet<SubmittedTogetherOption> o2 = EnumSet.of(
|
||||
SubmittedTogetherOption.DUMMY);
|
||||
if (isSubmitWholeTopicEnabled()) {
|
||||
setApiUser(admin);
|
||||
assertSubmittedTogether(id1, o1, id2, id1);
|
||||
assertSubmittedTogether(id2, o1, id2, id1);
|
||||
assertSubmittedTogether(id1, o2, id2, id1);
|
||||
assertSubmittedTogether(id2, o2, id2, id1);
|
||||
setApiUser(user);
|
||||
assertSubmittedTogether(id2, o1);
|
||||
assertSubmittedTogether(id2, o2, id2, draftId);
|
||||
} else {
|
||||
setApiUser(admin);
|
||||
assertSubmittedTogether(id1, o1);
|
||||
assertSubmittedTogether(id2, o1);
|
||||
assertSubmittedTogether(id1, o2);
|
||||
assertSubmittedTogether(id2, o2);
|
||||
setApiUser(user);
|
||||
assertSubmittedTogether(id2, o1);
|
||||
assertSubmittedTogether(id2, o2);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHiddenByACLChange() throws Exception {
|
||||
Project.NameKey p1 = createProject("a-new-project", null, false);
|
||||
TestRepository<?> repo1 = cloneProject(p1);
|
||||
|
||||
RevCommit c1 = repo1.branch("HEAD").commit().insertChangeId()
|
||||
.add("a.txt", "1")
|
||||
.message("subject: 1")
|
||||
.create();
|
||||
String id1 = GitUtil.getChangeId(repo1, c1).get();
|
||||
pushHead(repo1, "refs/for/master/" + name("connectingTopic"), false);
|
||||
|
||||
ProjectConfig cfg = projectCache.checkedGet(p1).getConfig();
|
||||
Util.block(cfg, Permission.READ, REGISTERED_USERS, "refs/*");
|
||||
saveProjectConfig(p1, cfg);
|
||||
|
||||
setApiUser(user);
|
||||
RevCommit c2_1 = commitBuilder()
|
||||
.add("b.txt", "2")
|
||||
.message("subject: 2")
|
||||
.create();
|
||||
String id2 = getChangeId(c2_1);
|
||||
pushHead(testRepo, "refs/for/master/" + name("connectingTopic"), false);
|
||||
|
||||
String invisibleId = "Some changes are not visible";
|
||||
EnumSet<SubmittedTogetherOption> o1 = EnumSet.noneOf(
|
||||
SubmittedTogetherOption.class);
|
||||
EnumSet<SubmittedTogetherOption> o2 = EnumSet.of(
|
||||
SubmittedTogetherOption.DUMMY);
|
||||
if (isSubmitWholeTopicEnabled()) {
|
||||
setApiUser(admin);
|
||||
assertSubmittedTogetherBroken(id1, "Not found: " + id1);
|
||||
assertSubmittedTogether(id2, o1);
|
||||
assertSubmittedTogether(id2, o2, id2, invisibleId);
|
||||
setApiUser(user);
|
||||
assertSubmittedTogetherBroken(id1, "Not found: " + id1);
|
||||
assertSubmittedTogether(id2, o1);
|
||||
assertSubmittedTogether(id2, o2, id2, invisibleId);
|
||||
} else {
|
||||
setApiUser(admin);
|
||||
assertSubmittedTogetherBroken(id1, "Not found: " + id1);
|
||||
assertSubmittedTogether(id2, o1);
|
||||
assertSubmittedTogether(id2, o2);
|
||||
setApiUser(user);
|
||||
assertSubmittedTogetherBroken(id1, "Not found: " + id1);
|
||||
assertSubmittedTogether(id2, o1);
|
||||
assertSubmittedTogether(id2, o2);
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertSubmittedTogetherBroken(String chId,
|
||||
String expectedMsg) throws Exception {
|
||||
EnumSet<SubmittedTogetherOption> o = EnumSet.noneOf(
|
||||
SubmittedTogetherOption.class);
|
||||
try {
|
||||
gApi.changes().id(chId).submittedTogether(o);
|
||||
fail("Expected ResourceNotFoundException");
|
||||
} catch (ResourceNotFoundException e) {
|
||||
assertThat(e.getMessage()).isEqualTo(expectedMsg);
|
||||
}
|
||||
}
|
||||
|
||||
private RevCommit getRemoteHead() throws Exception {
|
||||
try (Repository repo = repoManager.openRepository(project);
|
||||
RevWalk rw = new RevWalk(repo)) {
|
||||
|
||||
Reference in New Issue
Block a user