use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class ExternalIdIT method createCaseInsensitiveMigrationModeExternalIdAccountAfterTheMigration.
@Test
@GerritConfig(name = "auth.userNameCaseInsensitive", value = "true")
@GerritConfig(name = "auth.userNameCaseInsensitiveMigrationMode", value = "true")
public void createCaseInsensitiveMigrationModeExternalIdAccountAfterTheMigration() throws Exception {
Account.Id accountId = Account.id(66);
boolean isUserNameCaseInsensitive = true;
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(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());
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class OnlineExternalIdCaseSensivityMigratorIT method shouldNotThrowExceptionDuringTheMigrationForExternalIdsWithCaseInsensitiveSha1.
@Test
@GerritConfig(name = "auth.userNameCaseInsensitive", value = "true")
@GerritConfig(name = "auth.userNameCaseInsensitiveMigrationMode", value = "true")
public void shouldNotThrowExceptionDuringTheMigrationForExternalIdsWithCaseInsensitiveSha1() throws IOException, ConfigInvalidException {
final boolean caseInsensitiveUserName = true;
try (Repository allUsersRepo = repoManager.openRepository(allUsers);
MetaDataUpdate md = metaDataUpdateFactory.create(allUsers)) {
ExternalIdNotes extIdNotes = externalIdNotesFactory.load(allUsersRepo);
createExternalId(md, extIdNotes, SCHEME_GERRIT, "JonDoe", accountId, caseInsensitiveUserName);
createExternalId(md, extIdNotes, SCHEME_USERNAME, "JonDoe", accountId, caseInsensitiveUserName);
assertThat(getExactExternalId(extIdNotes, SCHEME_GERRIT, "JonDoe").isPresent()).isFalse();
assertThat(getExactExternalId(extIdNotes, SCHEME_GERRIT, "jondoe").isPresent()).isTrue();
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "JonDoe").isPresent()).isFalse();
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "jondoe").isPresent()).isTrue();
objectUnderTest.migrate();
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class OnlineExternalIdCaseSensivityMigratorIT method caseInsensitivityShouldWorkAfterMigration.
@Test
@GerritConfig(name = "auth.userNameCaseInsensitive", value = "true")
@GerritConfig(name = "auth.userNameCaseInsensitiveMigrationMode", value = "true")
public void caseInsensitivityShouldWorkAfterMigration() throws IOException, ConfigInvalidException {
try (Repository allUsersRepo = repoManager.openRepository(allUsers);
MetaDataUpdate md = metaDataUpdateFactory.create(allUsers)) {
ExternalIdNotes extIdNotes = externalIdNotesFactory.load(allUsersRepo);
createExternalId(md, extIdNotes, SCHEME_USERNAME, "JonDoe", accountId, isUserNameCaseInsensitive);
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "JonDoe").isPresent()).isTrue();
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "jondoe").isPresent()).isFalse();
objectUnderTest.migrate();
extIdNotes = externalIdNotesFactory.load(allUsersRepo);
assertThat(getExternalIdWithCaseInsensitive(extIdNotes, SCHEME_USERNAME, "JonDoe").isPresent()).isTrue();
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "jondoe").isPresent()).isTrue();
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class OnlineExternalIdCaseSensivityMigratorIT method shouldNotCreateDuplicateExternaIdNotesWhenUpdatingAccount.
@Test
@GerritConfig(name = "auth.userNameCaseInsensitive", value = "true")
@GerritConfig(name = "auth.userNameCaseInsensitiveMigrationMode", value = "true")
public void shouldNotCreateDuplicateExternaIdNotesWhenUpdatingAccount() throws IOException, ConfigInvalidException {
try (Repository allUsersRepo = repoManager.openRepository(allUsers);
MetaDataUpdate md = metaDataUpdateFactory.create(allUsers)) {
ExternalIdNotes extIdNotes = externalIdNotesFactory.load(allUsersRepo);
createExternalId(md, extIdNotes, SCHEME_GERRIT, "JonDoe", accountId, isUserNameCaseInsensitive);
createExternalId(md, extIdNotes, SCHEME_USERNAME, "JonDoe", accountId, isUserNameCaseInsensitive);
extIdNotes = externalIdNotesFactory.load(allUsersRepo);
ExternalId extId = externalIdFactory.create(externalIdKeyFactory.create(SCHEME_USERNAME, "JonDoe", true), accountId, "test@email.com", "w1m9Bg85GQ4hijLNxW+6xAfj4r9wyk9rzVQelIHxuQ");
extIdNotes.upsert(extId);
extIdNotes.commit(md);
extIdNotes = externalIdNotesFactory.load(allUsersRepo);
assertThat(getExactExternalId(extIdNotes, SCHEME_GERRIT, "JonDoe").isPresent()).isTrue();
assertThat(getExactExternalId(extIdNotes, SCHEME_GERRIT, "jondoe").isPresent()).isFalse();
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "JonDoe").isPresent()).isTrue();
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "jondoe").isPresent()).isFalse();
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "JonDoe").get().email()).isEqualTo("test@email.com");
objectUnderTest.migrate();
extIdNotes = externalIdNotesFactory.load(allUsersRepo);
assertThat(getExactExternalId(extIdNotes, SCHEME_GERRIT, "JonDoe").isPresent()).isFalse();
assertThat(getExactExternalId(extIdNotes, SCHEME_GERRIT, "jondoe").isPresent()).isTrue();
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "JonDoe").isPresent()).isFalse();
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "jondoe").isPresent()).isTrue();
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "jondoe").get().email()).isEqualTo("test@email.com");
}
}
use of com.google.gerrit.server.git.meta.MetaDataUpdate in project gerrit by GerritCodeReview.
the class OnlineExternalIdCaseSensivityMigratorIT method shouldSkipMigrationWhenUserNameCaseInsensitiveIsSetToFalse.
@Test
@GerritConfig(name = "auth.userNameCaseInsensitive", value = "false")
@GerritConfig(name = "auth.userNameCaseInsensitiveMigrationMode", value = "true")
public void shouldSkipMigrationWhenUserNameCaseInsensitiveIsSetToFalse() throws RepositoryNotFoundException, IOException, ConfigInvalidException {
try (Repository allUsersRepo = repoManager.openRepository(allUsers);
MetaDataUpdate md = metaDataUpdateFactory.create(allUsers)) {
ExternalIdNotes extIdNotes = externalIdNotesFactory.load(allUsersRepo);
createExternalId(md, extIdNotes, SCHEME_USERNAME, "JonDoe", accountId, isUserNameCaseInsensitive);
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "JonDoe").isPresent()).isTrue();
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "jondoe").isPresent()).isFalse();
objectUnderTest.migrate();
extIdNotes = externalIdNotesFactory.load(allUsersRepo);
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "JonDoe").isPresent()).isTrue();
assertThat(getExactExternalId(extIdNotes, SCHEME_USERNAME, "jondoe").isPresent()).isFalse();
}
}
Aggregations