Search in sources :

Example 21 with GerritConfig

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

the class RefAdvertisementIT method advertisedReferencesOmitPrivateChangesOfOtherUsersWhenShortcutDisabled.

@Test
@GerritConfig(name = "auth.skipFullRefEvaluationIfAllRefsAreVisible", value = "false")
public void advertisedReferencesOmitPrivateChangesOfOtherUsersWhenShortcutDisabled() throws Exception {
    projectOperations.project(project).forUpdate().add(allow(Permission.READ).ref("refs/*").group(REGISTERED_USERS)).update();
    TestRepository<?> userTestRepository = cloneProject(project, user);
    try (Git git = userTestRepository.git()) {
        String change3RefName = cd3.currentPatchSet().refName();
        assertWithMessage("Precondition violated").that(getRefs(git)).contains(change3RefName);
        gApi.changes().id(cd3.getId().get()).setPrivate(true, null);
        assertThat(getRefs(git)).doesNotContain(change3RefName);
    }
}
Also used : Git(org.eclipse.jgit.api.Git) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 22 with GerritConfig

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

the class CreateProjectIT method createProject_WhenDefaultBranchIsSet_WithBranches.

@Test
@GerritConfig(name = "gerrit.defaultBranch", value = "refs/heads/main")
public void createProject_WhenDefaultBranchIsSet_WithBranches() throws Exception {
    // Host-level default only applies if no branches were passed in the input
    String newProjectName = name("newProject");
    ProjectInput in = new ProjectInput();
    in.name = newProjectName;
    in.createEmptyCommit = true;
    in.branches = ImmutableList.of("refs/heads/test", "release");
    gApi.projects().create(in);
    ImmutableMap<String, BranchInfo> branches = getProjectBranches(newProjectName);
    assertThat(branches.keySet()).containsExactly("HEAD", "refs/meta/config", "refs/heads/test", "refs/heads/release");
    assertHead(newProjectName, "refs/heads/test");
    assertEmptyCommit(newProjectName, "refs/heads/test", "refs/heads/release");
}
Also used : ProjectInput(com.google.gerrit.extensions.api.projects.ProjectInput) BranchInfo(com.google.gerrit.extensions.api.projects.BranchInfo) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 23 with GerritConfig

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

the class CreateProjectIT method createPermissionOnlyProject_WhenDefaultBranchIsSet.

@Test
@GerritConfig(name = "gerrit.defaultBranch", value = "main")
public void createPermissionOnlyProject_WhenDefaultBranchIsSet() throws Exception {
    String newProjectName = name("newProject");
    ProjectInput in = new ProjectInput();
    in.name = newProjectName;
    in.permissionsOnly = true;
    gApi.projects().create(in);
    // For permissionOnly, don't use host-level default branch.
    assertHead(newProjectName, RefNames.REFS_CONFIG);
}
Also used : ProjectInput(com.google.gerrit.extensions.api.projects.ProjectInput) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 24 with GerritConfig

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

the class CreateProjectIT method createProjectWithEmptyCommit_WhenDefaultBranchIsSet.

@Test
@GerritConfig(name = "gerrit.defaultBranch", value = "main")
public void createProjectWithEmptyCommit_WhenDefaultBranchIsSet() throws Exception {
    String newProjectName = name("newProject");
    ProjectInput in = new ProjectInput();
    in.name = newProjectName;
    in.createEmptyCommit = true;
    gApi.projects().create(in);
    ImmutableMap<String, BranchInfo> branches = getProjectBranches(newProjectName);
    // HEAD symbolic ref is set to the default, and the actual ref is created.
    assertThat(branches.keySet()).containsExactly("HEAD", "refs/meta/config", "refs/heads/main");
    assertHead(newProjectName, "refs/heads/main");
    assertEmptyCommit(newProjectName, "HEAD", "refs/heads/main");
}
Also used : ProjectInput(com.google.gerrit.extensions.api.projects.ProjectInput) BranchInfo(com.google.gerrit.extensions.api.projects.BranchInfo) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 25 with GerritConfig

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

the class CreateProjectIT method repositoryConfigTakesPrecedenceOverInheritedSubmitType.

@SuppressWarnings("deprecation")
@Test
@GerritConfig(name = "repository.testinheritedsubmittype/*.defaultSubmitType", value = "CHERRY_PICK")
public void repositoryConfigTakesPrecedenceOverInheritedSubmitType() throws Exception {
    // Can't use name() since we need to specify this project name in gerrit.config prior to
    // startup. Pick something reasonably unique instead.
    String parent = "testinheritedsubmittype";
    ProjectInput pin = new ProjectInput();
    pin.name = parent;
    pin.submitType = SubmitType.MERGE_ALWAYS;
    ConfigInfo cfg = gApi.projects().create(pin).config();
    assertThat(cfg.submitType).isEqualTo(SubmitType.MERGE_ALWAYS);
    assertThat(cfg.defaultSubmitType.value).isEqualTo(SubmitType.MERGE_ALWAYS);
    assertThat(cfg.defaultSubmitType.configuredValue).isEqualTo(SubmitType.MERGE_ALWAYS);
    assertThat(cfg.defaultSubmitType.inheritedValue).isEqualTo(SubmitType.MERGE_IF_NECESSARY);
    String child = parent + "/child";
    pin = new ProjectInput();
    pin.parent = parent;
    pin.name = child;
    cfg = gApi.projects().create(pin).config();
    assertThat(cfg.submitType).isEqualTo(SubmitType.CHERRY_PICK);
    assertThat(cfg.defaultSubmitType.value).isEqualTo(SubmitType.CHERRY_PICK);
    assertThat(cfg.defaultSubmitType.configuredValue).isEqualTo(SubmitType.CHERRY_PICK);
    assertThat(cfg.defaultSubmitType.inheritedValue).isEqualTo(SubmitType.MERGE_ALWAYS);
}
Also used : ProjectInput(com.google.gerrit.extensions.api.projects.ProjectInput) ConfigInfo(com.google.gerrit.extensions.api.projects.ConfigInfo) 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