Search in sources :

Example 6 with GerritConfig

use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.

the class SuggestReviewersIT method suggestReviewersGroupSizeConsiderations.

@Test
@GerritConfig(name = "addreviewer.maxAllowed", value = "2")
@GerritConfig(name = "addreviewer.maxWithoutConfirmation", value = "1")
public void suggestReviewersGroupSizeConsiderations() throws Exception {
    AccountGroup largeGroup = group("large");
    AccountGroup mediumGroup = group("medium");
    // Both groups have Administrator as a member. Add two users to large
    // group to push it past maxAllowed, and one to medium group to push it
    // past maxWithoutConfirmation.
    user("individual 0", "Test0 Last0", largeGroup, mediumGroup);
    user("individual 1", "Test1 Last1", largeGroup);
    String changeId = createChange().getChangeId();
    List<SuggestedReviewerInfo> reviewers;
    SuggestedReviewerInfo reviewer;
    // Individual account suggestions have count of 1 and no confirm.
    reviewers = suggestReviewers(changeId, "test", 10);
    assertThat(reviewers).hasSize(2);
    reviewer = reviewers.get(0);
    assertThat(reviewer.count).isEqualTo(1);
    assertThat(reviewer.confirm).isNull();
    // Large group should never be suggested.
    reviewers = suggestReviewers(changeId, largeGroup.getName(), 10);
    assertThat(reviewers).isEmpty();
    // Medium group should be suggested with appropriate count and confirm.
    reviewers = suggestReviewers(changeId, mediumGroup.getName(), 10);
    assertThat(reviewers).hasSize(1);
    reviewer = reviewers.get(0);
    assertThat(reviewer.group.name).isEqualTo(mediumGroup.getName());
    assertThat(reviewer.count).isEqualTo(2);
    assertThat(reviewer.confirm).isTrue();
}
Also used : AccountGroup(com.google.gerrit.reviewdb.client.AccountGroup) SuggestedReviewerInfo(com.google.gerrit.extensions.common.SuggestedReviewerInfo) GerritConfig(com.google.gerrit.acceptance.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 7 with GerritConfig

use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.

the class ServerInfoIT method serverConfig.

@Test
// auth
@GerritConfig(name = "auth.type", value = "HTTP")
@GerritConfig(name = "auth.contributorAgreements", value = "true")
@GerritConfig(name = "auth.loginUrl", value = "https://example.com/login")
@GerritConfig(name = "auth.loginText", value = "LOGIN")
@GerritConfig(name = "auth.switchAccountUrl", value = "https://example.com/switch")
// auth fields ignored when auth == HTTP
@GerritConfig(name = "auth.registerUrl", value = "https://example.com/register")
@GerritConfig(name = "auth.registerText", value = "REGISTER")
@GerritConfig(name = "auth.editFullNameUrl", value = "https://example.com/editname")
@GerritConfig(name = "auth.httpPasswordUrl", value = "https://example.com/password")
// change
@GerritConfig(name = "change.allowDrafts", value = "false")
@GerritConfig(name = "change.largeChange", value = "300")
@GerritConfig(name = "change.replyTooltip", value = "Publish votes and draft comments")
@GerritConfig(name = "change.replyLabel", value = "Vote")
@GerritConfig(name = "change.updateDelay", value = "50s")
// download
@GerritConfig(name = "download.archive", values = { "tar", "tbz2", "tgz", "txz" })
// gerrit
@GerritConfig(name = "gerrit.allProjects", value = "Root")
@GerritConfig(name = "gerrit.allUsers", value = "Users")
@GerritConfig(name = "gerrit.enableGwtUi", value = "true")
@GerritConfig(name = "gerrit.reportBugText", value = "REPORT BUG")
@GerritConfig(name = "gerrit.reportBugUrl", value = "https://example.com/report")
// suggest
@GerritConfig(name = "suggest.from", value = "3")
// user
@GerritConfig(name = "user.anonymousCoward", value = "Unnamed User")
public void serverConfig() throws Exception {
    ServerInfo i = gApi.config().server().getInfo();
    // auth
    assertThat(i.auth.authType).isEqualTo(AuthType.HTTP);
    assertThat(i.auth.editableAccountFields).containsExactly(AccountFieldName.REGISTER_NEW_EMAIL, AccountFieldName.FULL_NAME);
    assertThat(i.auth.useContributorAgreements).isTrue();
    assertThat(i.auth.loginUrl).isEqualTo("https://example.com/login");
    assertThat(i.auth.loginText).isEqualTo("LOGIN");
    assertThat(i.auth.switchAccountUrl).isEqualTo("https://example.com/switch");
    assertThat(i.auth.registerUrl).isNull();
    assertThat(i.auth.registerText).isNull();
    assertThat(i.auth.editFullNameUrl).isNull();
    assertThat(i.auth.httpPasswordUrl).isNull();
    // change
    assertThat(i.change.allowDrafts).isNull();
    assertThat(i.change.largeChange).isEqualTo(300);
    assertThat(i.change.replyTooltip).startsWith("Publish votes and draft comments");
    assertThat(i.change.replyLabel).isEqualTo("Voteā€¦");
    assertThat(i.change.updateDelay).isEqualTo(50);
    // download
    assertThat(i.download.archives).containsExactly("tar", "tbz2", "tgz", "txz");
    assertThat(i.download.schemes).isEmpty();
    // gerrit
    assertThat(i.gerrit.allProjects).isEqualTo("Root");
    assertThat(i.gerrit.allUsers).isEqualTo("Users");
    assertThat(i.gerrit.reportBugUrl).isEqualTo("https://example.com/report");
    assertThat(i.gerrit.reportBugText).isEqualTo("REPORT BUG");
    // Acceptance tests force --headless even when UIs are specified in config.
    assertThat(i.gerrit.webUis).isEmpty();
    // plugin
    assertThat(i.plugin.jsResourcePaths).isEmpty();
    // sshd
    assertThat(i.sshd).isNotNull();
    // suggest
    assertThat(i.suggest.from).isEqualTo(3);
    // user
    assertThat(i.user.anonymousCowardName).isEqualTo("Unnamed User");
    // notedb
    notesMigration.setReadChanges(true);
    assertThat(gApi.config().server().getInfo().noteDbEnabled).isTrue();
    notesMigration.setReadChanges(false);
    assertThat(gApi.config().server().getInfo().noteDbEnabled).isNull();
}
Also used : ServerInfo(com.google.gerrit.extensions.common.ServerInfo) GerritConfig(com.google.gerrit.acceptance.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 8 with GerritConfig

use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.

the class ChangeIT method pushCertificates.

@Test
@GerritConfig(name = "gerrit.editGpgKeys", value = "true")
@GerritConfig(name = "receive.enableSignedPush", value = "true")
public void pushCertificates() throws Exception {
    PushOneCommit.Result r1 = createChange();
    PushOneCommit.Result r2 = amendChange(r1.getChangeId());
    ChangeInfo info = gApi.changes().id(r1.getChangeId()).get(EnumSet.of(ListChangesOption.ALL_REVISIONS, ListChangesOption.PUSH_CERTIFICATES));
    RevisionInfo rev1 = info.revisions.get(r1.getCommit().name());
    assertThat(rev1).isNotNull();
    assertThat(rev1.pushCertificate).isNotNull();
    assertThat(rev1.pushCertificate.certificate).isNull();
    assertThat(rev1.pushCertificate.key).isNull();
    RevisionInfo rev2 = info.revisions.get(r2.getCommit().name());
    assertThat(rev2).isNotNull();
    assertThat(rev2.pushCertificate).isNotNull();
    assertThat(rev2.pushCertificate.certificate).isNull();
    assertThat(rev2.pushCertificate.key).isNull();
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevisionInfo(com.google.gerrit.extensions.common.RevisionInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) GerritConfig(com.google.gerrit.acceptance.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 9 with GerritConfig

use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.

the class GroupsIT method getSystemGroupByConfiguredName.

@Test
@GerritConfig(name = "groups.global:Anonymous-Users.name", value = "All Users")
public void getSystemGroupByConfiguredName() throws Exception {
    GroupReference anonymousUsersGroup = systemGroupBackend.getGroup(ANONYMOUS_USERS);
    assertThat(anonymousUsersGroup.getName()).isEqualTo("All Users");
    GroupInfo group = gApi.groups().id(anonymousUsersGroup.getUUID().get()).get();
    assertThat(group.name).isEqualTo(anonymousUsersGroup.getName());
    group = gApi.groups().id(anonymousUsersGroup.getName()).get();
    assertThat(group.id).isEqualTo(Url.encode((anonymousUsersGroup.getUUID().get())));
}
Also used : GroupAssert.assertGroupInfo(com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo) GroupInfo(com.google.gerrit.extensions.common.GroupInfo) GroupReference(com.google.gerrit.common.data.GroupReference) GerritConfig(com.google.gerrit.acceptance.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 10 with GerritConfig

use of com.google.gerrit.acceptance.GerritConfig in project gerrit by GerritCodeReview.

the class SubmoduleSubscriptionsIT method testSubmoduleShortCommitMessage.

@Test
@GerritConfig(name = "submodule.verboseSuperprojectUpdate", value = "false")
public void testSubmoduleShortCommitMessage() 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");
    pushChangeTo(subRepo, "master");
    createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
    // The first update doesn't include any commit messages
    ObjectId subRepoId = pushChangeTo(subRepo, "master");
    expectToHaveSubmoduleState(superRepo, "master", "subscribed-to-project", subRepoId);
    expectToHaveCommitMessage(superRepo, "master", "Update git submodules\n\n");
    // Any following update also has a short message
    subRepoId = pushChangeTo(subRepo, "master");
    expectToHaveSubmoduleState(superRepo, "master", "subscribed-to-project", subRepoId);
    expectToHaveCommitMessage(superRepo, "master", "Update git submodules\n\n");
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) GerritConfig(com.google.gerrit.acceptance.GerritConfig) Test(org.junit.Test)

Aggregations

GerritConfig (com.google.gerrit.acceptance.GerritConfig)19 Test (org.junit.Test)19 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)12 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)6 ChangeMessageInfo (com.google.gerrit.extensions.common.ChangeMessageInfo)5 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)4 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)3 ObjectId (org.eclipse.jgit.lib.ObjectId)3 ServerInfo (com.google.gerrit.extensions.common.ServerInfo)2 SuggestedReviewerInfo (com.google.gerrit.extensions.common.SuggestedReviewerInfo)2 ChangeData (com.google.gerrit.server.query.change.ChangeData)2 RevCommit (org.eclipse.jgit.revwalk.RevCommit)2 RestResponse (com.google.gerrit.acceptance.RestResponse)1 TestAccount (com.google.gerrit.acceptance.TestAccount)1 UseSsh (com.google.gerrit.acceptance.UseSsh)1 GroupAssert.assertGroupInfo (com.google.gerrit.acceptance.api.group.GroupAssert.assertGroupInfo)1 GroupReference (com.google.gerrit.common.data.GroupReference)1 RobotCommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.RobotCommentInput)1 RevisionApi (com.google.gerrit.extensions.api.changes.RevisionApi)1 SubmitInput (com.google.gerrit.extensions.api.changes.SubmitInput)1