use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class ExternalIdIT method createCaseSensitiveExternalId_SchemeWithoutUsername.
@Test
@GerritConfig(name = "auth.userNameCaseInsensitive", value = "true")
public void createCaseSensitiveExternalId_SchemeWithoutUsername() throws Exception {
try (Repository allUsersRepo = repoManager.openRepository(allUsers);
MetaDataUpdate md = metaDataUpdateFactory.create(allUsers)) {
ExternalIdNotes extIdNotes = externalIdNotesFactory.load(allUsersRepo);
testCaseSensitiveExternalIdKey(md, extIdNotes, SCHEME_MAILTO, "Jane@doe.com", Account.id(66));
testCaseSensitiveExternalIdKey(md, extIdNotes, SCHEME_UUID, "1234ABCD", Account.id(66));
testCaseSensitiveExternalIdKey(md, extIdNotes, SCHEME_GPGKEY, "1234ABCD", Account.id(66));
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class ExternalIdIT method insertExtIdForNonExistingAccount.
private void insertExtIdForNonExistingAccount(ExternalId extId) throws Exception {
// Cannot use AccountsUpdate to insert an external ID for a non-existing account.
try (Repository repo = repoManager.openRepository(allUsers);
MetaDataUpdate update = metaDataUpdateFactory.create(allUsers)) {
ExternalIdNotes extIdNotes = externalIdNotesFactory.load(repo);
extIdNotes.insert(extId);
extIdNotes.commit(update);
externalIdNotesFactory.updateExternalIdCacheAndMaybeReindexAccounts(extIdNotes, ImmutableList.of());
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class ExternalIdIT method createCaseInsensitiveExternalId_DuplicateKey.
@Test
@GerritConfig(name = "auth.userNameCaseInsensitive", value = "true")
public void createCaseInsensitiveExternalId_DuplicateKey() throws Exception {
try (Repository allUsersRepo = repoManager.openRepository(allUsers);
MetaDataUpdate md = metaDataUpdateFactory.create(allUsers)) {
ExternalIdNotes extIdNotes = externalIdNotesFactory.load(allUsersRepo);
testCaseInsensitiveExternalIdKey(md, extIdNotes, SCHEME_USERNAME, "JohnDoe", Account.id(42));
assertThrows(DuplicateExternalIdKeyException.class, () -> extIdNotes.insert(externalIdFactory.create(SCHEME_USERNAME, "johndoe", Account.id(23))));
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class ExternalIdIT method addExtId.
private void addExtId(TestRepository<?> testRepo, ExternalId... extIds) throws IOException, DuplicateKeyException, ConfigInvalidException {
ExternalIdNotes extIdNotes = externalIdNotesFactory.load(testRepo.getRepository());
extIdNotes.insert(Arrays.asList(extIds));
try (MetaDataUpdate metaDataUpdate = new MetaDataUpdate(GitReferenceUpdated.DISABLED, null, testRepo.getRepository())) {
metaDataUpdate.getCommitBuilder().setAuthor(admin.newIdent());
metaDataUpdate.getCommitBuilder().setCommitter(admin.newIdent());
extIdNotes.commit(metaDataUpdate);
externalIdNotesFactory.updateExternalIdCacheAndMaybeReindexAccounts(extIdNotes, ImmutableList.of());
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class ExternalIdIT method insertExtIdBehindGerritsBack.
private void insertExtIdBehindGerritsBack(ExternalId extId) throws Exception {
try (Repository repo = repoManager.openRepository(allUsers)) {
// Inserting an external ID "behind Gerrit's back" means that the caches are not updated.
ExternalIdNotes extIdNotes = ExternalIdNotes.load(allUsers, repo, externalIdFactory, IS_USER_NAME_CASE_INSENSITIVE_MIGRATION_MODE);
extIdNotes.insert(extId);
try (MetaDataUpdate metaDataUpdate = new MetaDataUpdate(GitReferenceUpdated.DISABLED, null, repo)) {
metaDataUpdate.getCommitBuilder().setAuthor(admin.newIdent());
metaDataUpdate.getCommitBuilder().setCommitter(admin.newIdent());
extIdNotes.commit(metaDataUpdate);
}
}
}
Aggregations