1 | #!/usr/bin/python |
---|
2 | |
---|
3 | # Copyright (C) International Business Machines Corp., 2006 |
---|
4 | # Author: Stefan Berger <stefanb@us.ibm.com> |
---|
5 | # |
---|
6 | # A test that exercises the conflict set of the chinese wall policy. |
---|
7 | # Start a first domain and then a second one. The second one is |
---|
8 | # expected NOT to be starteable. |
---|
9 | |
---|
10 | from XmTestLib import * |
---|
11 | from acm_utils import * |
---|
12 | import commands |
---|
13 | import os |
---|
14 | |
---|
15 | testlabel1 = "blue" |
---|
16 | testlabel2 = "red" |
---|
17 | |
---|
18 | config = {"access_control":"policy=%s,label=%s" % (testpolicy,testlabel1)} |
---|
19 | |
---|
20 | domain1 = XmTestDomain(name="domain-%s" % testlabel1, |
---|
21 | extraConfig=config) |
---|
22 | |
---|
23 | try: |
---|
24 | domain1.start(noConsole=True) |
---|
25 | except DomainError, e: |
---|
26 | if verbose: |
---|
27 | print e.extra |
---|
28 | FAIL("Unable to start 1st labeled test domain") |
---|
29 | |
---|
30 | # Verify with xm dry-run |
---|
31 | status, output = traceCommand("xm dry-run /tmp/xm-test.conf | " |
---|
32 | "grep -v \"Dry Run\"") |
---|
33 | if status != 0: |
---|
34 | FAIL("'xm dry-run' failed") |
---|
35 | if not re.search("PERMITTED", output): |
---|
36 | FAIL("'xm dry-run' did not succeed.") |
---|
37 | |
---|
38 | config = {"access_control":"policy=%s,label=%s" % (testpolicy,testlabel2)} |
---|
39 | |
---|
40 | domain2 = XmTestDomain(name="domain-%s" % testlabel2, |
---|
41 | extraConfig=config) |
---|
42 | |
---|
43 | try: |
---|
44 | domain2.start(noConsole=True) |
---|
45 | # Should never get here! |
---|
46 | FAIL("Could start a domain in a conflict set - " |
---|
47 | "this should not be possible") |
---|
48 | except DomainError, e: |
---|
49 | #This is exactly what we want in this case |
---|
50 | status = 0 |
---|
51 | |
---|
52 | # Verify with xm dry-run |
---|
53 | status, output = traceCommand("xm dry-run /tmp/xm-test.conf | " |
---|
54 | "grep -v \"Dry Run\"") |
---|
55 | if status != 0: |
---|
56 | FAIL("'xm dry-run' failed.") |
---|
57 | if not re.search("PERMITTED", output): |
---|
58 | FAIL("'xm dry-run' did not show that operation was permitted.") |
---|
59 | |
---|
60 | domain1.destroy() |
---|