urn_perun_resource_attribute_def_def_apacheAuthzFile extends ResourceAttributesModuleAbstract implements ResourceAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl perunSession, Resource resource, Attribute attribute) throws WrongAttributeValueException { if (attribute.getValue() == null) return; Matcher match = pattern.matcher(attribute.valueAsString()); if(!match.matches()) { throw new WrongAttributeValueException(attribute, resource, null, "Wrong file path format in attribute (should be like '/dir1/dir2')."); } }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, Resource resource, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl perunSession, Resource resource, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongAttributeValueException.class) public void checkAttributeWithWrongSlashInFilePath() throws Exception { System.out.println("checkAttributeWithWrongValue()"); final Attribute attr = new Attribute(); attr.setValue("bad/file/path"); authzFileAttr.checkAttributeSyntax(ps, new Resource(), attr); }
@Test(expected = WrongAttributeValueException.class) public void checkAttributeWithNoSlashInFilePath() throws Exception { System.out.println("checkAttributeWithNoSlashInFilePath()"); final Attribute attr = new Attribute(); attr.setValue("pathToFile"); authzFileAttr.checkAttributeSyntax(ps, new Resource(), attr); }
@Test(expected = WrongAttributeValueException.class) public void checkAttributeEndingWithSlash() throws Exception { System.out.println("checkAttributeEndingWithSlash()"); final Attribute attr = new Attribute(); attr.setValue("/ending/with/slash/"); authzFileAttr.checkAttributeSyntax(ps, new Resource(), attr); }