letsencrypt: Fix tests requiring sudo

Closes #1084

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2017-10-24 14:11:11 +05:30 committed by James Valleroy
parent cf62269bf7
commit 29ca31fae2
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -18,21 +18,27 @@
Tests for letsencrypt module.
"""
import os
import unittest
from .. import on_domain_added, on_domain_removed
euid = os.geteuid()
class TestDomainNameChanges(unittest.TestCase):
"""Test for automatically obtaining and revoking Let's Encrypt certs"""
@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'))
@unittest.skipUnless(euid == 0, 'Needs to be root')
def test_remove_domain(self):
self.assertTrue(on_domain_removed('test', '', 'somedomain.tld'))