use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.
the class ExternalIdIT method testPushToExternalIdsBranchRejectsInvalidExternalId.
private void testPushToExternalIdsBranchRejectsInvalidExternalId(ExternalId invalidExtId) throws Exception {
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
addExtId(allUsersRepo, invalidExtId);
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");
}
use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.
the class ExternalIdIT method pushToExternalIdsBranch.
@Test
public void pushToExternalIdsBranch() throws Exception {
TestRepository<InMemoryRepository> allUsersRepo = cloneProject(allUsers);
fetch(allUsersRepo, RefNames.REFS_EXTERNAL_IDS + ":" + RefNames.REFS_EXTERNAL_IDS);
allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
// different case email is allowed
ExternalId newExtId = createExternalIdWithOtherCaseEmail("foo:bar");
addExtId(allUsersRepo, newExtId);
allUsersRepo.reset(RefNames.REFS_EXTERNAL_IDS);
List<AccountExternalIdInfo> extIdsBefore = gApi.accounts().self().getExternalIds();
allowPushOfExternalIds();
PushResult r = pushHead(allUsersRepo, RefNames.REFS_EXTERNAL_IDS);
assertThat(r.getRemoteUpdate(RefNames.REFS_EXTERNAL_IDS).getStatus()).isEqualTo(Status.OK);
List<AccountExternalIdInfo> extIdsAfter = gApi.accounts().self().getExternalIds();
assertThat(extIdsAfter).containsExactlyElementsIn(Iterables.concat(extIdsBefore, ImmutableSet.of(toExternalIdInfo(newExtId))));
}
use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.
the class AbstractSubmit method submitNoPermission.
@Test
public void submitNoPermission() throws Exception {
// create project where submit is blocked
Project.NameKey p = createProject("p");
block(p, "refs/*", Permission.SUBMIT, REGISTERED_USERS);
TestRepository<InMemoryRepository> repo = cloneProject(p, admin);
PushOneCommit push = pushFactory.create(db, admin.getIdent(), repo);
PushOneCommit.Result result = push.to("refs/for/master");
result.assertOkStatus();
submit(result.getChangeId(), new SubmitInput(), AuthException.class, "submit not permitted");
}
use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.
the class DeleteDraftPatchSetIT method deleteDraftPatchSetAndPushNewDraftPatchSet.
@Test
public void deleteDraftPatchSetAndPushNewDraftPatchSet() throws Exception {
String ref = "refs/drafts/master";
// Clone repository
TestRepository<InMemoryRepository> testRepo = cloneProject(project, admin);
// Create change
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result r1 = push.to(ref);
r1.assertOkStatus();
String revPs1 = r1.getChange().currentPatchSet().getRevision().get();
// Push draft patch set
PushOneCommit.Result r2 = amendChange(r1.getChangeId(), ref, admin, testRepo);
r2.assertOkStatus();
String revPs2 = r2.getChange().currentPatchSet().getRevision().get();
assertThat(gApi.changes().id(r1.getChange().getId().get()).get().currentRevision).isEqualTo(revPs2);
// Remove draft patch set
gApi.changes().id(r1.getChange().getId().get()).revision(revPs2).delete();
assertThat(gApi.changes().id(r1.getChange().getId().get()).get().currentRevision).isEqualTo(revPs1);
// Push new draft patch set
PushOneCommit.Result r3 = amendChange(r1.getChangeId(), ref, admin, testRepo);
r3.assertOkStatus();
String revPs3 = r2.getChange().currentPatchSet().getRevision().get();
assertThat(gApi.changes().id(r1.getChange().getId().get()).get().currentRevision).isEqualTo(revPs3);
// Check that all patch sets have different SHA1s
assertThat(revPs1).doesNotMatch(revPs2);
assertThat(revPs2).doesNotMatch(revPs3);
}
use of org.eclipse.jgit.internal.storage.dfs.InMemoryRepository in project gerrit by GerritCodeReview.
the class AccessIT method unknownPermissionRemainsUnchanged.
@Test
public void unknownPermissionRemainsUnchanged() throws Exception {
String access = "access";
String unknownPermission = "unknownPermission";
String registeredUsers = "group Registered Users";
String refsFor = "refs/for/*";
// Clone repository to forcefully add permission
TestRepository<InMemoryRepository> allProjectsRepo = cloneProject(allProjects, admin);
// Fetch permission ref
GitUtil.fetch(allProjectsRepo, "refs/meta/config:cfg");
allProjectsRepo.reset("cfg");
// Load current permissions
String config = gApi.projects().name(allProjects.get()).branch(RefNames.REFS_CONFIG).file("project.config").asString();
// Append and push unknown permission
Config cfg = new Config();
cfg.fromText(config);
cfg.setString(access, refsFor, unknownPermission, registeredUsers);
config = cfg.toText();
PushOneCommit push = pushFactory.create(db, admin.getIdent(), allProjectsRepo, "Subject", "project.config", config);
push.to(RefNames.REFS_CONFIG).assertOkStatus();
// Verify that unknownPermission is present
config = gApi.projects().name(allProjects.get()).branch(RefNames.REFS_CONFIG).file("project.config").asString();
cfg.fromText(config);
assertThat(cfg.getString(access, refsFor, unknownPermission)).isEqualTo(registeredUsers);
// Make permission change through API
ProjectAccessInput accessInput = newProjectAccessInput();
AccessSectionInfo accessSectionInfo = createDefaultAccessSectionInfo();
accessInput.add.put(refsFor, accessSectionInfo);
gApi.projects().name(allProjects.get()).access(accessInput);
accessInput.add.clear();
accessInput.remove.put(refsFor, accessSectionInfo);
gApi.projects().name(allProjects.get()).access(accessInput);
// Verify that unknownPermission is still present
config = gApi.projects().name(allProjects.get()).branch(RefNames.REFS_CONFIG).file("project.config").asString();
cfg.fromText(config);
assertThat(cfg.getString(access, refsFor, unknownPermission)).isEqualTo(registeredUsers);
}
Aggregations