@Test public void failedKeyUsageCheck() throws Exception { List<String> keyUsageBits = new ArrayList<String>(); keyUsageBits.add("Valid_Key"); MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Invalid_Key"); XmlCertificate xc = new XmlCertificate(); xc.setKeyUsageBits(keyUsageBits); XmlSubXCV result = new XmlSubXCV(); KeyUsageCheck kuc = new KeyUsageCheck(result, new CertificateWrapper(xc), constraint); kuc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void claimedRolesCheck() throws Exception { List<String> claimedRoles = new ArrayList<String>(); claimedRoles.add("Claimed_Role"); XmlSignature sig = new XmlSignature(); sig.setClaimedRoles(claimedRoles); MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Claimed_Role"); XmlSAV result = new XmlSAV(); ClaimedRolesCheck crc = new ClaimedRolesCheck(result, new SignatureWrapper(sig), constraint); crc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void certificateQCStatementCheck() throws Exception { List<XmlOID> qcStatementIds = new ArrayList<XmlOID>(); XmlOID oid = new XmlOID(); oid.setValue("0.4.0.1862.1.1"); qcStatementIds.add(oid); MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("0.4.0.1862.1.1"); XmlCertificate xc = new XmlCertificate(); xc.setQCStatementIds(qcStatementIds); XmlSubXCV result = new XmlSubXCV(); CertificateQCStatementIdsCheck cqcsic = new CertificateQCStatementIdsCheck(result, new CertificateWrapper(xc), constraint); cqcsic.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void failedOrganizationUnitCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Invalid_Org"); XmlCertificate xc = new XmlCertificate(); xc.setOrganizationalUnit("Valid_Org"); XmlSubXCV result = new XmlSubXCV(); OrganizationUnitCheck ouc = new OrganizationUnitCheck(result, new CertificateWrapper(xc), constraint); ouc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void pseudonymCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Valid_Pseudonym"); XmlCertificate xc = new XmlCertificate(); xc.setPseudonym("Valid_Pseudonym"); XmlSubXCV result = new XmlSubXCV(); PseudonymCheck pc = new PseudonymCheck(result, new CertificateWrapper(xc), constraint); pc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void failedCommonNameCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Invalid_Name"); XmlCertificate xc = new XmlCertificate(); xc.setCommonName("Valid_Name"); XmlSubXCV result = new XmlSubXCV(); CommonNameCheck cnc = new CommonNameCheck(result, new CertificateWrapper(xc), constraint); cnc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void certifiedRolesCheck() throws Exception { XmlCertifiedRole xcr = new XmlCertifiedRole(); xcr.setCertifiedRole("Valid_Role"); XmlSignature sig = new XmlSignature(); sig.getCertifiedRoles().add(xcr); MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Valid_Role"); XmlSAV result = new XmlSAV(); CertifiedRolesCheck crc = new CertifiedRolesCheck(result, new SignatureWrapper(sig), constraint); crc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void validFormat() throws Exception { XmlSignature sig = new XmlSignature(); sig.setSignatureFormat("CAdES_BASELINE_B"); MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("CAdES_BASELINE_B"); XmlFC result = new XmlFC(); FormatCheck fc = new FormatCheck(result, new SignatureWrapper(sig), constraint); fc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void failedSurnameCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Invalid_Surname"); XmlCertificate xc = new XmlCertificate(); xc.setSurname("Valid_Surname"); XmlSubXCV result = new XmlSubXCV(); SurnameCheck sc = new SurnameCheck(result, new CertificateWrapper(xc), constraint); sc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void failedOrganizationNameCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Invalid_Org"); XmlCertificate xc = new XmlCertificate(); xc.setOrganizationName("Valid_Org"); XmlSubXCV result = new XmlSubXCV(); OrganizationNameCheck onc = new OrganizationNameCheck(result, new CertificateWrapper(xc), constraint); onc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void failedGivenNameCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Invalid_Name"); XmlCertificate xc = new XmlCertificate(); xc.setGivenName("Valid_Name"); XmlSubXCV result = new XmlSubXCV(); GivenNameCheck gnc = new GivenNameCheck(result, new CertificateWrapper(xc), constraint); gnc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void invalidFormat() throws Exception { XmlSignature sig = new XmlSignature(); sig.setSignatureFormat("Invalid_format"); MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("CAdES_BASELINE_B"); XmlFC result = new XmlFC(); FormatCheck fc = new FormatCheck(result, new SignatureWrapper(sig), constraint); fc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void countryCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("BE"); XmlCertificate xc = new XmlCertificate(); xc.setCountryName("BE"); XmlSubXCV result = new XmlSubXCV(); CountryCheck cc = new CountryCheck(result, new CertificateWrapper(xc), constraint); cc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void commonNameCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Valid_Name"); XmlCertificate xc = new XmlCertificate(); xc.setCommonName("Valid_Name"); XmlSubXCV result = new XmlSubXCV(); CommonNameCheck cnc = new CommonNameCheck(result, new CertificateWrapper(xc), constraint); cnc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void givenNameCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Valid_Name"); XmlCertificate xc = new XmlCertificate(); xc.setGivenName("Valid_Name"); XmlSubXCV result = new XmlSubXCV(); GivenNameCheck gnc = new GivenNameCheck(result, new CertificateWrapper(xc), constraint); gnc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void failedCountryCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("BE"); XmlCertificate xc = new XmlCertificate(); xc.setCountryName("LU"); XmlSubXCV result = new XmlSubXCV(); CountryCheck cc = new CountryCheck(result, new CertificateWrapper(xc), constraint); cc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void surnameCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Valid_Surname"); XmlCertificate xc = new XmlCertificate(); xc.setSurname("Valid_Surname"); XmlSubXCV result = new XmlSubXCV(); SurnameCheck sc = new SurnameCheck(result, new CertificateWrapper(xc), constraint); sc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void failedPseudonymCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Invalid_Pseudonym"); XmlCertificate xc = new XmlCertificate(); xc.setPseudonym("Valid_Pseudonym"); XmlSubXCV result = new XmlSubXCV(); PseudonymCheck pc = new PseudonymCheck(result, new CertificateWrapper(xc), constraint); pc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void organizationUnitCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Valid_Org"); XmlCertificate xc = new XmlCertificate(); xc.setOrganizationalUnit("Valid_Org"); XmlSubXCV result = new XmlSubXCV(); OrganizationUnitCheck ouc = new OrganizationUnitCheck(result, new CertificateWrapper(xc), constraint); ouc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void organizationNameCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Valid_Org"); XmlCertificate xc = new XmlCertificate(); xc.setOrganizationName("Valid_Org"); XmlSubXCV result = new XmlSubXCV(); OrganizationNameCheck onc = new OrganizationNameCheck(result, new CertificateWrapper(xc), constraint); onc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }