AggregationHashChainLinkMetadataRule extends BaseRule { public VerificationErrorCode getErrorCode() { return VerificationErrorCode.INT_11; }  VerificationResultCode verifySignature(VerificationContext context); VerificationErrorCode getErrorCode();  }
@Test public void testMetadataWithPaddingNotFirstElement() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_METADATA_WRONG_ORDER))); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(rule.getErrorCode(), VerificationErrorCode.INT_11); }
@Test public void testMetadataWithMultiplePadding() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_METADATA_MULTIPLE_PADDINGS))); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(rule.getErrorCode(), VerificationErrorCode.INT_11); }
@Test public void testMetadataWithTooLongPadding() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_METADATA_PADDING_TOO_LONG))); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(rule.getErrorCode(), VerificationErrorCode.INT_11); }
@Test public void testMetadataWithInvalidPaddingContent() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_METADATA_WRONG_CONTENT))); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(rule.getErrorCode(), VerificationErrorCode.INT_11); }
@Test public void testMetadataWithPaddingForwardFlagNotSet() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_METADATA_PADDING_F_FLAG_NOT_SET))); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(rule.getErrorCode(), VerificationErrorCode.INT_11); }
@Test public void testMetadataWithPaddingNonCriticalFlagNotSet() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_METADATA_PADDING_N_FLAG_NOT_SET))); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(rule.getErrorCode(), VerificationErrorCode.INT_11); }
@Test public void testMetadataWithPaddingTLV16FlagSet() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_METADATA_PADDING_TLV_16_FLAG_SET))); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(rule.getErrorCode(), VerificationErrorCode.INT_11); }
@Test public void testMetadataWithPaddingNoFlagsSet() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_METADATA_PADDING_FLAGS_NOT_SET))); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(rule.getErrorCode(), VerificationErrorCode.INT_11); }
@Test public void testMetadataWithPaddingTooShort() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_METADATA_PADDING_TOO_SHORT))); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(rule.getErrorCode(), VerificationErrorCode.INT_11); }
@Test public void testMetadataMatchesHashImprint() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_METADATA_MATCHING_HASH_IMPRINT))); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.FAIL); Assert.assertEquals(rule.getErrorCode(), VerificationErrorCode.INT_11); }
@Test public void testCorrectMetadataWithPadding() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_2017_03_14))); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.OK); Assert.assertEquals(rule.getErrorCode(), VerificationErrorCode.INT_11); }
@Test public void testMetadataWithMissingPaddingNotMistakenForHashImprint() throws Exception { RuleResult result = rule.verify(build(TestUtil.loadSignature(SIGNATURE_METADATA_MISSING_PADDING))); Assert.assertNotNull(result); Assert.assertEquals(result.getResultCode(), VerificationResultCode.OK); Assert.assertEquals(rule.getErrorCode(), VerificationErrorCode.INT_11); }