1
0
mirror of https://github.com/laurivosandi/certidude synced 2025-10-31 01:19:11 +00:00

Add more API tests for lease, attribs etc

This commit is contained in:
2017-04-25 23:32:21 +03:00
parent 1517b902d6
commit b867eee67e
4 changed files with 83 additions and 26 deletions

View File

@@ -222,4 +222,7 @@ def certidude_app():
# Bootstrap resource
app.add_route("/api/bootstrap/", BootstrapResource())
# Add sink for serving static files
app.add_sink(StaticResource(os.path.join(__file__, "..", "..", "static")))
return app

View File

@@ -18,11 +18,14 @@ class LeaseDetailResource(object):
@login_required
@authorize_admin
def on_get(self, req, resp, cn):
path, buf, cert = authority.get_signed(cn)
return dict(
last_seen = xattr.getxattr(path, "user.lease.last_seen"),
address = xattr.getxattr(path, "user.lease.address").decode("ascii")
)
try:
path, buf, cert = authority.get_signed(cn)
return dict(
last_seen = xattr.getxattr(path, "user.lease.last_seen"),
address = xattr.getxattr(path, "user.lease.address").decode("ascii")
)
except EnvironmentError: # Certificate or attribute not found
raise falcon.HTTPNotFound()
class LeaseResource(object):