Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
acme-dns-tiny
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Adrien Dorsaz
acme-dns-tiny
Commits
1808bd9d
Commit
1808bd9d
authored
May 24, 2020
by
Adrien Dorsaz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: split out unit test from staging test
parent
a2d5f8cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
10 deletions
+54
-10
tests/config_factory.py
tests/config_factory.py
+13
-10
tests/unit_test_acme_dns_tiny.py
tests/unit_test_acme_dns_tiny.py
+41
-0
No files found.
tests/config_factory.py
View file @
1808bd9d
...
...
@@ -50,6 +50,19 @@ def generate_config():
return
account_key
.
name
,
domain_key
.
name
,
domain_csr
.
name
,
parser
def
generate_acme_dns_tiny_unit_test_config
():
"""Genereate acme_dns_tiny configurations used for unit tests"""
# Configuration missing DNS section
_
,
domain_key
,
_
,
config
=
generate_config
()
os
.
remove
(
domain_key
)
missing_dns
=
NamedTemporaryFile
(
delete
=
False
)
config
[
"DNS"
]
=
{}
with
open
(
missing_dns
.
name
,
'w'
)
as
configfile
:
config
.
write
(
configfile
)
return
{
"missing_dns"
:
missing_dns
.
name
}
def
generate_acme_dns_tiny_config
():
#pylint: disable=too-many-locals,too-many-statements
"""Generate acme_dns_tiny configuration with account and domain keys"""
# Simple configuration with good options
...
...
@@ -169,15 +182,6 @@ def generate_acme_dns_tiny_config(): #pylint: disable=too-many-locals,too-many-s
with
open
(
invalid_tsig_name
.
name
,
'w'
)
as
configfile
:
config
.
write
(
configfile
)
# Create config parser from the good default config to generate custom configs
account_key
,
domain_key
,
_
,
config
=
generate_config
()
os
.
remove
(
domain_key
)
missing_dns
=
NamedTemporaryFile
(
delete
=
False
)
config
[
"DNS"
]
=
{}
with
open
(
missing_dns
.
name
,
'w'
)
as
configfile
:
config
.
write
(
configfile
)
return
{
# configs
"good_cname"
:
good_cname
.
name
,
...
...
@@ -190,7 +194,6 @@ def generate_acme_dns_tiny_config(): #pylint: disable=too-many-locals,too-many-s
"weak_key"
:
weak_key
.
name
,
"account_as_domain"
:
account_as_domain
.
name
,
"invalid_tsig_name"
:
invalid_tsig_name
.
name
,
"missing_dns"
:
missing_dns
.
name
,
# cname CSR file to use with good_cname_without_csr as argument
"cname_csr"
:
cname_csr
,
}
...
...
tests/unit_test_acme_dns_tiny.py
0 → 100644
View file @
1808bd9d
"""Unit tests for the acme_dns_tiny script"""
import
unittest
import
sys
import
os
import
configparser
import
dns.version
import
acme_dns_tiny
from
tests.config_factory
import
generate_acme_dns_tiny_unit_test_config
class
TestACMEDNSTiny
(
unittest
.
TestCase
):
"Tests for acme_dns_tiny.get_crt()"
@
classmethod
def
setUpClass
(
cls
):
print
(
"Init acme_dns_tiny with python modules:"
)
print
(
" - python: {0}"
.
format
(
sys
.
version
))
print
(
" - dns python: {0}"
.
format
(
dns
.
version
.
version
))
cls
.
configs
=
generate_acme_dns_tiny_unit_test_config
()
sys
.
stdout
.
flush
()
super
(
TestACMEDNSTiny
,
cls
).
setUpClass
()
# Close correctly temporary files
@
classmethod
def
tearDownClass
(
cls
):
# close temp files correctly
for
conffile
in
cls
.
configs
:
parser
=
configparser
.
ConfigParser
()
parser
.
read
(
conffile
)
os
.
remove
(
parser
[
"acmednstiny"
][
"AccountKeyFile"
])
os
.
remove
(
parser
[
"acmednstiny"
][
"CSRFile"
])
os
.
remove
(
conffile
)
super
(
TestACMEDNSTiny
,
cls
).
tearDownClass
()
def
test_failure_notcompleted_configuration
(
self
):
""" Configuration file have to be completed """
self
.
assertRaisesRegex
(
ValueError
,
r
"Some required settings are missing."
,
acme_dns_tiny
.
main
,
[
self
.
configs
[
'missing_dns'
],
"--verbose"
])
if
__name__
==
"__main__"
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment