[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[] { |
---|
[5b277d6] | 15 | new WriteCreds("net.deterlab.abac.GENICredential"), |
---|
| 16 | new WriteCreds("net.deterlab.abac.X509Credential"), |
---|
[1fb793f] | 17 | new ReadCreds("e0-check-geni.xml", "Acme-check-geni.pem", 1), |
---|
| 18 | new ReadCreds("e0-check-x509.der", "Acme-check-x509.pem", 1), |
---|
| 19 | new ReadCreds("priv.xml", "issuer.pem", 6), |
---|
[30ed647] | 20 | new ReadCreds("ProtoGENI.xml", "PGissuer.pem", 5), |
---|
[4bd50f4] | 21 | new ReadCreds("not_ss.xml", "not_ss.pem", 1), |
---|
[5348b6c] | 22 | new RocketsTest("Rockets test"), |
---|
[c694dff] | 23 | new ExperimentTest("Experiment test"), |
---|
[811b6a4a] | 24 | new BigTest("Big test", 20), |
---|
[8375d4f] | 25 | }; |
---|
| 26 | |
---|
| 27 | public static void fatal(String s) { |
---|
| 28 | if (s != null ) |
---|
[1fb793f] | 29 | System.out.println(s); |
---|
[8375d4f] | 30 | System.exit(20); |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | public static boolean clearDir(File d) { |
---|
| 34 | for (String fn: d.list() ) { |
---|
| 35 | File f = new File(d, fn); |
---|
| 36 | |
---|
| 37 | if ( f.isDirectory() ) |
---|
| 38 | if ( !clearDir(f) ) return false; |
---|
| 39 | if ( !f.delete() ) return false; |
---|
| 40 | } |
---|
| 41 | return true; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | public static void main(String[] args) throws IOException { |
---|
| 46 | if (args.length < 2 ) |
---|
| 47 | fatal("Usage Regression regression_data_dir scratch"); |
---|
| 48 | |
---|
| 49 | File data = new File(args[0]); |
---|
| 50 | File scratch = new File(args[1]); |
---|
| 51 | |
---|
| 52 | if ( !data.isDirectory() ) |
---|
| 53 | fatal(data + " is not a directory"); |
---|
| 54 | if ( !scratch.isDirectory() ) |
---|
| 55 | fatal(scratch + " is not a directory"); |
---|
| 56 | |
---|
[6eac68b] | 57 | int i = 0; |
---|
[8375d4f] | 58 | for (RegressionTest test: tests) { |
---|
[6eac68b] | 59 | File testDir = new File(scratch, "test" +i); |
---|
| 60 | if ( testDir.isDirectory()) |
---|
| 61 | clearDir(testDir); |
---|
| 62 | if (!testDir.mkdir()) |
---|
| 63 | fatal("Cannot make " +testDir); |
---|
[8375d4f] | 64 | |
---|
[6eac68b] | 65 | if ( test.runTest(data, testDir)) |
---|
[8375d4f] | 66 | System.out.println(test.getName() + " Passed."); |
---|
| 67 | else |
---|
| 68 | fatal(test.getName() + " Failed: " + test.getReason()); |
---|
[6eac68b] | 69 | i++; |
---|
[8375d4f] | 70 | } |
---|
| 71 | System.exit(0); |
---|
| 72 | } |
---|
| 73 | } |
---|