GetServerInfo: Include configured contributor agreements
When contributor agreements are enabled, include the list of configured contributor agreements in the `auth` section. Add support to get the server info via the API, and use this in the existing agreements acceptance test to verify that the agreements are returned as expected. Change-Id: Ie6c8d25a4cd1519e3a42eb4cb3e6aeea77e56651
This commit is contained in:
@@ -24,6 +24,7 @@ import com.google.gerrit.common.data.GroupReference;
|
||||
import com.google.gerrit.common.data.PermissionRule;
|
||||
import com.google.gerrit.extensions.api.groups.GroupApi;
|
||||
import com.google.gerrit.extensions.common.AgreementInfo;
|
||||
import com.google.gerrit.extensions.common.ServerInfo;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
@@ -75,6 +76,25 @@ public class AgreementsIT extends AbstractDaemonTest {
|
||||
setApiUser(user);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailableAgreements() throws Exception {
|
||||
ServerInfo info = gApi.config().server().getInfo();
|
||||
if (isContributorAgreementsEnabled()) {
|
||||
assertThat(info.auth.useContributorAgreements).isTrue();
|
||||
assertThat(info.auth.contributorAgreements).hasSize(2);
|
||||
AgreementInfo agreementInfo = info.auth.contributorAgreements.get(0);
|
||||
assertThat(agreementInfo.name).isEqualTo(ca.getName());
|
||||
assertThat(agreementInfo.autoVerifyGroup.name)
|
||||
.isEqualTo(ca.getAutoVerify().getName());
|
||||
agreementInfo = info.auth.contributorAgreements.get(1);
|
||||
assertThat(agreementInfo.name).isEqualTo(ca2.getName());
|
||||
assertThat(agreementInfo.autoVerifyGroup).isNull();
|
||||
} else {
|
||||
assertThat(info.auth.useContributorAgreements).isNull();
|
||||
assertThat(info.auth.contributorAgreements).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void signNonExistingAgreement() throws Exception {
|
||||
assume().that(isContributorAgreementsEnabled()).isTrue();
|
||||
|
||||
Reference in New Issue
Block a user