diff --git a/src/test/kotlin/com/jetpackduba/gitnuro/app/git/BeforeRepoAllTestsExtension.kt b/src/test/kotlin/com/jetpackduba/gitnuro/app/git/BeforeRepoAllTestsExtension.kt index 2cfbafc..ec9ffb5 100644 --- a/src/test/kotlin/com/jetpackduba/gitnuro/app/git/BeforeRepoAllTestsExtension.kt +++ b/src/test/kotlin/com/jetpackduba/gitnuro/app/git/BeforeRepoAllTestsExtension.kt @@ -1,13 +1,13 @@ package com.jetpackduba.gitnuro.app.git -import com.jetpackduba.gitnuro.credentials.GProcess -import com.jetpackduba.gitnuro.credentials.GRemoteSession -import com.jetpackduba.gitnuro.credentials.GSessionManager +import com.jetpackduba.gitnuro.credentials.* +import com.jetpackduba.gitnuro.di.factories.HttpCredentialsFactory import com.jetpackduba.gitnuro.git.remote_operations.CloneRepositoryUseCase import com.jetpackduba.gitnuro.git.remote_operations.HandleTransportUseCase import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.runBlocking +import org.eclipse.jgit.api.Git import org.junit.jupiter.api.extension.AfterAllCallback import org.junit.jupiter.api.extension.BeforeAllCallback import org.junit.jupiter.api.extension.ExtensionContext @@ -32,12 +32,21 @@ class BeforeRepoAllTestsExtension : BeforeAllCallback, AfterAllCallback { // The following line registers a callback hook when the root test context is shut down context.root.getStore(GLOBAL).put("gitnuro_tests", this) + val credentialsStateManager = CredentialsStateManager() val cloneRepositoryUseCase = - CloneRepositoryUseCase(HandleTransportUseCase(GSessionManager { GRemoteSession { GProcess() } })) + CloneRepositoryUseCase( + HandleTransportUseCase( + sessionManager = GSessionManager { GRemoteSession({ GProcess() }, credentialsStateManager) }, + httpCredentialsProvider = object : HttpCredentialsFactory { + override fun create(git: Git?): HttpCredentialsProvider = + HttpCredentialsProvider(credentialsStateManager, git) + }, + ) + ) cloneRepositoryUseCase(repoDir, REPO_URL) .flowOn(Dispatchers.IO) .collect { newCloneStatus -> - println("Clonning test repository: $newCloneStatus") + println("Cloning test repository: $newCloneStatus") } } }