2021-09-10 13:14:56 +02:00
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
from mamba import description, context, it
|
|
|
|
from expects import expect, equal
|
|
|
|
|
2021-09-14 09:27:53 +02:00
|
|
|
|
2021-09-14 10:12:27 +02:00
|
|
|
def run_cmd(cmd, **kwargs):
|
2021-09-14 09:27:53 +02:00
|
|
|
completed_process = subprocess.run(cmd, shell=True, text=True,
|
|
|
|
capture_output=True,
|
2021-09-14 10:12:27 +02:00
|
|
|
executable='/bin/bash', **kwargs)
|
2021-09-14 09:27:53 +02:00
|
|
|
if completed_process.returncode != 0:
|
|
|
|
print(completed_process.stdout)
|
|
|
|
print(completed_process.stderr)
|
|
|
|
|
|
|
|
return completed_process
|
|
|
|
|
|
|
|
|
2021-09-14 10:19:06 +02:00
|
|
|
def add_kasmvnc_user_docker():
|
|
|
|
completed_process = run_cmd('echo -e "password\\npassword\\n" | vncpasswd -u docker')
|
|
|
|
expect(completed_process.returncode).to(equal(0))
|
|
|
|
|
|
|
|
|
2021-09-14 10:20:55 +02:00
|
|
|
def kill_xvnc():
|
|
|
|
run_cmd('vncserver -kill :1')
|
|
|
|
|
|
|
|
|
2021-09-10 13:14:56 +02:00
|
|
|
with description('vncserver') as self:
|
2021-09-10 13:35:47 +02:00
|
|
|
with it('selects passed DE with -s'):
|
2021-09-14 10:19:06 +02:00
|
|
|
add_kasmvnc_user_docker()
|
2021-09-10 13:14:56 +02:00
|
|
|
|
2021-09-10 13:35:47 +02:00
|
|
|
cmd = 'vncserver :1 -select-de mate -cert /etc/ssl/certs/ssl-cert-snakeoil.pem -key /etc/ssl/private/ssl-cert-snakeoil.key -sslOnly -FrameRate=24 -interface 0.0.0.0 -httpd /usr/share/kasmvnc/www -depth 24 -geometry 1280x1050'
|
|
|
|
try:
|
2021-09-14 09:27:53 +02:00
|
|
|
completed_process = run_cmd(cmd)
|
2021-09-10 13:35:47 +02:00
|
|
|
expect(completed_process.returncode).to(equal(0))
|
|
|
|
|
2021-09-14 09:27:53 +02:00
|
|
|
completed_process = run_cmd('grep -q mate ~/.vnc/xstartup')
|
|
|
|
expect(completed_process.returncode).to(equal(0))
|
2021-09-10 13:35:47 +02:00
|
|
|
finally:
|
2021-09-14 10:20:55 +02:00
|
|
|
kill_xvnc()
|
2021-09-14 10:16:44 +02:00
|
|
|
|
|
|
|
with it('asks to select a DE, when ran with -select-de'):
|
2021-09-14 10:19:06 +02:00
|
|
|
add_kasmvnc_user_docker()
|
2021-09-14 10:16:44 +02:00
|
|
|
|
|
|
|
cmd = 'vncserver :1 -select-de -cert /etc/ssl/certs/ssl-cert-snakeoil.pem -key /etc/ssl/private/ssl-cert-snakeoil.key -sslOnly -FrameRate=24 -interface 0.0.0.0 -httpd /usr/share/kasmvnc/www -depth 24 -geometry 1280x1050'
|
|
|
|
try:
|
|
|
|
completed_process = run_cmd(cmd, input="1\ny\n")
|
|
|
|
expect(completed_process.returncode).to(equal(0))
|
|
|
|
|
|
|
|
completed_process = run_cmd('grep -q cinnamon ~/.vnc/xstartup')
|
|
|
|
expect(completed_process.returncode).to(equal(0))
|
|
|
|
finally:
|
2021-09-14 10:20:55 +02:00
|
|
|
kill_xvnc()
|