From b3841396579fb731d596ea30712c3ce6a18844ec Mon Sep 17 00:00:00 2001 From: Simon Hwang Date: Thu, 22 Oct 2015 17:52:28 -0400 Subject: [PATCH 1/8] Use image instead of Unicode Character for Copy Button Due to the incompatibility of fonts and encoding in some environments, some browsers could not render the Copy Button correctly. This change uses instead a clipboard image to replace the unstable Unicode Character for the Copy Button. The image is open sourced and is discovered at: http://uxrepo.com/icon/clipboard-by-ionicons Also, license for the use of the image is included. Change-Id: Ie7d55e8cde40df445d32e6b8fcab91cf8a0c05b7 --- gerrit-gwtexpui/BUCK | 2 ++ .../clippy/client/ClippyResources.java | 4 ++++ .../gwtexpui/clippy/client/CopyableLabel.java | 7 +++++- .../gwtexpui/clippy/client/clipboard-16.png | Bin 0 -> 623 bytes lib/BUCK | 1 + lib/LICENSE-drifty | 21 ++++++++++++++++++ 6 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/clipboard-16.png create mode 100644 lib/LICENSE-drifty diff --git a/gerrit-gwtexpui/BUCK b/gerrit-gwtexpui/BUCK index 8e531c199c..f8b82d481d 100644 --- a/gerrit-gwtexpui/BUCK +++ b/gerrit-gwtexpui/BUCK @@ -7,6 +7,7 @@ gwt_module( resources = [ SRC + 'clippy/client/clippy.css', SRC + 'clippy/client/clippy.swf', + SRC + 'clippy/client/clipboard-16.png', SRC + 'clippy/client/CopyableLabelText.properties', ], provided_deps = ['//lib/gwt:user'], @@ -14,6 +15,7 @@ gwt_module( ':SafeHtml', ':UserAgent', '//lib:LICENSE-clippy', + '//lib:LICENSE-drifty', ], visibility = ['PUBLIC'], ) diff --git a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/ClippyResources.java b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/ClippyResources.java index dfa7679a97..dd3cc18cad 100644 --- a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/ClippyResources.java +++ b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/ClippyResources.java @@ -18,6 +18,7 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.resources.client.ClientBundle; import com.google.gwt.resources.client.DataResource; import com.google.gwt.resources.client.DataResource.DoNotEmbed; +import com.google.gwt.resources.client.ImageResource; public interface ClippyResources extends ClientBundle { public static final ClippyResources I = GWT.create(ClippyResources.class); @@ -28,4 +29,7 @@ public interface ClippyResources extends ClientBundle { @Source("clippy.swf") @DoNotEmbed DataResource swf(); + + @Source("clipboard-16.png") + ImageResource clipboard(); } diff --git a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/CopyableLabel.java b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/CopyableLabel.java index 4b6e7e4339..8d54b2f991 100644 --- a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/CopyableLabel.java +++ b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/CopyableLabel.java @@ -119,7 +119,12 @@ public class CopyableLabel extends Composite implements HasText { } if (UserAgent.hasJavaScriptClipboard()) { - copier = new Button("📋"); // CLIPBOARD + copier = new Button(new SafeHtmlBuilder() + .openElement("img") + .setAttribute("src", ClippyResources.I.clipboard().getSafeUri().asString()) + .setWidth(14) + .setHeight(14) + .closeSelf()); copier.setStyleName(ClippyResources.I.css().copier()); Tooltip.addStyle(copier); Tooltip.setLabel(copier, CopyableLabelText.I.tooltip()); diff --git a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/clipboard-16.png b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/clipboard-16.png new file mode 100644 index 0000000000000000000000000000000000000000..9c6e10a347127e9328834111a3757d4d7c6f2524 GIT binary patch literal 623 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^xl_H+M9WCijSl0AZa z85pY67#JE_7#My5g&JNkFq9fFFuY1&V6d9Oz#v{QXIG#NP=YDR+uenMVO6iP5d#CG zw5N+>h{pNU3md&+5(SQay#KvY|5cYnqTwQqjKsvu$>|;a6Hc*r#L6k=9=H^7E21+g zF+WqWtG7d;#lJy~T%`a_|2sR8cyiQ!R0g zC`m~yNwrEYN(E93Mh1qax&}tNhNdBg23AG}Rwf3z24+?U23!k*)KN6#=BH$)RpQoA z{rA;upoV0S4aH^YR>}Ffxv6<23<~b4d8tK-CHX~G3XUoHNvR5+IXR`pC14>1Lo+=i zJwqLZ;4pUu*NTGtq7sFGoYHh%&pZV^uwYnfQE_H|o|S@`o`HdaQ)y;Sih_Zrf`UZP St?xkV7(8A5T-G@yGywpl9_AJR literal 0 HcmV?d00001 diff --git a/lib/BUCK b/lib/BUCK index 0797af76ee..978a9c64bb 100644 --- a/lib/BUCK +++ b/lib/BUCK @@ -12,6 +12,7 @@ define_license(name = 'bouncycastle') define_license(name = 'clippy') define_license(name = 'codemirror') define_license(name = 'diffy') +define_license(name = 'drifty') define_license(name = 'freebie_application_icon_set') define_license(name = 'h2') define_license(name = 'jgit') diff --git a/lib/LICENSE-drifty b/lib/LICENSE-drifty new file mode 100644 index 0000000000..18ab118e71 --- /dev/null +++ b/lib/LICENSE-drifty @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Drifty (http://drifty.com/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. From 0a63010e56cb3300ecd5f186cdc5006276cdf415 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Tue, 10 Nov 2015 13:43:14 +0200 Subject: [PATCH 2/8] commit-msg: Do not add Change-Id to temp commits Temporary commits that are created using "git commit --fixup" or "git commit --squash" are not supposed to be pushed to gerrit. Prevent pushing them by mistake, at least for project that require Change-Id. Change-Id: I9ac25b7384a128fea376a357f2b324b286622e2c --- .../com/google/gerrit/server/tools/root/hooks/commit-msg | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gerrit-server/src/main/resources/com/google/gerrit/server/tools/root/hooks/commit-msg b/gerrit-server/src/main/resources/com/google/gerrit/server/tools/root/hooks/commit-msg index be88bd4f54..69884597f0 100644 --- a/gerrit-server/src/main/resources/com/google/gerrit/server/tools/root/hooks/commit-msg +++ b/gerrit-server/src/main/resources/com/google/gerrit/server/tools/root/hooks/commit-msg @@ -38,6 +38,12 @@ add_ChangeId() { return fi + # Do not add Change-Id to temp commits + if echo "$clean_message" | head -1 | grep -q '^\(fixup\|squash\)!' + then + return + fi + if test "false" = "`git config --bool --get gerrit.createChangeId`" then return From 08f1cfa977ef1a3d6bac9ec459076c7df4044c15 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Tue, 10 Nov 2015 16:06:30 -0800 Subject: [PATCH 3/8] Fix double slash on URL when switching account. One too many ending forward slashes causes OpenIdService to redirect url to http://localhost:8080// Remove the extra slash on switch account. Bug: Issue 3664 Change-Id: I7fc66aaacc0c2f49a837222b2c2cf67a84ac967d --- .../src/main/java/com/google/gerrit/client/UserPopupPanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/UserPopupPanel.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/UserPopupPanel.java index cfb7e9217a..1857043e70 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/UserPopupPanel.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/UserPopupPanel.java @@ -55,7 +55,7 @@ public class UserPopupPanel extends PopupPanel { switchAccount.setHref(Gerrit.getConfig().getSwitchAccountUrl()); } else if (Gerrit.getConfig().getAuthType() == AuthType.DEVELOPMENT_BECOME_ANY_ACCOUNT || Gerrit.getConfig().getAuthType() == AuthType.OPENID) { - switchAccount.setHref(Gerrit.selfRedirect("/login/")); + switchAccount.setHref(Gerrit.selfRedirect("/login")); } else { switchAccount.removeFromParent(); switchAccount = null; From be1c400c5f096a7770dcd77aad3aecc01d617b8f Mon Sep 17 00:00:00 2001 From: Scott Dial Date: Tue, 10 Nov 2015 11:07:44 -0500 Subject: [PATCH 4/8] Add hmac-sha2-256 and hmac-sha2-512 as MACs for sshd Change-Id: Iec8e5904f77fe644573b31984cb99343224fe169 --- Documentation/config-gerrit.txt | 3 ++- .../main/java/com/google/gerrit/sshd/SshDaemon.java | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt index db52a1b4de..359f281983 100644 --- a/Documentation/config-gerrit.txt +++ b/Documentation/config-gerrit.txt @@ -3515,7 +3515,8 @@ configuration file, one MAC per key. MAC names starting with `+` are enabled in addition to the default MACs, MAC names starting with `-` are removed from the default MACs. + -Supported MACs: hmac-md5, hmac-md5-96, hmac-sha1, hmac-sha1-96. +Supported MACs: hmac-md5, hmac-md5-96, hmac-sha1, hmac-sha1-96, +hmac-sha2-256, hmac-sha2-512. + By default, all supported MACs are available. diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshDaemon.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshDaemon.java index 3afb208937..d6b3e5c551 100644 --- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshDaemon.java +++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshDaemon.java @@ -79,6 +79,8 @@ import org.apache.sshd.common.mac.HMACMD5; import org.apache.sshd.common.mac.HMACMD596; import org.apache.sshd.common.mac.HMACSHA1; import org.apache.sshd.common.mac.HMACSHA196; +import org.apache.sshd.common.mac.HMACSHA256; +import org.apache.sshd.common.mac.HMACSHA512; import org.apache.sshd.common.random.BouncyCastleRandom; import org.apache.sshd.common.random.JceRandom; import org.apache.sshd.common.random.SingletonRandomFactory; @@ -515,9 +517,13 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener { } private void initMacs(final Config cfg) { - setMacFactories(filter(cfg, "mac", new HMACMD5.Factory(), - new HMACSHA1.Factory(), new HMACMD596.Factory(), - new HMACSHA196.Factory())); + setMacFactories(filter(cfg, "mac", + new HMACMD5.Factory(), + new HMACSHA1.Factory(), + new HMACMD596.Factory(), + new HMACSHA196.Factory(), + new HMACSHA256.Factory(), + new HMACSHA512.Factory())); } @SafeVarargs From ab61e20f32ffe0224af6faeddb439f3f0ac16c24 Mon Sep 17 00:00:00 2001 From: Doug Kelly Date: Wed, 11 Nov 2015 09:58:49 -0800 Subject: [PATCH 5/8] Correct timezone logged for DST changes When encountering a DST switch, the timezone wasn't updated until the server was reloaded. Ensure the timezone text is accurate when logging messages to sshd_log. Bug: Issue 3653 Change-Id: Ie317ef826148b60cdac3b9262c6c04f8410908ae --- .../java/com/google/gerrit/sshd/SshLogLayout.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshLogLayout.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshLogLayout.java index 0c047495c5..2622fbdfce 100644 --- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshLogLayout.java +++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/SshLogLayout.java @@ -20,7 +20,6 @@ import org.eclipse.jgit.util.QuotedString; import java.text.SimpleDateFormat; import java.util.Calendar; -import java.util.Date; import java.util.TimeZone; public final class SshLogLayout extends Layout { @@ -35,15 +34,15 @@ public final class SshLogLayout extends Layout { private final Calendar calendar; private long lastTimeMillis; private final char[] lastTimeString = new char[20]; - private final char[] timeZone; + private final SimpleDateFormat tzFormat; + private char[] timeZone; public SshLogLayout() { final TimeZone tz = TimeZone.getDefault(); calendar = Calendar.getInstance(tz); - final SimpleDateFormat sdf = new SimpleDateFormat("Z"); - sdf.setTimeZone(tz); - timeZone = sdf.format(new Date()).toCharArray(); + tzFormat = new SimpleDateFormat("Z"); + tzFormat.setTimeZone(tz); } @Override @@ -52,8 +51,6 @@ public final class SshLogLayout extends Layout { buf.append('['); formatDate(event.getTimeStamp(), buf); - buf.append(' '); - buf.append(timeZone); buf.append(']'); req(P_SESSION, buf, event); @@ -92,11 +89,14 @@ public final class SshLogLayout extends Layout { sbuf.append(','); sbuf.getChars(start, sbuf.length(), lastTimeString, 0); lastTimeMillis = rounded; + timeZone = tzFormat.format(calendar.getTime()).toCharArray(); } } else { sbuf.append(lastTimeString); } sbuf.append(String.format("%03d", millis)); + sbuf.append(' '); + sbuf.append(timeZone); } private String toTwoDigits(int input) { From 00515b6d1c055f5b2d978085c9cd7fd9d52f7948 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Wed, 11 Nov 2015 15:25:46 -0800 Subject: [PATCH 6/8] Add tooltip with subject message in related changes tab The titles in the related changes tab often get truncated. Add tooltip to show the full subject. Change-Id: I1fa0cd0c322f1a9233d6b56a5d3107a5784f60d5 --- .../java/com/google/gerrit/client/change/RelatedChangesTab.java | 1 + 1 file changed, 1 insertion(+) diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/RelatedChangesTab.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/RelatedChangesTab.java index 525f5a9b23..23959e709e 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/RelatedChangesTab.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/RelatedChangesTab.java @@ -292,6 +292,7 @@ class RelatedChangesTab implements IsWidget { if (url.startsWith("#")) { sb.setAttribute("onclick", OPEN); } + sb.setAttribute("title", info.commit().subject()); if (showProjects) { sb.append(info.project()).append(": "); } From efd882024b3acf2f17c9069fe186f58992dd4ff9 Mon Sep 17 00:00:00 2001 From: Kenny Ho Date: Tue, 29 Sep 2015 17:46:18 -0400 Subject: [PATCH 7/8] Make email validation case insensitive While RFC 5321 section 2.3.11 allows for the local-part (the part left of the '@') of an email address to be case sensitive, the domain portion is case insensitive according to RFC 1035 section 3.1. And in practice, even the local-part is typically case insensitive also. HashSet and equal() was used for email matching/validation, which is overly strict. For example, if the email-address-on-record is FirstName.LastName@SomeCorp.com and the user committed a change using firstname.lastname@somecorp.com, then the commit would be rejected unless Forge Author permission is enabled or the user registered the "second" email address. TreeSet is used in place of HashSet and equalsIgnoreCase() is used in place of equals() to resolve this issue. While TreeSet has the time complexity of O(logN), which is worse than that of HashSet (O(1)), the performance impact should be negligible given the problem at hand. IdentifiedUserTest unit test can be executed by running: buck test //gerrit-server:server_tests Change-Id: I820f183a7024d16284ad0a2e7698179384fe6920 --- .../google/gerrit/server/IdentifiedUser.java | 5 +- .../gerrit/server/account/AbstractRealm.java | 3 +- .../gerrit/server/IdentifiedUserTest.java | 131 ++++++++++++++++++ 3 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 gerrit-server/src/test/java/com/google/gerrit/server/IdentifiedUserTest.java diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/IdentifiedUser.java b/gerrit-server/src/main/java/com/google/gerrit/server/IdentifiedUser.java index 9e5ff12d63..276873341c 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/IdentifiedUser.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/IdentifiedUser.java @@ -196,7 +196,8 @@ public class IdentifiedUser extends CurrentUser { private final GroupBackend groupBackend; private final String anonymousCowardName; private final Boolean disableReverseDnsLookup; - private final Set validEmails = Sets.newHashSetWithExpectedSize(4); + private final Set validEmails = + Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER); @Nullable private final Provider remotePeerProvider; @@ -284,7 +285,7 @@ public class IdentifiedUser extends CurrentUser { validEmails.add(email); return true; } else if (invalidEmails == null) { - invalidEmails = Sets.newHashSetWithExpectedSize(4); + invalidEmails = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER); } invalidEmails.add(email); return false; diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/AbstractRealm.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/AbstractRealm.java index 34f83f743e..30420e0567 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/AbstractRealm.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/AbstractRealm.java @@ -25,7 +25,6 @@ import com.google.inject.Inject; import java.util.Collection; import java.util.HashSet; -import java.util.Objects; import java.util.Set; /** Basic implementation of {@link Realm}. */ @@ -57,7 +56,7 @@ public abstract class AbstractRealm implements Realm { @Override public boolean hasEmailAddress(IdentifiedUser user, String email) { for (AccountExternalId ext : user.state().getExternalIds()) { - if (Objects.equals(ext.getEmailAddress(), email)) { + if (email != null && email.equalsIgnoreCase(ext.getEmailAddress())) { return true; } } diff --git a/gerrit-server/src/test/java/com/google/gerrit/server/IdentifiedUserTest.java b/gerrit-server/src/test/java/com/google/gerrit/server/IdentifiedUserTest.java new file mode 100644 index 0000000000..039871e28c --- /dev/null +++ b/gerrit-server/src/test/java/com/google/gerrit/server/IdentifiedUserTest.java @@ -0,0 +1,131 @@ +// Copyright (C) 2015 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.server; + +import static com.google.common.truth.Truth.assertThat; +import static com.google.inject.Scopes.SINGLETON; + +import com.google.gerrit.common.TimeUtil; +import com.google.gerrit.reviewdb.client.Account; +import com.google.gerrit.server.account.AccountCache; +import com.google.gerrit.server.account.CapabilityControl; +import com.google.gerrit.server.account.FakeRealm; +import com.google.gerrit.server.account.GroupBackend; +import com.google.gerrit.server.account.Realm; +import com.google.gerrit.server.config.AnonymousCowardName; +import com.google.gerrit.server.config.AnonymousCowardNameProvider; +import com.google.gerrit.server.config.CanonicalWebUrl; +import com.google.gerrit.server.config.DisableReverseDnsLookup; +import com.google.gerrit.server.config.GerritServerConfig; +import com.google.gerrit.server.group.SystemGroupBackend; +import com.google.gerrit.testutil.ConfigSuite; +import com.google.gerrit.testutil.FakeAccountCache; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Inject; +import com.google.inject.Injector; +import com.google.inject.util.Providers; + +import org.eclipse.jgit.lib.Config; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +@RunWith(ConfigSuite.class) +public class IdentifiedUserTest { + @ConfigSuite.Parameter + public Config config; + + private IdentifiedUser identifiedUser; + + @Inject + private IdentifiedUser.GenericFactory identifiedUserFactory; + + private static final String[] TEST_CASES = { + "", + "FirstName.LastName@Corporation.com", + "!#$%&'+-/=.?^`{|}~@[IPv6:0123:4567:89AB:CDEF:0123:4567:89AB:CDEF]" + }; + + @Before + public void setUp() throws Exception { + final FakeAccountCache accountCache = new FakeAccountCache(); + final Realm mockRealm = new FakeRealm() { + HashSet emails = new HashSet<>(Arrays.asList(TEST_CASES)); + + @Override + public boolean hasEmailAddress(IdentifiedUser who, String email) { + return emails.contains(email); + } + + @Override + public Set getEmailAddresses(IdentifiedUser who) { + return emails; + } + }; + + AbstractModule mod = new AbstractModule() { + @Override + protected void configure() { + bind(Boolean.class).annotatedWith(DisableReverseDnsLookup.class) + .toInstance(Boolean.FALSE); + bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(config); + bind(String.class).annotatedWith(AnonymousCowardName.class) + .toProvider(AnonymousCowardNameProvider.class); + bind(String.class).annotatedWith(CanonicalWebUrl.class) + .toInstance("http://localhost:8080/"); + bind(AccountCache.class).toInstance(accountCache); + bind(GroupBackend.class).to(SystemGroupBackend.class).in(SINGLETON); + bind(CapabilityControl.Factory.class) + .toProvider(Providers.of(null)); + bind(Realm.class).toInstance(mockRealm); + + } + }; + + Injector injector = Guice.createInjector(mod); + injector.injectMembers(this); + + Account account = new Account(new Account.Id(1), TimeUtil.nowTs()); + Account.Id ownerId = account.getId(); + + identifiedUser = identifiedUserFactory.create(ownerId); + + /* Trigger identifiedUser to load the email addresses from mockRealm */ + identifiedUser.getEmailAddresses(); + } + + @Test + public void testEmailsExistence() { + assertThat(identifiedUser.hasEmailAddress(TEST_CASES[0])).isTrue(); + assertThat(identifiedUser.hasEmailAddress(TEST_CASES[1].toLowerCase())).isTrue(); + assertThat(identifiedUser.hasEmailAddress(TEST_CASES[1])).isTrue(); + assertThat(identifiedUser.hasEmailAddress(TEST_CASES[1].toUpperCase())).isTrue(); + /* assert again to test cached email address by IdentifiedUser.validEmails */ + assertThat(identifiedUser.hasEmailAddress(TEST_CASES[1])).isTrue(); + + assertThat(identifiedUser.hasEmailAddress(TEST_CASES[2])).isTrue(); + assertThat(identifiedUser.hasEmailAddress(TEST_CASES[2].toLowerCase())).isTrue(); + + + assertThat(identifiedUser.hasEmailAddress("non-exist@email.com")).isFalse(); + /* assert again to test cached email address by IdentifiedUser.invalidEmails */ + assertThat(identifiedUser.hasEmailAddress("non-exist@email.com")).isFalse(); + } +} From e740443e7f29d9ab27a9a2bfed07878551544b58 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 12 Nov 2015 09:35:16 -0800 Subject: [PATCH 8/8] Add 2.12 release notes to release notes index Change-Id: I59c22ea7e1b37cf127d802efde82b766fa980ab3 --- ReleaseNotes/index.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ReleaseNotes/index.txt b/ReleaseNotes/index.txt index e1831adb32..05368c81ee 100644 --- a/ReleaseNotes/index.txt +++ b/ReleaseNotes/index.txt @@ -1,6 +1,11 @@ Gerrit Code Review - Release Notes ================================== +[[2_12]] +Version 2.12.x +-------------- +* link:ReleaseNotes-2.12.html[2.12] + [[2_11]] Version 2.11.x --------------