use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class AccountIndexerIT method updateAccountWithoutCacheOrIndex.
private void updateAccountWithoutCacheOrIndex(Account.Id accountId, AccountDelta accountDelta) throws IOException, ConfigInvalidException {
try (Repository allUsersRepo = repoManager.openRepository(allUsersName);
MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, allUsersName, allUsersRepo)) {
PersonIdent ident = serverIdent.get();
md.getCommitBuilder().setAuthor(ident);
md.getCommitBuilder().setCommitter(ident);
AccountConfig accountConfig = new AccountConfig(accountId, allUsersName, allUsersRepo).load();
accountConfig.setAccountDelta(accountDelta);
accountConfig.commit(md);
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class AccessIT method grantRevertPermissionOnlyWorksOnce.
@Test
public void grantRevertPermissionOnlyWorksOnce() throws Exception {
grantRevertPermission.execute(newProjectName);
grantRevertPermission.execute(newProjectName);
try (Repository repo = repoManager.openRepository(newProjectName)) {
MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, newProjectName, repo);
ProjectConfig projectConfig = projectConfigFactory.read(md);
AccessSection all = projectConfig.getAccessSection(AccessSection.ALL);
Permission permission = all.getPermission(Permission.REVERT);
assertThat(permission.getRules()).hasSize(1);
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class ExternalIdIT method createCaseInsensitiveMigrationModeExternalIdBeforeTheMigration.
@Test
@GerritConfig(name = "auth.userNameCaseInsensitive", value = "true")
@GerritConfig(name = "auth.userNameCaseInsensitiveMigrationMode", value = "true")
public void createCaseInsensitiveMigrationModeExternalIdBeforeTheMigration() throws Exception {
Account.Id accountId = Account.id(66);
boolean isUserNameCaseInsensitive = false;
try (Repository allUsersRepo = repoManager.openRepository(allUsers);
MetaDataUpdate md = metaDataUpdateFactory.create(allUsers)) {
ExternalIdNotes extIdNotes = externalIdNotesFactory.load(allUsersRepo);
createExternalId(md, extIdNotes, SCHEME_GERRIT, "JaneDoe", accountId, isUserNameCaseInsensitive);
createExternalId(md, extIdNotes, SCHEME_USERNAME, "JaneDoe", accountId, isUserNameCaseInsensitive);
assertThat(getAccountId(extIdNotes, SCHEME_GERRIT, "JaneDoe")).isEqualTo(accountId.get());
assertThat(getExternalId(extIdNotes, SCHEME_GERRIT, "janedoe").isPresent()).isFalse();
assertThat(getAccountId(extIdNotes, SCHEME_USERNAME, "JaneDoe")).isEqualTo(accountId.get());
assertThat(getExternalId(extIdNotes, SCHEME_USERNAME, "janedoe").isPresent()).isFalse();
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class ExternalIdNotesUpsertPreprocessorIT method blockUpsert_replace.
@Test
public void blockUpsert_replace() throws Exception {
Account.Id id = Account.id(sequences.nextAccountId());
ExternalId extId1 = extIdFactory.create("foo", "bar", id, "email1@foo", "hash");
ExternalId extId2 = extIdFactory.create("foo", "bar", id, "email2@foo", "hash");
accountsUpdateProvider.get().insert("test", id, u -> u.addExternalId(extId1));
assertThat(accounts.get(id).get().externalIds()).containsExactly(extId1);
testPreprocessor.reset();
testPreprocessor.throwException = true;
try (Repository allUsersRepo = repoManager.openRepository(allUsers);
MetaDataUpdate md = metaDataUpdateFactory.create(allUsers)) {
ExternalIdNotes extIdNotes = extIdNotesFactory.load(allUsersRepo);
extIdNotes.replace(ImmutableSet.of(extId1), ImmutableSet.of(extId2));
StorageException e = assertThrows(StorageException.class, () -> extIdNotes.commit(md));
assertThat(e).hasMessageThat().contains("upsert not good");
}
assertThat(testPreprocessor.upserted).isEmpty();
assertThat(accounts.get(id).get().externalIds()).containsExactly(extId1);
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class ExternalIdNotesUpsertPreprocessorIT method upsert.
@Test
public void upsert() throws Exception {
Account.Id id = Account.id(sequences.nextAccountId());
ExternalId extId = extIdFactory.create("foo", "bar", id);
try (Repository allUsersRepo = repoManager.openRepository(allUsers);
MetaDataUpdate md = metaDataUpdateFactory.create(allUsers)) {
ExternalIdNotes extIdNotes = extIdNotesFactory.load(allUsersRepo);
extIdNotes.upsert(extId);
extIdNotes.commit(md);
}
assertThat(testPreprocessor.upserted).containsExactly(extId);
}
Aggregations