summaryrefslogtreecommitdiff
path: root/src/cz/crcs/ectester/reader/test/InvalidCurvesSuite.java
diff options
context:
space:
mode:
authorJ08nY2017-11-05 16:48:30 +0100
committerJ08nY2017-11-05 16:48:30 +0100
commitdaaa7abd91ff8ae12e0b1835045489acbda0539f (patch)
tree1a2a944473285359a9af3691f2ce69b608264f12 /src/cz/crcs/ectester/reader/test/InvalidCurvesSuite.java
parent16f20afbff36a7e048d24d7e7d1db8657f002c5e (diff)
downloadECTester-daaa7abd91ff8ae12e0b1835045489acbda0539f.tar.gz
ECTester-daaa7abd91ff8ae12e0b1835045489acbda0539f.tar.zst
ECTester-daaa7abd91ff8ae12e0b1835045489acbda0539f.zip
Implement Result.ExpectedValue to add more logic to test evaluation.
- Introduces a new enum Result.ExpectedValue, which is used to signify what Test results are expected. - Changes the Result.Value enum to contain information about what was expected. It gains more values: - UXSUCCESS -> Unexpected success. - XFAILURE -> Expected failure. The values SUCCESS and XFAILURE are the OK, values. - Creates a hierarchy of evaluating Responses, Simple tests and Compoung tests. Simple test evaluates the OK property of the response object (using .successfull() method) and again exposes its OK property which depends on the tests ExpectedValue and the response success. Compound test evaluates the OK property of the Simple tests it contains (using the .ok() method) and again exposes its OK property which depends on the concrete Compound test variant, but involves some ExpectedValues and the success of the individual Simple tests it contains.
Diffstat (limited to 'src/cz/crcs/ectester/reader/test/InvalidCurvesSuite.java')
-rw-r--r--src/cz/crcs/ectester/reader/test/InvalidCurvesSuite.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/cz/crcs/ectester/reader/test/InvalidCurvesSuite.java b/src/cz/crcs/ectester/reader/test/InvalidCurvesSuite.java
index 229a5a3..f61b695 100644
--- a/src/cz/crcs/ectester/reader/test/InvalidCurvesSuite.java
+++ b/src/cz/crcs/ectester/reader/test/InvalidCurvesSuite.java
@@ -16,6 +16,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import static cz.crcs.ectester.reader.test.Result.ExpectedValue;
+
/**
* @author Jan Jancar johny@neuromancer.sk
*/
@@ -51,16 +53,16 @@ public class InvalidCurvesSuite extends TestSuite {
EC_Curve curve = e.getKey();
List<EC_Key.Public> keys = e.getValue();
- tests.add(new Test.Simple(new Command.Allocate(cardManager, ECTesterApplet.KEYPAIR_BOTH, curve.getBits(), curve.getField()), Result.Value.SUCCESS));
- tests.add(new Test.Simple(new Command.Set(cardManager, ECTesterApplet.KEYPAIR_BOTH, EC_Consts.CURVE_external, curve.getParams(), curve.flatten()), Result.Value.SUCCESS));
- tests.add(new Test.Simple(new Command.Generate(cardManager, ECTesterApplet.KEYPAIR_LOCAL), Result.Value.SUCCESS));
+ tests.add(new Test.Simple(new Command.Allocate(cardManager, ECTesterApplet.KEYPAIR_BOTH, curve.getBits(), curve.getField()), ExpectedValue.SUCCESS));
+ tests.add(new Test.Simple(new Command.Set(cardManager, ECTesterApplet.KEYPAIR_BOTH, EC_Consts.CURVE_external, curve.getParams(), curve.flatten()), ExpectedValue.SUCCESS));
+ tests.add(new Test.Simple(new Command.Generate(cardManager, ECTesterApplet.KEYPAIR_LOCAL), ExpectedValue.SUCCESS));
List<Test> ecdhTests = new LinkedList<>();
for (EC_Key.Public pub : keys) {
Command ecdhCommand = new Command.ECDH_direct(cardManager, ECTesterApplet.KEYPAIR_LOCAL, ECTesterApplet.EXPORT_FALSE, EC_Consts.CORRUPTION_NONE, EC_Consts.KA_ANY, pub.flatten());
- ecdhTests.add(new Test.Simple(ecdhCommand, Result.Value.FAILURE, "Card correctly rejected point on invalid curve." , "Card incorrectly accepted point on invalid curve."));
+ ecdhTests.add(new Test.Simple(ecdhCommand, ExpectedValue.FAILURE, "Card correctly rejected point on invalid curve." , "Card incorrectly accepted point on invalid curve."));
}
- tests.add(Test.Compound.all(Result.Value.SUCCESS, "Invalid curve test of " + curve.getId(), ecdhTests.toArray(new Test[0])));
- tests.add(new Test.Simple(new Command.Cleanup(cardManager), Result.Value.ANY));
+ tests.add(Test.Compound.all(ExpectedValue.SUCCESS, "Invalid curve test of " + curve.getId(), ecdhTests.toArray(new Test[0])));
+ tests.add(new Test.Simple(new Command.Cleanup(cardManager), ExpectedValue.ANY));
}
}
}