use of com.google.gerrit.reviewdb.client.Project in project gerrit by GerritCodeReview.
the class ChangeIT method createNewPatchSetAsOwnerWithoutPermission.
@Test
public void createNewPatchSetAsOwnerWithoutPermission() throws Exception {
// Create new project with clean permissions
Project.NameKey p = createProject("addPatchSet2");
// Clone separate repositories of the same project as admin and as user
TestRepository<?> adminTestRepo = cloneProject(project, admin);
// Block default permission
block(p, "refs/for/*", Permission.ADD_PATCH_SET, REGISTERED_USERS);
// Create change as admin
PushOneCommit push = pushFactory.create(db, admin.getIdent(), adminTestRepo);
PushOneCommit.Result r1 = push.to("refs/for/master");
r1.assertOkStatus();
// Fetch change
GitUtil.fetch(adminTestRepo, r1.getPatchSet().getRefName() + ":ps");
adminTestRepo.reset("ps");
// Amend change as admin
PushOneCommit.Result r2 = amendChange(r1.getChangeId(), "refs/for/master", admin, adminTestRepo);
r2.assertOkStatus();
}
use of com.google.gerrit.reviewdb.client.Project 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());
}
use of com.google.gerrit.reviewdb.client.Project in project gerrit by GerritCodeReview.
the class SubmoduleSubscriptionsWholeTopicMergeIT method subscriptionUpdateOfManyChanges.
@Test
public void subscriptionUpdateOfManyChanges() throws Exception {
TestRepository<?> superRepo = createProjectWithPush("super-project");
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master", "super-project", "refs/heads/master");
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
ObjectId subHEAD = subRepo.branch("HEAD").commit().insertChangeId().message("some change").add("a.txt", "a contents ").create();
subRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec("HEAD:refs/heads/master")).call();
RevCommit c = subRepo.getRevWalk().parseCommit(subHEAD);
RevCommit c1 = subRepo.branch("HEAD").commit().insertChangeId().message("first change").add("asdf", "asdf\n").create();
subRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec("HEAD:refs/for/master/" + name("topic-foo"))).call();
subRepo.reset(c.getId());
RevCommit c2 = subRepo.branch("HEAD").commit().insertChangeId().message("qwerty").add("qwerty", "qwerty").create();
RevCommit c3 = subRepo.branch("HEAD").commit().insertChangeId().message("qwerty followup").add("qwerty", "qwerty\nqwerty\n").create();
subRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec("HEAD:refs/for/master/" + name("topic-foo"))).call();
String id1 = getChangeId(subRepo, c1).get();
String id2 = getChangeId(subRepo, c2).get();
String id3 = getChangeId(subRepo, c3).get();
gApi.changes().id(id1).current().review(ReviewInput.approve());
gApi.changes().id(id2).current().review(ReviewInput.approve());
gApi.changes().id(id3).current().review(ReviewInput.approve());
Map<Branch.NameKey, ObjectId> preview = fetchFromSubmitPreview(id1);
gApi.changes().id(id1).current().submit();
ObjectId subRepoId = subRepo.git().fetch().setRemote("origin").call().getAdvertisedRef("refs/heads/master").getObjectId();
expectToHaveSubmoduleState(superRepo, "master", "subscribed-to-project", subRepoId);
// As the submodules have changed commits, the superproject tree will be
// different, so we cannot directly compare the trees here, so make
// assumptions only about the changed branches:
Project.NameKey p1 = new Project.NameKey(name("super-project"));
Project.NameKey p2 = new Project.NameKey(name("subscribed-to-project"));
assertThat(preview).containsKey(new Branch.NameKey(p1, "refs/heads/master"));
assertThat(preview).containsKey(new Branch.NameKey(p2, "refs/heads/master"));
if ((getSubmitType() == SubmitType.CHERRY_PICK) || (getSubmitType() == SubmitType.REBASE_ALWAYS)) {
// each change is updated and the respective target branch is updated:
assertThat(preview).hasSize(5);
} else if ((getSubmitType() == SubmitType.REBASE_IF_NECESSARY)) {
// Either the first is used first as is, then the second and third need
// rebasing, or those two stay as is and the first is rebased.
// add in 2 master branches, expect 3 or 4:
assertThat(preview.size()).isAnyOf(3, 4);
} else {
assertThat(preview).hasSize(2);
}
}
use of com.google.gerrit.reviewdb.client.Project in project gerrit by GerritCodeReview.
the class SubmoduleSectionParserIT method withSlashesInProjectName.
@Test
public void withSlashesInProjectName() throws Exception {
Project.NameKey p = createProject("project/with/slashes/a");
Config cfg = new Config();
cfg.fromText("" + "[submodule \"project/with/slashes/a\"]\n" + "path = a\n" + "url = http://localhost:80/" + p.get() + "\n" + "branch = master\n");
Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master");
Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p, "master"), "a"));
assertThat(res).containsExactlyElementsIn(expected);
}
use of com.google.gerrit.reviewdb.client.Project in project gerrit by GerritCodeReview.
the class SubmoduleSectionParserIT method withSlashesInPath.
@Test
public void withSlashesInPath() throws Exception {
Project.NameKey p = createProject("a");
Config cfg = new Config();
cfg.fromText("" + "[submodule \"a\"]\n" + "path = a/b/c/d/e\n" + "url = http://localhost:80/" + p.get() + "\n" + "branch = master\n");
Branch.NameKey targetBranch = new Branch.NameKey(new Project.NameKey("project"), "master");
Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, new Branch.NameKey(p, "master"), "a/b/c/d/e"));
assertThat(res).containsExactlyElementsIn(expected);
}
Aggregations