Merge branch 'stable-2.16' into stable-3.0
* stable-2.16: Update git submodules Update git submodules Apply diff preferences immediately after clicking save Grant the InternalUser back access to changes Rewrite upload archive tests as real integration tests Add support for Elasticsearch version 7.7.* Change-Id: I531f7336bdbe191b5d88bbc1282a59861250c897
This commit is contained in:
@@ -15,10 +15,15 @@
|
||||
package com.google.gerrit.acceptance;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.extensions.api.GerritApi;
|
||||
import com.google.gerrit.extensions.api.groups.GroupInput;
|
||||
@@ -34,6 +39,10 @@ import com.google.gerrit.testing.ConfigSuite;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
@@ -214,4 +223,50 @@ public abstract class StandaloneSiteTest {
|
||||
protected static void runGerrit(Iterable<String>... multiArgs) throws Exception {
|
||||
runGerrit(Arrays.stream(multiArgs).flatMap(Streams::stream).toArray(String[]::new));
|
||||
}
|
||||
|
||||
protected static String execute(
|
||||
ImmutableList<String> cmd, File dir, ImmutableMap<String, String> env) throws IOException {
|
||||
return execute(cmd, dir, env, null);
|
||||
}
|
||||
|
||||
protected static String execute(
|
||||
ImmutableList<String> cmd,
|
||||
File dir,
|
||||
ImmutableMap<String, String> env,
|
||||
@Nullable Path outputPath)
|
||||
throws IOException {
|
||||
ProcessBuilder pb = new ProcessBuilder(cmd);
|
||||
pb.directory(dir);
|
||||
if (outputPath != null) {
|
||||
pb.redirectOutput(outputPath.toFile());
|
||||
} else {
|
||||
pb.redirectErrorStream(true);
|
||||
}
|
||||
pb.environment().putAll(env);
|
||||
Process p = pb.start();
|
||||
byte[] out;
|
||||
try (InputStream in = p.getInputStream()) {
|
||||
out = ByteStreams.toByteArray(in);
|
||||
} finally {
|
||||
p.getOutputStream().close();
|
||||
}
|
||||
|
||||
int status;
|
||||
try {
|
||||
status = p.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
InterruptedIOException iioe =
|
||||
new InterruptedIOException(
|
||||
"interrupted waiting for: " + Joiner.on(' ').join(pb.command()));
|
||||
iioe.initCause(e);
|
||||
throw iioe;
|
||||
}
|
||||
|
||||
String result = new String(out, UTF_8);
|
||||
if (status != 0) {
|
||||
throw new IOException(result);
|
||||
}
|
||||
|
||||
return result.trim();
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,8 @@ public enum ElasticVersion {
|
||||
V7_3("7.3.*"),
|
||||
V7_4("7.4.*"),
|
||||
V7_5("7.5.*"),
|
||||
V7_6("7.6.*");
|
||||
V7_6("7.6.*"),
|
||||
V7_7("7.7.*");
|
||||
|
||||
private final String version;
|
||||
private final Pattern pattern;
|
||||
|
@@ -21,6 +21,7 @@ import com.google.gerrit.index.query.IsVisibleToPredicate;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.AnonymousUser;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.InternalUser;
|
||||
import com.google.gerrit.server.index.IndexUtils;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.permissions.ChangePermission;
|
||||
@@ -94,7 +95,7 @@ public class ChangeIsVisibleToPredicate extends IsVisibleToPredicate<ChangeData>
|
||||
? permissionBackend.absentUser(user.getAccountId())
|
||||
: permissionBackend.user(
|
||||
Optional.of(user)
|
||||
.filter(u -> u instanceof SingleGroupUser)
|
||||
.filter(u -> u instanceof SingleGroupUser || u instanceof InternalUser)
|
||||
.orElseGet(anonymousUserProvider::get));
|
||||
try {
|
||||
withUser.indexedChange(cd, notes).check(ChangePermission.READ);
|
||||
|
Reference in New Issue
Block a user