Search in sources :

Example 31 with ExternalIdNotes

use of com.google.gerrit.server.account.externalids.ExternalIdNotes 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();
    }
}
Also used : Repository(org.eclipse.jgit.lib.Repository) ExternalIdNotes(com.google.gerrit.server.account.externalids.ExternalIdNotes) MetaDataUpdate(com.google.gerrit.server.git.meta.MetaDataUpdate) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

ExternalIdNotes (com.google.gerrit.server.account.externalids.ExternalIdNotes)31 MetaDataUpdate (com.google.gerrit.server.git.meta.MetaDataUpdate)29 Repository (org.eclipse.jgit.lib.Repository)28 Test (org.junit.Test)23 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)18 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)14 ExternalId (com.google.gerrit.server.account.externalids.ExternalId)13 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)12 TestRepository (org.eclipse.jgit.junit.TestRepository)12 Account (com.google.gerrit.entities.Account)11 LightweightPluginDaemonTest (com.google.gerrit.acceptance.LightweightPluginDaemonTest)5 TestAccount (com.google.gerrit.acceptance.TestAccount)5 FactoryModule (com.google.gerrit.extensions.config.FactoryModule)2 GitReferenceUpdated (com.google.gerrit.server.extensions.events.GitReferenceUpdated)2 GitRepositoryManager (com.google.gerrit.server.git.GitRepositoryManager)2 Injector (com.google.inject.Injector)2 PersonIdent (org.eclipse.jgit.lib.PersonIdent)2 DuplicateKeyException (com.google.gerrit.exceptions.DuplicateKeyException)1 StorageException (com.google.gerrit.exceptions.StorageException)1 AccountInfo (com.google.gerrit.extensions.common.AccountInfo)1