Merge branch 'stable-3.0' into stable-3.1
* stable-3.0: Fix gr-label-info test Set version to 2.16.21-SNAPSHOT Set version to 2.16.20 Trim parameterized strings evaluated from LdapRealm Update account full name when it changes in LDAP Set Api version for plugin jars Update git submodules Update git submodules Update git submodules Update git submodules Hide "No Votes" notice for for labels added and approved by rules Change-Id: I816ed4716a4c69b4c4f479b4203b405dbdf0e8ca
This commit is contained in:
@@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_USERNAME;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -78,8 +79,9 @@ public class AccountManager {
|
||||
private final boolean autoUpdateAccountActiveStatus;
|
||||
private final SetInactiveFlag setInactiveFlag;
|
||||
|
||||
@VisibleForTesting
|
||||
@Inject
|
||||
AccountManager(
|
||||
public AccountManager(
|
||||
Sequences sequences,
|
||||
@GerritServerConfig Config cfg,
|
||||
Accounts accounts,
|
||||
@@ -239,13 +241,7 @@ public class AccountManager {
|
||||
|
||||
if (!Strings.isNullOrEmpty(who.getDisplayName())
|
||||
&& !Objects.equals(user.getAccount().fullName(), who.getDisplayName())) {
|
||||
if (realm.allowsEdit(AccountFieldName.FULL_NAME)) {
|
||||
accountUpdates.add(a -> a.setFullName(who.getDisplayName()));
|
||||
} else {
|
||||
logger.atWarning().log(
|
||||
"Not changing already set display name '%s' to '%s'",
|
||||
user.getAccount().fullName(), who.getDisplayName());
|
||||
}
|
||||
accountUpdates.add(a -> a.setFullName(who.getDisplayName()));
|
||||
}
|
||||
|
||||
if (!realm.allowsEdit(AccountFieldName.USER_NAME)
|
||||
|
||||
@@ -218,7 +218,7 @@ class LdapRealm extends AbstractRealm {
|
||||
values.put(name, m.get(name));
|
||||
}
|
||||
|
||||
String r = p.replace(values);
|
||||
String r = p.replace(values).trim();
|
||||
return r.isEmpty() ? null : r;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.entities.Account;
|
||||
import com.google.gerrit.extensions.client.AccountFieldName;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.ServerInitiated;
|
||||
import com.google.gerrit.server.account.AccountException;
|
||||
import com.google.gerrit.server.account.AccountManager;
|
||||
@@ -33,12 +35,16 @@ import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gerrit.server.account.AccountsUpdate;
|
||||
import com.google.gerrit.server.account.AuthRequest;
|
||||
import com.google.gerrit.server.account.AuthResult;
|
||||
import com.google.gerrit.server.account.SetInactiveFlag;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.account.externalids.ExternalIdNotes;
|
||||
import com.google.gerrit.server.account.externalids.ExternalIds;
|
||||
import com.google.gerrit.server.git.meta.MetaDataUpdate;
|
||||
import com.google.gerrit.server.group.db.GroupsUpdate;
|
||||
import com.google.gerrit.server.notedb.Sequences;
|
||||
import com.google.gerrit.server.ssh.SshKeyCache;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.util.Providers;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
@@ -51,6 +57,12 @@ public class AccountManagerIT extends AbstractDaemonTest {
|
||||
@Inject @ServerInitiated private AccountsUpdate accountsUpdate;
|
||||
@Inject private ExternalIdNotes.Factory extIdNotesFactory;
|
||||
|
||||
@Inject private Sequences sequences;
|
||||
@Inject private IdentifiedUser.GenericFactory userFactory;
|
||||
@Inject private SshKeyCache sshKeyCache;
|
||||
@Inject private GroupsUpdate.Factory groupsUpdateFactory;
|
||||
@Inject private SetInactiveFlag setInactiveFlag;
|
||||
|
||||
@Test
|
||||
public void authenticateNewAccountWithEmail() throws Exception {
|
||||
String email = "foo@example.com";
|
||||
@@ -200,6 +212,31 @@ public class AccountManagerIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void authenticateWithUsernameAndUpdateDisplayName() throws Exception {
|
||||
authenticateWithUsernameAndUpdateDisplayName(accountManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readOnlyFullNameField_authenticateWithUsernameAndUpdateDisplayName()
|
||||
throws Exception {
|
||||
TestRealm realm = server.getTestInjector().getInstance(TestRealm.class);
|
||||
realm.denyEdit(AccountFieldName.FULL_NAME);
|
||||
authenticateWithUsernameAndUpdateDisplayName(
|
||||
new AccountManager(
|
||||
sequences,
|
||||
cfg,
|
||||
accounts,
|
||||
Providers.of(accountsUpdate),
|
||||
accountCache,
|
||||
realm,
|
||||
userFactory,
|
||||
sshKeyCache,
|
||||
projectCache,
|
||||
externalIds,
|
||||
groupsUpdateFactory,
|
||||
setInactiveFlag));
|
||||
}
|
||||
|
||||
private void authenticateWithUsernameAndUpdateDisplayName(AccountManager am) throws Exception {
|
||||
String username = "foo";
|
||||
String email = "foo@example.com";
|
||||
Account.Id accountId = Account.id(seq.nextAccountId());
|
||||
@@ -215,7 +252,7 @@ public class AccountManagerIT extends AbstractDaemonTest {
|
||||
AuthRequest who = AuthRequest.forUser(username);
|
||||
String newName = "Updated Name";
|
||||
who.setDisplayName(newName);
|
||||
AuthResult authResult = accountManager.authenticate(who);
|
||||
AuthResult authResult = am.authenticate(who);
|
||||
assertAuthResultForExistingAccount(authResult, accountId, gerritExtIdKey);
|
||||
|
||||
Optional<AccountState> accountState = accounts.get(accountId);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
load("@rules_java//java:defs.bzl", "java_library")
|
||||
load("//javatests/com/google/gerrit/acceptance:tests.bzl", "acceptance_tests")
|
||||
|
||||
acceptance_tests(
|
||||
@@ -9,8 +10,18 @@ acceptance_tests(
|
||||
"no_windows",
|
||||
],
|
||||
deps = [
|
||||
":util",
|
||||
"//java/com/google/gerrit/git",
|
||||
"//java/com/google/gerrit/mail",
|
||||
"//java/com/google/gerrit/server/util/time",
|
||||
],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "util",
|
||||
testonly = True,
|
||||
srcs = glob(["TestRealm.java"]),
|
||||
deps = [
|
||||
"//java/com/google/gerrit/acceptance:lib",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright (C) 2020 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.acceptance.api.accounts;
|
||||
|
||||
import com.google.gerrit.extensions.client.AccountFieldName;
|
||||
import com.google.gerrit.server.account.DefaultRealm;
|
||||
import com.google.gerrit.server.account.EmailExpander;
|
||||
import com.google.gerrit.server.account.Emails;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Singleton
|
||||
public class TestRealm extends DefaultRealm {
|
||||
|
||||
private final Set<AccountFieldName> readOnlyFields = new HashSet<>();
|
||||
|
||||
@Inject
|
||||
public TestRealm(EmailExpander emailExpander, Provider<Emails> emails, AuthConfig authConfig) {
|
||||
super(emailExpander, emails, authConfig);
|
||||
}
|
||||
|
||||
public void denyEdit(AccountFieldName field) {
|
||||
readOnlyFields.add(field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowsEdit(AccountFieldName field) {
|
||||
return !readOnlyFields.contains(field);
|
||||
}
|
||||
}
|
||||
@@ -148,6 +148,11 @@
|
||||
* order to trigger computation when a label is removed from the change.
|
||||
*/
|
||||
_computeShowPlaceholder(labelInfo, changeLabelsRecord) {
|
||||
if (labelInfo &&
|
||||
!labelInfo.values && (labelInfo.rejected || labelInfo.approved)) {
|
||||
return 'hidden';
|
||||
}
|
||||
|
||||
if (labelInfo && labelInfo.all) {
|
||||
for (const label of labelInfo.all) {
|
||||
if (label.value && label.value != labelInfo.default_value) {
|
||||
|
||||
@@ -226,6 +226,14 @@ limitations under the License.
|
||||
assert.isFalse(isHidden(element.$$('.placeholder')));
|
||||
element.labelInfo = {all: [{value: 1}]};
|
||||
assert.isTrue(isHidden(element.$$('.placeholder')));
|
||||
element.labelInfo = {rejected: []};
|
||||
assert.isTrue(isHidden(element.$$('.placeholder')));
|
||||
element.labelInfo = {values: [], rejected: [], all: [{value: 1}]};
|
||||
assert.isTrue(isHidden(element.$$('.placeholder')));
|
||||
element.labelInfo = {approved: []};
|
||||
assert.isTrue(isHidden(element.$$('.placeholder')));
|
||||
element.labelInfo = {values: [], approved: [], all: [{value: 1}]};
|
||||
assert.isTrue(isHidden(element.$$('.placeholder')));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
|
||||
load("//tools/bzl:genrule2.bzl", "genrule2")
|
||||
load("//:version.bzl", "GERRIT_VERSION")
|
||||
|
||||
PLUGIN_DEPS = ["//plugins:plugin-lib"]
|
||||
|
||||
@@ -61,7 +62,7 @@ def gerrit_plugin(
|
||||
"GEN_VERSION=$$(cat bazel-out/stable-status.txt | grep -w STABLE_BUILD_%s_LABEL | cut -d ' ' -f 2)" % dir_name.upper(),
|
||||
"cd $$TMP",
|
||||
"unzip -q $$ROOT/$<",
|
||||
"echo \"Implementation-Version: $$GEN_VERSION\n$$(cat META-INF/MANIFEST.MF)\" > META-INF/MANIFEST.MF",
|
||||
"echo \"Implementation-Version: $$GEN_VERSION\nGerrit-ApiVersion: " + GERRIT_VERSION + "\n$$(cat META-INF/MANIFEST.MF)\" > META-INF/MANIFEST.MF",
|
||||
"find . -exec touch '{}' ';'",
|
||||
"zip -Xqr $$ROOT/$@ .",
|
||||
]),
|
||||
|
||||
Reference in New Issue
Block a user