source: examples/scaling_tests/daisychain/likes_python/base/BQUERY.py @ 2485307

mei_rt2mei_rt2_fix_1
Last change on this file since 2485307 was 373bf68, checked in by Mei <mei@…>, 12 years ago

1) add the scaling test suite

  • Property mode set to 100755
File size: 1.4 KB
Line 
1#!/usr/bin/env python
2
3"""
4Run the queries described in README
5
6cmd2: env ABAC_CN=1 keystore=`pwd` ./query.py
7
8"""
9
10import os
11import ABAC
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:
21    print("keystore is not set...")
22    exit(1)
23
24##########################################################################
25# dump the loaded principals/policies
26#
27
28fd=os.open("creds_dump",os.O_WRONLY|os.O_CREAT)
29out = ctxt.context_principals()
30for x in out[1]:
31    os.write(fd, x.string())
32    os.write(fd,"\n")
33out = ctxt.context_credentials()
34for c in out[1]:
35    string="%s <- %s" % (c.head_string(), c.tail_string())
36    os.write(fd,string) 
37    os.write(fd,"\n")
38os.close(fd)
39
40##########################################################################
41# Does John0 likes JohnX ?
42# role = [keyid:JohnX].role:after
43# p [Keyid:john0]
44bid="John%s_ID.pem"% #VAL#
45bID=ABAC.ID(bid)
46b=bID.id_keyid()
47
48aID=ABAC.ID("John0_ID.pem")
49a=aID.id_keyid()
50
51role = ABAC.Role(a,"likes")
52p = ABAC.Role(b)
53
54print "\n===bad============ john0.likes <- johnX "
55out = ctxt.query(role, p)
56for c in out[1]:
57    print "%s <- %s" % (c.head_string(), c.tail_string())
58
59#### border case for VAL=0 (faking it) ####
60if ( #VAL# == 0) :
61    print "YAP query failed (fake)\n"
62
Note: See TracBrowser for help on using the repository browser.