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
507688a7
Commit
507688a7
authored
Jan 30, 2018
by
Adrien Dorsaz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: v2 update deactivation test
parent
51099579
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
20 deletions
+44
-20
tests/README.md
tests/README.md
+1
-1
tests/config_factory.py
tests/config_factory.py
+26
-5
tests/test_acme_account_deactivate.py
tests/test_acme_account_deactivate.py
+17
-14
No files found.
tests/README.md
View file @
507688a7
...
...
@@ -21,7 +21,7 @@ explains how to setup and test acme-tiny yourself.
## List of environment variables
*
`GITLABCI_
CAURL`
: URL of a staging
ACME server
*
`GITLABCI_
ACMEDIRECTORY_V2`
: URL of a staging V2
ACME server
*
`GITLABCI_CHALLENGEDELAY`
: time to wait between dns update and self-check (set it to
`0`
to cover a bit more code)
*
`GITLABCI_DNSHOST`
: domain name to reach of your DNS server (e.g.
`adorsaz.ch`
)
*
`GITLABCI_DNSHOSTIP`
: IP address to reach of your DNS server
...
...
tests/config_factory.py
View file @
507688a7
...
...
@@ -4,7 +4,7 @@ from subprocess import Popen
# domain with server.py running on it for testing
DOMAIN
=
os
.
getenv
(
"GITLABCI_DOMAIN"
)
ACMEDIRECTORY
=
os
.
getenv
(
"GITLABCI_ACMEDIRECTORY
"
,
"https://acme-staging
.api.letsencrypt.org/directory"
)
ACMEDIRECTORY
=
os
.
getenv
(
"GITLABCI_ACMEDIRECTORY
_V2"
,
"https://acme-staging-v02
.api.letsencrypt.org/directory"
)
CHALLENGEDELAY
=
os
.
getenv
(
"GITLABCI_CHALLENGEDELAY"
,
"3"
)
DNSHOST
=
os
.
getenv
(
"GITLABCI_DNSHOST"
)
DNSHOSTIP
=
os
.
getenv
(
"GITLABCI_DNSHOSTIP"
)
...
...
@@ -50,8 +50,7 @@ def generate_acme_dns_tiny_config():
config
.
read
(
"./example.ini"
.
format
(
DOMAIN
))
config
[
"acmednstiny"
][
"ACMEDirectory"
]
=
ACMEDIRECTORY
config
[
"acmednstiny"
][
"CheckChallengeDelay"
]
=
CHALLENGEDELAY
config
[
"acmednstiny"
][
"MailContact"
]
=
"mail@example.com"
del
config
[
"acmednstiny"
][
"PhoneContact"
]
config
[
"acmednstiny"
][
"Contacts"
]
=
"mailto:mail@example.com"
config
[
"TSIGKeyring"
][
"KeyName"
]
=
TSIGKEYNAME
config
[
"TSIGKeyring"
][
"KeyValue"
]
=
TSIGKEYVALUE
config
[
"TSIGKeyring"
][
"Algorithm"
]
=
TSIGALGORITHM
...
...
@@ -133,8 +132,30 @@ def generate_acme_account_rollover_config():
}
# generate an account key to delete it
def
generate_acme_account_de
le
te_config
():
def
generate_acme_account_de
activa
te_config
():
# account key
account_key
=
NamedTemporaryFile
()
Popen
([
"openssl"
,
"genrsa"
,
"-out"
,
account_key
.
name
,
"2048"
]).
wait
()
return
account_key
# default test configuration
config
=
configparser
.
ConfigParser
()
config
.
read
(
"./example.ini"
.
format
(
DOMAIN
))
config
[
"acmednstiny"
][
"AccountKeyFile"
]
=
account_key
.
name
config
[
"acmednstiny"
][
"CSRFile"
]
=
account_key
.
name
config
[
"acmednstiny"
][
"ACMEDirectory"
]
=
ACMEDIRECTORY
config
[
"acmednstiny"
][
"CheckChallengeDelay"
]
=
CHALLENGEDELAY
config
[
"TSIGKeyring"
][
"KeyName"
]
=
TSIGKEYNAME
config
[
"TSIGKeyring"
][
"KeyValue"
]
=
TSIGKEYVALUE
config
[
"TSIGKeyring"
][
"Algorithm"
]
=
TSIGALGORITHM
config
[
"DNS"
][
"Host"
]
=
DNSHOST
config
[
"DNS"
][
"Port"
]
=
DNSPORT
config
[
"DNS"
][
"Zone"
]
=
DNSZONE
deactivateConfig
=
NamedTemporaryFile
()
with
open
(
deactivateConfig
.
name
,
'w'
)
as
configfile
:
config
.
write
(
configfile
)
return
{
"config"
:
deactivateConfig
.
name
,
"key"
:
account_key
}
tests/test_acme_account_deactivate.py
View file @
507688a7
import
unittest
,
os
import
acme_dns_tiny
from
tests.config_factory
import
generate_acme_account_de
le
te_config
import
tools.acme_account_de
le
te
from
tests.config_factory
import
generate_acme_account_de
activa
te_config
import
tools.acme_account_de
activa
te
ACMEDirectory
=
os
.
getenv
(
"GITLABCI_ACMEDIRECTORY
"
,
"https://acme-staging
.api.letsencrypt.org/directory"
)
ACMEDirectory
=
os
.
getenv
(
"GITLABCI_ACMEDIRECTORY
_V2"
,
"https://acme-staging-v02
.api.letsencrypt.org/directory"
)
class
TestACMEAccountDe
le
te
(
unittest
.
TestCase
):
"Tests for acme_account_de
le
te"
class
TestACMEAccountDe
activa
te
(
unittest
.
TestCase
):
"Tests for acme_account_de
activa
te"
@
classmethod
def
setUpClass
(
self
):
self
.
accountkey
=
generate_acme_account_delete_config
()
super
(
TestACMEAccountDelete
,
self
).
setUpClass
()
configs
=
generate_acme_account_deactivate_config
()
self
.
account_key
=
configs
[
"key"
]
acme_dns_tiny
.
main
([
self
.
configs
[
'config'
].
name
])
super
(
TestACMEAccountDeactivate
,
self
).
setUpClass
()
# To clean ACME staging server and close correctly temporary files
@
classmethod
def
tearDownClass
(
self
):
# close temp files correctly
self
.
configs
[
'config'
].
close
self
.
accountkey
.
close
()
super
(
TestACMEAccountDe
le
te
,
self
).
tearDownClass
()
super
(
TestACMEAccountDe
activa
te
,
self
).
tearDownClass
()
def
test_success_account_de
le
te
(
self
):
""" Test success account key de
le
te """
with
self
.
assertLogs
(
level
=
'INFO'
)
as
accountde
le
telog
:
tools
.
acme_account_de
le
te
.
main
([
"--account-key"
,
self
.
accountkey
.
name
,
def
test_success_account_de
activa
te
(
self
):
""" Test success account key de
activa
te """
with
self
.
assertLogs
(
level
=
'INFO'
)
as
accountde
activa
telog
:
tools
.
acme_account_de
activa
te
.
main
([
"--account-key"
,
self
.
accountkey
.
name
,
"--acme-directory"
,
ACMEDirectory
])
self
.
assertIn
(
"INFO:acme_account_de
lete:Account key dele
ted !"
,
accountde
le
telog
.
output
)
self
.
assertIn
(
"INFO:acme_account_de
activate:Account key deactiva
ted !"
,
accountde
activa
telog
.
output
)
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