From 3291fc2ccdcd59f2f52950ca837d34423ddc8ae9 Mon Sep 17 00:00:00 2001 From: az Date: Sun, 30 Apr 2023 15:31:31 +0200 Subject: [PATCH] [skip ci] fix firefox installation by allowing downgrades after having removed snap ff --- .../provs/desktop/infrastructure/Firefox.kt | 2 +- .../desktop/infrastructure/FirefoxKtTest.kt | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt index 5b590b4..6ce584a 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt @@ -38,5 +38,5 @@ fun Prov.installFirefox() = task { ) aptInstall("firefox") - cmd("apt-get upgrade -y firefox", sudo = true) + cmd("apt-get upgrade -y --allow-downgrades firefox", sudo = true) } diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt index 018a36d..9c9386c 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt @@ -1,12 +1,18 @@ package org.domaindrivenarchitecture.provs.desktop.infrastructure +import org.domaindrivenarchitecture.provs.framework.core.remote import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.checkPackageInstalled +import org.domaindrivenarchitecture.provs.framework.ubuntu.secret.secretSources.PromptSecretSource import org.domaindrivenarchitecture.provs.test.defaultTestContainer import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test internal class FirefoxKtTest { + // Attention: this test does not test full functionality of installFirefox, e.g. does not test + // remove snap, as this test runs against a container which does not have snap-firefox installed @ExtensiveContainerTest fun installFirefox() { // when @@ -18,4 +24,29 @@ internal class FirefoxKtTest { // then assertTrue(result.success) } + + @Test + @Disabled("Update connection details,then enable and run manually") + fun installFirefox_remotely() { + val host = "192.168.56.123" + val user = "user" + var firefoxVersion = "" + + // when + val result = remote( + host, + user, + /* remove for ssh authentication */ + PromptSecretSource("Remote password for user $user").secret() + ).session { + installFirefox() + firefoxVersion = cmd("apt list firefox --installed").out ?: "" + checkPackageInstalled("firefox") + } + + // then + assertTrue(result.success) + println("Firefox: $firefoxVersion") + assertTrue(firefoxVersion.contains("ubuntu") && !firefoxVersion.contains("snap")) + } }