Search in sources :

Example 11 with ProjectConfig

use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.

the class AbstractDaemonTest method allow.

protected void allow(String permission, AccountGroup.UUID id, String ref) throws Exception {
    ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
    Util.allow(cfg, permission, id, ref);
    saveProjectConfig(project, cfg);
}
Also used : ProjectConfig(com.google.gerrit.server.git.ProjectConfig)

Example 12 with ProjectConfig

use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.

the class StickyApprovalsIT method setup.

@Before
public void setup() throws Exception {
    ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
    // Overwrite "Code-Review" label that is inherited from All-Projects.
    // This way changes to the "Code Review" label don't affect other tests.
    LabelType codeReview = category("Code-Review", value(2, "Looks good to me, approved"), value(1, "Looks good to me, but someone else must approve"), value(0, "No score"), value(-1, "I would prefer that you didn't submit this"), value(-2, "Do not submit"));
    codeReview.setCopyAllScoresIfNoChange(false);
    cfg.getLabelSections().put(codeReview.getName(), codeReview);
    LabelType verified = category("Verified", value(1, "Passes"), value(0, "No score"), value(-1, "Failed"));
    verified.setCopyAllScoresIfNoChange(false);
    cfg.getLabelSections().put(verified.getName(), verified);
    AccountGroup.UUID registeredUsers = systemGroupBackend.getGroup(REGISTERED_USERS).getUUID();
    String heads = RefNames.REFS_HEADS + "*";
    Util.allow(cfg, Permission.forLabel(Util.codeReview().getName()), -2, 2, registeredUsers, heads);
    Util.allow(cfg, Permission.forLabel(Util.verified().getName()), -1, 1, registeredUsers, heads);
    saveProjectConfig(project, cfg);
}
Also used : ProjectConfig(com.google.gerrit.server.git.ProjectConfig) AccountGroup(com.google.gerrit.reviewdb.client.AccountGroup) LabelType(com.google.gerrit.common.data.LabelType) Before(org.junit.Before)

Example 13 with ProjectConfig

use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.

the class StickyApprovalsIT method deleteStickyVote.

@Test
public void deleteStickyVote() throws Exception {
    String label = "Code-Review";
    ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
    cfg.getLabelSections().get(label).setCopyMaxScore(true);
    saveProjectConfig(project, cfg);
    // Vote max score on PS1
    String changeId = createChange(REWORK);
    vote(admin, changeId, label, 2);
    assertVotes(detailedChange(changeId), admin, label, 2, null);
    updateChange(changeId, REWORK);
    assertVotes(detailedChange(changeId), admin, label, 2, REWORK);
    // Delete vote that was copied via sticky approval
    deleteVote(admin, changeId, "Code-Review");
    assertVotes(detailedChange(changeId), admin, label, 0, REWORK);
}
Also used : ProjectConfig(com.google.gerrit.server.git.ProjectConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 14 with ProjectConfig

use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.

the class ImpersonationIT method blockRead.

private void blockRead(GroupInfo group) throws Exception {
    ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
    Util.block(cfg, Permission.READ, new AccountGroup.UUID(group.id), "refs/heads/master");
    saveProjectConfig(project, cfg);
}
Also used : ProjectConfig(com.google.gerrit.server.git.ProjectConfig) AccountGroup(com.google.gerrit.reviewdb.client.AccountGroup)

Example 15 with ProjectConfig

use of com.google.gerrit.server.git.ProjectConfig in project gerrit by GerritCodeReview.

the class ImpersonationIT method allowCodeReviewOnBehalfOf.

private void allowCodeReviewOnBehalfOf() throws Exception {
    ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
    LabelType codeReviewType = Util.codeReview();
    String forCodeReviewAs = Permission.forLabelAs(codeReviewType.getName());
    String heads = "refs/heads/*";
    AccountGroup.UUID uuid = systemGroupBackend.getGroup(REGISTERED_USERS).getUUID();
    Util.allow(cfg, forCodeReviewAs, -1, 1, uuid, heads);
    saveProjectConfig(project, cfg);
}
Also used : ProjectConfig(com.google.gerrit.server.git.ProjectConfig) AccountGroup(com.google.gerrit.reviewdb.client.AccountGroup) LabelType(com.google.gerrit.common.data.LabelType)

Aggregations

ProjectConfig (com.google.gerrit.server.git.ProjectConfig)64 MetaDataUpdate (com.google.gerrit.server.git.MetaDataUpdate)23 AccessSection (com.google.gerrit.common.data.AccessSection)15 Project (com.google.gerrit.reviewdb.client.Project)14 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)14 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)12 Permission (com.google.gerrit.common.data.Permission)10 PermissionRule (com.google.gerrit.common.data.PermissionRule)10 IOException (java.io.IOException)10 Repository (org.eclipse.jgit.lib.Repository)9 LabelType (com.google.gerrit.common.data.LabelType)8 Test (org.junit.Test)8 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)7 RepositoryNotFoundException (org.eclipse.jgit.errors.RepositoryNotFoundException)7 Before (org.junit.Before)7 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)6 GroupReference (com.google.gerrit.common.data.GroupReference)6 OrmException (com.google.gwtorm.server.OrmException)6 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)5 AuthException (com.google.gerrit.extensions.restapi.AuthException)4