-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-458 Provide working directory to FS storage implementation and fix…
… repository initialization. Bump CDN to 1.9.1 and cover deployment with its unit test
- Loading branch information
Showing
18 changed files
with
116 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
reposilite-backend/src/test/kotlin/org/panda_lang/reposilite/maven/MavenFacadeTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.panda_lang.reposilite.maven | ||
|
||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Assertions.assertFalse | ||
import org.junit.jupiter.api.Assertions.fail | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.EnumSource | ||
import org.panda_lang.reposilite.config.Configuration.RepositoryConfiguration | ||
import org.panda_lang.reposilite.maven.api.DeployRequest | ||
import org.panda_lang.reposilite.maven.api.FileType.FILE | ||
import org.panda_lang.reposilite.maven.api.RepositoryVisibility | ||
|
||
internal class MavenFacadeTest : MavenSpec() { | ||
|
||
override fun repositories() = mapOf( | ||
"public" to RepositoryConfiguration().also { | ||
it.visibility = RepositoryVisibility.PUBLIC | ||
}, | ||
"hidden" to RepositoryConfiguration().also { | ||
it.visibility = RepositoryVisibility.HIDDEN | ||
}, | ||
"private" to RepositoryConfiguration().also { | ||
it.visibility = RepositoryVisibility.PRIVATE | ||
} | ||
) | ||
|
||
@ParameterizedTest | ||
@EnumSource(RepositoryVisibility::class) | ||
fun `should deploy file under the given path`(visibility: RepositoryVisibility) { | ||
// given: an uri and file to store | ||
val repository = visibility.name.lowercase() | ||
val gav = "/org/panda-lang/reposilite/3.0.0/reposilite-3.0.0.jar" | ||
val by = "[email protected]" | ||
val file = "content".byteInputStream() | ||
|
||
// when: the following file is deployed | ||
val fileDetails = mavenFacade.deployFile(DeployRequest(repository, gav, by, file)) | ||
.onError { fail { it.toString() } } | ||
.get() | ||
|
||
// then: file has been successfully stored | ||
assertEquals(FILE, fileDetails.type) | ||
assertEquals("reposilite-3.0.0.jar", fileDetails.name) | ||
assertFalse(fileDetails.isReadable()) | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
reposilite-backend/src/test/kotlin/org/panda_lang/reposilite/maven/MavenSpec.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.panda_lang.reposilite.maven | ||
|
||
import net.dzikoysk.dynamiclogger.backend.InMemoryLogger | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.io.TempDir | ||
import org.panda_lang.reposilite.config.Configuration.RepositoryConfiguration | ||
import org.panda_lang.reposilite.failure.FailureFacade | ||
import java.io.File | ||
|
||
@Suppress("LeakingThis") | ||
internal abstract class MavenSpec { | ||
|
||
@TempDir | ||
@JvmField | ||
var workingDirectory: File? = null | ||
|
||
lateinit var mavenFacade: MavenFacade | ||
|
||
@BeforeEach | ||
private fun initializeFacade() { | ||
val logger = InMemoryLogger() | ||
val failureFacade = FailureFacade(logger) | ||
val metadataService = MetadataService(failureFacade) | ||
val repositorySecurityProvider = RepositorySecurityProvider() | ||
val repositoryService = RepositoryServiceFactory.createRepositoryService(logger, workingDirectory!!.toPath(), repositories()) | ||
|
||
this.mavenFacade = MavenFacade(logger, metadataService, repositorySecurityProvider, repositoryService) | ||
} | ||
|
||
protected abstract fun repositories(): Map<String, RepositoryConfiguration> | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters