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

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

1) add the new tests

  • Property mode set to 100755
File size: 1.2 KB
Line 
1#!/usr/bin/env python
2"""
3attr4.py
4
5generate an attribute with principal initialized
6with nickname
7
8"""
9import os
10import sys
11import ABAC
12
13ctx = ABAC.Context()
14
15## this would replace
16ctx.load_id_file('./issuer.pem')
17i = ABAC.ID('./issuer.pem')
18ctx.set_nickname(i.keyid(), "Ted")
19a = ABAC.Attribute(i, 'ABAC_Guy', 20 * 365 * 24 * 3600)
20a.principal(i.keyid())
21a.bake(ctx)
22a.write_file("Ted_attr.xml")
23a.write(sys.stdout)
24
25
26## this would not replace
27ctx.load_id_file('./issuer2.pem')
28i2 = ABAC.ID('./issuer2.pem')
29ctx.set_nickname(i2.keyid(), "AnotherTed")
30a2 = ABAC.Attribute(i2, 'ABAC_Guy', 20 * 365 * 24 * 3600)
31a2.principal(i.keyid())
32a2.bake()
33a2.write_file("AnotherTed_attr.xml")
34a2.write(sys.stdout)
35
36## this would be mixed ?
37ctx.set_nickname(i.keyid(), "OtherTed")
38a3 = ABAC.Attribute(i, 'ABAC_Guy', 20 * 365 * 24 * 3600)
39a3.principal(i2.keyid())
40a3.bake(ctx)
41a3.write_file("OtherTed_attr.xml")
42a3.write(sys.stdout)
43
44
45## this would replace with original common name..
46ctx.load_id_file('./issuer3.pem')
47i3 = ABAC.ID('./issuer3.pem')
48a3 = ABAC.Attribute(i3, 'ABAC_Guy', 20 * 365 * 24 * 3600)
49a3.principal(i3.keyid())
50a3.bake(ctx)
51a3.write_file("NotTed_attr.xml")
52a3.write(sys.stdout)
53
Note: See TracBrowser for help on using the repository browser.