update tests
This commit is contained in:
parent
aa09ef03ea
commit
c09ab0c794
7 changed files with 38 additions and 18 deletions
|
@ -67,6 +67,11 @@
|
|||
<variable name="oauth2_client_external" redefine="True" remove_fill="True"/>
|
||||
</family>
|
||||
</family>
|
||||
<family name="postgresql">
|
||||
<variable name="pg_client_key_owner" redefine="True">
|
||||
<value>forgejo</value>
|
||||
</variable>
|
||||
</family>
|
||||
</variables>
|
||||
<constraints>
|
||||
<fill name="get_password">
|
||||
|
|
|
@ -8,3 +8,4 @@ auth_server: %%oauth2_server_domainname
|
|||
username: %%username
|
||||
password: %%get_password(server_name='test', username=%%username, description='test', type="cleartext", hide=%%hide_secret, temporary=True)
|
||||
forgejo_title: "%%forgejo_title"
|
||||
git_url: "[%%domain]:2222"
|
||||
|
|
|
@ -7,7 +7,7 @@ from shutil import move
|
|||
from glob import glob
|
||||
from tempfile import TemporaryDirectory
|
||||
from subprocess import run
|
||||
from dulwich.porcelain import init, clone, add, commit, push
|
||||
from dulwich.porcelain import init, clone, add, commit, push, pull
|
||||
|
||||
|
||||
from revprox import Authentication
|
||||
|
@ -15,13 +15,14 @@ from mookdns import MookDnsSystem
|
|||
|
||||
|
||||
PORT = '3000'
|
||||
FORGEJO_USERNAME = 'forgejo'
|
||||
FORGEJO_USERNAME = 'git'
|
||||
FORGEJO_PORT = '2222'
|
||||
KEY_FILE = '/var/lib/risotto/srv/hosts/forgejo'
|
||||
# transition between gitea and forgejo
|
||||
GITEA_KEY_FILE = '/var/lib/risotto/srv/hosts/gitea'
|
||||
CONFIG_SSH = expandvars('$HOME/.ssh/config')
|
||||
CONFIG_GIT = expandvars('$HOME/.gitconfig')
|
||||
CONFIG_KNOWN_HOST = expandvars('$HOME/.ssh/known_hosts')
|
||||
|
||||
|
||||
AUTHENTICATION = None
|
||||
|
@ -193,6 +194,8 @@ def test_repo():
|
|||
if 'FIRST_RUN' in environ:
|
||||
# delete_ssh_key(authentication, data)
|
||||
add_ssh_key(authentication, data)
|
||||
cmd = ['/usr/bin/ssh-keygen', '-f', CONFIG_KNOWN_HOST, '-R', data['git_url']]
|
||||
run(cmd)
|
||||
if not isfile(KEY_FILE):
|
||||
if isfile(GITEA_KEY_FILE):
|
||||
move(GITEA_KEY_FILE, KEY_FILE)
|
||||
|
@ -292,6 +295,8 @@ def test_repo_persistent():
|
|||
# add a new line in file and commit
|
||||
with open(filename, 'a') as fh:
|
||||
fh.write('\ntest')
|
||||
with open(filename, 'r') as fh:
|
||||
len_line = len(fh.read().split('\n'))
|
||||
add(repo, filename)
|
||||
date = datetime.datetime.now()
|
||||
commit_message = f'test commit {date}'.encode()
|
||||
|
@ -301,7 +306,12 @@ def test_repo_persistent():
|
|||
refspecs='master',
|
||||
)
|
||||
# test if commit is added and last commit
|
||||
pull(repo=repo,
|
||||
remote_location=ssh_url,
|
||||
refspecs='master',
|
||||
)
|
||||
lst = list(repo.get_walker())
|
||||
len_after_commit = len(lst)
|
||||
assert len_after_commit == len_line
|
||||
assert len_before_commit + 1 == len_after_commit
|
||||
assert lst[-1].commit.message == commit_message
|
||||
assert lst[0].commit.message == commit_message
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<service name="risotto-images" type="timer" engine="cheetah"/>
|
||||
<service name="risottofirewall" engine="cheetah"/>
|
||||
<service name="systemd-nspawn@">
|
||||
<file>/usr/local/lib/risotto-tmpfiles.d/0asystemd-nspawn.conf</file>
|
||||
<file>/tmpfiles.d/0asystemd-nspawn.conf</file>
|
||||
<file>/etc/systemd/system/systemd-nspawn@.service.d/systemd-nspawn@.conf</file>
|
||||
<file>/etc/distro.repos.d/boot.repo</file>
|
||||
<file engine="none">/etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-35-x86_64</file>
|
||||
|
@ -58,6 +58,7 @@
|
|||
<value>python3-dulwich</value>
|
||||
<value>python3-psycopg2</value>
|
||||
<value>python3-redis</value>
|
||||
<value>python3-imaplib2</value>
|
||||
</variable>
|
||||
<family name="network">
|
||||
<variable name="output_interface" description="Nom de l'interface de sortie" mandatory="True"/>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
</variables>
|
||||
<constraints>
|
||||
<fill name="calc_value">
|
||||
<param>/usr/local/lib/sbin/network-</param>
|
||||
<param>/sbin/network-</param>
|
||||
<param type="variable">machined.machines</param>
|
||||
<param name="join"></param>
|
||||
<param name="multi" type="boolean">True</param>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
D /usr/local/lib/sbin/ 0755 root root - -
|
||||
D /etc/systemd/nspawn/ 0755 root root - -
|
||||
D /etc/systemd/network/ 0755 root root - -
|
||||
D /usr/local/lib/systemd/system/ 0755 root root - -
|
||||
D /etc/systemd/system/machines.target.wants/ 0755 root root - -
|
||||
d /var/lib/risotto/configurations/ 0755 root root - -
|
||||
r /etc/network/interfaces - - - - -
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from yaml import load, SafeLoader
|
||||
from os import environ
|
||||
from os.path import isfile
|
||||
import pytest
|
||||
import datetime
|
||||
|
||||
|
@ -7,18 +8,22 @@ from imaplib2 import IMAP4_SSL
|
|||
from smtplib import SMTP, SMTPNotSupportedError, SMTPAuthenticationError
|
||||
|
||||
|
||||
|
||||
conf_file = f'{environ["MACHINE_TEST_DIR"]}/imap.yml'
|
||||
with open(conf_file) as yaml:
|
||||
data = load(yaml, Loader=SafeLoader)
|
||||
parameters = (
|
||||
(1, 5, 'user', data['username'], data['username'], data['username'], [data['password']]),
|
||||
(2, 5, 'user', data['username'], data['username'], 'alias_' + data['username'], [data['password']]),
|
||||
(1, 3, 'family', data['username_family'], data['username_family'], data['username_family'], [data['password_family'], data['password_family'] + "2"]),
|
||||
(3, 5, 'user', data['username'], data['ext_username'], data['username'], [data['password']]),
|
||||
(4, 5, 'user', data['username'], data['ext_username'], 'alias_' + data['username'], [data['password']]),
|
||||
(2, 3, 'family', data['username_family'], data['ext_username'], data['username_family'], [data['password_family'], data['password_family'] + "2"]),
|
||||
)
|
||||
if not isfile(conf_file):
|
||||
print('no IMAP server, so desactived')
|
||||
parameters = ()
|
||||
else:
|
||||
NO_DATA=False
|
||||
with open(conf_file) as yaml:
|
||||
data = load(yaml, Loader=SafeLoader)
|
||||
parameters = (
|
||||
(1, 5, 'user', data['username'], data['username'], data['username'], [data['password']]),
|
||||
(2, 5, 'user', data['username'], data['username'], 'alias_' + data['username'], [data['password']]),
|
||||
(1, 3, 'family', data['username_family'], data['username_family'], data['username_family'], [data['password_family'], data['password_family'] + "2"]),
|
||||
(3, 5, 'user', data['username'], data['ext_username'], data['username'], [data['password']]),
|
||||
(4, 5, 'user', data['username'], data['ext_username'], 'alias_' + data['username'], [data['password']]),
|
||||
(2, 3, 'family', data['username_family'], data['ext_username'], data['username_family'], [data['password_family'], data['password_family'] + "2"]),
|
||||
)
|
||||
|
||||
|
||||
def get_msg(username, dest, msg='MESSAGE', with_date=True):
|
||||
|
|
Loading…
Reference in a new issue