Search in sources :

Example 56 with GerritConfig

use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.

the class TraceIT method traceProjectForAccountNoProjectMatch.

@Test
@GerritConfig(name = "tracing.issue123.account", value = "1000000")
@GerritConfig(name = "tracing.issue123.projectPattern", value = "foo.*")
public void traceProjectForAccountNoProjectMatch() throws Exception {
    TraceValidatingProjectCreationValidationListener projectCreationListener = new TraceValidatingProjectCreationValidationListener();
    try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
        RestResponse response = adminRestSession.put("/projects/new23");
        assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
        assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNull();
        assertThat(projectCreationListener.traceId).isNull();
        assertThat(projectCreationListener.isLoggingForced).isFalse();
        // The logging tag with the project name is also set if tracing is off.
        assertThat(projectCreationListener.tags.get("project")).containsExactly("new23");
    }
}
Also used : Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) RestResponse(com.google.gerrit.acceptance.RestResponse) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 57 with GerritConfig

use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.

the class TraceIT method traceAccountInvalidId.

@Test
@GerritConfig(name = "tracing.issue123.account", value = "invalid")
public void traceAccountInvalidId() throws Exception {
    TraceValidatingProjectCreationValidationListener projectCreationListener = new TraceValidatingProjectCreationValidationListener();
    try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
        RestResponse response = adminRestSession.put("/projects/new18");
        assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
        assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNull();
        assertThat(projectCreationListener.traceId).isNull();
        assertThat(projectCreationListener.isLoggingForced).isFalse();
        // The logging tag with the project name is also set if tracing is off.
        assertThat(projectCreationListener.tags.get("project")).containsExactly("new18");
    }
}
Also used : Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) RestResponse(com.google.gerrit.acceptance.RestResponse) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 58 with GerritConfig

use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.

the class TraceIT method traceProjectMatchRegEx.

@Test
@GerritConfig(name = "tracing.issue123.projectPattern", value = "new.*")
public void traceProjectMatchRegEx() throws Exception {
    TraceValidatingProjectCreationValidationListener projectCreationListener = new TraceValidatingProjectCreationValidationListener();
    try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
        RestResponse response = adminRestSession.put("/projects/new13");
        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("new13");
    }
}
Also used : Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) RestResponse(com.google.gerrit.acceptance.RestResponse) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 59 with GerritConfig

use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.

the class TraceIT method traceAccountNoMatch.

@Test
@GerritConfig(name = "tracing.issue123.account", value = "1000001")
public void traceAccountNoMatch() throws Exception {
    TraceValidatingProjectCreationValidationListener projectCreationListener = new TraceValidatingProjectCreationValidationListener();
    try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
        RestResponse response = adminRestSession.put("/projects/new16");
        assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
        assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNull();
        assertThat(projectCreationListener.traceId).isNull();
        assertThat(projectCreationListener.isLoggingForced).isFalse();
        // The logging tag with the project name is also set if tracing is off.
        assertThat(projectCreationListener.tags.get("project")).containsExactly("new16");
    }
}
Also used : Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) RestResponse(com.google.gerrit.acceptance.RestResponse) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 60 with GerritConfig

use of com.google.gerrit.acceptance.config.GerritConfig in project gerrit by GerritCodeReview.

the class TraceIT method traceProjectForAccountNoAccountMatch.

@Test
@GerritConfig(name = "tracing.issue123.account", value = "1000001")
@GerritConfig(name = "tracing.issue123.projectPattern", value = "new.*")
public void traceProjectForAccountNoAccountMatch() throws Exception {
    TraceValidatingProjectCreationValidationListener projectCreationListener = new TraceValidatingProjectCreationValidationListener();
    try (Registration registration = extensionRegistry.newRegistration().add(projectCreationListener)) {
        RestResponse response = adminRestSession.put("/projects/new24");
        assertThat(response.getStatusCode()).isEqualTo(SC_CREATED);
        assertThat(response.getHeader(RestApiServlet.X_GERRIT_TRACE)).isNull();
        assertThat(projectCreationListener.traceId).isNull();
        assertThat(projectCreationListener.isLoggingForced).isFalse();
        // The logging tag with the project name is also set if tracing is off.
        assertThat(projectCreationListener.tags.get("project")).containsExactly("new24");
    }
}
Also used : Registration(com.google.gerrit.acceptance.ExtensionRegistry.Registration) RestResponse(com.google.gerrit.acceptance.RestResponse) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)187 Test (org.junit.Test)185 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)170 RestResponse (com.google.gerrit.acceptance.RestResponse)56 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)40 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)35 Repository (org.eclipse.jgit.lib.Repository)21 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)19 MetaDataUpdate (com.google.gerrit.server.git.meta.MetaDataUpdate)17 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)17 ExternalIdNotes (com.google.gerrit.server.account.externalids.ExternalIdNotes)16 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)14 TestRepository (org.eclipse.jgit.junit.TestRepository)14 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)11 TestAccount (com.google.gerrit.acceptance.TestAccount)10 Account (com.google.gerrit.entities.Account)10 RevCommit (org.eclipse.jgit.revwalk.RevCommit)10 Project (com.google.gerrit.entities.Project)9 ConfigInfo (com.google.gerrit.extensions.api.projects.ConfigInfo)9 Change (com.google.gerrit.entities.Change)8