use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class IndexChangesIT method indexRequestFromNonAdminRejected.
@Test
public void indexRequestFromNonAdminRejected() throws Exception {
ChangeIndexedCounter changeIndexedCounter = new ChangeIndexedCounter();
try (Registration registration = extensionRegistry.newRegistration().add(changeIndexedCounter)) {
String changeId = createChange().getChangeId();
IndexChanges.Input in = new IndexChanges.Input();
in.changes = ImmutableSet.of(changeId);
changeIndexedCounter.clear();
userRestSession.post("/config/server/index.changes", in).assertForbidden();
assertThat(changeIndexedCounter.getCount(info(changeId))).isEqualTo(0);
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class CreateBranchIT method createBranchViaPushFailsIfCommitIsInvalid.
@Test
public void createBranchViaPushFailsIfCommitIsInvalid() throws Exception {
TestRefOperationValidationListener testRefOperationValidationListener = new TestRefOperationValidationListener();
testRefOperationValidationListener.doReject = true;
try (Registration registration = extensionRegistry.newRegistration().add(testRefOperationValidationListener)) {
PushResult r = pushHead(testRepo, "refs/heads/new", /* pushTags= */
false, /* force= */
false, /* pushOptions= */
ImmutableList.of());
assertPushRejected(r, "refs/heads/new", String.format("Validation for creation of ref 'refs/heads/new' in project %s failed:\n%s", project, TestRefOperationValidationListener.FAILURE_MESSAGE));
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class CreateBranchIT method createBranchViaPushWithValidationOptions.
@Test
public void createBranchViaPushWithValidationOptions() throws Exception {
TestRefOperationValidationListener testRefOperationValidationListener = new TestRefOperationValidationListener();
try (Registration registration = extensionRegistry.newRegistration().add(testRefOperationValidationListener)) {
PushResult r = pushHead(testRepo, "refs/heads/new", /* pushTags= */
false, /* force= */
false, /* pushOptions= */
ImmutableList.of("key=value"));
assertPushOk(r, "refs/heads/new");
assertThat(testRefOperationValidationListener.refReceivedEvent.pushOptions).containsExactly("key", "value");
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class TraceIT method restCallWithTraceRequestParam.
@Test
public void restCallWithTraceRequestParam() throws Exception {
TraceValidatingProjectCreationValidationListener projectCreationListener = new TraceValidatingProjectCreationValidationListener();
try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
RestResponse response = adminRestSession.put("/projects/new2?" + ParameterParser.TRACE_PARAMETER);
assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNotNull();
assertThat(projectCreationListener.traceId).isNotNull();
assertThat(projectCreationListener.isLoggingForced).isTrue();
assertThat(projectCreationListener.tags.get("project")).containsExactly("new2");
}
}
use of com.google.gerrit.acceptance.ExtensionRegistry.Registration in project gerrit by GerritCodeReview.
the class TraceIT method traceAccount.
@Test
@GerritConfig(name = "tracing.issue123.account", value = "1000000")
public void traceAccount() throws Exception {
TraceValidatingProjectCreationValidationListener projectCreationListener = new TraceValidatingProjectCreationValidationListener();
try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
RestResponse response = adminRestSession.put("/projects/new15");
assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNull();
assertThat(projectCreationListener.traceId).isEqualTo("issue123");
assertThat(projectCreationListener.isLoggingForced).isTrue();
assertThat(projectCreationListener.tags.get("project")).containsExactly("new15");
}
}
Aggregations