urn_perun_user_attribute_def_def_vsupMail extends UserAttributesModuleAbstract implements UserAttributesModuleImplApi { @Override public void checkAttributeSemantics(PerunSessionImpl sess, User user, Attribute attribute) throws WrongAttributeAssignmentException, WrongReferenceAttributeValueException { if (attribute.getValue() != null) { try { Attribute login = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, user, A_U_D_loginNamespace_vsup); if (login.getValue() != null && attribute.getValue() != null) { if (!Objects.equals(login.getValue()+"@vsup.cz", attribute.getValue())) throw new WrongReferenceAttributeValueException(attribute, login, user, null, user, null, "VŠUP mail must match users login at VŠUP."); } } catch (AttributeNotExistsException e) { throw new ConsistencyErrorException("Attribute for login-namespace: vsup doesn't exists.", e); } } }  @Override void checkAttributeSyntax(PerunSessionImpl sess, User user, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl sess, User user, Attribute attribute); @Override List<String> getDependencies(); @Override void changedAttributeHook(PerunSessionImpl session, User user, Attribute attribute); @Override AttributeDefinition getAttributeDefinition(); static final Pattern emailPattern; static final String usedMailsUrn; static final String usedMailsKeyVsup; static final String vsupMailUrn; static final String vsupMailAliasUrn; static final String vsupMailAliasesUrn; static final String vsupPreferredMailUrn; }
@Test(expected = WrongReferenceAttributeValueException.class) public void testCheckSemanticsWithInvalidLogin() throws Exception { System.out.println("testCheckSemanticsWithInvalidLogin()"); reqAttribute.setValue("bad_example"); attributeToCheck.setValue("example@vsup.cz"); classInstance.checkAttributeSemantics(session, user, attributeToCheck); }
@Test public void testCorrectSemantics() throws Exception { System.out.println("testCorrectSemantics()"); reqAttribute.setValue("example"); attributeToCheck.setValue("example@vsup.cz"); classInstance.checkAttributeSemantics(session, user, attributeToCheck); }