fix test gpgFingerprint_returnsCorrectFingerprint in pipeline

This commit is contained in:
az 2021-08-07 17:21:38 +02:00
parent 77f2cf7c10
commit 64eae8235e
4 changed files with 15 additions and 10 deletions

View file

@ -1,7 +1,6 @@
package io.provs.core.processors package io.provs.core.processors
import io.provs.core.platforms.SHELL import io.provs.core.platforms.SHELL
import io.provs.test.DEFAULT_START_MODE_TEST_CONTAINER
import io.provs.test.tags.ContainerTest import io.provs.test.tags.ContainerTest
import io.provs.test.testDockerWithSudo import io.provs.test.testDockerWithSudo
import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertEquals
@ -9,6 +8,7 @@ import org.junit.jupiter.api.Test
import org.junit.jupiter.api.condition.EnabledOnOs import org.junit.jupiter.api.condition.EnabledOnOs
import org.junit.jupiter.api.condition.OS.LINUX import org.junit.jupiter.api.condition.OS.LINUX
val DEFAULT_START_MODE_TEST_CONTAINER = ContainerStartMode.USE_RUNNING_ELSE_CREATE
class ContainerUbuntuHostProcessorTest { class ContainerUbuntuHostProcessorTest {

View file

@ -5,6 +5,7 @@ import io.provs.core.ProvResult
import io.provs.core.Secret import io.provs.core.Secret
import io.provs.core.docker.exitAndRmContainer import io.provs.core.docker.exitAndRmContainer
import io.provs.core.local import io.provs.core.local
import io.provs.core.processors.ContainerStartMode
import io.provs.test.defaultTestContainer import io.provs.test.defaultTestContainer
import io.provs.test.tags.ContainerTest import io.provs.test.tags.ContainerTest
import io.provs.test.tags.NonCi import io.provs.test.tags.NonCi
@ -73,8 +74,7 @@ internal class GopassBridgeKtTest {
@NonCi @NonCi
fun test_install_GopassBridgeJsonApi_with_incompatible_gopass_jsonapi_version_installed() { fun test_install_GopassBridgeJsonApi_with_incompatible_gopass_jsonapi_version_installed() {
// given // given
local().exitAndRmContainer("provs_test") val a = defaultTestContainer(ContainerStartMode.CREATE_NEW_KILL_EXISTING)
val a = defaultTestContainer()
val preparationResult = a.def { val preparationResult = a.def {
aptInstallCurl() aptInstallCurl()
@ -108,8 +108,7 @@ internal class GopassBridgeKtTest {
@NonCi @NonCi
fun test_install_GopassBridgeJsonApi_with_incompatible_gopass_version_installed() { fun test_install_GopassBridgeJsonApi_with_incompatible_gopass_version_installed() {
// given // given
local().exitAndRmContainer("provs_test") val a = defaultTestContainer(ContainerStartMode.CREATE_NEW_KILL_EXISTING)
val a = defaultTestContainer()
val preparationResult = a.def { val preparationResult = a.def {
aptInstallCurl() aptInstallCurl()
configureGpgKeys( configureGpgKeys(

View file

@ -2,8 +2,10 @@ package io.provs.ubuntu.keys.base
import io.provs.core.Prov import io.provs.core.Prov
import io.provs.core.Secret import io.provs.core.Secret
import io.provs.core.processors.ContainerStartMode
import io.provs.test.defaultTestContainer import io.provs.test.defaultTestContainer
import io.provs.test.tags.ContainerTest import io.provs.test.tags.ContainerTest
import io.provs.ubuntu.install.base.aptInstall
import io.provs.ubuntu.keys.KeyPair import io.provs.ubuntu.keys.KeyPair
import io.provs.ubuntu.keys.privateGPGSnakeoilKey import io.provs.ubuntu.keys.privateGPGSnakeoilKey
import io.provs.ubuntu.keys.publicGPGSnakeoilKey import io.provs.ubuntu.keys.publicGPGSnakeoilKey
@ -14,9 +16,15 @@ import org.junit.jupiter.api.Test
internal class GpgKtTest { internal class GpgKtTest {
@Test @Test
@ContainerTest
fun gpgFingerprint_returnsCorrectFingerprint() { fun gpgFingerprint_returnsCorrectFingerprint() {
// given
val a = defaultTestContainer(ContainerStartMode.CREATE_NEW_KILL_EXISTING)
a.aptInstall("gpg")
a.cmd("gpg --version") // just for info reasons
// when // when
val fingerprint = Prov.defaultInstance().gpgFingerprint(publicGPGSnakeoilKey()) val fingerprint = a.gpgFingerprint(publicGPGSnakeoilKey())
// then // then
assertEquals("85052C6954262D61D4E9977E0674104CA81A4905", fingerprint) assertEquals("85052C6954262D61D4E9977E0674104CA81A4905", fingerprint)

View file

@ -8,13 +8,11 @@ import io.provs.core.docker.dockerimages.UbuntuPlusUser
import io.provs.core.processors.ContainerStartMode import io.provs.core.processors.ContainerStartMode
import io.provs.core.processors.ContainerUbuntuHostProcessor import io.provs.core.processors.ContainerUbuntuHostProcessor
val DEFAULT_START_MODE_TEST_CONTAINER = ContainerStartMode.USE_RUNNING_ELSE_CREATE
val testDockerWithSudo = !"true".equals(System.getProperty("testdockerwithoutsudo")?.toLowerCase()) val testDockerWithSudo = !"true".equals(System.getProperty("testdockerwithoutsudo")?.toLowerCase())
const val defaultTestContainerName = "provs_test" const val defaultTestContainerName = "provs_test"
fun defaultTestContainer(): Prov { fun defaultTestContainer(startMode: ContainerStartMode = ContainerStartMode.USE_RUNNING_ELSE_CREATE): Prov {
val image = UbuntuPlusUser() val image = UbuntuPlusUser()
val prov = testLocal() val prov = testLocal()
if (!prov.dockerImageExists(image.imageName(), testDockerWithSudo)) { if (!prov.dockerImageExists(image.imageName(), testDockerWithSudo)) {
@ -24,7 +22,7 @@ fun defaultTestContainer(): Prov {
return Prov.newInstance( return Prov.newInstance(
ContainerUbuntuHostProcessor( ContainerUbuntuHostProcessor(
defaultTestContainerName, defaultTestContainerName,
startMode = DEFAULT_START_MODE_TEST_CONTAINER, startMode = startMode,
sudo = testDockerWithSudo, sudo = testDockerWithSudo,
dockerImage = image.imageName() dockerImage = image.imageName()
), ),