[skip ci] update DesktopServiceKtTest.kt
This commit is contained in:
parent
252bf48d3d
commit
921fda2d91
3 changed files with 19 additions and 21 deletions
|
@ -3,10 +3,9 @@ FROM ubuntu:latest
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
RUN apt-get update && apt-get -y install apt-utils sudo
|
RUN apt-get update && apt-get -y install apt-utils sudo
|
||||||
RUN useradd -m testuser && echo "testuserpw:testuser" | chpasswd && adduser testuser sudo
|
|
||||||
RUN echo "testuser ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/testuser
|
|
||||||
|
|
||||||
RUN useradd testuser2 && echo "testuser2pw:testuser2" | chpasswd && adduser testuser2 sudo
|
RUN useradd -m testuser && echo "testuser:testuserpw" | chpasswd && adduser testuser sudo
|
||||||
|
RUN echo "testuser ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/testuser
|
||||||
|
|
||||||
USER testuser
|
USER testuser
|
||||||
CMD /bin/bash
|
CMD /bin/bash
|
||||||
|
|
|
@ -71,7 +71,7 @@ dependencies {
|
||||||
api("org.jetbrains.kotlinx:kotlinx-serialization-core:1.3.2")
|
api("org.jetbrains.kotlinx:kotlinx-serialization-core:1.3.2")
|
||||||
api("org.jetbrains.kotlinx:kotlinx-cli:0.3.4")
|
api("org.jetbrains.kotlinx:kotlinx-cli:0.3.4")
|
||||||
|
|
||||||
api('com.charleskorn.kaml:kaml:0.43.0')
|
api('com.charleskorn.kaml:kaml:0.49.0')
|
||||||
|
|
||||||
api("org.slf4j:slf4j-api:1.7.36")
|
api("org.slf4j:slf4j-api:1.7.36")
|
||||||
api('ch.qos.logback:logback-classic:1.2.11')
|
api('ch.qos.logback:logback-classic:1.2.11')
|
||||||
|
|
|
@ -3,47 +3,46 @@ package org.domaindrivenarchitecture.provs.desktop.domain
|
||||||
import org.domaindrivenarchitecture.provs.desktop.infrastructure.getConfig
|
import org.domaindrivenarchitecture.provs.desktop.infrastructure.getConfig
|
||||||
import org.domaindrivenarchitecture.provs.framework.core.ProgressType
|
import org.domaindrivenarchitecture.provs.framework.core.ProgressType
|
||||||
import org.domaindrivenarchitecture.provs.framework.core.Prov
|
import org.domaindrivenarchitecture.provs.framework.core.Prov
|
||||||
|
import org.domaindrivenarchitecture.provs.framework.core.docker.provideContainer
|
||||||
import org.domaindrivenarchitecture.provs.framework.core.local
|
import org.domaindrivenarchitecture.provs.framework.core.local
|
||||||
import org.domaindrivenarchitecture.provs.framework.core.processors.ContainerStartMode
|
import org.domaindrivenarchitecture.provs.framework.core.processors.ContainerStartMode
|
||||||
import org.domaindrivenarchitecture.provs.framework.core.processors.ContainerUbuntuHostProcessor
|
import org.domaindrivenarchitecture.provs.framework.core.processors.ContainerUbuntuHostProcessor
|
||||||
import org.domaindrivenarchitecture.provs.framework.core.remote
|
import org.domaindrivenarchitecture.provs.framework.core.remote
|
||||||
|
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.deleteFile
|
||||||
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
|
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
|
||||||
import org.domaindrivenarchitecture.provs.test.defaultTestContainerName
|
|
||||||
import org.domaindrivenarchitecture.provs.test.tags.ContainerTest
|
|
||||||
import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest
|
import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest
|
||||||
import org.domaindrivenarchitecture.provs.test.testDockerWithSudo
|
import org.junit.jupiter.api.Assertions
|
||||||
import org.junit.jupiter.api.Assertions.assertTrue
|
import org.junit.jupiter.api.Assertions.assertTrue
|
||||||
import org.junit.jupiter.api.Disabled
|
import org.junit.jupiter.api.Disabled
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
internal class DesktopServiceKtTest {
|
internal class DesktopServiceKtTest {
|
||||||
|
|
||||||
@ContainerTest
|
@ExtensiveContainerTest
|
||||||
fun provisionLocalDesktop_fails_if_user_cannot_sudo_without_password() {
|
fun provisionLocalDesktop_fails_if_user_cannot_sudo_without_password() {
|
||||||
// given
|
// given
|
||||||
local().cmd( "sudo docker exec -it --user testuser2 provs-test-no-pw /bin/bash" )
|
val containerName = "prov-test-sudo-no-pw"
|
||||||
|
local().provideContainer(containerName, "ubuntu_plus_user")
|
||||||
val prov = Prov.newInstance(
|
val prov = Prov.newInstance(
|
||||||
ContainerUbuntuHostProcessor(
|
ContainerUbuntuHostProcessor(
|
||||||
"prov-test-no-pw",
|
containerName,
|
||||||
startMode = ContainerStartMode.USE_RUNNING_ELSE_CREATE,
|
startMode = ContainerStartMode.USE_RUNNING_ELSE_CREATE,
|
||||||
sudo = true,
|
sudo = true,
|
||||||
dockerImage = "ubuntu_plus_user"
|
dockerImage = "ubuntu_plus_user"
|
||||||
),
|
),
|
||||||
progressType = ProgressType.NONE
|
progressType = ProgressType.NONE
|
||||||
)
|
)
|
||||||
|
prov.deleteFile("/etc/sudoers.de/testuser", sudo = true) // remove no password required
|
||||||
|
|
||||||
// when
|
// when
|
||||||
// in order to test DesktopType.OFFICE: fix installing libreoffice for a fresh container as it hangs the first time but succeeds 2nd time
|
Assertions.assertThrows(Exception::class.java) {
|
||||||
val res = prov.provisionDesktop(
|
prov.provisionDesktop(
|
||||||
DesktopType.BASIC,
|
DesktopType.BASIC,
|
||||||
gitUserName = "testuser",
|
gitUserName = "testuser",
|
||||||
gitEmail = "testuser@test.org",
|
gitEmail = "testuser@test.org",
|
||||||
onlyModules = null
|
onlyModules = null
|
||||||
)
|
)
|
||||||
|
}
|
||||||
// then
|
|
||||||
assertTrue(res.success)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExtensiveContainerTest
|
@ExtensiveContainerTest
|
||||||
|
|
Loading…
Reference in a new issue