Small cleanups

This commit is contained in:
Stephane Bortzmeyer 2021-07-07 12:08:37 +02:00
parent 65d8deb569
commit 09f5ccc3e4
2 changed files with 12 additions and 1 deletions

4
ianardap.py Normal file → Executable file
View File

@ -17,7 +17,7 @@ import fcntl
IANABASE = "https://data.iana.org/rdap/dns.json" IANABASE = "https://data.iana.org/rdap/dns.json"
CACHE = os.environ["HOME"] + "/.ianardapcache.json" CACHE = os.environ["HOME"] + "/.ianardapcache.json"
MAXAGE = 24 # Hours MAXAGE = 24 # Hours
IANATIMEOUT = 10 IANATIMEOUT = 10 # Seconds
class IanaRDAPDatabase(): class IanaRDAPDatabase():
@ -67,6 +67,8 @@ class IanaRDAPDatabase():
def find(self, domain): def find(self, domain):
""" Get the RDAP server for a given domain name. None if there is none.""" """ Get the RDAP server for a given domain name. None if there is none."""
if domain.endswith("."):
domain = domain[:-1]
labels = domain.split(".") labels = domain.split(".")
tld = labels[len(labels)-1] tld = labels[len(labels)-1]
if tld in self.services: if tld in self.services:

View File

@ -72,6 +72,15 @@ tests:
stderr: '' stderr: ''
partstdout: 'RDAP server is' partstdout: 'RDAP server is'
- exe: './check_expire'
args:
- '-u'
- '-H'
- 'bortzmeyer.org'
retcode: 0
stderr: ''
# TODO how to test we get an integer?
- exe: './check_expire' - exe: './check_expire'
args: args:
- '-c' - '-c'