Search in sources :

Example 36 with ProjectConfig

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

the class TagsIT method setupPermissions.

@Before
public void setupPermissions() throws Exception {
    try (ProjectConfigUpdate u = updateProject(allProjects)) {
        ProjectConfig cfg = u.getConfig();
        removeAllBranchPermissions(cfg, Permission.CREATE, Permission.CREATE_TAG, Permission.CREATE_SIGNED_TAG);
        u.save();
    }
}
Also used : ProjectConfig(com.google.gerrit.server.project.ProjectConfig) Before(org.junit.Before)

Example 37 with ProjectConfig

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

the class ProjectOperationsImplTest method getProjectConfigNoRefsMetaConfig.

@Test
public void getProjectConfigNoRefsMetaConfig() throws Exception {
    Project.NameKey key = projectOperations.newProject().create();
    deleteRefsMetaConfig(key);
    ProjectConfig projectConfig = projectOperations.project(key).getProjectConfig();
    assertThat(projectConfig.getName()).isEqualTo(key);
    assertThat(projectConfig.getRevision()).isNull();
}
Also used : ProjectConfig(com.google.gerrit.server.project.ProjectConfig) Project(com.google.gerrit.entities.Project) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 38 with ProjectConfig

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

the class LabelNormalizerTest method configureProject.

private void configureProject() throws Exception {
    ProjectConfig pc = loadAllProjects();
    for (AccessSection sec : pc.getAccessSections()) {
        pc.upsertAccessSection(sec.getName(), updatedSection -> {
            for (String label : pc.getLabelSections().keySet()) {
                updatedSection.removePermission(forLabel(label));
            }
        });
    }
    LabelType lt = label(LabelId.VERIFIED, value(1, LabelId.VERIFIED), value(0, "No score"), value(-1, "Fails"));
    pc.upsertLabelType(lt);
    save(pc);
}
Also used : ProjectConfig(com.google.gerrit.server.project.ProjectConfig) LabelType(com.google.gerrit.entities.LabelType) AccessSection(com.google.gerrit.entities.AccessSection)

Example 39 with ProjectConfig

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

the class AbstractQueryChangesTest method grant.

protected void grant(Project.NameKey project, String ref, String permission, boolean force, AccountGroup.UUID groupUUID) throws RepositoryNotFoundException, IOException, ConfigInvalidException {
    try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
        md.setMessage(String.format("Grant %s on %s", permission, ref));
        ProjectConfig config = projectConfigFactory.read(md);
        config.upsertAccessSection(ref, s -> {
            Permission.Builder p = s.upsertPermission(permission);
            PermissionRule.Builder rule = PermissionRule.builder(GroupReference.create(groupUUID, groupUUID.get())).setForce(force);
            p.add(rule);
        });
        config.commit(md);
        projectCache.evictAndReindex(config.getProject());
    }
}
Also used : ProjectConfig(com.google.gerrit.server.project.ProjectConfig) PermissionRule(com.google.gerrit.entities.PermissionRule) Permission(com.google.gerrit.entities.Permission) MetaDataUpdate(com.google.gerrit.server.git.meta.MetaDataUpdate)

Aggregations

ProjectConfig (com.google.gerrit.server.project.ProjectConfig)39 MetaDataUpdate (com.google.gerrit.server.git.meta.MetaDataUpdate)26 AuthException (com.google.gerrit.extensions.restapi.AuthException)8 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)8 Project (com.google.gerrit.entities.Project)7 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)7 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)7 Test (org.junit.Test)7 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)6 AccessSection (com.google.gerrit.entities.AccessSection)6 BooleanProjectConfig (com.google.gerrit.entities.BooleanProjectConfig)6 LabelType (com.google.gerrit.entities.LabelType)6 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)6 Repository (org.eclipse.jgit.lib.Repository)6 GroupReference (com.google.gerrit.entities.GroupReference)5 Permission (com.google.gerrit.entities.Permission)5 IOException (java.io.IOException)5 ProjectState (com.google.gerrit.server.project.ProjectState)4 RepositoryNotFoundException (org.eclipse.jgit.errors.RepositoryNotFoundException)4 TestRepository (org.eclipse.jgit.junit.TestRepository)4