use of com.google.gerrit.extensions.api.projects.TagInfo in project gerrit by GerritCodeReview.
the class TagsIT method listTagsOfNonVisibleBranch.
@Test
public void listTagsOfNonVisibleBranch() throws Exception {
grantTagPermissions();
// Allow creating a new hidden branch
projectOperations.project(project).forUpdate().add(allow(Permission.CREATE).group(REGISTERED_USERS).ref("refs/heads/hidden")).update();
PushOneCommit push1 = pushFactory.create(admin.newIdent(), testRepo);
PushOneCommit.Result r1 = push1.to("refs/heads/master");
r1.assertOkStatus();
TagInput tag1 = new TagInput();
tag1.ref = "v1.0";
tag1.revision = r1.getCommit().getName();
TagInfo result = tag(tag1.ref).create(tag1).get();
assertThat(result.ref).isEqualTo(R_TAGS + tag1.ref);
assertThat(result.revision).isEqualTo(tag1.revision);
pushTo("refs/heads/hidden").assertOkStatus();
PushOneCommit push2 = pushFactory.create(admin.newIdent(), testRepo);
PushOneCommit.Result r2 = push2.to("refs/heads/hidden");
r2.assertOkStatus();
TagInput tag2 = new TagInput();
tag2.ref = "v2.0";
tag2.revision = r2.getCommit().getName();
result = tag(tag2.ref).create(tag2).get();
assertThat(result.ref).isEqualTo(R_TAGS + tag2.ref);
assertThat(result.revision).isEqualTo(tag2.revision);
List<TagInfo> tags = getTags().get();
assertThat(tags).hasSize(2);
assertThat(tags.get(0).ref).isEqualTo(R_TAGS + tag1.ref);
assertThat(tags.get(0).revision).isEqualTo(tag1.revision);
assertThat(tags.get(1).ref).isEqualTo(R_TAGS + tag2.ref);
assertThat(tags.get(1).revision).isEqualTo(tag2.revision);
projectOperations.project(project).forUpdate().add(block(Permission.READ).ref("refs/heads/hidden").group(REGISTERED_USERS)).update();
tags = getTags().get();
assertThat(tags).hasSize(1);
assertThat(tags.get(0).ref).isEqualTo(R_TAGS + tag1.ref);
assertThat(tags.get(0).revision).isEqualTo(tag1.revision);
}
Aggregations