aboutsummaryrefslogtreecommitdiff
path: root/rpkid/tests
diff options
context:
space:
mode:
Diffstat (limited to 'rpkid/tests')
-rw-r--r--rpkid/tests/myrpki-xml-parse-test.py6
-rw-r--r--rpkid/tests/smoketest.py60
-rw-r--r--rpkid/tests/testpoke.py4
-rw-r--r--rpkid/tests/yamlconf.py16
-rw-r--r--rpkid/tests/yamltest.py38
5 files changed, 75 insertions, 49 deletions
diff --git a/rpkid/tests/myrpki-xml-parse-test.py b/rpkid/tests/myrpki-xml-parse-test.py
index 5aaf5cbf..6818dbe5 100644
--- a/rpkid/tests/myrpki-xml-parse-test.py
+++ b/rpkid/tests/myrpki-xml-parse-test.py
@@ -3,7 +3,7 @@ Test parser and display tool for myrpki.xml files.
$Id$
-Copyright (C) 2009--2010 Internet Systems Consortium ("ISC")
+Copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -29,9 +29,9 @@ if False:
relaxng.assertValid(tree)
-def showitems(x):
+def showitems(y):
if False:
- for k, v in x.items():
+ for k, v in y.items():
if v:
print " ", k, v
diff --git a/rpkid/tests/smoketest.py b/rpkid/tests/smoketest.py
index 3321f04e..07ad4d0e 100644
--- a/rpkid/tests/smoketest.py
+++ b/rpkid/tests/smoketest.py
@@ -17,7 +17,7 @@ things that don't belong in yaml_script.
$Id$
-Copyright (C) 2009--2011 Internet Systems Consortium ("ISC")
+Copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -46,9 +46,25 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import os, yaml, warnings, subprocess, signal, time, getopt, sys, errno
-import rpki.resource_set, rpki.sundial, rpki.x509, rpki.http
-import rpki.log, rpki.left_right, rpki.config, rpki.publication, rpki.async
+# pylint: disable=W0621
+
+import os
+import yaml
+import subprocess
+import signal
+import time
+import getopt
+import sys
+import errno
+import rpki.resource_set
+import rpki.sundial
+import rpki.x509
+import rpki.http
+import rpki.log
+import rpki.left_right
+import rpki.config
+import rpki.publication
+import rpki.async
from rpki.mysql_import import MySQLdb
@@ -194,21 +210,21 @@ def main():
# Apparently os.walk() can't tell the difference between directories
# and symlinks to directories, so we have to handle both.
for root, dirs, files in os.walk(".", topdown = False):
- for file in files:
- if not file.endswith(".key"):
- os.remove(os.path.join(root, file))
- for dir in dirs:
+ for fn in files:
+ if not fn.endswith(".key"):
+ os.remove(os.path.join(root, fn))
+ for d in dirs:
try:
- os.rmdir(os.path.join(root, dir))
+ os.rmdir(os.path.join(root, d))
except OSError, e:
if e.errno == errno.ENOTDIR:
- os.remove(os.path.join(root, dir))
+ os.remove(os.path.join(root, d))
else:
raise
rpki.log.info("Reading master YAML configuration")
y = yaml_script.pop(0)
-
+
rpki.log.info("Constructing internal allocation database")
db = allocation_db(y)
@@ -218,6 +234,7 @@ def main():
rpki.log.info("Constructing BPKI keys and certs for pubd")
setup_bpki_cert_chain(pubd_name, ee = ("PUBD", "IRBE"))
+
for a in db:
a.setup_bpki_certs()
@@ -322,6 +339,7 @@ def main():
for proc, name in ((rootd_process, "rootd"),
(pubd_process, "pubd"),
(rsyncd_process, "rsyncd")):
+ # pylint: disable=E1103
if proc is not None:
rpki.log.info("Killing %s, pid %s" % (name, proc.pid))
try:
@@ -416,10 +434,7 @@ class allocation_db(list):
a.crl_interval = a.parent.crl_interval
if a.regen_margin is None:
a.regen_margin = a.parent.regen_margin
- i = 0
- for j in xrange(4):
- i = a.sia_base.index("/", i) + 1
- a.client_handle = a.sia_base[i:].rstrip("/")
+ a.client_handle = "/".join(a.sia_base.split("/")[4:]).rstrip("/")
self.root.closure()
self.map = dict((a.name, a) for a in self)
self.engines = [a for a in self if a.is_engine]
@@ -782,6 +797,7 @@ class allocation(object):
"""
Kill daemons for this entity.
"""
+ # pylint: disable=E1103
rpki.log.info("Killing daemons for %s" % self.name)
try:
for proc in (self.rpkid_process, self.irdbd_process):
@@ -1175,15 +1191,13 @@ def setup_publication(pubd_sql):
Set up publication daemon.
"""
rpki.log.info("Configure publication daemon")
- publication_dir = os.getcwd() + "/publication/"
+ publication_dir = os.getcwd() + "/publication"
assert rootd_sia.startswith("rsync://")
- i = 0
- for j in xrange(4):
- i = rootd_sia.index("/", i + 1)
global rsyncd_dir
- rsyncd_dir = publication_dir.rstrip("/") + rootd_sia[i:]
- pubd_dir = rsyncd_dir
- os.makedirs(pubd_dir + "root/trunk")
+ rsyncd_dir = publication_dir + "/".join(rootd_sia.split("/")[4:])
+ if not rsyncd_dir.endswith("/"):
+ rsyncd_dir += "/"
+ os.makedirs(rsyncd_dir + "root/trunk")
db = MySQLdb.connect(db = pubd_db_name, user = pubd_db_user, passwd = pubd_db_pass)
cur = db.cursor()
db.autocommit(True)
@@ -1199,7 +1213,7 @@ def setup_publication(pubd_sql):
"pubd_db_name" : pubd_db_name,
"pubd_db_user" : pubd_db_user,
"pubd_db_pass" : pubd_db_pass,
- "pubd_dir" : pubd_dir }
+ "pubd_dir" : rsyncd_dir }
f = open(pubd_name + ".conf", "w")
f.write(pubd_fmt_1 % d)
f.close()
diff --git a/rpkid/tests/testpoke.py b/rpkid/tests/testpoke.py
index ad20992d..49919709 100644
--- a/rpkid/tests/testpoke.py
+++ b/rpkid/tests/testpoke.py
@@ -12,7 +12,7 @@ Default configuration file is testpoke.yaml, override with --yaml option.
$Id$
-Copyright (C) 2010--2011 Internet Systems Consortium ("ISC")
+Copyright (C) 2010--2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -154,7 +154,7 @@ def do_revoke():
dispatch = { "list" : do_list, "issue" : do_issue, "revoke" : do_revoke }
-def fail(e):
+def fail(e): # pylint: disable=W0621
rpki.log.traceback(debug)
sys.exit("Testpoke failed: %s" % e)
diff --git a/rpkid/tests/yamlconf.py b/rpkid/tests/yamlconf.py
index d0ff6b4f..deb7890f 100644
--- a/rpkid/tests/yamlconf.py
+++ b/rpkid/tests/yamlconf.py
@@ -36,15 +36,15 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
-
"""
+# pylint: disable=W0702,W0621,W0602
+
import subprocess
import re
import os
import sys
import yaml
-import signal
import time
import argparse
import rpki.resource_set
@@ -57,8 +57,8 @@ import rpki.sql_schemas
from rpki.mysql_import import MySQLdb
-section_regexp = re.compile("\s*\[\s*(.+?)\s*\]\s*$")
-variable_regexp = re.compile("\s*([-a-zA-Z0-9_]+)\s*=\s*(.+?)\s*$")
+section_regexp = re.compile(r"\s*\[\s*(.+?)\s*\]\s*$")
+variable_regexp = re.compile(r"\s*([-a-zA-Z0-9_]+)\s*=\s*(.+?)\s*$")
flat_publication = False
only_one_pubd = True
@@ -672,10 +672,10 @@ def body():
ts = timestamp()
for root, dirs, files in os.walk(test_dir, topdown = False):
- for file in files:
- os.unlink(os.path.join(root, file))
- for dir in dirs:
- os.rmdir(os.path.join(root, dir))
+ for fn in files:
+ os.unlink(os.path.join(root, fn))
+ for d in dirs:
+ os.rmdir(os.path.join(root, d))
if not quiet:
print
diff --git a/rpkid/tests/yamltest.py b/rpkid/tests/yamltest.py
index a0903b42..a5f72788 100644
--- a/rpkid/tests/yamltest.py
+++ b/rpkid/tests/yamltest.py
@@ -15,7 +15,7 @@ Still to do:
$Id$
-Copyright (C) 2009--2010 Internet Systems Consortium ("ISC")
+Copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -42,19 +42,31 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
-
"""
-import subprocess, re, os, getopt, sys, yaml, signal, time
-import rpki.resource_set, rpki.sundial, rpki.config, rpki.log
-import rpki.csv_utils, rpki.x509
+# pylint: disable=W0702,W0621
+
+import subprocess
+import re
+import os
+import getopt
+import sys
+import yaml
+import signal
+import time
+import rpki.resource_set
+import rpki.sundial
+import rpki.config
+import rpki.log
+import rpki.csv_utils
+import rpki.x509
# Nasty regular expressions for parsing config files. Sadly, while
# the Python ConfigParser supports writing config files, it does so in
# such a limited way that it's easier just to hack this ourselves.
-section_regexp = re.compile("\s*\[\s*(.+?)\s*\]\s*$")
-variable_regexp = re.compile("\s*([-a-zA-Z0-9_]+)\s*=\s*(.+?)\s*$")
+section_regexp = re.compile(r"\s*\[\s*(.+?)\s*\]\s*$")
+variable_regexp = re.compile(r"\s*([-a-zA-Z0-9_]+)\s*=\s*(.+?)\s*$")
def cleanpath(*names):
"""
@@ -99,11 +111,11 @@ class roa_request(object):
return "%s: %s" % (self.asn, self.v4 or self.v6)
@classmethod
- def parse(cls, yaml):
+ def parse(cls, y):
"""
Parse a ROA request from YAML format.
"""
- return cls(yaml.get("asn"), yaml.get("ipv4"), yaml.get("ipv6"))
+ return cls(y.get("asn"), y.get("ipv4"), y.get("ipv6"))
class allocation_db(list):
"""
@@ -577,10 +589,10 @@ try:
if not skip_config:
for root, dirs, files in os.walk(test_dir, topdown = False):
- for file in files:
- os.unlink(os.path.join(root, file))
- for dir in dirs:
- os.rmdir(os.path.join(root, dir))
+ for fn in files:
+ os.unlink(os.path.join(root, fn))
+ for d in dirs:
+ os.rmdir(os.path.join(root, d))
# Read first YAML doc in file and process as compact description of
# test layout and resource allocations. Ignore subsequent YAML docs,