InputHashLevelVerificationRule extends BaseRule { VerificationErrorCode getErrorCode() { return VerificationErrorCode.GEN_03; }    }
@Test public void testLevelNotProvided() throws Exception { KSISignature signature = TestUtil.loadSignature(SIGNATURE_INPUT_HASH_LEVEL_5); RuleResult result = rule.verify(build(signature)); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.OK); Assert.assertNull(result.getErrorCode()); }
@Test public void testProvidedLevelSmaller() throws Exception { KSISignature signature = TestUtil.loadSignature(SIGNATURE_INPUT_HASH_LEVEL_5); RuleResult result = rule.verify(build(signature, 4L)); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.OK); Assert.assertNull(result.getErrorCode()); }
@Test public void testProvidedLevelEqual() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_INPUT_HASH_LEVEL_5), 5L)); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.OK); Assert.assertNull(result.getErrorCode()); }
@Test public void testProvidedLevelBigger() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_INPUT_HASH_LEVEL_5), 11L)); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(result.getErrorCode(), VerificationErrorCode.GEN_03); }
@Test public void testRfc3161SignatureProvidedLevelZero() throws Exception { KSISignature signature = TestUtil.loadSignature(RFC3161_SIGNATURE); RuleResult result = rule.verify(build(signature, 0L)); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.OK); Assert.assertNull(result.getErrorCode()); }
@Test public void testRfc3161SignatureProvidedLevelOne() throws Exception { KSISignature signature = TestUtil.loadSignature(RFC3161_SIGNATURE); RuleResult result = rule.verify(build(signature, 1L)); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(result.getErrorCode(), VerificationErrorCode.GEN_03); }