Compare commits

..

9 Commits

Author SHA1 Message Date
Stephane Bortzmeyer
ff901cfc06 Fix a bug when no RDAP server and verbose 2024-07-13 18:00:37 +02:00
Stephane Bortzmeyer
014fe9fec5 Merge branch 'Seb35-issue-4' 2024-06-16 20:43:20 +02:00
Stephane Bortzmeyer
60a6410941 Merge branch 'issue-4' of https://forge.chapril.org/Seb35/check_expire into Seb35-issue-4 2024-06-16 20:40:29 +02:00
Stephane Bortzmeyer
4e17d48adb Merge branch 'Seb35-pull-request-6' 2024-06-16 20:37:52 +02:00
Stephane Bortzmeyer
f7e355702f Post-merge cleaning 2024-06-16 20:37:42 +02:00
Stephane Bortzmeyer
6d6f054a26 Iran RDAP server down 2024-06-16 20:36:55 +02:00
Stephane Bortzmeyer
30d4678e03 Merge branch 'pull-request-6' of https://forge.chapril.org/Seb35/check_expire into Seb35-pull-request-6 2024-06-16 20:36:43 +02:00
Stephane Bortzmeyer
9dc05e9c7b Error code outside of its visibility 2023-03-15 19:53:12 +00:00
3af8b31034 Fix two failing tests
By the way, converted the timeout parameter to a float.
2022-12-18 19:56:04 +01:00
2 changed files with 18 additions and 14 deletions

View File

@ -45,6 +45,9 @@ warning_t = datetime.timedelta(days=7)
unixtime = False unixtime = False
timeout = 20 # Seconds timeout = 20 # Seconds
# Cannot be changed on the command-line (yet)
server = None
def usage(msg=None): def usage(msg=None):
print("Usage: %s -H domain-name [-c critical -w warning -u -t timeout]" % sys.argv[0], end="") print("Usage: %s -H domain-name [-c critical -w warning -u -t timeout]" % sys.argv[0], end="")
if msg is not None and msg != "": if msg is not None and msg != "":
@ -103,7 +106,7 @@ try:
elif option == "--hostname" or option == "-H": elif option == "--hostname" or option == "-H":
domain = value domain = value
elif option == "--timeout" or option == "-t": elif option == "--timeout" or option == "-t":
timeout = int(value) timeout = float(value)
elif option == "--unixtime" or option == "-u": elif option == "--unixtime" or option == "-u":
unixtime = True unixtime = True
elif option == "--verbose" or option == "-v": elif option == "--verbose" or option == "-v":
@ -144,6 +147,7 @@ for server in servers:
response = requests.get("%s/domain/%s" % (server, domain), timeout=timeout) response = requests.get("%s/domain/%s" % (server, domain), timeout=timeout)
except requests.exceptions.Timeout: except requests.exceptions.Timeout:
unknowns += "Timeout when trying to reach %s " % server unknowns += "Timeout when trying to reach %s " % server
continue
if response.status_code != 200: if response.status_code != 200:
errors += "Invalid RDAP return code at %s: %s " % \ errors += "Invalid RDAP return code at %s: %s " % \
(server, response.status_code) (server, response.status_code)

View File

@ -28,11 +28,11 @@ tests:
retcode: 1 retcode: 1
partstderr: 'ValueError' partstderr: 'ValueError'
# 2021-07-05: no RDAP server for this TLD # No RDAP server for this TLD
- exe: './check_expire' - exe: './check_expire'
args: args:
- '-H' - '-H'
- 'bie.re' - 'welcome.this-is-not-a-tld'
retcode: 3 retcode: 3
partstdout: 'No RDAP server' partstdout: 'No RDAP server'
@ -45,13 +45,13 @@ tests:
retcode: 2 retcode: 2
partstdout: 'No expiration found' partstdout: 'No expiration found'
# Far away and slow, timeout is expected # With a timeout of 1µs, a timeout is expected
- exe: './check_expire' - exe: './check_expire'
args: args:
- '-t' - '-t'
- '1' - '0.000001'
- '-H' - '-H'
- 'nic.ar' - 'bortzmeyer.org'
retcode: 3 retcode: 3
partstdout: 'Timeout' partstdout: 'Timeout'
@ -143,14 +143,14 @@ tests:
retcode: 0 retcode: 0
stderr: '' stderr: ''
# Iran, expiration date in the past # Iran, expiration date in the past. But down (2024-06-16)
- exe: './check_expire' #- exe: './check_expire'
args: # args:
- '-H' # - '-H'
- 'nic.pars' # - 'nic.pars'
retcode: 2 # retcode: 2
partstdout: "already expired" # partstdout: "already expired"
stderr: '' # stderr: ''
# Brazil # Brazil
- exe: './check_expire' - exe: './check_expire'