Exemple #1
0
def imap_openssl(user_domain, ca, name, server_name):
    run_ssh(user_domain, "/openssl/bin/openssl version -a", password=DEVICE_PASSWORD)
    output = run_ssh(user_domain, "echo \"A Logout\" | "
                                  "/openssl/bin/openssl s_client {0} -connect localhost:143 "
                                  "-servername {1} -verify 3 -starttls imap".format(ca, server_name),
                     password=DEVICE_PASSWORD)
    with open('{0}/openssl.{1}.log'.format(LOG_DIR, name), 'w') as f:
        f.write(output)
    assert 'Verify return code: 0 (ok)' in output
Exemple #2
0
def module_teardown(user_domain, platform_data_dir, data_dir):

    platform_log_dir = join(LOG_DIR, 'platform_log')
    os.mkdir(platform_log_dir)
    run_scp('root@{0}:{1}/log/* {2}'.format(user_domain, platform_data_dir, platform_log_dir), password=LOGS_SSH_PASSWORD, throw=False)

    app_log_dir = join(LOG_DIR, 'files_log')
    os.mkdir(app_log_dir)

    run_ssh(user_domain, 'mkdir {0}'.format(TMP_DIR), password=LOGS_SSH_PASSWORD)

    run_ssh(user_domain, 'journalctl > {0}/journalctl.log'.format(TMP_DIR), password=LOGS_SSH_PASSWORD, throw=False)
    run_ssh(user_domain, 'journalctl -u snap.files.uwsgi > {0}/journalctl.uwsgi.log'.format(TMP_DIR), password=LOGS_SSH_PASSWORD, throw=False)
    run_ssh(user_domain, 'journalctl -u snap.files.nginx > {0}/journalctl.nginx.log'.format(TMP_DIR), password=LOGS_SSH_PASSWORD, throw=False)

    run_scp('root@{0}:{1}/log/* {2}'.format(user_domain, data_dir, app_log_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_scp('root@{0}:{1}/*.log {2}'.format(user_domain, TMP_DIR, app_log_dir), password=LOGS_SSH_PASSWORD, throw=False)
Exemple #3
0
def test_udev_script(app_dir, device_host):
    run_ssh(device_host, '{0}/bin/check_external_disk'.format(app_dir), password=DEVICE_PASSWORD)
Exemple #4
0
def disk_writable(device_host):
    run_ssh(device_host, 'ls -la /data/', password=DEVICE_PASSWORD)
    run_ssh(device_host, "touch /data/platform/test.file", password=DEVICE_PASSWORD)
Exemple #5
0
def test_postfix_check(user_domain, app_dir, data_dir):
    run_ssh(user_domain,
            '{0}/postfix/usr/sbin/postfix.sh -c {1}/config/postfix -v check > {1}/log/postfix.check.log 2>&1'.format(
                app_dir, data_dir),
            password=LOGS_SSH_PASSWORD, throw=False)
Exemple #6
0
def test_certbot_cli(app_dir, device_host):
    output = run_ssh(device_host, '{0}/bin/certbot --help'.format(app_dir), password=LOGS_SSH_PASSWORD)
    assert not output.strip() == ""
    run_ssh(device_host, '{0}/bin/certbot --help nginx'.format(app_dir), password=LOGS_SSH_PASSWORD)
Exemple #7
0
def test_api_service_restart(app_dir, app_domain, ssh_env_vars):
    response = run_ssh(app_domain, '{0}/python/bin/python '
                                   '/integration/api_wrapper_service_restart.py '
                                   'platform.nginx-public'.format(app_dir),
                       password=LOGS_SSH_PASSWORD, env_vars=ssh_env_vars)
    assert 'OK' in response, response
Exemple #8
0
def cron_is_enabled_after_install(device_host):
    crontab = run_ssh(device_host, "crontab -l", password=DEVICE_PASSWORD)
    assert len(crontab.splitlines()) == 1
    assert 'cron' in crontab, crontab
    assert not crontab.startswith('#'), crontab
Exemple #9
0
def test_cron(app_dir, ssh_env_vars, device_host):
    run_ssh(device_host,
            '{0}/bin/cron'.format(app_dir),
            password=DEVICE_PASSWORD,
            env_vars=ssh_env_vars)
Exemple #10
0
def test_protocol(auth, public_web_session, device_host, app_dir, ssh_env_vars,
                  main_domain):

    email, password, domain, release = auth

    response = public_web_session.get(
        'https://{0}/rest/access/access'.format(device_host), verify=False)
    assert response.status_code == 200

    response = public_web_session.get(
        'https://{0}/rest/access/set_access'.format(device_host),
        verify=False,
        params={
            'upnp_enabled': 'false',
            'external_access': 'false',
            'public_ip': 0,
            'certificate_port': 443,
            'access_port': 443
        })
    assert '"success": true' in response.text
    assert response.status_code == 200

    response = public_web_session.get(
        'https://{0}/rest/access/access'.format(device_host), verify=False)
    assert response.status_code == 200
    url = run_ssh(
        device_host,
        '{0}/python/bin/python /integration/api_wrapper_app_url.py platform'.
        format(app_dir),
        password=DEVICE_PASSWORD,
        env_vars=ssh_env_vars)

    assert main_domain in url, url
    assert 'https' in url, url

    response = public_web_session.get(
        'https://{0}/rest/access/set_access'.format(device_host),
        verify=False,
        params={
            'upnp_enabled': 'false',
            'external_access': 'false',
            'public_ip': 0,
            'certificate_port': 80,
            'access_port': 10000
        })
    assert '"success": true' in response.text
    assert response.status_code == 200

    response = public_web_session.get(
        'https://{0}/rest/access/access'.format(device_host), verify=False)
    assert response.status_code == 200

    url = run_ssh(
        device_host,
        '{0}/python/bin/python /integration/api_wrapper_app_url.py platform'.
        format(app_dir),
        password=DEVICE_PASSWORD,
        env_vars=ssh_env_vars)

    assert main_domain in url, url
    assert 'https' in url, url
Exemple #11
0
def module_teardown(user_domain, app_dir, data_dir, platform_data_dir): 
    platform_log_dir = join(LOG_DIR, 'platform_log')
    os.mkdir(platform_log_dir)
    run_scp('root@{0}:{1}/log/* {2}'.format(user_domain, platform_data_dir, platform_log_dir), password=LOGS_SSH_PASSWORD, throw=False) 
    run_scp('root@{0}:/var/log/sam.log {1}'.format(user_domain, platform_log_dir), password=LOGS_SSH_PASSWORD, throw=False)

    mail_log_dir = join(LOG_DIR, 'mail_log')
    os.mkdir(mail_log_dir)
    run_ssh(user_domain, 'ls -la {0}/ > {0}/log/ls.log'.format(data_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_ssh(user_domain, 'ls -la {0}/dovecot/ > {0}/log/data.dovecot.ls.log'.format(data_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_ssh(user_domain, '{0}/postfix/usr/sbin/postfix.sh -c {1}/config/postfix -v status > {1}/log/postfix.status.teardowm.log 2>&1'.format(app_dir, data_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_ssh(user_domain, 'ls -la {0}/ > {0}/log/data.ls.log'.format(data_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_ssh(user_domain, 'ls -la {0}/box/ > {0}/log/data.box.ls.log'.format(data_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_ssh(user_domain, 'ls -la {0}/log/ > {0}/log/log.ls.log'.format(data_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_ssh(user_domain, 'ls -la {0}/roundcubemail/ > {1}/log/roundcubemail.ls.log'.format(app_dir, data_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_ssh(user_domain, 'ls -la {0}/roundcubemail/config/ > {1}/log/roundcubemail.config.ls.log'.format(app_dir, data_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_ssh(user_domain, 'ls -la {0}/roundcubemail/logs/ > {1}/log/roundcubemail.logs.ls.log'.format(app_dir, data_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_ssh(user_domain, 'journalctl > {0}/log/journalctl.log'.format(data_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_ssh(user_domain, 'netstat -nlp > {0}/log/netstat.log'.format(data_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_ssh(user_domain, 'DATA_DIR={1} {0}/bin/php -i > {1}/log/php.info.log'.format(app_dir, data_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_scp('root@{0}:{1}/log/*.log {2}'.format(user_domain, data_dir, mail_log_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_scp('root@{0}:/var/log/mail* {2}'.format(user_domain, data_dir, mail_log_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_scp('root@{0}:/var/log/mail/errors {2}/var.log.mail.errors.log'.format(user_domain, data_dir, mail_log_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_scp('root@{0}:/var/log/messages* {2}'.format(user_domain, data_dir, mail_log_dir), password=LOGS_SSH_PASSWORD, throw=False)
    run_scp('root@{0}:/var/log/*syslog* {2}'.format(user_domain, data_dir, mail_log_dir), password=LOGS_SSH_PASSWORD, throw=False) 
    config_dir = join(LOG_DIR, 'config')
    os.mkdir(config_dir)
    run_scp('-r root@{0}:{1}/config/* {2}'.format(user_domain, data_dir, config_dir), password=LOGS_SSH_PASSWORD, throw=False)
Exemple #12
0
def test_postfix_ldap_aliases(user_domain, app_dir, data_dir):
    run_ssh(user_domain,
            '{0}/postfix/usr/sbin/postmap -c {3}/config/postfix -q {1}@{2} ldap:{3}/config/postfix/ldap-aliases.cf'
            .format(app_dir, DEVICE_USER, user_domain, data_dir), password=DEVICE_PASSWORD)
Exemple #13
0
def test_filesystem_mailbox(user_domain, data_dir):
    run_ssh(user_domain, 'find {0}/box'.format(data_dir), password=DEVICE_PASSWORD)
Exemple #14
0
def test_dovecot_auth(user_domain, app_dir, data_dir):
    run_ssh(user_domain,
            '{0}/dovecot/bin/doveadm -D -c {1}/config/dovecot/dovecot.conf auth test {2} {3} > {1}/log/doveadm.auth.test.log 2>&1'
            .format(app_dir, data_dir, DEVICE_USER, DEVICE_PASSWORD), 
            password=DEVICE_PASSWORD, 
            env_vars='LD_LIBRARY_PATH={0}/dovecot/lib/dovecot DOVECOT_BINDIR={0}/dovecot/bin'.format(app_dir))
Exemple #15
0
def disk_create(loop_device, fs, device_host, installer):
    tmp_disk = '/tmp/test_{0}'.format(installer)
    run_ssh(device_host, 'mkfs.{0} {1}'.format(fs, loop_device), password=DEVICE_PASSWORD, retries=3)

    run_ssh(device_host, 'rm -rf {0}'.format(tmp_disk), password=DEVICE_PASSWORD)
    run_ssh(device_host, 'mkdir {0}'.format(tmp_disk), password=DEVICE_PASSWORD)
    run_ssh(device_host, 'sync', password=DEVICE_PASSWORD)

    run_ssh(device_host, 'mount {0} {1}'.format(loop_device, tmp_disk), password=DEVICE_PASSWORD, retries=3)
    for mount in run_ssh(device_host, 'mount', debug=True, password=DEVICE_PASSWORD).splitlines():
        if 'loop' in mount:
            print(mount)
    run_ssh(device_host, 'umount {0}'.format(loop_device), password=DEVICE_PASSWORD)
Exemple #16
0
def test_api_data_path(app_dir, data_dir, main_domain, ssh_env_vars):
    response = run_ssh(main_domain, '{0}/python/bin/python /integration/api_wrapper_data_dir.py platform'.format(app_dir), password=DEVICE_PASSWORD, env_vars=ssh_env_vars)
    assert data_dir in response, response
Exemple #17
0
def current_disk_link(device_host, ssh_env_vars, app_dir):
    return run_ssh(device_host,
                   '{0}/python/bin/python /integration/api_wrapper_storage_init.py platform root'.format(app_dir),
                   password=DEVICE_PASSWORD, env_vars=ssh_env_vars)
Exemple #18
0
def test_certbot_cli(app_dir, device_host):
    run_ssh(device_host, '{0}/bin/certbot --help'.format(app_dir), password=DEVICE_PASSWORD)
    run_ssh(device_host, '{0}/bin/certbot --help nginx'.format(app_dir), password=DEVICE_PASSWORD)
Exemple #19
0
def test_drop_activation(device_host):
    run_ssh(device_host, 'rm /var/snap/platform/common/platform.db', password=LOGS_SSH_PASSWORD)
Exemple #20
0
def test_show_https_certificate(device_host):
    run_ssh(device_host, "echo | "
            "openssl s_client -showcerts -servername localhost -connect localhost:443 2>/dev/null | "
            "openssl x509 -inform pem -noout -text", password=DEVICE_PASSWORD)
Exemple #21
0
def test_api_url(app_dir, app_domain, ssh_env_vars):
    response = run_ssh(app_domain, '{0}/python/bin/python /integration/api_wrapper_app_url.py platform'.format(app_dir),
                       password=LOGS_SSH_PASSWORD, env_vars=ssh_env_vars)
    assert app_domain in response, response
Exemple #22
0
def test_cron_job(app_dir, ssh_env_vars, device_host):
    assert '"success": true' in run_ssh(device_host, '{0}/bin/insider sync_all'.format(app_dir),
                                        password=DEVICE_PASSWORD, env_vars=ssh_env_vars)
Exemple #23
0
def test_openssl_cli(app_dir, device_host):
    run_ssh(device_host, '{0}/openssl/bin/openssl --help'.format(app_dir), password=LOGS_SSH_PASSWORD)
Exemple #24
0
def loop_device(device_host, installer):
    dev_file = '/tmp/disk_{0}'.format(installer)
    loop_device_cleanup(device_host, dev_file, password=DEVICE_PASSWORD)

    print('adding loop device')
    run_ssh(device_host, 'dd if=/dev/zero bs=1M count=10 of={0}'.format(dev_file), password=DEVICE_PASSWORD)
    run_ssh(device_host, 'sync', password=DEVICE_PASSWORD)
    run_ssh(device_host, 'ls -la {0}'.format(dev_file), password=DEVICE_PASSWORD)
    loop = run_ssh(device_host, 'losetup -f --show {0}'.format(dev_file), password=DEVICE_PASSWORD)
    run_ssh(device_host, 'losetup', password=DEVICE_PASSWORD)
    run_ssh(device_host, 'losetup -j {0} | grep {0}'.format(dev_file), password=DEVICE_PASSWORD, retries=3)
    run_ssh(device_host, 'file -s {0}'.format(loop), password=DEVICE_PASSWORD)
    run_ssh(device_host, 'sync', password=DEVICE_PASSWORD)
    run_ssh(device_host, 'partprobe {0}'.format(loop), password=DEVICE_PASSWORD, retries=3)
    yield loop

    loop_device_cleanup(device_host, dev_file, password=DEVICE_PASSWORD)
Exemple #25
0
def test_activate_password(device_domain):
    print('default password')
    run_ssh(device_domain, 'date', password=DEFAULT_DEVICE_PASSWORD, throw=False)
    print('activate password')
    run_ssh(device_domain, 'date', password=DEVICE_PASSWORD)
Exemple #26
0
def test_access_change_event(user_domain):
    run_ssh(user_domain,
            '/snap/platform/current/python/bin/python /snap/mail/current/hooks/access-change.py',
             password=LOGS_SSH_PASSWORD)