[8375d4f] | 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[] { |
---|
[c1736fe] | 15 | new WriteCreds("net.deterlab.abac.GENICredentialv1_0"), |
---|
| 16 | new WriteCreds("net.deterlab.abac.GENICredentialv1_1"), |
---|
[5b277d6] | 17 | new WriteCreds("net.deterlab.abac.X509Credential"), |
---|
[1fb793f] | 18 | new ReadCreds("e0-check-geni.xml", "Acme-check-geni.pem", 1), |
---|
[7b4118a] | 19 | new ReadCreds("e0-check-geni11.xml", "Acme-check-geni11.pem", 1), |
---|
[1fb793f] | 20 | new ReadCreds("e0-check-x509.der", "Acme-check-x509.pem", 1), |
---|
| 21 | new ReadCreds("priv.xml", "issuer.pem", 6), |
---|
[28d6d08] | 22 | new ReadCreds("ProtoGENI.xml", "PGissuer.pem", 5, 2), |
---|
[4bd50f4] | 23 | new ReadCreds("not_ss.xml", "not_ss.pem", 1), |
---|
[5348b6c] | 24 | new RocketsTest("Rockets test"), |
---|
[c694dff] | 25 | new ExperimentTest("Experiment test"), |
---|
[811b6a4a] | 26 | new BigTest("Big test", 20), |
---|
[8375d4f] | 27 | }; |
---|
| 28 | |
---|
| 29 | public static void fatal(String s) { |
---|
| 30 | if (s != null ) |
---|
[1fb793f] | 31 | System.out.println(s); |
---|
[8375d4f] | 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 | |
---|
[6eac68b] | 59 | int i = 0; |
---|
[8375d4f] | 60 | for (RegressionTest test: tests) { |
---|
[6eac68b] | 61 | File testDir = new File(scratch, "test" +i); |
---|
| 62 | if ( testDir.isDirectory()) |
---|
| 63 | clearDir(testDir); |
---|
| 64 | if (!testDir.mkdir()) |
---|
| 65 | fatal("Cannot make " +testDir); |
---|
[8375d4f] | 66 | |
---|
[6eac68b] | 67 | if ( test.runTest(data, testDir)) |
---|
[8375d4f] | 68 | System.out.println(test.getName() + " Passed."); |
---|
| 69 | else |
---|
| 70 | fatal(test.getName() + " Failed: " + test.getReason()); |
---|
[6eac68b] | 71 | i++; |
---|
[8375d4f] | 72 | } |
---|
| 73 | System.exit(0); |
---|
| 74 | } |
---|
| 75 | } |
---|