1 | import java.io.*; |
---|
2 | import java.util.*; |
---|
3 | |
---|
4 | import net.deterlab.abac.*; |
---|
5 | import net.deterlab.abac.regression.*; |
---|
6 | |
---|
7 | |
---|
8 | /** |
---|
9 | * Simple test of the native Java implementation of ABAC. Loads credentials |
---|
10 | * from an rt0 file and runs a query against them. |
---|
11 | */ |
---|
12 | public class Regression { |
---|
13 | |
---|
14 | static RegressionTest[] tests = new RegressionTest[] { |
---|
15 | new WriteCreds("net.deterlab.abac.GENICredentialv1_0"), |
---|
16 | new WriteCreds("net.deterlab.abac.GENICredentialv1_1"), |
---|
17 | new WriteCreds("net.deterlab.abac.X509Credential"), |
---|
18 | new ReadCreds("e0-check-geni.xml", "Acme-check-geni.pem", 1), |
---|
19 | new ReadCreds("e0-check-geni11.xml", "Acme-check-geni11.pem", 1), |
---|
20 | new ReadCreds("e0-check-x509.der", "Acme-check-x509.pem", 1), |
---|
21 | new ReadCreds("priv.xml", "issuer.pem", 6), |
---|
22 | new ReadCreds("ProtoGENI.xml", "PGissuer.pem", 5, 2), |
---|
23 | new ReadCreds("not_ss.xml", "not_ss.pem", 1), |
---|
24 | new RocketsTest("Rockets test"), |
---|
25 | new ExperimentTest("Experiment test"), |
---|
26 | new BigTest("Big test", 20), |
---|
27 | }; |
---|
28 | |
---|
29 | public static void fatal(String s) { |
---|
30 | if (s != null ) |
---|
31 | System.out.println(s); |
---|
32 | System.exit(20); |
---|
33 | } |
---|
34 | |
---|
35 | public static boolean clearDir(File d) { |
---|
36 | for (String fn: d.list() ) { |
---|
37 | File f = new File(d, fn); |
---|
38 | |
---|
39 | if ( f.isDirectory() ) |
---|
40 | if ( !clearDir(f) ) return false; |
---|
41 | if ( !f.delete() ) return false; |
---|
42 | } |
---|
43 | return true; |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | public static void main(String[] args) throws IOException { |
---|
48 | if (args.length < 2 ) |
---|
49 | fatal("Usage Regression regression_data_dir scratch"); |
---|
50 | |
---|
51 | File data = new File(args[0]); |
---|
52 | File scratch = new File(args[1]); |
---|
53 | |
---|
54 | if ( !data.isDirectory() ) |
---|
55 | fatal(data + " is not a directory"); |
---|
56 | if ( !scratch.isDirectory() ) |
---|
57 | fatal(scratch + " is not a directory"); |
---|
58 | |
---|
59 | int i = 0; |
---|
60 | for (RegressionTest test: tests) { |
---|
61 | File testDir = new File(scratch, "test" +i); |
---|
62 | if ( testDir.isDirectory()) |
---|
63 | clearDir(testDir); |
---|
64 | if (!testDir.mkdir()) |
---|
65 | fatal("Cannot make " +testDir); |
---|
66 | |
---|
67 | if ( test.runTest(data, testDir)) |
---|
68 | System.out.println(test.getName() + " Passed."); |
---|
69 | else |
---|
70 | fatal(test.getName() + " Failed: " + test.getReason()); |
---|
71 | i++; |
---|
72 | } |
---|
73 | System.exit(0); |
---|
74 | } |
---|
75 | } |
---|