Skip to content

Commit

Permalink
CASSH Client : Add version and new status "NEVER SIGNED"
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Beguier committed Oct 4, 2017
1 parent 977c259 commit 93a1151
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cassh
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ class CASSH(object):
if result == {}:
print(dumps(result, indent=4, sort_keys=True))
return
is_expired = datetime.strptime(result['expiration'],
'%Y-%m-%d %H:%M:%S') < datetime.now()
date_formatted = datetime.strptime(result['expiration'], '%Y-%m-%d %H:%M:%S')
is_expired = date_formatted < datetime.now()
if result['status'] == 'ACTIVE':
if is_expired:
if is_expired and date_formatted.year == 1970:
result['status'] = 'NEVER SIGNED'
elif is_expired:
result['status'] = 'EXPIRED'
else:
result['status'] = 'SIGNED'
Expand Down Expand Up @@ -172,7 +174,7 @@ class CASSH(object):
except ConnectionError:
print('Connection error : %s' % self.url)
exit(1)
if 'Error' in req.text:
if 'Error' in req.text or 'Status' in req.text:
print(req.text)
exit(1)
if do_write_on_disk:
Expand Down Expand Up @@ -209,9 +211,12 @@ class CASSH(object):
if result == {}:
print(dumps(result, indent=4, sort_keys=True))
return
is_expired = datetime.strptime(result['expiration'], '%Y-%m-%d %H:%M:%S') < datetime.now()
date_formatted = datetime.strptime(result['expiration'], '%Y-%m-%d %H:%M:%S')
is_expired = date_formatted < datetime.now()
if result['status'] == 'ACTIVE':
if is_expired:
if is_expired and date_formatted.year == 1970:
result['status'] = 'NEVER SIGNED'
elif is_expired:
result['status'] = 'EXPIRED'
else:
result['status'] = 'SIGNED'
Expand Down Expand Up @@ -261,6 +266,8 @@ if __name__ == '__main__':

SUBPARSERS = PARSER.add_subparsers(help='commands')

PARSER.add_argument('--version', action='version', version='%(prog)s 1.0.0')

# ADMIN Arguments
ADMIN_PARSER = SUBPARSERS.add_parser('admin',\
help='Administrator command : active - revoke - delete - status keys')
Expand Down

0 comments on commit 93a1151

Please sign in to comment.