use of com.google.gerrit.extensions.api.config.ConsistencyCheckInput in project gerrit by GerritCodeReview.
the class GroupsConsistencyIT method check.
private List<ConsistencyProblemInfo> check() throws Exception {
ConsistencyCheckInput in = new ConsistencyCheckInput();
in.checkGroups = new ConsistencyCheckInput.CheckGroupsInput();
ConsistencyCheckInfo info = gApi.config().server().checkConsistency(in);
return info.checkGroupsResult.problems;
}
use of com.google.gerrit.extensions.api.config.ConsistencyCheckInput in project gerrit by GerritCodeReview.
the class AccountIT method checkConsistency.
@Test
public void checkConsistency() throws Exception {
projectOperations.allProjectsForUpdate().add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS)).update();
requestScopeOperations.resetCurrentApiUser();
// Create an account with a preferred email.
String username = name("foo");
String email = username + "@example.com";
TestAccount account = accountCreator.create(username, email, "Foo Bar", null);
ConsistencyCheckInput input = new ConsistencyCheckInput();
input.checkAccounts = new CheckAccountsInput();
ConsistencyCheckInfo checkInfo = gApi.config().server().checkConsistency(input);
assertThat(checkInfo.checkAccountsResult.problems).isEmpty();
Set<ConsistencyProblemInfo> expectedProblems = new HashSet<>();
// Delete the external ID for the preferred email. This makes the account inconsistent since it
// now doesn't have an external ID for its preferred email.
accountsUpdateProvider.get().update("Delete External ID", account.id(), u -> u.deleteExternalId(externalIdFactory.createEmail(account.id(), email)));
expectedProblems.add(new ConsistencyProblemInfo(ConsistencyProblemInfo.Status.ERROR, "Account '" + account.id().get() + "' has no external ID for its preferred email '" + email + "'"));
checkInfo = gApi.config().server().checkConsistency(input);
assertThat(checkInfo.checkAccountsResult.problems).hasSize(expectedProblems.size());
assertThat(checkInfo.checkAccountsResult.problems).containsExactlyElementsIn(expectedProblems);
}
use of com.google.gerrit.extensions.api.config.ConsistencyCheckInput in project gerrit by GerritCodeReview.
the class ExternalIdIT method checkConsistency.
@Test
public void checkConsistency() throws Exception {
projectOperations.allProjectsForUpdate().add(allowCapability(GlobalCapability.ACCESS_DATABASE).group(REGISTERED_USERS)).update();
requestScopeOperations.resetCurrentApiUser();
insertValidExternalIds();
ConsistencyCheckInput input = new ConsistencyCheckInput();
input.checkAccountExternalIds = new CheckAccountExternalIdsInput();
ConsistencyCheckInfo checkInfo = gApi.config().server().checkConsistency(input);
assertThat(checkInfo.checkAccountExternalIdsResult.problems).isEmpty();
Set<ConsistencyProblemInfo> expectedProblems = new HashSet<>();
expectedProblems.addAll(insertInvalidButParsableExternalIds());
expectedProblems.addAll(insertNonParsableExternalIds());
checkInfo = gApi.config().server().checkConsistency(input);
assertThat(checkInfo.checkAccountExternalIdsResult.problems).hasSize(expectedProblems.size());
assertThat(checkInfo.checkAccountExternalIdsResult.problems).containsExactlyElementsIn(expectedProblems);
}
use of com.google.gerrit.extensions.api.config.ConsistencyCheckInput in project gerrit by GerritCodeReview.
the class ExternalIdIT method checkConsistencyNotAllowed.
@Test
public void checkConsistencyNotAllowed() {
AuthException thrown = assertThrows(AuthException.class, () -> gApi.config().server().checkConsistency(new ConsistencyCheckInput()));
assertThat(thrown).hasMessageThat().contains("access database not permitted");
}
Aggregations