source: tests/python_tests/experiment_create_rt0/query.py @ 4f79997

abac0-leakabac0-mei
Last change on this file since 4f79997 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.4 KB
Line 
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
11
12from test_util import runTest
13
14ctxt = ABAC.Context()
15
16# Keystore is the directory containing the principal credentials.
17# Load existing principals and/or policy credentials
18if (os.environ.has_key("keystore")) :
19    keystore=os.environ["keystore"]
20    ctxt.load_directory(keystore)
21else:
22    print("keystore is not set, using current directory...")
23    ctxt.load_directory(".")
24
25# retrieve principals' keyid value from local credential files
26acmeID=ABAC.ID("Acme_ID.pem");
27acmeID.load_privkey("Acme_private.pem");
28ctxt.load_id_chunk(acmeID.cert_chunk())
29acme=acmeID.keyid()
30
31bobID=ABAC.ID("Bob_ID.pem");
32bobID.load_privkey("Bob_private.pem");
33ctxt.load_id_chunk(bobID.cert_chunk())
34bob=bobID.keyid()
35
36aliceID=ABAC.ID("Alice_ID.pem");
37aliceID.load_privkey("Alice_private.pem");
38ctxt.load_id_chunk(aliceID.cert_chunk())
39alice=aliceID.keyid()
40
41globotronID=ABAC.ID("Globotron_ID.pem");
42globotronID.load_privkey("Globotron_private.pem");
43ctxt.load_id_chunk(globotronID.cert_chunk())
44globotron=globotronID.keyid()
45
46##########################################################################
47# dump the loaded attribute policies
48#
49print "\n...policy attribute set..."
50credentials = ctxt.credentials()
51for credential in credentials:
52    print "context: %s <- %s" % (credential.head().string(), credential.tail().string())
53
54##########################################################################
55# is alice a admin at Globotron ?
56# role=[keyid:Globotron].role:admin
57# p=[keyid:Alice]
58print "===good=============== Globotron.admin <- Alice"
59runTest("python_tests/experiment_create_rt0","test1",ctxt,"%s.admin" % globotron, alice, 1, "query in python")
60
61##########################################################################
62# is bob a admin at Globotron ?
63# role=[keyid:Globotron].role:admin
64# p=[keyid:Bob]
65print "===bad=============== Globotron.admin <- Bob"
66runTest("python_tests/experiment_create_rt0","test2",ctxt,"%s.admin" % globotron, bob, 0, "no linking relation")
67
68##########################################################################
69# can bob create experiment at Acme ?
70# role=[keyid:Acme].role:experiment_create
71# p=[keyid:Bob]
72print "===good=============== Acme.experiment_create <- Bob"
73runTest("python_tests/experiment_create_rt0","test3",ctxt,"%s.experiment_create" % acme, bob, 1, "query python with inference")
74
Note: See TracBrowser for help on using the repository browser.