source: tests/example_scripts/wiki/ctxtQuery3.py @ 7c748c9

abac0-leakabac0-mei
Last change on this file since 7c748c9 was 7c748c9, checked in by Mei <mei@…>, 6 years ago

1) more new tests

  • Property mode set to 100755
File size: 882 bytes
Line 
1#!/usr/bin/env python
2"""
3ctxtQuery3.py
4 
5shows auto loading of self-contained attribute
6
7  externally,
8      make a,
9      make b,
10      make c,
11      make a.yes <- c
12      make b.no <- c
13
14  load a
15  load a.yes <-c
16  load b.no <- c
17
18  query b.no <-?-c
19  query a.yes <-?-c
20
21  todo, dump principals
22"""
23import os
24
25import ABAC
26ctxt = ABAC.Context()
27
28aID=ABAC.ID("A_ID.pem");
29a=aID.keyid()
30bID=ABAC.ID("B_ID.pem");
31b=bID.keyid()
32cID=ABAC.ID("C_ID.pem");
33c=cID.keyid()
34
35ctxt.load_id_chunk(aID.cert_chunk())
36ctxt.load_attribute_file("A_yes__C_attr.xml")
37ctxt.load_attribute_file("B_no__C_attr.xml")
38
39# Same code as above to initialize the ids and load the context
40
41ok, proof = ctxt.query(a + ".yes", c)
42print "regular, ok? %d" %ok
43
44ok, proof = ctxt.query(b + ".no", c)
45print "self contain, ok? %d" %ok
46
47## should also dump the context principal to make sure b is not in the
48## context
Note: See TracBrowser for help on using the repository browser.