source: tests/python_tests/acme_rockets_intersection_rt0/query.py @ 65e3c6b

abac0-leakabac0-mei 0.1.5
Last change on this file since 65e3c6b was 3c30b59, checked in by Mei <mei@…>, 11 years ago

1) add in new refactored regression testing directory
2) undo the abac.hh/ABAC.hh api changes
3) merged with Ted's changes to attribute format/nickname/issuer processing

  • Property mode set to 100755
File size: 2.0 KB
RevLine 
[be6cb41]1#!/usr/bin/env python
2
3"""
4Run the queries described in README
5
6cmd:env keystore=`pwd` ./query.py
7"""
8
9import os
10import ABAC
[3c30b59]11from test_util import runTest
[be6cb41]12
13ctxt = ABAC.Context()
14
15# Keystore is the directory containing the principal credentials.
16# Load existing principals and/or policy credentials
17if (os.environ.has_key("keystore")) :
18    keystore=os.environ["keystore"]
19    ctxt.load_directory(keystore)
20else:
[3c30b59]21    print("keystore is not set, using current directory...")
22    ctxt.load_directory(".")
[be6cb41]23
24# retrieve principals' keyid value from local credential files
25acmeID=ABAC.ID("Acme_ID.pem");
26acmeID.load_privkey("Acme_private.pem");
27acme=acmeID.keyid()
28
29coyoteID=ABAC.ID("Coyote_ID.pem");
30coyoteID.load_privkey("Coyote_private.pem");
31coyote=coyoteID.keyid()
32
33warnerbrosID=ABAC.ID("WarnerBros_ID.pem");
34warnerbrosID.load_privkey("WarnerBros_private.pem");
35warnerbros=warnerbrosID.keyid()
36
37batmanID=ABAC.ID("Batman_ID.pem");
38batmanID.load_privkey("Batman_private.pem");
39batman=batmanID.keyid()
40
41##########################################################################
42# dump the loaded principals/policies
43#
44print "\n...policy attribute set..."
45credentials = ctxt.credentials()
46for credential in credentials:
47    print "context: %s <- %s" % (credential.head().string(), credential.tail().string())
48
49##########################################################################
50# can coyote buy rockets from Acme ?
51# role = "[keyid:Acme].role:buy_rockets"
52# p = "[keyid:coyote]"
[3c30b59]53print "===good============ Acme.buy_rockets <- Coyote"
54runTest("python_tests/acme_rockets_intersection_rt0","test1",ctxt,"%s.buy_rockets" % acme, coyote, 1, "query in python with intersect")
[be6cb41]55
56##########################################################################
57# can batman buy rockets from Acme ?
58# role = "[keyid:Acme].role:buy_rockets"
59# p = "[keyid:batman]"
[3c30b59]60print "===bad============ Acme.buy_rockets <- Batman"
61runTest("python_tests/acme_rockets_intersection_rt0","test2",ctxt,"%s.buy_rockets" % acme, batman, 0, "expected failure, no such relation in db")
62
[be6cb41]63
Note: See TracBrowser for help on using the repository browser.