Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Adrien Dorsaz
acme-dns-tiny
Commits
114fe459
Commit
114fe459
authored
Feb 26, 2017
by
Adrien Dorsaz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: add ACME account key rollover test
parent
2d22e977
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
+54
-0
tests/config_factory.py
tests/config_factory.py
+13
-0
tests/test_account_rollover.py
tests/test_account_rollover.py
+41
-0
No files found.
tests/config_factory.py
View file @
114fe459
...
...
@@ -118,3 +118,16 @@ def generate_acme_dns_tiny_config():
"accountcsr"
:
account_csr
}
# generate account and domain keys
def
generate_account_rollover_config
():
# Old account key
old_account_key
=
NamedTemporaryFile
()
Popen
([
"openssl"
,
"genrsa"
,
"-out"
,
old_account_key
.
name
,
"2048"
]).
wait
()
# New account key
new_account_key
=
NamedTemporaryFile
()
Popen
([
"openssl"
,
"genrsa"
,
"-out"
,
new_account_key
.
name
,
"2048"
]).
wait
()
return
{
# keys (returned to keep files on system)
"oldaccountkey"
:
old_account_key
,
"newaccountkey"
:
new_account_key
}
tests/test_account_rollover.py
0 → 100644
View file @
114fe459
import
unittest
,
sys
,
os
from
subprocess
import
Popen
,
PIPE
from
io
import
StringIO
import
acme_dns_tiny
from
tests.config_factory
import
generate_account_rollover_config
from
tools.acme_account_delete
import
delete_account
import
tools.acme_account_rollover
import
logassert
ACMEDirectory
=
os
.
getenv
(
"GITLABCI_ACMEDIRECTORY"
,
"https://acme-staging.api.letsencrypt.org/directory"
)
class
TestACMEAccountRollover
(
unittest
.
TestCase
):
"Tests for acme_account_key_rollover"
@
classmethod
def
setUpClass
(
self
):
self
.
configs
=
generate_account_rollover_config
()
super
(
TestACMEAccountRollover
,
self
).
setUpClass
()
# To clean ACME staging server and close correctly temporary files
@
classmethod
def
tearDownClass
(
self
):
# delete account key registration at end of tests
delete_account
(
self
.
configs
[
"newaccountkey"
].
name
,
ACMEDirectory
)
# close temp files correctly
for
tmpfile
in
self
.
configs
:
self
.
configs
[
tmpfile
].
close
()
super
(
TestACMEAccountRollover
,
self
).
tearDownClass
()
def
setUp
(
self
):
logassert
.
setup
(
self
,
'acme_account_rollover'
)
def
test_success_account_rollover
(
self
):
""" Test success account key rollover """
tools
.
acme_account_rollover
.
main
([
"--current-account-key"
,
self
.
configs
[
'oldaccountkey'
].
name
,
"--new-account-key"
,
self
.
configs
[
'newaccountkey'
].
name
,
"--acme-directory"
,
ACMEDirectory
])
self
.
assertLoggedInfo
(
"Account keys rolled over !"
)
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