57641f3b9a
the nsupdate.info zone is configured to allow updating test.nsupdate.info with a non-secret key used for the tests. we also have a test that tries to update another host with that key and checks that this fails. change the tests so they only use test.nsupdate.info (if possible). single-host update secrets need a Domain record for the fqdn of this single host, the fqdn is tried first, before it tries the origin zone.
46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
"""
|
|
configuration for the tests
|
|
"""
|
|
|
|
import pytest
|
|
|
|
# this is to create a Domain entries in the database, so they can be used for unit tests:
|
|
BASEDOMAIN = "nsupdate.info"
|
|
TEST_HOST = 'test.' + BASEDOMAIN # unit tests can update this host ONLY
|
|
NAMESERVER_IP = "85.10.192.104"
|
|
NAMESERVER_UPDATE_ALGORITHM = "HMAC_SHA512"
|
|
# no problem, you can ONLY update the TEST_HOST with this key, nothing else:
|
|
NAMESERVER_UPDATE_KEY = "YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYQ=="
|
|
NAMESERVER_PUBLIC = True
|
|
|
|
from django.utils.translation import activate
|
|
|
|
|
|
# Note: fixture must be "function" scope (default), see https://github.com/pelme/pytest_django/issues/33
|
|
@pytest.fixture(autouse=True)
|
|
def db_init(db): # note: db is a predefined fixture and required here to have the db available
|
|
"""
|
|
Init the database contents for testing, so we have a service domain, ...
|
|
"""
|
|
from nsupdate.main.models import Domain
|
|
# this is for updating:
|
|
Domain.objects.create(
|
|
domain=TEST_HOST, # special: single-host update secret!
|
|
nameserver_ip=NAMESERVER_IP,
|
|
nameserver_update_algorithm=NAMESERVER_UPDATE_ALGORITHM,
|
|
nameserver_update_key=NAMESERVER_UPDATE_KEY,
|
|
public=NAMESERVER_PUBLIC,
|
|
)
|
|
# this is for querying:
|
|
Domain.objects.create(
|
|
domain=BASEDOMAIN,
|
|
nameserver_ip=NAMESERVER_IP,
|
|
nameserver_update_algorithm=NAMESERVER_UPDATE_ALGORITHM,
|
|
nameserver_update_key='invalid=', # we don't send updates there (and the real key is really secret)
|
|
public=NAMESERVER_PUBLIC,
|
|
)
|
|
|
|
|
|
def pytest_runtest_setup(item):
|
|
activate('en')
|