use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class ProjectConfigTest method commit.
private RevCommit commit(ProjectConfig cfg) throws IOException, MissingObjectException, IncorrectObjectTypeException {
try (MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, cfg.getProject().getNameKey(), db)) {
tr.tick(5);
tr.setAuthorAndCommitter(md.getCommitBuilder());
md.setMessage("Edit\n");
cfg.commit(md);
Ref ref = db.exactRef(RefNames.REFS_CONFIG);
return tr.getRevWalk().parseCommit(ref.getObjectId());
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class RefControlTest method setUp.
@Before
public void setUp() throws Exception {
Injector injector = Guice.createInjector(new InMemoryModule());
injector.injectMembers(this);
// Tests previously used ProjectConfig.Factory to create ProjectConfigs without going through
// the ProjectCache, which was wrong. Manually call getInstance so we don't store it in a
// field that is accessible to test methods.
ProjectConfig.Factory projectConfigFactory = injector.getInstance(ProjectConfig.Factory.class);
singleVersionListener.start();
try {
schemaCreator.create();
} finally {
singleVersionListener.stop();
}
// changing defaults in SchemaCreator or ProjectCreator.
try (Repository allProjectsRepo = repoManager.createRepository(allProjectsName);
TestRepository<Repository> tr = new TestRepository<>(allProjectsRepo)) {
tr.delete(REFS_CONFIG);
try (MetaDataUpdate md = metaDataUpdateFactory.create(allProjectsName)) {
ProjectConfig allProjectsConfig = projectConfigFactory.create(allProjectsName);
allProjectsConfig.load(md);
LabelType cr = TestLabels.codeReview();
allProjectsConfig.upsertLabelType(cr);
allProjectsConfig.commit(md);
}
}
repoManager.createRepository(parentKey).close();
repoManager.createRepository(localKey).close();
try (MetaDataUpdate md = metaDataUpdateFactory.create(localKey)) {
ProjectConfig newLocal = projectConfigFactory.create(localKey);
newLocal.load(md);
newLocal.updateProject(p -> p.setParent(parentKey));
newLocal.commit(md);
}
requestContext.setContext(() -> null);
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class ExternalIdIT method unsetEmail.
@Test
public void unsetEmail() throws Exception {
ExternalId extId = externalIdFactory.createWithEmail("x", "1", user.id(), "x@example.com");
insertExtId(extId);
ExternalId extIdWithoutEmail = externalIdFactory.create("x", "1", user.id());
try (Repository allUsersRepo = repoManager.openRepository(allUsers);
MetaDataUpdate md = metaDataUpdateFactory.create(allUsers)) {
ExternalIdNotes extIdNotes = externalIdNotesFactory.load(allUsersRepo);
extIdNotes.upsert(extIdWithoutEmail);
extIdNotes.commit(md);
assertThat(extIdNotes.get(extId.key())).hasValue(extIdWithoutEmail);
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class ExternalIdIT method createCaseInsensitiveExternalId_SchemeWithUsername.
@Test
@GerritConfig(name = "auth.userNameCaseInsensitive", value = "true")
public void createCaseInsensitiveExternalId_SchemeWithUsername() throws Exception {
try (Repository allUsersRepo = repoManager.openRepository(allUsers);
MetaDataUpdate md = metaDataUpdateFactory.create(allUsers)) {
ExternalIdNotes extIdNotes = externalIdNotesFactory.load(allUsersRepo);
testCaseInsensitiveExternalIdKey(md, extIdNotes, SCHEME_USERNAME, "janedoe", Account.id(66));
testCaseInsensitiveExternalIdKey(md, extIdNotes, SCHEME_GERRIT, "JaneDoe", Account.id(66));
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class ExternalIdIT method createCaseInsensitiveMigrationModeExternalIdAccountDuringTheMigration.
@Test
@GerritConfig(name = "auth.userNameCaseInsensitive", value = "true")
@GerritConfig(name = "auth.userNameCaseInsensitiveMigrationMode", value = "true")
public void createCaseInsensitiveMigrationModeExternalIdAccountDuringTheMigration() throws Exception {
Account.Id accountId = Account.id(66);
boolean userNameCaseInsensitive = true;
try (Repository allUsersRepo = repoManager.openRepository(allUsers);
MetaDataUpdate md = metaDataUpdateFactory.create(allUsers)) {
ExternalIdNotes extIdNotes = externalIdNotesFactory.load(allUsersRepo);
createExternalId(md, extIdNotes, SCHEME_GERRIT, "JonDoe", accountId, !userNameCaseInsensitive);
createExternalId(md, extIdNotes, SCHEME_USERNAME, "JonDoe", accountId, !userNameCaseInsensitive);
createExternalId(md, extIdNotes, SCHEME_GERRIT, "JaneDoe", accountId, userNameCaseInsensitive);
createExternalId(md, extIdNotes, SCHEME_USERNAME, "JaneDoe", accountId, userNameCaseInsensitive);
assertThat(getAccountId(extIdNotes, SCHEME_GERRIT, "JonDoe")).isEqualTo(accountId.get());
assertThat(getExternalId(extIdNotes, SCHEME_GERRIT, "jondoe").isPresent()).isFalse();
assertThat(getAccountId(extIdNotes, SCHEME_USERNAME, "JonDoe")).isEqualTo(accountId.get());
assertThat(getExternalId(extIdNotes, SCHEME_USERNAME, "jondoe").isPresent()).isFalse();
assertThat(getAccountId(extIdNotes, SCHEME_GERRIT, "JaneDoe")).isEqualTo(accountId.get());
assertThat(getAccountId(extIdNotes, SCHEME_GERRIT, "janedoe")).isEqualTo(accountId.get());
assertThat(getAccountId(extIdNotes, SCHEME_USERNAME, "JaneDoe")).isEqualTo(accountId.get());
assertThat(getAccountId(extIdNotes, SCHEME_USERNAME, "janedoe")).isEqualTo(accountId.get());
}
}
Aggregations