forked from igroykt/letsencrypt-nic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·57 lines (45 loc) · 1.52 KB
/
test.py
File metadata and controls
executable file
·57 lines (45 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/local/bin/python3
import os
import pytest
from func import Func
def test_checkTXTRecord():
result = Func.checkTXTRecord(['8.8.8.8'], 'google.com', test=True)
assert isinstance(result, bool)
def test_mainDomainTail():
result = Func.mainDomainTail('top.level.mydomain.ru')
assert result == 'mydomain.ru'
def test_NIC_findTXTID():
result = Func.NIC_findTXTID([{'name':'_acme-challenge.google.com', 'id':'google.com'}])
assert result == ['google.com']
def test_call():
code, out, err = Func.call('ls')
assert code == 0
'''
result = Func.sendEmail(
'robot@mydomain.ru',
['admin@mydomain.ru', 'security@mydomain.ru'],
'test',
'test message',
'smtp.gmail.com',
'587',
'xxx',
'yyy',
test=True,
)
assert isinstance(result, bool)
'''
def test_makeList():
result = Func.makeList(['mydomain.ru', '*.mydomain.ru', 'mydomain2.ru'])
assert result == '-d mydomain.ru -d *.mydomain.ru -d mydomain2.ru'
def test_makeMainDomain():
result = Func.makeMainDomain(['mydomain.ru', '*.mydomain.ru', 'mydomain2.ru'])
assert result == 'mydomain.ru'
ENC_KEY = '0IFzRIVb4i42OPaovw0RDHNgOiRsKLlyDumAW_xFs0M='
script_dir = os.path.dirname(os.path.realpath(__file__))
ENC_DAT = f'{script_dir}/test_enc.dat'
def test_encrypt():
result = Func.encrypt(ENC_KEY, ENC_DAT, 'testuser', 'testpass', 'testid', 'testsecret')
assert isinstance(result, bool)
def test_decrypt():
username, password, client_id, client_secret = Func.decrypt(ENC_KEY, ENC_DAT)
assert username == 'testuser'