Merge branch 'stable-2.9' into stable-2.10

* stable-2.9:
  Fix SubmoduleOp tests
  Fix quoted-printable encoding of e-mail addresses
  Fix incorrect submodule subscriptions
  Remove 'send email' checkbox from reply box on change screen
  Update system group documentation
  Consider rule action while constructing local owners list
  Increase the size of HTTP passwords
  Do not throw away random bytes from the CSPRNG

Conflicts:
	gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java
	gerrit-server/src/main/java/com/google/gerrit/server/git/SubmoduleOp.java
	gerrit-server/src/test/java/com/google/gerrit/server/git/SubmoduleOpTest.java

Change-Id: If086a9021aabb512023753d8dea59f50799cd91a
This commit is contained in:
David Pursehouse
2014-11-26 17:32:24 +09:00
11 changed files with 183 additions and 82 deletions

View File

@@ -14,13 +14,10 @@
package com.google.gerrit.server.git;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.capture;
import static org.easymock.EasyMock.createNiceMock;
import static org.easymock.EasyMock.createStrictMock;
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertEquals;
import com.google.gerrit.common.ChangeHooks;
@@ -41,6 +38,8 @@ import com.google.gwtorm.server.StandardKeyEncoder;
import com.google.inject.Provider;
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.easymock.IMocksControl;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.dircache.DirCacheBuilder;
import org.eclipse.jgit.dircache.DirCacheEntry;
@@ -75,6 +74,7 @@ public class SubmoduleOpTest extends LocalDiskRepositoryTestCase {
private static final String newLine = System.getProperty("line.separator");
private IMocksControl mockMaker;
private SchemaFactory<ReviewDb> schemaFactory;
private SubmoduleSubscriptionAccess subscriptions;
private ReviewDb schema;
@@ -89,23 +89,22 @@ public class SubmoduleOpTest extends LocalDiskRepositoryTestCase {
public void setUp() throws Exception {
super.setUp();
schemaFactory = createStrictMock(SchemaFactory.class);
schema = createStrictMock(ReviewDb.class);
subscriptions = createStrictMock(SubmoduleSubscriptionAccess.class);
urlProvider = createStrictMock(Provider.class);
repoManager = createStrictMock(GitRepositoryManager.class);
gitRefUpdated = createStrictMock(GitReferenceUpdated.class);
changeHooks = createNiceMock(ChangeHooks.class);
mockMaker = EasyMock.createStrictControl();
schemaFactory = mockMaker.createMock(SchemaFactory.class);
schema = mockMaker.createMock(ReviewDb.class);
subscriptions = mockMaker.createMock(SubmoduleSubscriptionAccess.class);
urlProvider = mockMaker.createMock(Provider.class);
repoManager = mockMaker.createMock(GitRepositoryManager.class);
gitRefUpdated = mockMaker.createMock(GitReferenceUpdated.class);
changeHooks = mockMaker.createMock(ChangeHooks.class);
}
private void doReplay() {
replay(schemaFactory, schema, subscriptions, urlProvider, repoManager,
gitRefUpdated);
mockMaker.replay();
}
private void doVerify() {
verify(schemaFactory, schema, subscriptions, urlProvider, repoManager,
gitRefUpdated);
mockMaker.verify();
}
/**
@@ -640,6 +639,8 @@ public class SubmoduleOpTest extends LocalDiskRepositoryTestCase {
Capture<RefUpdate> ruCapture = new Capture<>();
gitRefUpdated.fire(eq(targetBranchNameKey.getParentKey()),
capture(ruCapture));
changeHooks.doRefUpdatedHook(eq(targetBranchNameKey),
anyObject(RefUpdate.class), EasyMock.<Account>isNull());
expect(schema.submoduleSubscriptions()).andReturn(subscriptions);
final ResultSet<SubmoduleSubscription> emptySubscriptions =
@@ -743,6 +744,8 @@ public class SubmoduleOpTest extends LocalDiskRepositoryTestCase {
Capture<RefUpdate> ruCapture = new Capture<>();
gitRefUpdated.fire(eq(targetBranchNameKey.getParentKey()),
capture(ruCapture));
changeHooks.doRefUpdatedHook(eq(targetBranchNameKey),
anyObject(RefUpdate.class), EasyMock.<Account>isNull());
expect(schema.submoduleSubscriptions()).andReturn(subscriptions);
final ResultSet<SubmoduleSubscription> incorrectSubscriptions =

View File

@@ -130,6 +130,12 @@ public class AddressTest {
assertEquals("=?UTF-8?Q?A_=E2=82=AC_B?= <a@a>", format("A \u20ac B", "a@a"));
}
@Test
public void testToHeaderString_NameEmail7() {
assertEquals("=?UTF-8?Q?A_=E2=82=AC_B_=28Code_Review=29?= <a@a>",
format("A \u20ac B (Code Review)", "a@a"));
}
@Test
public void testToHeaderString_Email1() {
assertEquals("a@a", format(null, "a@a"));

View File

@@ -72,11 +72,23 @@ public class RefControlTest {
public void testOwnerProject() {
allow(local, OWNER, ADMIN, "refs/*");
ProjectControl uBlah = util.user(local, DEVS);
ProjectControl uAdmin = util.user(local, DEVS, ADMIN);
assertAdminsAreOwnersAndDevsAreNot();
}
assertFalse("not owner", uBlah.isOwner());
assertTrue("is owner", uAdmin.isOwner());
@Test
public void testDenyOwnerProject() {
allow(local, OWNER, ADMIN, "refs/*");
deny(local, OWNER, DEVS, "refs/*");
assertAdminsAreOwnersAndDevsAreNot();
}
@Test
public void testBlockOwnerProject() {
allow(local, OWNER, ADMIN, "refs/*");
block(local, OWNER, DEVS, "refs/*");
assertAdminsAreOwnersAndDevsAreNot();
}
@Test
@@ -520,4 +532,12 @@ public class RefControlTest {
assertFalse("u can vote -2", range.contains(-2));
assertFalse("u can vote +2", range.contains(2));
}
private void assertAdminsAreOwnersAndDevsAreNot() {
ProjectControl uBlah = util.user(local, DEVS);
ProjectControl uAdmin = util.user(local, DEVS, ADMIN);
assertFalse("not owner", uBlah.isOwner());
assertTrue("is owner", uAdmin.isOwner());
}
}