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