ReadOnlyByHttpIT: Extend to cover both 'readonly' and 'readonly~readonly'
Change I297e79df2 fixed a bug where the DELETE request was not allowed
on 'readonly'. Extend the tests to cover this case.
Change-Id: I770495840f807582bdf2fa91bd934887cd4b7ce9
diff --git a/src/test/java/com/googlesource/gerrit/plugins/readonly/ReadOnlyByHttpIT.java b/src/test/java/com/googlesource/gerrit/plugins/readonly/ReadOnlyByHttpIT.java
index 9cc4f15..b078dae 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/readonly/ReadOnlyByHttpIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/readonly/ReadOnlyByHttpIT.java
@@ -17,22 +17,44 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.gerrit.acceptance.RestResponse;
+import com.google.gerrit.server.config.GerritServerConfig;
+import com.google.gerrit.testutil.ConfigSuite;
+import com.google.inject.Inject;
+import org.eclipse.jgit.lib.Config;
public class ReadOnlyByHttpIT extends AbstractReadOnlyTest {
+ @ConfigSuite.Default
+ public static Config withPluginNamePrefix() {
+ Config cfg = new Config();
+ cfg.setString("readonly", "test", "endpoint", "readonly~readonly");
+ return cfg;
+ }
+
+ @ConfigSuite.Config
+ public static Config withoutPluginNamePrefix() {
+ Config cfg = new Config();
+ cfg.setString("readonly", "test", "endpoint", "readonly");
+ return cfg;
+ }
+
+ @Inject @GerritServerConfig private Config config;
+
@Override
protected void setReadOnly(boolean readOnly) throws Exception {
+ String endpoint =
+ String.format("/config/server/%s", config.getString("readonly", "test", "endpoint"));
String expectedStatus = readOnly ? "on" : "off";
RestResponse response;
if (readOnly) {
- response = adminRestSession.put("/config/server/readonly~readonly");
+ response = adminRestSession.put(endpoint);
response.assertOK();
assertThat(response.getEntityContent()).contains(expectedStatus);
} else {
- response = adminRestSession.delete("/config/server/readonly~readonly");
+ response = adminRestSession.delete(endpoint);
response.assertOK();
assertThat(response.getEntityContent()).contains(expectedStatus);
}
- response = adminRestSession.get("/config/server/readonly~readonly");
+ response = adminRestSession.get(endpoint);
response.assertOK();
assertThat(response.getEntityContent()).contains(expectedStatus);
}