mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
letsencrypt: Convert tests to pytest style
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
parent
a195fdca57
commit
54b684dbaf
@ -18,30 +18,21 @@
|
||||
Tests for letsencrypt module.
|
||||
"""
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import unittest
|
||||
import pytest
|
||||
|
||||
from .. import on_domain_added, on_domain_removed
|
||||
|
||||
euid = os.geteuid()
|
||||
sudo_available = os.path.isfile("/usr/bin/sudo")
|
||||
pytestmark = pytest.mark.usefixtures('needs_root', 'needs_sudo')
|
||||
|
||||
|
||||
@unittest.skipUnless(sudo_available, 'Requires sudo')
|
||||
class TestDomainNameChanges(unittest.TestCase):
|
||||
"""Test for automatically obtaining and revoking Let's Encrypt certs"""
|
||||
def test_add_onion_domain():
|
||||
assert not on_domain_added('test', 'hiddenservice', 'ddddd.onion')
|
||||
|
||||
@unittest.skipUnless(euid == 0, 'Needs to be root')
|
||||
def test_add_onion_domain(self):
|
||||
self.assertFalse(
|
||||
on_domain_added('test', 'hiddenservice', 'ddddd.onion'))
|
||||
|
||||
@unittest.skipUnless(euid == 0, 'Needs to be root')
|
||||
def test_add_valid_domain(self):
|
||||
self.assertTrue(
|
||||
on_domain_added('test', 'domainname', 'subdomain.domain.tld'))
|
||||
@pytest.mark.usefixtures('load_cfg')
|
||||
def test_add_valid_domain():
|
||||
assert on_domain_added('test', 'domainname', 'subdomain.domain.tld')
|
||||
|
||||
@unittest.skipUnless(euid == 0, 'Needs to be root')
|
||||
def test_remove_domain(self):
|
||||
self.assertTrue(on_domain_removed('test', '', 'somedomain.tld'))
|
||||
|
||||
def test_remove_domain():
|
||||
assert on_domain_removed('test', '', 'somedomain.tld')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user