Search in sources :

Example 36 with InMemoryRepository

use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.

the class ChangeIT method createNewPatchSetOnVisibleDraftPatchSet.

@Test
public void createNewPatchSetOnVisibleDraftPatchSet() throws Exception {
    // Clone separate repositories of the same project as admin and as user
    TestRepository<InMemoryRepository> adminTestRepo = cloneProject(project, admin);
    TestRepository<InMemoryRepository> userTestRepo = cloneProject(project, user);
    // Create change as admin
    PushOneCommit push = pushFactory.create(db, admin.getIdent(), adminTestRepo);
    PushOneCommit.Result r1 = push.to("refs/for/master");
    r1.assertOkStatus();
    // Amend draft as admin
    PushOneCommit.Result r2 = amendChange(r1.getChangeId(), "refs/drafts/master", admin, adminTestRepo);
    r2.assertOkStatus();
    // Add user as reviewer to make this patch set visible
    AddReviewerInput in = new AddReviewerInput();
    in.reviewer = user.email;
    gApi.changes().id(r1.getChangeId()).addReviewer(in);
    // Fetch change
    GitUtil.fetch(userTestRepo, r2.getPatchSet().getRefName() + ":ps");
    userTestRepo.reset("ps");
    // Amend change as user
    PushOneCommit.Result r3 = amendChange(r2.getChangeId(), "refs/drafts/master", user, userTestRepo);
    r3.assertOkStatus();
}
Also used : InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AddReviewerInput(com.google.gerrit.extensions.api.changes.AddReviewerInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 37 with InMemoryRepository

use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.

the class DiffPreferencesIT method cleanUp.

@After
public void cleanUp() throws Exception {
    gApi.accounts().id(admin.getId().toString()).setDiffPreferences(DiffPreferencesInfo.defaults());
    TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
    try {
        fetch(allUsersRepo, RefNames.REFS_USERS_DEFAULT + ":defaults");
    } catch (TransportException e) {
        if (e.getMessage().equals("Remote does not have " + RefNames.REFS_USERS_DEFAULT + " available for fetch.")) {
            return;
        }
        throw e;
    }
    allUsersRepo.reset("defaults");
    PushOneCommit push = pushFactory.create(db, admin.getIdent(), allUsersRepo, "Delete default preferences", VersionedAccountPreferences.PREFERENCES, "");
    push.rm(RefNames.REFS_USERS_DEFAULT).assertOkStatus();
}
Also used : InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) TransportException(org.eclipse.jgit.api.errors.TransportException) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) After(org.junit.After)

Example 38 with InMemoryRepository

use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.

the class ChangeEditIT method createEditWithoutPushPatchSetPermission.

@Test
public void createEditWithoutPushPatchSetPermission() throws Exception {
    // Create new project with clean permissions
    Project.NameKey p = createProject("addPatchSetEdit");
    // Clone repository as user
    TestRepository<InMemoryRepository> userTestRepo = cloneProject(p, user);
    // Block default permission
    block(p, "refs/for/*", Permission.ADD_PATCH_SET, REGISTERED_USERS);
    // Create change as user
    PushOneCommit push = pushFactory.create(db, user.getIdent(), userTestRepo);
    PushOneCommit.Result r1 = push.to("refs/for/master");
    r1.assertOkStatus();
    // Try to create edit as admin
    exception.expect(AuthException.class);
    createEmptyEditFor(r1.getChangeId());
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 39 with InMemoryRepository

use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.

the class ExternalIdIT method pushToExternalIdsBranchRejectsExternalIdWithoutAccountId.

@Test
public void pushToExternalIdsBranchRejectsExternalIdWithoutAccountId() throws Exception {
    TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
    fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
    allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
    insertExternalIdWithoutAccountId(allUsersRepo.getRepository(), allUsersRepo.getRevWalk(), "foo:bar");
    allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
    allowPushOfExternalIds();
    PushResult r = pushHead(allUsersRepo, RefNames.REFS_EXTERNAL_IDS);
    assertRefUpdateFailure(r.getRemoteUpdate(RefNames.REFS_EXTERNAL_IDS), "invalid external IDs");
}
Also used : InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) PushResult(org.eclipse.jgit.transport.PushResult) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 40 with InMemoryRepository

use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.

the class ExternalIdIT method pushToExternalIdsBranchRejectsExternalIdWithEmptyNote.

@Test
public void pushToExternalIdsBranchRejectsExternalIdWithEmptyNote() throws Exception {
    TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
    fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
    allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
    insertExternalIdWithEmptyNote(allUsersRepo.getRepository(), allUsersRepo.getRevWalk(), "foo:bar");
    allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
    allowPushOfExternalIds();
    PushResult r = pushHead(allUsersRepo, RefNames.REFS_EXTERNAL_IDS);
    assertRefUpdateFailure(r.getRemoteUpdate(RefNames.REFS_EXTERNAL_IDS), "invalid external IDs");
}
Also used : InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) PushResult(org.eclipse.jgit.transport.PushResult) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)54 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)37 Test (org.junit.Test)37 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)30 Project (com.google.gerrit.reviewdb.client.Project)21 DfsRepositoryDescription (org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription)12 Before (org.junit.Before)12 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)8 Message (com.google.gerrit.testutil.FakeEmailSender.Message)8 PushResult (org.eclipse.jgit.transport.PushResult)8 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)6 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)6 PublicKeyStore.keyToString (com.google.gerrit.gpg.PublicKeyStore.keyToString)5 TestAccount (com.google.gerrit.acceptance.TestAccount)4 CurrentUser (com.google.gerrit.server.CurrentUser)4 Config (org.eclipse.jgit.lib.Config)4 Sandboxed (com.google.gerrit.acceptance.Sandboxed)3 SubmitInput (com.google.gerrit.extensions.api.changes.SubmitInput)3 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)3 LifecycleManager (com.google.gerrit.lifecycle.LifecycleManager)3