target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void testFilterPasswordsInMessage() { final String input = "" + "red: adsfasdf\n" + "blue: asdfasdfasdf\n" + "yellow%3A++asdfasdfasdf\n" + "green: asdfasdfasdf # password: test\n" + "purple: password\n" + "password: test1 \n" + "password:test2\n" + "password: test3\n" + "password%3A++test4\n" + "password%3A++test5\n" + "delete: adsf\n"; assertThat(PasswordFilter.filterPasswordsInContents(input), containsString("" + "red: adsfasdf\n" + "blue: asdfasdfasdf\n" + "yellow%3A++asdfasdfasdf\n" + "green: asdfasdfasdf # password: test\n" + "purple: password\n" + "password:FILTERED\n" + "password:FILTERED\n" + "password:FILTERED\n" + "password%3AFILTERED\n" + "password%3AFILTERED\n" + "delete: adsf\n")); }
public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; }
PasswordFilter { public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; } }
PasswordFilter { public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; } }
PasswordFilter { public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; } static String filterPasswordsInContents(final String contents); static String filterPasswordsInUrl(final String url); }
PasswordFilter { public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; } static String filterPasswordsInContents(final String contents); static String filterPasswordsInUrl(final String url); }
@Test public void validate_allowed_address() { when(preparedUpdate.getUpdatedObject()).thenReturn(RpslObject.parse("mntner: OWNER-MNT\nupd-to: [email protected]\nsource: TEST")); excludedEmailValidator.validate(preparedUpdate, updateContext); verify(updateContext, never()).addMessage(Matchers.<Update>anyObject(), Matchers.<RpslAttribute>anyObject(), Matchers.<Message>anyObject()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } @Autowired ExcludedEmailValidator( @Value("#{'${email.excluded:}'.split(',')}") final List<String> excludedEmailAddresses); }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } @Autowired ExcludedEmailValidator( @Value("#{'${email.excluded:}'.split(',')}") final List<String> excludedEmailAddresses); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } @Autowired ExcludedEmailValidator( @Value("#{'${email.excluded:}'.split(',')}") final List<String> excludedEmailAddresses); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_excluded_address() { when(preparedUpdate.getUpdatedObject()).thenReturn(RpslObject.parse("mntner: OWNER-MNT\nupd-to: [email protected]\nsource: TEST")); excludedEmailValidator.validate(preparedUpdate, updateContext); verify(updateContext).addMessage(Matchers.<Update>anyObject(), Matchers.<RpslAttribute>anyObject(), Matchers.<Message>anyObject()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } @Autowired ExcludedEmailValidator( @Value("#{'${email.excluded:}'.split(',')}") final List<String> excludedEmailAddresses); }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } @Autowired ExcludedEmailValidator( @Value("#{'${email.excluded:}'.split(',')}") final List<String> excludedEmailAddresses); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } @Autowired ExcludedEmailValidator( @Value("#{'${email.excluded:}'.split(',')}") final List<String> excludedEmailAddresses); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_excluded_address_is_case_insensitive() { when(preparedUpdate.getUpdatedObject()).thenReturn(RpslObject.parse("mntner: OWNER-MNT\nupd-to: [email protected]\nsource: TEST")); excludedEmailValidator.validate(preparedUpdate, updateContext); verify(updateContext).addMessage(Matchers.<Update>anyObject(), Matchers.<RpslAttribute>anyObject(), Matchers.<Message>anyObject()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } @Autowired ExcludedEmailValidator( @Value("#{'${email.excluded:}'.split(',')}") final List<String> excludedEmailAddresses); }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } @Autowired ExcludedEmailValidator( @Value("#{'${email.excluded:}'.split(',')}") final List<String> excludedEmailAddresses); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } @Autowired ExcludedEmailValidator( @Value("#{'${email.excluded:}'.split(',')}") final List<String> excludedEmailAddresses); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_excluded_name_and_address() { when(preparedUpdate.getUpdatedObject()).thenReturn(RpslObject.parse("mntner: OWNER-MNT\nupd-to: RIPE DBM <[email protected]>\nsource: TEST")); excludedEmailValidator.validate(preparedUpdate, updateContext); verify(updateContext).addMessage(Matchers.<Update>anyObject(), Matchers.<RpslAttribute>anyObject(), Matchers.<Message>anyObject()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } @Autowired ExcludedEmailValidator( @Value("#{'${email.excluded:}'.split(',')}") final List<String> excludedEmailAddresses); }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } @Autowired ExcludedEmailValidator( @Value("#{'${email.excluded:}'.split(',')}") final List<String> excludedEmailAddresses); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ExcludedEmailValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER) || subject.hasPrincipal(Principal.RS_MAINTAINER)) { return; } final RpslObject updatedObject = update.getUpdatedObject(); for (final RpslAttribute attribute : updatedObject.getAttributes()) { if (EMAIL_ATTRIBUTES.contains(attribute.getType())) { try { final CIString address = CIString.ciString(getAddress(attribute.getValue())); if (excludedEmailAddresses.contains(address)) { updateContext.addMessage(update, attribute, UpdateMessages.emailAddressCannotBeUsed(address)); } } catch (IllegalArgumentException e) { LOGGER.debug("Skipped {} attribute in {} due to: {}", attribute.getType().getName(), updatedObject.getKey(), e.getMessage()); } } } } @Autowired ExcludedEmailValidator( @Value("#{'${email.excluded:}'.split(',')}") final List<String> excludedEmailAddresses); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.DELETE)); }
@Override public ImmutableList<Action> getActions() { return ACTIONS; }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_no_original_object() { subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_not_referenced() { final RpslObject object = RpslObject.parse("mntner: TST-MNT"); when(update.getReferenceObject()).thenReturn(object); when(rpslObjectUpdateDao.getInvalidReferences(object)).thenReturn(Collections.<RpslAttribute, Set<CIString>>emptyMap()); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_referenced() { final RpslObject object = RpslObject.parse("mntner: TST-MNT\nadmin-c: ADMIN-NC"); when(update.getType()).thenReturn(ObjectType.MNTNER); when(update.hasOriginalObject()).thenReturn(true); when(update.getReferenceObject()).thenReturn(object); when(rpslObjectUpdateDao.isReferenced(object)).thenReturn(true); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.objectInUse(object)); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_referenced_autnum() { final RpslObject object = RpslObject.parse("aut-num: AS1"); when(update.getType()).thenReturn(ObjectType.AUT_NUM); when(update.hasOriginalObject()).thenReturn(true); when(update.getReferenceObject()).thenReturn(object); when(rpslObjectUpdateDao.isReferenced(object)).thenReturn(true); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ObjectReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (!update.hasOriginalObject() || update.getType().equals(ObjectType.AUT_NUM)) { return; } if (rpslObjectUpdateDao.isReferenced(update.getReferenceObject())) { updateContext.addMessage(update, UpdateMessages.objectInUse(update.getReferenceObject())); } } @Autowired ObjectReferencedValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void valid_country() { when(repository.getCountryCodes()).thenReturn(CIString.ciSet("DK", "UK")); final RpslObject rpslObject = RpslObject.parse("inetnum: 193.0/32\ncountry:DK"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(PreparedUpdate update, UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.COUNTRY)) { return; } final Set<CIString> countryCodes = countryCodeRepository.getCountryCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.COUNTRY)) { if (!countryCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, attribute, UpdateMessages.countryNotRecognised(attribute.getCleanValue())); } } }
CountryValidator implements BusinessRuleValidator { @Override public void validate(PreparedUpdate update, UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.COUNTRY)) { return; } final Set<CIString> countryCodes = countryCodeRepository.getCountryCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.COUNTRY)) { if (!countryCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, attribute, UpdateMessages.countryNotRecognised(attribute.getCleanValue())); } } } }
CountryValidator implements BusinessRuleValidator { @Override public void validate(PreparedUpdate update, UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.COUNTRY)) { return; } final Set<CIString> countryCodes = countryCodeRepository.getCountryCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.COUNTRY)) { if (!countryCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, attribute, UpdateMessages.countryNotRecognised(attribute.getCleanValue())); } } } @Autowired CountryValidator(final CountryCodeRepository countryCodeRepository); }
CountryValidator implements BusinessRuleValidator { @Override public void validate(PreparedUpdate update, UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.COUNTRY)) { return; } final Set<CIString> countryCodes = countryCodeRepository.getCountryCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.COUNTRY)) { if (!countryCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, attribute, UpdateMessages.countryNotRecognised(attribute.getCleanValue())); } } } @Autowired CountryValidator(final CountryCodeRepository countryCodeRepository); @Override void validate(PreparedUpdate update, UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
CountryValidator implements BusinessRuleValidator { @Override public void validate(PreparedUpdate update, UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.COUNTRY)) { return; } final Set<CIString> countryCodes = countryCodeRepository.getCountryCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.COUNTRY)) { if (!countryCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, attribute, UpdateMessages.countryNotRecognised(attribute.getCleanValue())); } } } @Autowired CountryValidator(final CountryCodeRepository countryCodeRepository); @Override void validate(PreparedUpdate update, UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void testFilterOverridePasswordsInMessage() { final String input = "" + "red: adsfasdf\n" + "blue: asdfasdfasdf\n" + "yellow%3A++asdfasdfasdf\n" + "green: asdfasdfasdf # override: test\n" + "purple: override\n" + "override:user,pass\n" + "override:user,pass,reason\n" + "override: user,pass\n" + "override%3A++user,pass\n" + "delete: adsf\n"; assertThat(PasswordFilter.filterPasswordsInContents(input), containsString("" + "red: adsfasdf\n" + "blue: asdfasdfasdf\n" + "yellow%3A++asdfasdfasdf\n" + "green: asdfasdfasdf # override: test\n" + "purple: override\n" + "override:user,FILTERED\n" + "override:user,FILTERED,reason\n" + "override:user,FILTERED\n" + "override%3A++user,FILTERED\n" + "delete: adsf\n")); }
public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; }
PasswordFilter { public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; } }
PasswordFilter { public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; } }
PasswordFilter { public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; } static String filterPasswordsInContents(final String contents); static String filterPasswordsInUrl(final String url); }
PasswordFilter { public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; } static String filterPasswordsInContents(final String contents); static String filterPasswordsInUrl(final String url); }
@Test public void invalid_country() { when(repository.getCountryCodes()).thenReturn(CIString.ciSet("DK", "UK")); final RpslObject rpslObject = RpslObject.parse("inetnum: 193.0/32\ncountry:AB"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); verify(updateContext).addMessage(update, rpslObject.findAttribute(AttributeType.COUNTRY), UpdateMessages.countryNotRecognised(ciString("AB"))); }
@Override public void validate(PreparedUpdate update, UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.COUNTRY)) { return; } final Set<CIString> countryCodes = countryCodeRepository.getCountryCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.COUNTRY)) { if (!countryCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, attribute, UpdateMessages.countryNotRecognised(attribute.getCleanValue())); } } }
CountryValidator implements BusinessRuleValidator { @Override public void validate(PreparedUpdate update, UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.COUNTRY)) { return; } final Set<CIString> countryCodes = countryCodeRepository.getCountryCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.COUNTRY)) { if (!countryCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, attribute, UpdateMessages.countryNotRecognised(attribute.getCleanValue())); } } } }
CountryValidator implements BusinessRuleValidator { @Override public void validate(PreparedUpdate update, UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.COUNTRY)) { return; } final Set<CIString> countryCodes = countryCodeRepository.getCountryCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.COUNTRY)) { if (!countryCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, attribute, UpdateMessages.countryNotRecognised(attribute.getCleanValue())); } } } @Autowired CountryValidator(final CountryCodeRepository countryCodeRepository); }
CountryValidator implements BusinessRuleValidator { @Override public void validate(PreparedUpdate update, UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.COUNTRY)) { return; } final Set<CIString> countryCodes = countryCodeRepository.getCountryCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.COUNTRY)) { if (!countryCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, attribute, UpdateMessages.countryNotRecognised(attribute.getCleanValue())); } } } @Autowired CountryValidator(final CountryCodeRepository countryCodeRepository); @Override void validate(PreparedUpdate update, UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
CountryValidator implements BusinessRuleValidator { @Override public void validate(PreparedUpdate update, UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.COUNTRY)) { return; } final Set<CIString> countryCodes = countryCodeRepository.getCountryCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.COUNTRY)) { if (!countryCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, attribute, UpdateMessages.countryNotRecognised(attribute.getCleanValue())); } } } @Autowired CountryValidator(final CountryCodeRepository countryCodeRepository); @Override void validate(PreparedUpdate update, UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void valid_language() { when(repository.getLanguageCodes()).thenReturn(ciSet("DK", "UK")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("inetnum: 193.0/32\nlanguage:DK")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.LANGUAGE)) { return; } final Set<CIString> languageCodes = languageRepository.getLanguageCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.LANGUAGE)) { if (!languageCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, UpdateMessages.languageNotRecognised(attribute.getCleanValue())); } } }
LanguageValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.LANGUAGE)) { return; } final Set<CIString> languageCodes = languageRepository.getLanguageCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.LANGUAGE)) { if (!languageCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, UpdateMessages.languageNotRecognised(attribute.getCleanValue())); } } } }
LanguageValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.LANGUAGE)) { return; } final Set<CIString> languageCodes = languageRepository.getLanguageCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.LANGUAGE)) { if (!languageCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, UpdateMessages.languageNotRecognised(attribute.getCleanValue())); } } } @Autowired LanguageValidator(final LanguageCodeRepository repository); }
LanguageValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.LANGUAGE)) { return; } final Set<CIString> languageCodes = languageRepository.getLanguageCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.LANGUAGE)) { if (!languageCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, UpdateMessages.languageNotRecognised(attribute.getCleanValue())); } } } @Autowired LanguageValidator(final LanguageCodeRepository repository); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
LanguageValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.LANGUAGE)) { return; } final Set<CIString> languageCodes = languageRepository.getLanguageCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.LANGUAGE)) { if (!languageCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, UpdateMessages.languageNotRecognised(attribute.getCleanValue())); } } } @Autowired LanguageValidator(final LanguageCodeRepository repository); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void invalid_language() { when(repository.getLanguageCodes()).thenReturn(ciSet("DK", "UK")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("inetnum: 193.0/32\nlanguage:AB")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.languageNotRecognised("AB")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.LANGUAGE)) { return; } final Set<CIString> languageCodes = languageRepository.getLanguageCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.LANGUAGE)) { if (!languageCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, UpdateMessages.languageNotRecognised(attribute.getCleanValue())); } } }
LanguageValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.LANGUAGE)) { return; } final Set<CIString> languageCodes = languageRepository.getLanguageCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.LANGUAGE)) { if (!languageCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, UpdateMessages.languageNotRecognised(attribute.getCleanValue())); } } } }
LanguageValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.LANGUAGE)) { return; } final Set<CIString> languageCodes = languageRepository.getLanguageCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.LANGUAGE)) { if (!languageCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, UpdateMessages.languageNotRecognised(attribute.getCleanValue())); } } } @Autowired LanguageValidator(final LanguageCodeRepository repository); }
LanguageValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.LANGUAGE)) { return; } final Set<CIString> languageCodes = languageRepository.getLanguageCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.LANGUAGE)) { if (!languageCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, UpdateMessages.languageNotRecognised(attribute.getCleanValue())); } } } @Autowired LanguageValidator(final LanguageCodeRepository repository); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
LanguageValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (!updatedObject.containsAttribute(AttributeType.LANGUAGE)) { return; } final Set<CIString> languageCodes = languageRepository.getLanguageCodes(); for (final RpslAttribute attribute : updatedObject.findAttributes(AttributeType.LANGUAGE)) { if (!languageCodes.contains(attribute.getCleanValue())) { updateContext.addMessage(update, UpdateMessages.languageNotRecognised(attribute.getCleanValue())); } } } @Autowired LanguageValidator(final LanguageCodeRepository repository); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getActions() { assertThat(subject.getActions().size(), is(2)); assertThat(subject.getActions().contains(Action.MODIFY), is(true)); assertThat(subject.getActions().contains(Action.CREATE), is(true)); }
@Override public ImmutableList<Action> getActions() { return ACTIONS; }
MemberOfValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
MemberOfValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getTypes() { assertThat(subject.getTypes().size(), is(4)); assertThat(subject.getTypes().contains(ObjectType.AUT_NUM), is(true)); assertThat(subject.getTypes().contains(ObjectType.ROUTE), is(true)); assertThat(subject.getTypes().contains(ObjectType.ROUTE6), is(true)); assertThat(subject.getTypes().contains(ObjectType.INET_RTR), is(true)); }
@Override public ImmutableList<ObjectType> getTypes() { return TYPES; }
MemberOfValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
MemberOfValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void nothing_to_validate_when_no_new_member_of() { when(update.getNewValues(AttributeType.MEMBER_OF)).thenReturn(Sets.<CIString>newHashSet()); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("aut-num: AS23454")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void referenced_asset_not_found() { when(update.getType()).thenReturn(ObjectType.AUT_NUM); when(update.getNewValues(AttributeType.MEMBER_OF)).thenReturn(ciSet("AS-23425")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("aut-num: AS23454\nmnt-by: TEST-MNT\nmember-of: AS-23425")); when(objectDao.getByKey(ObjectType.AS_SET, "AS-23425")).thenThrow(EmptyResultDataAccessException.class); subject.validate(update, updateContext); verify(updateContext, never()).addMessage(update, UpdateMessages.referenceNotFound("AS-23425")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void maintainer_does_not_exist_in_referenced_mbrsbyref() { when(update.getType()).thenReturn(ObjectType.AUT_NUM); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("aut-num: AS23454\nmnt-by: TEST-MNT\nmember-of: AS-23425")); when(objectDao.getByKey(ObjectType.AS_SET, "AS-23425")).thenReturn(RpslObject.parse("as-set: AS-23425\nmbrs-by-ref: OTHER-MNT\ndescr: description")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet("[AS-23425]")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void success() { when(update.getType()).thenReturn(ObjectType.AUT_NUM); when(update.getNewValues(AttributeType.MEMBER_OF)).thenReturn(ciSet("AS-23425")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("aut-num: AS23454\nmnt-by: TEST-MNT\nmember-of: AS-23425")); when(objectDao.getByKey(ObjectType.AS_SET, "AS-23425")).thenReturn(RpslObject.parse("as-set: AS-23425\nmbrs-by-ref: TEST-MNT\ndescr: description")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void referenced_routeset_not_found() { when(update.getType()).thenReturn(ObjectType.ROUTE); when(update.getNewValues(AttributeType.MEMBER_OF)).thenReturn(ciSet("RS-TEST-FOO")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("route: 193.254.30.0/24\norigin:AS12726\nmnt-by: TEST-MNT\nmember-of: RS-TEST-FOO")); when(objectDao.getByKey(ObjectType.ROUTE_SET, "RS-TEST-FOO")).thenThrow(EmptyResultDataAccessException.class); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void testFilterOverrideAndPasswordsInMessage() { final String input = "" + "red: adsfasdf\n" + "purple: override\n" + "override:user,pass\n" + "password:test\n"; assertThat(PasswordFilter.filterPasswordsInContents(input), containsString("" + "red: adsfasdf\n" + "purple: override\n" + "override:user,FILTERED\n" + "password:FILTERED")); }
public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; }
PasswordFilter { public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; } }
PasswordFilter { public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; } }
PasswordFilter { public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; } static String filterPasswordsInContents(final String contents); static String filterPasswordsInUrl(final String url); }
PasswordFilter { public static String filterPasswordsInContents(final String contents) { String result = contents; if( contents != null ) { final Matcher matcher = PASSWORD_PATTERN_FOR_CONTENT.matcher(contents); result = replacePassword(matcher); } return result; } static String filterPasswordsInContents(final String contents); static String filterPasswordsInUrl(final String url); }
@Test public void maintainer_does_not_exist_in_referenced_mbrsbyref_route() { when(update.getType()).thenReturn(ObjectType.ROUTE); when(update.getNewValues(AttributeType.MEMBER_OF)).thenReturn(ciSet("RS-TEST-FOO")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("route: 193.254.30.0/24\norigin:AS12726\nmnt-by: TEST-MNT\nmember-of: RS-TEST-FOO")); when(objectDao.getByKey(ObjectType.ROUTE_SET, "RS-TEST-FOO")).thenReturn(RpslObject.parse("route-set:RS-TEST-FOO\nmbrs-by-ref: any\ndescr: description")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route_success() { when(update.getType()).thenReturn(ObjectType.ROUTE); when(update.getNewValues(AttributeType.MEMBER_OF)).thenReturn(ciSet("RS-TEST-FOO")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("route: 193.254.30.0/24\norigin:AS12726\nmnt-by: TEST-MNT\nmember-of: RS-TEST-FOO")); when(objectDao.getByKey(ObjectType.ROUTE_SET, "RS-TEST-FOO")).thenReturn(RpslObject.parse("route-set: RS-TEST-FOO\nmbrs-by-ref: TEST-MNT\ndescr: description")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void referenced_routeset_not_found_route6() { when(update.getType()).thenReturn(ObjectType.ROUTE6); when(update.getNewValues(AttributeType.MEMBER_OF)).thenReturn(ciSet("RS-TEST-FOO")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("route6:2001:1578:0200::/40\norigin:AS12726\nmnt-by: TEST-MNT\nmember-of: RS-TEST-FOO")); when(objectDao.getByKey(ObjectType.ROUTE_SET, "RS-TEST-FOO")).thenThrow(EmptyResultDataAccessException.class); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void maintainer_does_not_exist_in_referenced_mbrsbyref_route6() { when(update.getType()).thenReturn(ObjectType.ROUTE6); when(update.getNewValues(AttributeType.MEMBER_OF)).thenReturn(ciSet("RS-TEST-FOO")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("route6:2001:1578:0200::/40\norigin:AS12726\nmnt-by: TEST-MNT\nmember-of: RS-TEST-FOO")); when(objectDao.getByKey(ObjectType.ROUTE_SET, "RS-TEST-FOO")).thenReturn(RpslObject.parse("route-set:RS-TEST-FOO\nmbrs-by-ref: any\ndescr: description")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route6_success() { when(update.getType()).thenReturn(ObjectType.ROUTE6); when(update.getNewValues(AttributeType.MEMBER_OF)).thenReturn(ciSet("RS-TEST-FOO")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("route6:2001:1578:0200::/40\norigin:AS12726\nmnt-by: TEST-MNT\nmember-of: RS-TEST-FOO")); when(objectDao.getByKey(ObjectType.ROUTE_SET, "RS-TEST-FOO")).thenReturn(RpslObject.parse("route-set: RS-TEST-FOO\nmbrs-by-ref: TEST-MNT\ndescr: description")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void referenced_maintainer_not_found_inetrtr() { when(update.getType()).thenReturn(ObjectType.INET_RTR); when(update.getNewValues(AttributeType.MEMBER_OF)).thenReturn(ciSet("RTRS-23425")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("inet-rtr: test.ripe.net\nmnt-by: TEST-MNT\nmember-of: RTRS-23425")); when(objectDao.getByKey(ObjectType.RTR_SET, "RTRS-23425")).thenThrow(EmptyResultDataAccessException.class); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void maintainer_does_not_exist_in_referenced_mbrsbyref_inetrtr() { when(update.getType()).thenReturn(ObjectType.INET_RTR); when(update.getNewValues(AttributeType.MEMBER_OF)).thenReturn(ciSet("RTRS-23425")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("inet-rtr: test.ripe.net\nmnt-by: TEST-MNT\nmember-of: RTRS-23425")); when(objectDao.getByKey(ObjectType.RTR_SET, "RTRS-23425")).thenReturn(RpslObject.parse("route-set: RTRS-23425\nmbrs-by-ref: OTHER-MNT\ndescr: description")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet("[RTRS-23425]")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void success_inetrtr() { when(update.getType()).thenReturn(ObjectType.INET_RTR); when(update.getNewValues(AttributeType.MEMBER_OF)).thenReturn(ciSet("RTRS-23425")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("inet-rtr: test.ripe.net\nmnt-by: TEST-MNT\nmember-of: RTRS-23425")); when(objectDao.getByKey(ObjectType.RTR_SET, "RTRS-23425")).thenReturn(RpslObject.parse("rtr-set: RTRS-23425\nmbrs-by-ref: TEST-MNT\ndescr: description")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MemberOfValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Collection<CIString> memberOfs = update.getUpdatedObject().getValuesForAttribute((AttributeType.MEMBER_OF)); if (memberOfs.isEmpty()) { return; } final Set<CIString> updatedObjectMaintainers = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); final ObjectType referencedObjectType = objectTypeMap.get(update.getType()); final Set<CIString> unsupportedSets = findUnsupportedMembers(memberOfs, updatedObjectMaintainers, referencedObjectType); if (!unsupportedSets.isEmpty()) { updateContext.addMessage(update, UpdateMessages.membersNotSupportedInReferencedSet(unsupportedSets.toString())); } } @Autowired MemberOfValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.DELETE)); }
@Override public ImmutableList<Action> getActions() { return ACTIONS; }
ObjectMismatchValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
ObjectMismatchValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
ObjectMismatchValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ObjectMismatchValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.MODIFY, Action.CREATE)); }
@Override public ImmutableList<Action> getActions() { return ACTIONS; }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void password_filtering_in_url() { assertThat(PasswordFilter.filterPasswordsInUrl(uriWithParams(new Pair("password","secret"))), is("/some/path?password=FILTERED")); assertThat(PasswordFilter.filterPasswordsInUrl(uriWithParams(new Pair("password", "p%3Fssword%26"))), is("/some/path?password=FILTERED")); assertThat(PasswordFilter.filterPasswordsInUrl(uriWithParams(new Pair("password", "secret"), new Pair("param", null))), is("/some/path?password=FILTERED&param")); assertThat(PasswordFilter.filterPasswordsInUrl(uriWithParams(new Pair("password", "secret"), new Pair("password", "other"))), is("/some/path?password=FILTERED&password=FILTERED")); assertThat(PasswordFilter.filterPasswordsInUrl(uriWithParams(new Pair("password", "secret"), new Pair("password", "other"), new Pair("param", "value"))), is("/some/path?password=FILTERED&password=FILTERED&param=value")); assertThat(PasswordFilter.filterPasswordsInUrl(uriWithParams(new Pair("param","value"),new Pair("password","secret"),new Pair("password","other"))), is("/some/path?param=value&password=FILTERED&password=FILTERED")); assertThat(PasswordFilter.filterPasswordsInUrl(uriWithParams(new Pair("param", "value"), new Pair("password", "secret"), new Pair("param", "password"))), is("/some/path?param=value&password=FILTERED&param=password")); assertThat(PasswordFilter.filterPasswordsInUrl(uriWithParams(new Pair("password", "test$#@!%^*-ab"), new Pair("param", "other"))), is("/some/path?password=FILTERED&param=other")); assertThat( PasswordFilter.filterPasswordsInUrl("whois/syncupdates/test?DATA=person%3A+++++++++Test+Person%0asource%3a+RIPE%0apassword%3a+team-red%0a&NEW=yes"), is("whois/syncupdates/test?DATA=person%3A+++++++++Test+Person%0asource%3a+RIPE%0apassword%3aFILTERED&NEW=yes")); assertThat( PasswordFilter.filterPasswordsInUrl("whois/syncupdates/test?DATA=person%3A+++++++++Test+Person%0asource%3a+RIPE%0apassword%3a+team-red%0a%0anotify%3a+email%40ripe.net%0a&NEW=yes"), is("whois/syncupdates/test?DATA=person%3A+++++++++Test+Person%0asource%3a+RIPE%0apassword%3aFILTERED&NEW=yes")); }
public static String filterPasswordsInUrl(final String url) { String result = url; if( url != null ) { final Matcher matcher = URI_PASSWORD_PATTERN_PASSWORD_FOR_URL.matcher(url); result = replacePassword(matcher); } return result; }
PasswordFilter { public static String filterPasswordsInUrl(final String url) { String result = url; if( url != null ) { final Matcher matcher = URI_PASSWORD_PATTERN_PASSWORD_FOR_URL.matcher(url); result = replacePassword(matcher); } return result; } }
PasswordFilter { public static String filterPasswordsInUrl(final String url) { String result = url; if( url != null ) { final Matcher matcher = URI_PASSWORD_PATTERN_PASSWORD_FOR_URL.matcher(url); result = replacePassword(matcher); } return result; } }
PasswordFilter { public static String filterPasswordsInUrl(final String url) { String result = url; if( url != null ) { final Matcher matcher = URI_PASSWORD_PATTERN_PASSWORD_FOR_URL.matcher(url); result = replacePassword(matcher); } return result; } static String filterPasswordsInContents(final String contents); static String filterPasswordsInUrl(final String url); }
PasswordFilter { public static String filterPasswordsInUrl(final String url) { String result = url; if( url != null ) { final Matcher matcher = URI_PASSWORD_PATTERN_PASSWORD_FOR_URL.matcher(url); result = replacePassword(matcher); } return result; } static String filterPasswordsInContents(final String contents); static String filterPasswordsInUrl(final String url); }
@Test public void getTypes() { assertThat(subject.getTypes(), contains(ObjectType.ROLE)); }
@Override public ImmutableList<ObjectType> getTypes() { return TYPES; }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void not_self_referenced() { when(preparedUpdate.getUpdate()).thenReturn(update); when(update.getSubmittedObject()).thenReturn(RpslObject.parse("role: Some Role\nnic-hdl: NIC-TEST\nadmin-c: OTHER-TEST\ntech-c: TECH-TEST")); subject.validate(preparedUpdate, updateContext); verify(updateContext, never()).addMessage(preparedUpdate, UpdateMessages.selfReferenceError(AttributeType.ADMIN_C)); verify(updateContext, never()).addMessage(preparedUpdate, UpdateMessages.selfReferenceError(AttributeType.TECH_C)); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void self_referenced_adminC() { final RpslObject role = RpslObject.parse("role: Some Role\nnic-hdl: NIC-TEST\nadmin-c: NIC-TEST\ntech-c: TECH-TEST"); when(preparedUpdate.getUpdate()).thenReturn(update); when(update.getSubmittedObject()).thenReturn(role); subject.validate(preparedUpdate, updateContext); verify(updateContext, times(1)).addMessage(preparedUpdate, role.findAttribute(AttributeType.ADMIN_C), UpdateMessages.selfReferenceError(AttributeType.ADMIN_C)); verify(updateContext, never()).addMessage(preparedUpdate, role.findAttribute(AttributeType.TECH_C), UpdateMessages.selfReferenceError(AttributeType.TECH_C)); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void self_referenced_techC() { final RpslObject role = RpslObject.parse("role: Some Role\nnic-hdl: NIC-TEST\nadmin-c: OTHER-TEST\ntech-c: NIC-TEST"); when(preparedUpdate.getUpdate()).thenReturn(update); when(update.getSubmittedObject()).thenReturn(role); subject.validate(preparedUpdate, updateContext); verify(updateContext, never()).addMessage(preparedUpdate, role.findAttribute(AttributeType.ADMIN_C), UpdateMessages.selfReferenceError(AttributeType.ADMIN_C)); verify(updateContext, times(1)).addMessage(preparedUpdate, role.findAttribute(AttributeType.TECH_C), UpdateMessages.selfReferenceError(AttributeType.TECH_C)); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void self_referenced_techC_adminC() { final RpslObject role = RpslObject.parse("role: Some Role\nnic-hdl: NIC-TEST\nadmin-c: NIC-TEST\ntech-c: NIC-TEST"); when(preparedUpdate.getUpdate()).thenReturn(update); when(update.getSubmittedObject()).thenReturn(role); subject.validate(preparedUpdate, updateContext); verify(updateContext, times(1)).addMessage(preparedUpdate, role.findAttribute(AttributeType.ADMIN_C), UpdateMessages.selfReferenceError(AttributeType.ADMIN_C)); verify(updateContext, times(1)).addMessage(preparedUpdate, role.findAttribute(AttributeType.TECH_C), UpdateMessages.selfReferenceError(AttributeType.TECH_C)); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
SelfReferencePreventionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { errorOnSelfReference(update, updateContext, AttributeType.ADMIN_C); errorOnSelfReference(update, updateContext, AttributeType.TECH_C); } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.DELETE, Action.MODIFY)); }
@Override public ImmutableList<Action> getActions() { return ACTIONS; }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getTypes() { assertThat(subject.getTypes(), contains(ObjectType.ROLE)); }
@Override public ImmutableList<ObjectType> getTypes() { return TYPES; }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void add_referenced_abuse_mailbox() { when(update.getReferenceObject()).thenReturn(RpslObject.parse("role: Abuse Role\nnic-hdl: TEST-NIC")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("role: Abuse Role\nnic-hdl: TEST-NIC\nabuse-mailbox: [email protected]")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void remove_unreferenced_abuse_mailbox() { final RpslObject originalObject = RpslObject.parse("role: Abuse Role\nnic-hdl: TEST-NIC\nabuse-mailbox: [email protected]"); final RpslObject updatedObject = RpslObject.parse("role: Abuse Role\nnic-hdl: TEST-NIC"); when(update.getReferenceObject()).thenReturn(originalObject); when(update.getUpdatedObject()).thenReturn(updatedObject); when(updateDao.getReferences(updatedObject)).thenReturn(Sets.<RpslObjectInfo>newHashSet()); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void modify_referenced_abuse_mailbox() { final RpslObject originalObject = RpslObject.parse("role: Abuse Role\nnic-hdl: TEST-NIC\nabuse-mailbox: [email protected]"); final RpslObject updatedObject = RpslObject.parse("role: Abuse Role\nnic-hdl: TEST-NIC\nabuse-mailbox: [email protected]"); when(update.getReferenceObject()).thenReturn(originalObject); when(update.getUpdatedObject()).thenReturn(updatedObject); when(updateDao.getReferences(updatedObject)).thenReturn(Sets.newHashSet(new RpslObjectInfo(1, ObjectType.ORGANISATION, "ORG-TEST1"))); when(objectDao.getById(1)).thenReturn(RpslObject.parse("organisation: ORG-TEST1\nabuse-c: TEST-NIC")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void testFilterWithOverrideInUrl() { assertThat(PasswordFilter.filterPasswordsInUrl(uriWithParams(new Pair("override","admin,secret"), new Pair("param","other"))), is("/some/path?override=admin,FILTERED&param=other")); assertThat(PasswordFilter.filterPasswordsInUrl(uriWithParams(new Pair("override","admin,secret,reason"),new Pair("param","other"))), is("/some/path?override=admin,FILTERED,reason&param=other")); assertThat(PasswordFilter.filterPasswordsInUrl(uriWithParams(new Pair("DATA", "person: Test+Person\nsource: TEST\n\noverride:admin,password"), new Pair("NEW", "yes"))), is("/some/path?DATA=person:++Test%2BPerson%0Asource:++TEST%0A%0Aoverride:admin,FILTERED&NEW=yes")); assertThat(PasswordFilter.filterPasswordsInUrl(uriWithParams(new Pair("DATA", "person: Test+Person\nsource: TEST\n\noverride:admin,password,reason"), new Pair("NEW", "yes"))), is("/some/path?DATA=person:++Test%2BPerson%0Asource:++TEST%0A%0Aoverride:admin,FILTERED,reason&NEW=yes")); assertThat( PasswordFilter.filterPasswordsInUrl(uriWithParams(new Pair("DATA", "person: TestP\n\noverride:personadmin,team-red1234"), new Pair("NEW","yes"))), is("/some/path?DATA=person:++TestP%0A%0Aoverride:personadmin,FILTERED&NEW=yes")); assertThat( PasswordFilter.filterPasswordsInUrl("/some/path?DATA=person:++TestP%0A%0Aoverride%3Apersonadmin,team-red1234&NEW=yes"), is("/some/path?DATA=person:++TestP%0A%0Aoverride%3Apersonadmin,FILTERED&NEW=yes")); assertThat( PasswordFilter.filterPasswordsInUrl("whois/syncupdates/test?DATA=person%3A+++++++++Test+Person%0Aaddress%3A++++++++Singel+258%0Aphone%3A++++++++++%2B31+6+12345678%0Anic-hdl%3A++++++++TP2-TEST%0Amnt-by%3A+++++++++OWNER-MNT%0Achanged%3A++++++++dbtest%40ripe.net+20120101%0A"+ "source%3A+++++++++TEST%0Aoverride%3Apersonadmin%2Cteam-red1234&NEW=yes"), is("whois/syncupdates/test?DATA=person%3A+++++++++Test+Person%0Aaddress%3A++++++++Singel+258%0Aphone%3A++++++++++%2B31+6+12345678%0Anic-hdl%3A++++++++TP2-TEST%0Amnt-by%3A+++++++++OWNER-MNT%0Achanged%3A++++++++dbtest%40ripe.net+20120101%0Asource%3A+++++++++TEST%0Aoverride%3Apersonadmin,FILTERED&NEW=yes")); assertThat( PasswordFilter.filterPasswordsInUrl("whois/syncupdates/test?DATA=person%3A+++++++++Test+Person%0asource%3a+RIPE%0Aoverride:+admin,teamred,reason%0anotify%3a+email%40ripe.net%0a&NEW=yes"), is("whois/syncupdates/test?DATA=person%3A+++++++++Test+Person%0asource%3a+RIPE%0Aoverride:+admin,FILTERED,reason%0anotify%3a+email%40ripe.net%0a&NEW=yes")); }
public static String filterPasswordsInUrl(final String url) { String result = url; if( url != null ) { final Matcher matcher = URI_PASSWORD_PATTERN_PASSWORD_FOR_URL.matcher(url); result = replacePassword(matcher); } return result; }
PasswordFilter { public static String filterPasswordsInUrl(final String url) { String result = url; if( url != null ) { final Matcher matcher = URI_PASSWORD_PATTERN_PASSWORD_FOR_URL.matcher(url); result = replacePassword(matcher); } return result; } }
PasswordFilter { public static String filterPasswordsInUrl(final String url) { String result = url; if( url != null ) { final Matcher matcher = URI_PASSWORD_PATTERN_PASSWORD_FOR_URL.matcher(url); result = replacePassword(matcher); } return result; } }
PasswordFilter { public static String filterPasswordsInUrl(final String url) { String result = url; if( url != null ) { final Matcher matcher = URI_PASSWORD_PATTERN_PASSWORD_FOR_URL.matcher(url); result = replacePassword(matcher); } return result; } static String filterPasswordsInContents(final String contents); static String filterPasswordsInUrl(final String url); }
PasswordFilter { public static String filterPasswordsInUrl(final String url) { String result = url; if( url != null ) { final Matcher matcher = URI_PASSWORD_PATTERN_PASSWORD_FOR_URL.matcher(url); result = replacePassword(matcher); } return result; } static String filterPasswordsInContents(final String contents); static String filterPasswordsInUrl(final String url); }
@Test public void remove_referenced_abuse_mailbox() { final RpslObject originalObject = RpslObject.parse("role: Abuse Role\nnic-hdl: TEST-NIC\nabuse-mailbox: [email protected]"); final RpslObject updatedObject = RpslObject.parse("role: Abuse Role\nnic-hdl: TEST-NIC"); when(update.getReferenceObject()).thenReturn(originalObject); when(update.getUpdatedObject()).thenReturn(updatedObject); when(updateDao.getReferences(updatedObject)).thenReturn(Sets.newHashSet(new RpslObjectInfo(1, ObjectType.ORGANISATION, "ORG-TEST1"))); when(objectDao.getById(1)).thenReturn(RpslObject.parse("organisation: ORG-TEST1\nabuse-c: TEST-NIC")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.abuseMailboxReferenced("Abuse Role", ObjectType.ORGANISATION)); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MustKeepAbuseMailboxIfReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Set<CIString> originalAbuseMailbox = update.getReferenceObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); final Set<CIString> updatedAbuseMailbox = update.getUpdatedObject().getValuesForAttribute(AttributeType.ABUSE_MAILBOX); if (!updatedAbuseMailbox.isEmpty() || originalAbuseMailbox.isEmpty()) { return; } for (final RpslObjectInfo referenceInfo : updateObjectDao.getReferences(update.getUpdatedObject())) { if (REFERENCED_OBJECT_TYPES.contains(referenceInfo.getObjectType())) { final Set<CIString> abuseCAttributes = objectDao.getById(referenceInfo.getObjectId()).getValuesForAttribute(AttributeType.ABUSE_C); if (!abuseCAttributes.isEmpty() && abuseCAttributes.contains(update.getUpdatedObject().getValueForAttribute(AttributeType.NIC_HDL))) { updateContext.addMessage(update, UpdateMessages.abuseMailboxReferenced(update.getUpdatedObject().getValueForAttribute(AttributeType.ROLE), referenceInfo.getObjectType())); break; } } } } @Autowired MustKeepAbuseMailboxIfReferencedValidator(final RpslObjectUpdateDao updateObjectDao, final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE)); }
@Override public ImmutableList<Action> getActions() { return ACTIONS; }
KeycertValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
KeycertValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); }
KeycertValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
KeycertValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.KEY_CERT)); }
@Override public ImmutableList<ObjectType> getTypes() { return TYPES; }
KeycertValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
KeycertValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); }
KeycertValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
KeycertValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void auto_1_with_x509() throws Exception { RpslObject object = RpslObject.parse(getResource("keycerts/AUTO-1-X509.TXT")); when(update.getAction()).thenReturn(Action.CREATE); when(update.getUpdatedObject()).thenReturn(object); when(keyWrapperFactory.createKeyWrapper(object, update, updateContext)).thenReturn(X509CertificateWrapper.parse(object)); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } }
KeycertValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } } }
KeycertValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); }
KeycertValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
KeycertValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void auto_3_with_pgp() throws Exception { RpslObject object = RpslObject.parse("" + "key-cert: AUTO-3\n" + "certif: -----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "certif: Version: GnuPG v1.4.11 (Darwin)\n" + "certif:\n" + "certif: mQENBE841dMBCAC80IDqJpJC7ch16NEaWvLDM8CslkhiqYk9fgXgUdMNuBsJJ/KV\n" + "certif: 4oUwzrX+3lNvMPSoW7yRfiokFQ48IhYVZuGlH7DzwsyfS3MniXmw6/vT6JaYPuIF\n" + "certif: 7TmMHIIxQbzJe+SUrauzJ2J0xQbnKhcfuLkmNO7jiOoKGJWIrO5wUZfd0/4nOoaz\n" + "certif: RMokk0Paj6r52ZMni44vV4R0QnuUJRNIIesPDYDkOZGXX1lD9fprTc2DJe8tjAu0\n" + "certif: VJz5PpCHwvS9ge22CRTUBSgmf2NBHJwDF+dnvijLuoDFyTuOrSkq0nAt0B9kTUxt\n" + "certif: Bsb7mNxlARduo5419hBp08P07LJb4upuVsMPABEBAAG0HkVkIFNocnlhbmUgPGVz\n" + "certif: aHJ5YW5lQHJpcGUubmV0PokBOAQTAQIAIgUCTzjV0wIbAwYLCQgHAwIGFQgCCQoL\n" + "certif: BBYCAwECHgECF4AACgkQ7pke4ij2zWyUKAf+MmDQnBUUSjDeFvCnNN4JTraMXFUi\n" + "certif: Ke2HzVnLvT/Z/XN5W6TIje7u1luTJk/siJJyKYa1ZWQoVOCXruTSge+vP6LxENOX\n" + "certif: /sOJ1YxWHJUr3OVOfW2NoKBaUkBBCxi/CSaPti7YPHF0D6rn3GJtoJTnLL4KPnWV\n" + "certif: gtja4FtpsgwhiPF/jVmx6/d5Zc/dndDLZZt2sMjh0KDVf7F03hsF/EAauBbxMLvK\n" + "certif: yEHMdw7ab5CxeorgWEDaLrR1YwHWHy9cbYC00Mgp1zQR1ok2wN/XZVL7BZYPS/UC\n" + "certif: H03bFi3AcN1Vm55QpbU0QJ4qPN8uwYc5VBFSSYRITUCwbB5qBO5kIIBLP7kBDQRP\n" + "certif: ONXTAQgA16kMTcjxOtkU8v3sLAIpr2xWwG91BdB2fLV0aUgaZWfexKMnWDu8xpm1\n" + "certif: qY+viF+/emdXBc/C7QbFUmhmXCslX5kfD10hkYFTIqc1Axk5Ya8FZtwHFpo0TVTl\n" + "certif: sGodZ2gy8334rT9yMH+bZNSlZ+07Fxa7maC1ycxPPL/68+LSBy6wWlAFCwwr7XwN\n" + "certif: LGnrBbELgvoi04yMu1EpqAvxZLH1TBgzrFcWzXJjj1JKIB1RGapoDc3m7dvHa3+e\n" + "certif: 27aQosQnNVNWrHiS67zqWoC963aNuHZBY174yfKPRaN6s5GppC2hMPYGnJV07yah\n" + "certif: P0mwRcp4e3AaJIg2SP9CUQJKGPY+mQARAQABiQEfBBgBAgAJBQJPONXTAhsMAAoJ\n" + "certif: EO6ZHuIo9s1souEH/ieP9J69j59zfVcN6FimT86JF9CVyB86PGv+naHEyzOrBjml\n" + "certif: xBn2TPCNSE5KH8+gENyvYaQ6Wxv4Aki2HnJj5H43LfXPZZ6HNME4FPowoIkumc9q\n" + "certif: mndn6WXsgjwT9lc2HQmUgolQObg3JMBRe0rYzVf5N9+eXkc5lR/PpTOHdesP17uM\n" + "certif: QqtJs2hKdZKXgKNufSypfQBLXxkhez0KvoZ4PvrLItZTZUjrnRXdObNUgvz5/SVh\n" + "certif: 4Oqesj+Z36YNFrsYobghzIqOiP4hINsm9mQoshz8YLZe0z7InwcFYHp7HvQWEOyj\n" + "certif: kSYadR4aN+CVhYHOsn5nxbiKSFNAWh40q7tDP7I=\n" + "certif: =XRho\n" + "certif: -----END PGP PUBLIC KEY BLOCK-----\n" + "mnt-by: UPD-MNT\n" + "notify: [email protected]\n" + "source: TEST\n"); when(update.getAction()).thenReturn(Action.CREATE); when(update.getUpdatedObject()).thenReturn(object); when(x509AutoKeyFactory.isKeyPlaceHolder("AUTO-3")).thenReturn(true); when(keyWrapperFactory.createKeyWrapper(object, update, updateContext)).thenReturn(PgpPublicKeyWrapper.parse(object)); subject.validate(update, updateContext); verify(updateContext).addMessage(update, object.getAttributes().get(0), UpdateMessages.autokeyForX509KeyCertsOnly()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } }
KeycertValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } } }
KeycertValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); }
KeycertValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
KeycertValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void one_public_key_with_multiple_sub_keys() throws Exception { RpslObject object = RpslObject.parse(getResource("keycerts/PGPKEY-MULTIPLE-SUBKEYS.TXT")); when(update.getUpdatedObject()).thenReturn(object); when(keyWrapperFactory.createKeyWrapper(object, update, updateContext)).thenReturn(PgpPublicKeyWrapper.parse(object)); subject.validate(update, updateContext); assertThat(messages.size(), is(0)); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } }
KeycertValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } } }
KeycertValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); }
KeycertValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
KeycertValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (x509AutoKeyFactory.isKeyPlaceHolder(updatedObject.getKey().toString())) { final KeyWrapper keyWrapper = keyWrapperFactory.createKeyWrapper(updatedObject, update, updateContext); if (keyWrapper instanceof PgpPublicKeyWrapper) { updateContext.addMessage(update, update.getUpdatedObject().getTypeAttribute(), UpdateMessages.autokeyForX509KeyCertsOnly()); } } } @Autowired KeycertValidator(final KeyWrapperFactory keyWrapperFactory, final X509AutoKeyFactory x509AutoKeyFactory); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE)); }
@Override public ImmutableList<Action> getActions() { return ACTIONS; }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.DOMAIN)); }
@Override public ImmutableList<ObjectType> getTypes() { return TYPES; }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_enum() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "domain: 2.1.2.1.5.5.5.2.0.2.1.e164.arpa")); subject.validate(update, updateContext); verifyZeroInteractions(ipv4DomainTree, ipv6DomainTree); }
@SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_ipv4_domain_success() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "domain: 200.193.193.in-addr.arpa")); subject.validate(update, updateContext); verify(ipv4DomainTree).findFirstLessSpecific(Ipv4Resource.parse("193.193.200.0/24")); verify(ipv4DomainTree).findFirstMoreSpecific(Ipv4Resource.parse("193.193.200.0/24")); verifyZeroInteractions(ipv6DomainTree); }
@SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void shouldGetRemoteAddressFromChannel() { InetAddress remoteAddress = ChannelUtil.getRemoteAddress(new StubbedChannel("192.168.0.1")); assertThat(remoteAddress.getHostAddress(), is("192.168.0.1")); }
public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; }
ChannelUtil { public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; } }
ChannelUtil { public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; } private ChannelUtil(); }
ChannelUtil { public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; } private ChannelUtil(); static InetAddress getRemoteAddress(final Channel channel); }
ChannelUtil { public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; } private ChannelUtil(); static InetAddress getRemoteAddress(final Channel channel); static final Charset BYTE_ENCODING; }
@Test public void run() { subject.run(); verify(rpslObjectsExporter).export(); }
@Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "DatabaseTextExport") public void run() { rpslObjectsExporter.export(); }
DatabaseTextExport implements DailyScheduledTask { @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "DatabaseTextExport") public void run() { rpslObjectsExporter.export(); } }
DatabaseTextExport implements DailyScheduledTask { @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "DatabaseTextExport") public void run() { rpslObjectsExporter.export(); } @Autowired DatabaseTextExport(final RpslObjectsExporter rpslObjectsExporter); }
DatabaseTextExport implements DailyScheduledTask { @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "DatabaseTextExport") public void run() { rpslObjectsExporter.export(); } @Autowired DatabaseTextExport(final RpslObjectsExporter rpslObjectsExporter); @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "DatabaseTextExport") void run(); }
DatabaseTextExport implements DailyScheduledTask { @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "DatabaseTextExport") public void run() { rpslObjectsExporter.export(); } @Autowired DatabaseTextExport(final RpslObjectsExporter rpslObjectsExporter); @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "DatabaseTextExport") void run(); }
@Test public void validate_ipv6_domain_success() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "domain: 0.0.0.0.8.f.7.0.1.0.0.2.ip6.arpa")); subject.validate(update, updateContext); verify(ipv6DomainTree).findFirstLessSpecific(Ipv6Resource.parse("2001:7f8::/48")); verify(ipv6DomainTree).findFirstMoreSpecific(Ipv6Resource.parse("2001:7f8::/48")); verifyZeroInteractions(ipv4DomainTree); }
@SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_ipv4_domain_less_specific() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "domain: 200.193.193.in-addr.arpa")); final Ipv4Resource lessSpecific = Ipv4Resource.parse("193/8"); when(ipv4DomainTree.findFirstLessSpecific(Ipv4Resource.parse("193.193.200.0/24"))).thenReturn(Lists.newArrayList(new Ipv4Entry(lessSpecific, 1))); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.toString())); verifyZeroInteractions(ipv6DomainTree); }
@SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_ipv4_domain_more_specific() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "domain: 200.193.193.in-addr.arpa")); final Ipv4Resource moreSpecific = Ipv4Resource.parse("193.193.200.0/32"); when(ipv4DomainTree.findFirstMoreSpecific(Ipv4Resource.parse("193.193.200.0/24"))).thenReturn(Lists.newArrayList(new Ipv4Entry(moreSpecific, 1))); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.toString())); verifyZeroInteractions(ipv6DomainTree); }
@SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
IpDomainUniqueHierarchyValidator implements BusinessRuleValidator { @SuppressWarnings("unchecked") @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Domain domain = Domain.parse(update.getUpdatedObject().getKey()); if (domain.getType() == Domain.Type.E164) { return; } final IpInterval reverseIp = domain.getReverseIp(); final IpTree ipTree = getIpTree(reverseIp); final List<IpEntry> lessSpecific = ipTree.findFirstLessSpecific(reverseIp); if (!lessSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.lessSpecificDomainFound(lessSpecific.get(0).getKey().toString())); return; } final List<IpEntry> moreSpecific = ipTree.findFirstMoreSpecific(reverseIp); if (!moreSpecific.isEmpty()) { updateContext.addMessage(update, UpdateMessages.moreSpecificDomainFound(moreSpecific.get(0).getKey().toString())); } } @Autowired IpDomainUniqueHierarchyValidator(final Ipv4DomainTree ipv4DomainTree, final Ipv6DomainTree ipv6DomainTree); @SuppressWarnings("unchecked") @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE)); }
@Override public ImmutableList<Action> getActions() { return ACTIONS; }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.DOMAIN)); }
@Override public ImmutableList<ObjectType> getTypes() { return TYPES; }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_non_enum() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "domain: 200.193.193.in-addr.arpa")); subject.validate(update, updateContext); verify(updateContext).getSubject(any(UpdateContainer.class)); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_override() { when(authSubject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)).thenReturn(true); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("domain: 2.1.2.1.5.5.5.2.0.2.1.e164.arpa")); when(authSubject.hasPrincipal(Principal.ENUM_MAINTAINER)).thenReturn(false); subject.validate(update, updateContext); verify(updateContext).getSubject(any(UpdateContainer.class)); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_enum_no_enum_maintainer() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "domain: 2.1.2.1.5.5.5.2.0.2.1.e164.arpa")); when(authSubject.hasPrincipal(Principal.ENUM_MAINTAINER)).thenReturn(false); subject.validate(update, updateContext); verify(authSubject).hasPrincipal(Principal.ENUM_MAINTAINER); verify(updateContext).addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_enum_with_enum_maintainer() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "domain: 2.1.2.1.5.5.5.2.0.2.1.e164.arpa")); when(authSubject.hasPrincipal(Principal.ENUM_MAINTAINER)).thenReturn(true); subject.validate(update, updateContext); verify(authSubject).hasPrincipal(Principal.ENUM_MAINTAINER); verify(updateContext, never()).addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
EnumDomainAuthorisationValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslObject rpslObject = update.getUpdatedObject(); final CIString domainString = rpslObject.getKey(); final Domain domain = Domain.parse(domainString); if (domain.getType() == Domain.Type.E164) { if (!subject.hasPrincipal(Principal.ENUM_MAINTAINER)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForEnumDomain()); } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE, Action.MODIFY)); }
@Override public ImmutableList<Action> getActions() { return ACTIONS; }
NServerValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
NServerValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
NServerValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void shouldGetRemoteAddressFromIpv6AddressChannel() { InetAddress remoteAddress = ChannelUtil.getRemoteAddress(new StubbedChannel("2001:67c:2e8:13:1146:e6f4:bfd7:c324")); assertThat(remoteAddress.getHostAddress(), is("2001:67c:2e8:13:1146:e6f4:bfd7:c324")); }
public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; }
ChannelUtil { public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; } }
ChannelUtil { public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; } private ChannelUtil(); }
ChannelUtil { public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; } private ChannelUtil(); static InetAddress getRemoteAddress(final Channel channel); }
ChannelUtil { public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; } private ChannelUtil(); static InetAddress getRemoteAddress(final Channel channel); static final Charset BYTE_ENCODING; }
@Test public void getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.DOMAIN)); }
@Override public ImmutableList<ObjectType> getTypes() { return TYPES; }
NServerValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
NServerValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
NServerValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void enum_domain_mandatory_nserver_glue_present() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse( "domain: 8.8.8.e164.arpa\n" + "nserver: ns1.8.8.8.e164.arpa 192.0.2.1")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void enum_domain_mandatory_nserver_glue_not_present() { final RpslObject rpslObject = RpslObject.parse( "domain: 8.8.8.e164.arpa\n" + "nserver: ns1.8.8.8.e164.arpa"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); verify(updateContext).addMessage(update, rpslObject.findAttribute(AttributeType.NSERVER), UpdateMessages.glueRecordMandatory("8.8.8.e164.arpa")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void enum_domain_nserver_glue_not_mandatory_not_present() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse( "domain: 8.8.8.e164.arpa\n" + "nserver: ns1.example.net")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void enum_domain_nserver_glue_is_present() { final RpslObject rpslObject = RpslObject.parse( "domain: 8.8.8.e164.arpa\n" + "nserver: ns1.example.net 192.0.2.1"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); verify(updateContext).addMessage(update, rpslObject.findAttribute(AttributeType.NSERVER), UpdateMessages.invalidGlueForEnumDomain("192.0.2.1/32")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_enum_missing_glue() { final RpslObject rpslObject = RpslObject.parse( "domain: 2.1.2.1.5.5.5.2.0.2.1.e164.arpa\n" + "nserver: a.ns.2.1.2.1.5.5.5.2.0.2.1.e164.arpa\n"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); verify(updateContext).addMessage(update, rpslObject.findAttribute(AttributeType.NSERVER), UpdateMessages.glueRecordMandatory("2.1.2.1.5.5.5.2.0.2.1.e164.arpa")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_enum_nserver_does_not_end_with_domain() { final RpslObject rpslObject = RpslObject.parse("" + "domain: 1.e164.arpa\n" + "nserver: a.ns.e164.arpa\n"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_enum_nserver_with_glue() { final RpslObject rpslObject = RpslObject.parse("" + "domain: 1.e164.arpa\n" + "nserver: a.ns.1.e164.arpa 193.46.210.1\n"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_in_addr_success() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "domain: 144.102.5.in-addr.arpa\n" + "nserver: 144.102.5.in-addr.arpa 81.20.133.177\n")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_in_addr_success_ipv4_ipv6() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "domain: 64.67.217.in-addr.arpa\n" + "nserver: a.ns.64.67.217.in-addr.arpa 193.46.210.1\n" + "nserver: ns1.64.67.217.in-addr.arpa 2001:db8::1\n")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void shouldGetRemoteAddressFromIpv6WithoutInterface() { InetAddress remoteAddress = ChannelUtil.getRemoteAddress(new StubbedChannel("2001:67c:2e8:13:1146:e6f4:bfd7:c324", true)); assertThat(remoteAddress.getHostAddress(), is("2001:67c:2e8:13:1146:e6f4:bfd7:c324")); }
public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; }
ChannelUtil { public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; } }
ChannelUtil { public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; } private ChannelUtil(); }
ChannelUtil { public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; } private ChannelUtil(); static InetAddress getRemoteAddress(final Channel channel); }
ChannelUtil { public static InetAddress getRemoteAddress(final Channel channel) { final InetAddress inetAddress = ((InetSocketAddress) channel.getRemoteAddress()).getAddress(); if (inetAddress instanceof Inet6Address) { try { return InetAddress.getByAddress(inetAddress.getAddress()); } catch (UnknownHostException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } } return inetAddress; } private ChannelUtil(); static InetAddress getRemoteAddress(final Channel channel); static final Charset BYTE_ENCODING; }
@Test public void validate_in_addr_invalid() { final RpslObject rpslObject = RpslObject.parse("" + "domain: 144.102.5.in-addr.arpa\n" + "nserver: ns1.internetprovider.ch 81.20.133.177\n"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); verify(updateContext).addMessage(update, rpslObject.findAttribute(AttributeType.NSERVER), UpdateMessages.hostNameMustEndWith("144.102.5.in-addr.arpa")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_glue_record_mandatory() { final RpslObject rpslObject = RpslObject.parse("" + "domain: 144.102.5.in-addr.arpa\n" + "nserver: ns1.144.102.5.in-addr.arpa\n"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); verify(updateContext).addMessage(update, rpslObject.findAttribute(AttributeType.NSERVER), UpdateMessages.glueRecordMandatory("144.102.5.in-addr.arpa")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_in_addr_valid() { final RpslObject rpslObject = RpslObject.parse("" + "domain: 144.102.5.in-addr.arpa\n" + "nserver: ns1.144.102.5.in-addr.arpa 81.20.133.177\n"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NServerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Domain domain = Domain.parse(updatedObject.getKey()); for (final RpslAttribute nServerAttribute : updatedObject.findAttributes(AttributeType.NSERVER)) { final NServer nServer = NServer.parse(nServerAttribute.getCleanValue()); switch (domain.getType()) { case E164: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.invalidGlueForEnumDomain(nServer.getIpInterval().toString())); } break; } case INADDR: case IP6: { final boolean endsWithDomain = domain.endsWithDomain(nServer.getHostname()); if (endsWithDomain && nServer.getIpInterval() == null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.glueRecordMandatory(domain.getValue())); } else if (!endsWithDomain && nServer.getIpInterval() != null) { updateContext.addMessage(update, nServerAttribute, UpdateMessages.hostNameMustEndWith(domain.getValue())); } break; } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void mntner() { when(updateRequest.getUpdates()).thenReturn(Lists.newArrayList(update)); when(ack.getUpdateStatus()).thenReturn(UpdateStatus.SUCCESS); when(responseFactory.createAckResponse(updateContext, origin, ack)).thenReturn("ACK"); final RpslObject maintainer = RpslObject.parse("mntner: DEV-ROOT-MNT"); when(update.getSubmittedObject()).thenReturn(maintainer); when(updateContext.getStatus(any(PreparedUpdate.class))).thenReturn(UpdateStatus.SUCCESS); subject.handle(updateRequest, updateContext); verify(sourceContext).setCurrentSourceToWhoisMaster(); verify(sourceContext).removeCurrentSource(); verify(dnsChecker).checkAll(updateRequest, updateContext); verify(singleUpdateHandler).handle(origin, Keyword.NONE, update, updateContext); verify(updateNotifier).sendNotifications(updateRequest, updateContext); }
public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } @Autowired UpdateRequestHandler(final SourceContext sourceContext, final ResponseFactory responseFactory, final SingleUpdateHandler singleUpdateHandler, final MultipleUpdateHandler multipleUpdateHandler, final LoggerContext loggerContext, final DnsChecker dnsChecker, final SsoTranslator ssoTranslator, final UpdateNotifier updateNotifier, final UpdateLog updateLog); }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } @Autowired UpdateRequestHandler(final SourceContext sourceContext, final ResponseFactory responseFactory, final SingleUpdateHandler singleUpdateHandler, final MultipleUpdateHandler multipleUpdateHandler, final LoggerContext loggerContext, final DnsChecker dnsChecker, final SsoTranslator ssoTranslator, final UpdateNotifier updateNotifier, final UpdateLog updateLog); UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext); }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } @Autowired UpdateRequestHandler(final SourceContext sourceContext, final ResponseFactory responseFactory, final SingleUpdateHandler singleUpdateHandler, final MultipleUpdateHandler multipleUpdateHandler, final LoggerContext loggerContext, final DnsChecker dnsChecker, final SsoTranslator ssoTranslator, final UpdateNotifier updateNotifier, final UpdateLog updateLog); UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext); }
@Test public void domain() { when(updateRequest.getUpdates()).thenReturn(Lists.newArrayList(update)); when(ack.getUpdateStatus()).thenReturn(UpdateStatus.SUCCESS); when(responseFactory.createAckResponse(updateContext, origin, ack)).thenReturn("ACK"); final RpslObject domain = RpslObject.parse("domain: 36.84.80.in-addr.arpa"); when(update.getType()).thenReturn(ObjectType.DOMAIN); when(update.getSubmittedObject()).thenReturn(domain); when(updateContext.getStatus(any(PreparedUpdate.class))).thenReturn(UpdateStatus.SUCCESS); subject.handle(updateRequest, updateContext); verify(sourceContext).setCurrentSourceToWhoisMaster(); verify(sourceContext).removeCurrentSource(); verify(dnsChecker).checkAll(updateRequest, updateContext); verify(singleUpdateHandler).handle(origin, Keyword.NONE, update, updateContext); }
public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } @Autowired UpdateRequestHandler(final SourceContext sourceContext, final ResponseFactory responseFactory, final SingleUpdateHandler singleUpdateHandler, final MultipleUpdateHandler multipleUpdateHandler, final LoggerContext loggerContext, final DnsChecker dnsChecker, final SsoTranslator ssoTranslator, final UpdateNotifier updateNotifier, final UpdateLog updateLog); }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } @Autowired UpdateRequestHandler(final SourceContext sourceContext, final ResponseFactory responseFactory, final SingleUpdateHandler singleUpdateHandler, final MultipleUpdateHandler multipleUpdateHandler, final LoggerContext loggerContext, final DnsChecker dnsChecker, final SsoTranslator ssoTranslator, final UpdateNotifier updateNotifier, final UpdateLog updateLog); UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext); }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } @Autowired UpdateRequestHandler(final SourceContext sourceContext, final ResponseFactory responseFactory, final SingleUpdateHandler singleUpdateHandler, final MultipleUpdateHandler multipleUpdateHandler, final LoggerContext loggerContext, final DnsChecker dnsChecker, final SsoTranslator ssoTranslator, final UpdateNotifier updateNotifier, final UpdateLog updateLog); UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext); }
@Test public void domain_delete() { when(updateRequest.getUpdates()).thenReturn(Lists.newArrayList(update)); when(ack.getUpdateStatus()).thenReturn(UpdateStatus.SUCCESS); when(responseFactory.createAckResponse(updateContext, origin, ack)).thenReturn("ACK"); final RpslObject domain = RpslObject.parse("domain: 36.84.80.in-addr.arpa"); when(update.getType()).thenReturn(ObjectType.DOMAIN); when(update.getSubmittedObject()).thenReturn(domain); when(update.getOperation()).thenReturn(Operation.DELETE); when(updateContext.getStatus(any(PreparedUpdate.class))).thenReturn(UpdateStatus.SUCCESS); subject.handle(updateRequest, updateContext); verify(sourceContext).setCurrentSourceToWhoisMaster(); verify(sourceContext).removeCurrentSource(); verify(dnsChecker).checkAll(updateRequest, updateContext); verify(singleUpdateHandler).handle(origin, Keyword.NONE, update, updateContext); }
public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } @Autowired UpdateRequestHandler(final SourceContext sourceContext, final ResponseFactory responseFactory, final SingleUpdateHandler singleUpdateHandler, final MultipleUpdateHandler multipleUpdateHandler, final LoggerContext loggerContext, final DnsChecker dnsChecker, final SsoTranslator ssoTranslator, final UpdateNotifier updateNotifier, final UpdateLog updateLog); }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } @Autowired UpdateRequestHandler(final SourceContext sourceContext, final ResponseFactory responseFactory, final SingleUpdateHandler singleUpdateHandler, final MultipleUpdateHandler multipleUpdateHandler, final LoggerContext loggerContext, final DnsChecker dnsChecker, final SsoTranslator ssoTranslator, final UpdateNotifier updateNotifier, final UpdateLog updateLog); UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext); }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } @Autowired UpdateRequestHandler(final SourceContext sourceContext, final ResponseFactory responseFactory, final SingleUpdateHandler singleUpdateHandler, final MultipleUpdateHandler multipleUpdateHandler, final LoggerContext loggerContext, final DnsChecker dnsChecker, final SsoTranslator ssoTranslator, final UpdateNotifier updateNotifier, final UpdateLog updateLog); UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext); }
@Test public void help() { when(responseFactory.createHelpResponse(updateContext, origin)).thenReturn("help"); final UpdateRequest updateRequest = new UpdateRequest(origin, Keyword.HELP, Collections.<Update>emptyList()); final UpdateResponse response = subject.handle(updateRequest, updateContext); assertThat(response.getStatus(), is(UpdateStatus.SUCCESS)); assertThat(response.getResponse(), is("help")); verify(sourceContext, never()).setCurrentSourceToWhoisMaster(); verify(sourceContext, never()).removeCurrentSource(); }
public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } @Autowired UpdateRequestHandler(final SourceContext sourceContext, final ResponseFactory responseFactory, final SingleUpdateHandler singleUpdateHandler, final MultipleUpdateHandler multipleUpdateHandler, final LoggerContext loggerContext, final DnsChecker dnsChecker, final SsoTranslator ssoTranslator, final UpdateNotifier updateNotifier, final UpdateLog updateLog); }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } @Autowired UpdateRequestHandler(final SourceContext sourceContext, final ResponseFactory responseFactory, final SingleUpdateHandler singleUpdateHandler, final MultipleUpdateHandler multipleUpdateHandler, final LoggerContext loggerContext, final DnsChecker dnsChecker, final SsoTranslator ssoTranslator, final UpdateNotifier updateNotifier, final UpdateLog updateLog); UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext); }
UpdateRequestHandler { public UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext) { UpdateResponse updateResponse; try { updateResponse = handleUpdateRequest(updateRequest, updateContext); } catch (RuntimeException e) { LOGGER.error("Handling update request", e); updateResponse = new UpdateResponse(UpdateStatus.EXCEPTION, responseFactory.createExceptionResponse(updateContext, updateRequest.getOrigin())); } return updateResponse; } @Autowired UpdateRequestHandler(final SourceContext sourceContext, final ResponseFactory responseFactory, final SingleUpdateHandler singleUpdateHandler, final MultipleUpdateHandler multipleUpdateHandler, final LoggerContext loggerContext, final DnsChecker dnsChecker, final SsoTranslator ssoTranslator, final UpdateNotifier updateNotifier, final UpdateLog updateLog); UpdateResponse handle(final UpdateRequest updateRequest, final UpdateContext updateContext); }
@Test public void sendNotifications_empty() { when(updateRequest.getUpdates()).thenReturn(Lists.<Update>newArrayList()); subject.sendNotifications(updateRequest, updateContext); verifyZeroInteractions(responseFactory, mailGateway); }
public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } @Autowired UpdateNotifier(final RpslObjectDao rpslObjectDao, final ResponseFactory responseFactory, final MailGateway mailGateway, final VersionDao versionDao, final Maintainers maintainers); }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } @Autowired UpdateNotifier(final RpslObjectDao rpslObjectDao, final ResponseFactory responseFactory, final MailGateway mailGateway, final VersionDao versionDao, final Maintainers maintainers); void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext); }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } @Autowired UpdateNotifier(final RpslObjectDao rpslObjectDao, final ResponseFactory responseFactory, final MailGateway mailGateway, final VersionDao versionDao, final Maintainers maintainers); void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext); }
@Test public void sendNotifications_noPreparedUpdate() { final Update update = mock(Update.class); when(updateRequest.getUpdates()).thenReturn(Lists.newArrayList(update)); subject.sendNotifications(updateRequest, updateContext); verifyZeroInteractions(responseFactory, mailGateway); }
public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } @Autowired UpdateNotifier(final RpslObjectDao rpslObjectDao, final ResponseFactory responseFactory, final MailGateway mailGateway, final VersionDao versionDao, final Maintainers maintainers); }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } @Autowired UpdateNotifier(final RpslObjectDao rpslObjectDao, final ResponseFactory responseFactory, final MailGateway mailGateway, final VersionDao versionDao, final Maintainers maintainers); void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext); }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } @Autowired UpdateNotifier(final RpslObjectDao rpslObjectDao, final ResponseFactory responseFactory, final MailGateway mailGateway, final VersionDao versionDao, final Maintainers maintainers); void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext); }
@Test public void sendNotifications_single_no_notifications() { final Update update = mock(Update.class); final RpslObject rpslObject = RpslObject.parse( "mntner: UPD-MNT\n" + "descr: description\n" + "admin-c: TEST-RIPE\n" + "mnt-by: UPD-MNT\n" + "mnt-nfy: [email protected]\n" + "mnt-nfy: [email protected]\n" + "notify: [email protected]\n" + "notify: [email protected]\n" + "upd-to: [email protected]\n" + "auth: MD5-PW $1$fU9ZMQN9$QQtm3kRqZXWAuLpeOiLN7. # update\n" + "source: TEST\n"); final PreparedUpdate preparedUpdate = new PreparedUpdate(update, null, rpslObject, Action.CREATE); when(updateRequest.getUpdates()).thenReturn(Lists.newArrayList(update)); when(updateContext.getPreparedUpdate(update)).thenReturn(preparedUpdate); when(updateContext.getStatus(preparedUpdate)).thenReturn(UpdateStatus.SUCCESS); ResponseMessage responseMessage = new ResponseMessage("Notification of RIPE Database changes", "message"); when(responseFactory.createNotification(any(UpdateContext.class), any(Origin.class), any(Notification.class))).thenReturn(responseMessage); subject.sendNotifications(updateRequest, updateContext); verify(mailGateway).sendEmail(eq("[email protected]"), eq(responseMessage)); verify(mailGateway).sendEmail(eq("[email protected]"), eq(responseMessage)); }
public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } @Autowired UpdateNotifier(final RpslObjectDao rpslObjectDao, final ResponseFactory responseFactory, final MailGateway mailGateway, final VersionDao versionDao, final Maintainers maintainers); }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } @Autowired UpdateNotifier(final RpslObjectDao rpslObjectDao, final ResponseFactory responseFactory, final MailGateway mailGateway, final VersionDao versionDao, final Maintainers maintainers); void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext); }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } @Autowired UpdateNotifier(final RpslObjectDao rpslObjectDao, final ResponseFactory responseFactory, final MailGateway mailGateway, final VersionDao versionDao, final Maintainers maintainers); void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext); }
@Test public void maintenance_mode_set() { subject.setMaintenanceMode("FULL, FULL"); verify(maintenanceMode, times(1)).set(anyString()); }
@ManagedOperation(description = "Sets maintenance mode") @ManagedOperationParameters({ @ManagedOperationParameter(name = "mode", description = "Access rights for 'world,trusted' (values: FULL/READONLY/NONE) (e.g. 'none,full')"), }) public void setMaintenanceMode(final String mode) { invokeOperation("Set maintenance mode", mode, new Callable<Void>() { @Override public Void call() throws Exception { maintenanceMode.set(mode); return null; } }); }
MaintenanceModeJmx extends JmxBase { @ManagedOperation(description = "Sets maintenance mode") @ManagedOperationParameters({ @ManagedOperationParameter(name = "mode", description = "Access rights for 'world,trusted' (values: FULL/READONLY/NONE) (e.g. 'none,full')"), }) public void setMaintenanceMode(final String mode) { invokeOperation("Set maintenance mode", mode, new Callable<Void>() { @Override public Void call() throws Exception { maintenanceMode.set(mode); return null; } }); } }
MaintenanceModeJmx extends JmxBase { @ManagedOperation(description = "Sets maintenance mode") @ManagedOperationParameters({ @ManagedOperationParameter(name = "mode", description = "Access rights for 'world,trusted' (values: FULL/READONLY/NONE) (e.g. 'none,full')"), }) public void setMaintenanceMode(final String mode) { invokeOperation("Set maintenance mode", mode, new Callable<Void>() { @Override public Void call() throws Exception { maintenanceMode.set(mode); return null; } }); } @Autowired MaintenanceModeJmx(final MaintenanceMode maintenanceMode, IpRanges ipRanges); }
MaintenanceModeJmx extends JmxBase { @ManagedOperation(description = "Sets maintenance mode") @ManagedOperationParameters({ @ManagedOperationParameter(name = "mode", description = "Access rights for 'world,trusted' (values: FULL/READONLY/NONE) (e.g. 'none,full')"), }) public void setMaintenanceMode(final String mode) { invokeOperation("Set maintenance mode", mode, new Callable<Void>() { @Override public Void call() throws Exception { maintenanceMode.set(mode); return null; } }); } @Autowired MaintenanceModeJmx(final MaintenanceMode maintenanceMode, IpRanges ipRanges); @ManagedOperation(description = "Sets maintenance mode") @ManagedOperationParameters({ @ManagedOperationParameter(name = "mode", description = "Access rights for 'world,trusted' (values: FULL/READONLY/NONE) (e.g. 'none,full')"), }) void setMaintenanceMode(final String mode); @ManagedOperation(description = "Sets trusted range (ipranges.trusted)") @ManagedOperationParameters({ @ManagedOperationParameter(name = "ranges", description = "Comma-separated list of IP prefixes/ranges (e.g. '10/8,::1/64)"), }) void setTrustedIpRanges(final String ranges); }
MaintenanceModeJmx extends JmxBase { @ManagedOperation(description = "Sets maintenance mode") @ManagedOperationParameters({ @ManagedOperationParameter(name = "mode", description = "Access rights for 'world,trusted' (values: FULL/READONLY/NONE) (e.g. 'none,full')"), }) public void setMaintenanceMode(final String mode) { invokeOperation("Set maintenance mode", mode, new Callable<Void>() { @Override public Void call() throws Exception { maintenanceMode.set(mode); return null; } }); } @Autowired MaintenanceModeJmx(final MaintenanceMode maintenanceMode, IpRanges ipRanges); @ManagedOperation(description = "Sets maintenance mode") @ManagedOperationParameters({ @ManagedOperationParameter(name = "mode", description = "Access rights for 'world,trusted' (values: FULL/READONLY/NONE) (e.g. 'none,full')"), }) void setMaintenanceMode(final String mode); @ManagedOperation(description = "Sets trusted range (ipranges.trusted)") @ManagedOperationParameters({ @ManagedOperationParameter(name = "ranges", description = "Comma-separated list of IP prefixes/ranges (e.g. '10/8,::1/64)"), }) void setTrustedIpRanges(final String ranges); }
@Test public void sendNotifications_sanitized_email() { final Update update = mock(Update.class); final RpslObject rpslObject = RpslObject.parse( "mntner: UPD-MNT\n" + "descr: description\n" + "admin-c: TEST-RIPE\n" + "mnt-by: UPD-MNT\n" + "mnt-nfy: [email protected]\n" + "mnt-nfy: [email protected]\n" + "notify: notifies us <mailto:[email protected]>\n" + "upd-to: [email protected]\n" + "auth: MD5-PW $1$fU9ZMQN9$QQtm3kRqZXWAuLpeOiLN7. # update\n" + "source: TEST\n"); final PreparedUpdate preparedUpdate = new PreparedUpdate(update, null, rpslObject, Action.CREATE); when(updateRequest.getUpdates()).thenReturn(Lists.newArrayList(update)); when(updateContext.getPreparedUpdate(update)).thenReturn(preparedUpdate); when(updateContext.getStatus(preparedUpdate)).thenReturn(UpdateStatus.SUCCESS); when(responseFactory.createNotification(eq(updateContext), any(Origin.class), any(Notification.class))).thenReturn(responseMessage); subject.sendNotifications(updateRequest, updateContext); verify(mailGateway, never()).sendEmail("notifies us <mailto:[email protected]>", responseMessage); }
public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } @Autowired UpdateNotifier(final RpslObjectDao rpslObjectDao, final ResponseFactory responseFactory, final MailGateway mailGateway, final VersionDao versionDao, final Maintainers maintainers); }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } @Autowired UpdateNotifier(final RpslObjectDao rpslObjectDao, final ResponseFactory responseFactory, final MailGateway mailGateway, final VersionDao versionDao, final Maintainers maintainers); void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext); }
UpdateNotifier { public void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext) { if (updateContext.isDryRun()) { return; } final Map<CIString, Notification> notifications = Maps.newHashMap(); for (final Update update : updateRequest.getUpdates()) { final PreparedUpdate preparedUpdate = updateContext.getPreparedUpdate(update); if (preparedUpdate != null && !notificationsDisabledByOverride(preparedUpdate)) { addNotifications(notifications, preparedUpdate, updateContext); } } for (final Notification notification : notifications.values()) { final ResponseMessage responseMessage = responseFactory.createNotification(updateContext, updateRequest.getOrigin(), notification); try { new InternetAddress(notification.getEmail(), true); mailGateway.sendEmail(notification.getEmail(), responseMessage); } catch (final AddressException e) { LOGGER.info("Failed to send notification to '{}' because it's an invalid email address", notification.getEmail()); } } } @Autowired UpdateNotifier(final RpslObjectDao rpslObjectDao, final ResponseFactory responseFactory, final MailGateway mailGateway, final VersionDao versionDao, final Maintainers maintainers); void sendNotifications(final UpdateRequest updateRequest, final UpdateContext updateContext); }
@Test public void getCountryCodes() { assertThat(subject.getCountryCodes(), containsInAnyOrder(ciString("NL"), ciString("EN"))); }
public Set<CIString> getCountryCodes() { return countryCodes; }
CountryCodeRepository { public Set<CIString> getCountryCodes() { return countryCodes; } }
CountryCodeRepository { public Set<CIString> getCountryCodes() { return countryCodes; } @Autowired CountryCodeRepository(@Value("${whois.countrycodes}") final String[] countryCodes); }
CountryCodeRepository { public Set<CIString> getCountryCodes() { return countryCodes; } @Autowired CountryCodeRepository(@Value("${whois.countrycodes}") final String[] countryCodes); Set<CIString> getCountryCodes(); }
CountryCodeRepository { public Set<CIString> getCountryCodes() { return countryCodes; } @Autowired CountryCodeRepository(@Value("${whois.countrycodes}") final String[] countryCodes); Set<CIString> getCountryCodes(); }
@Test(expected = UnsupportedOperationException.class) public void getCountryCodes_immutable() { subject.getCountryCodes().add(ciString("DE")); }
public Set<CIString> getCountryCodes() { return countryCodes; }
CountryCodeRepository { public Set<CIString> getCountryCodes() { return countryCodes; } }
CountryCodeRepository { public Set<CIString> getCountryCodes() { return countryCodes; } @Autowired CountryCodeRepository(@Value("${whois.countrycodes}") final String[] countryCodes); }
CountryCodeRepository { public Set<CIString> getCountryCodes() { return countryCodes; } @Autowired CountryCodeRepository(@Value("${whois.countrycodes}") final String[] countryCodes); Set<CIString> getCountryCodes(); }
CountryCodeRepository { public Set<CIString> getCountryCodes() { return countryCodes; } @Autowired CountryCodeRepository(@Value("${whois.countrycodes}") final String[] countryCodes); Set<CIString> getCountryCodes(); }
@Test public void attributeType() { assertThat(subject.getAttributeType(), is(AttributeType.KEY_CERT)); }
@Override public AttributeType getAttributeType() { return AttributeType.KEY_CERT; }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public AttributeType getAttributeType() { return AttributeType.KEY_CERT; } }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public AttributeType getAttributeType() { return AttributeType.KEY_CERT; } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public AttributeType getAttributeType() { return AttributeType.KEY_CERT; } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); @Override AttributeType getAttributeType(); @Override boolean isKeyPlaceHolder(final CharSequence s); @Override CIString getKeyPlaceholder(final CharSequence s); @Override X509KeycertId claim(final String key); @Override X509KeycertId generate(final String keyPlaceHolder, final RpslObject object); @Override boolean isApplicableFor(final RpslObject object); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public AttributeType getAttributeType() { return AttributeType.KEY_CERT; } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); @Override AttributeType getAttributeType(); @Override boolean isKeyPlaceHolder(final CharSequence s); @Override CIString getKeyPlaceholder(final CharSequence s); @Override X509KeycertId claim(final String key); @Override X509KeycertId generate(final String keyPlaceHolder, final RpslObject object); @Override boolean isApplicableFor(final RpslObject object); }
@Test public void correct_keyPlaceHolder() { assertThat(subject.isKeyPlaceHolder("AUTO-100"), is(true)); }
@Override public boolean isKeyPlaceHolder(final CharSequence s) { return AUTO_PATTERN.matcher(s).matches(); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public boolean isKeyPlaceHolder(final CharSequence s) { return AUTO_PATTERN.matcher(s).matches(); } }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public boolean isKeyPlaceHolder(final CharSequence s) { return AUTO_PATTERN.matcher(s).matches(); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public boolean isKeyPlaceHolder(final CharSequence s) { return AUTO_PATTERN.matcher(s).matches(); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); @Override AttributeType getAttributeType(); @Override boolean isKeyPlaceHolder(final CharSequence s); @Override CIString getKeyPlaceholder(final CharSequence s); @Override X509KeycertId claim(final String key); @Override X509KeycertId generate(final String keyPlaceHolder, final RpslObject object); @Override boolean isApplicableFor(final RpslObject object); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public boolean isKeyPlaceHolder(final CharSequence s) { return AUTO_PATTERN.matcher(s).matches(); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); @Override AttributeType getAttributeType(); @Override boolean isKeyPlaceHolder(final CharSequence s); @Override CIString getKeyPlaceholder(final CharSequence s); @Override X509KeycertId claim(final String key); @Override X509KeycertId generate(final String keyPlaceHolder, final RpslObject object); @Override boolean isApplicableFor(final RpslObject object); }
@Test public void incorrect_keyPlaceHolder() { assertThat(subject.isKeyPlaceHolder("AUTO-100NL"), is(false)); assertThat(subject.isKeyPlaceHolder("AUTO-"), is(false)); assertThat(subject.isKeyPlaceHolder("AUTO"), is(false)); assertThat(subject.isKeyPlaceHolder("AUTO-100-NL"), is(false)); }
@Override public boolean isKeyPlaceHolder(final CharSequence s) { return AUTO_PATTERN.matcher(s).matches(); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public boolean isKeyPlaceHolder(final CharSequence s) { return AUTO_PATTERN.matcher(s).matches(); } }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public boolean isKeyPlaceHolder(final CharSequence s) { return AUTO_PATTERN.matcher(s).matches(); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public boolean isKeyPlaceHolder(final CharSequence s) { return AUTO_PATTERN.matcher(s).matches(); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); @Override AttributeType getAttributeType(); @Override boolean isKeyPlaceHolder(final CharSequence s); @Override CIString getKeyPlaceholder(final CharSequence s); @Override X509KeycertId claim(final String key); @Override X509KeycertId generate(final String keyPlaceHolder, final RpslObject object); @Override boolean isApplicableFor(final RpslObject object); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public boolean isKeyPlaceHolder(final CharSequence s) { return AUTO_PATTERN.matcher(s).matches(); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); @Override AttributeType getAttributeType(); @Override boolean isKeyPlaceHolder(final CharSequence s); @Override CIString getKeyPlaceholder(final CharSequence s); @Override X509KeycertId claim(final String key); @Override X509KeycertId generate(final String keyPlaceHolder, final RpslObject object); @Override boolean isApplicableFor(final RpslObject object); }
@Test(expected = ClaimException.class) public void claim_not_supported() throws ClaimException { subject.claim("irrelevant here"); }
@Override public X509KeycertId claim(final String key) throws ClaimException { throw new ClaimException(ValidationMessages.syntaxError(key, "must be AUTO-nnn for create")); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public X509KeycertId claim(final String key) throws ClaimException { throw new ClaimException(ValidationMessages.syntaxError(key, "must be AUTO-nnn for create")); } }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public X509KeycertId claim(final String key) throws ClaimException { throw new ClaimException(ValidationMessages.syntaxError(key, "must be AUTO-nnn for create")); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public X509KeycertId claim(final String key) throws ClaimException { throw new ClaimException(ValidationMessages.syntaxError(key, "must be AUTO-nnn for create")); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); @Override AttributeType getAttributeType(); @Override boolean isKeyPlaceHolder(final CharSequence s); @Override CIString getKeyPlaceholder(final CharSequence s); @Override X509KeycertId claim(final String key); @Override X509KeycertId generate(final String keyPlaceHolder, final RpslObject object); @Override boolean isApplicableFor(final RpslObject object); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public X509KeycertId claim(final String key) throws ClaimException { throw new ClaimException(ValidationMessages.syntaxError(key, "must be AUTO-nnn for create")); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); @Override AttributeType getAttributeType(); @Override boolean isKeyPlaceHolder(final CharSequence s); @Override CIString getKeyPlaceholder(final CharSequence s); @Override X509KeycertId claim(final String key); @Override X509KeycertId generate(final String keyPlaceHolder, final RpslObject object); @Override boolean isApplicableFor(final RpslObject object); }
@Test(expected = IllegalArgumentException.class) public void generate_invalid_placeHolder() { subject.generate("AUTO", RpslObject.parse("key-cert: AUTO")); }
@Override public X509KeycertId generate(final String keyPlaceHolder, final RpslObject object) { Validate.notEmpty(object.getValueForAttribute(AttributeType.KEY_CERT).toString(), "Name must not be empty"); final Matcher matcher = AUTO_PATTERN.matcher(keyPlaceHolder); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid key request: " + keyPlaceHolder); } return repository.claimNextAvailableIndex(SPACE, source.toString()); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public X509KeycertId generate(final String keyPlaceHolder, final RpslObject object) { Validate.notEmpty(object.getValueForAttribute(AttributeType.KEY_CERT).toString(), "Name must not be empty"); final Matcher matcher = AUTO_PATTERN.matcher(keyPlaceHolder); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid key request: " + keyPlaceHolder); } return repository.claimNextAvailableIndex(SPACE, source.toString()); } }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public X509KeycertId generate(final String keyPlaceHolder, final RpslObject object) { Validate.notEmpty(object.getValueForAttribute(AttributeType.KEY_CERT).toString(), "Name must not be empty"); final Matcher matcher = AUTO_PATTERN.matcher(keyPlaceHolder); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid key request: " + keyPlaceHolder); } return repository.claimNextAvailableIndex(SPACE, source.toString()); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public X509KeycertId generate(final String keyPlaceHolder, final RpslObject object) { Validate.notEmpty(object.getValueForAttribute(AttributeType.KEY_CERT).toString(), "Name must not be empty"); final Matcher matcher = AUTO_PATTERN.matcher(keyPlaceHolder); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid key request: " + keyPlaceHolder); } return repository.claimNextAvailableIndex(SPACE, source.toString()); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); @Override AttributeType getAttributeType(); @Override boolean isKeyPlaceHolder(final CharSequence s); @Override CIString getKeyPlaceholder(final CharSequence s); @Override X509KeycertId claim(final String key); @Override X509KeycertId generate(final String keyPlaceHolder, final RpslObject object); @Override boolean isApplicableFor(final RpslObject object); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public X509KeycertId generate(final String keyPlaceHolder, final RpslObject object) { Validate.notEmpty(object.getValueForAttribute(AttributeType.KEY_CERT).toString(), "Name must not be empty"); final Matcher matcher = AUTO_PATTERN.matcher(keyPlaceHolder); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid key request: " + keyPlaceHolder); } return repository.claimNextAvailableIndex(SPACE, source.toString()); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); @Override AttributeType getAttributeType(); @Override boolean isKeyPlaceHolder(final CharSequence s); @Override CIString getKeyPlaceholder(final CharSequence s); @Override X509KeycertId claim(final String key); @Override X509KeycertId generate(final String keyPlaceHolder, final RpslObject object); @Override boolean isApplicableFor(final RpslObject object); }
@Test public void generate_correct() { when(x509Repository.claimNextAvailableIndex("X509", "TEST")).thenReturn(new X509KeycertId("X509", 2, "TEST")); final X509KeycertId generated = subject.generate("AuTO-1", RpslObject.parse("kEy-Cert: auto\nremarks: optional")); assertThat(generated.toString(), is("X509-2")); }
@Override public X509KeycertId generate(final String keyPlaceHolder, final RpslObject object) { Validate.notEmpty(object.getValueForAttribute(AttributeType.KEY_CERT).toString(), "Name must not be empty"); final Matcher matcher = AUTO_PATTERN.matcher(keyPlaceHolder); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid key request: " + keyPlaceHolder); } return repository.claimNextAvailableIndex(SPACE, source.toString()); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public X509KeycertId generate(final String keyPlaceHolder, final RpslObject object) { Validate.notEmpty(object.getValueForAttribute(AttributeType.KEY_CERT).toString(), "Name must not be empty"); final Matcher matcher = AUTO_PATTERN.matcher(keyPlaceHolder); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid key request: " + keyPlaceHolder); } return repository.claimNextAvailableIndex(SPACE, source.toString()); } }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public X509KeycertId generate(final String keyPlaceHolder, final RpslObject object) { Validate.notEmpty(object.getValueForAttribute(AttributeType.KEY_CERT).toString(), "Name must not be empty"); final Matcher matcher = AUTO_PATTERN.matcher(keyPlaceHolder); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid key request: " + keyPlaceHolder); } return repository.claimNextAvailableIndex(SPACE, source.toString()); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public X509KeycertId generate(final String keyPlaceHolder, final RpslObject object) { Validate.notEmpty(object.getValueForAttribute(AttributeType.KEY_CERT).toString(), "Name must not be empty"); final Matcher matcher = AUTO_PATTERN.matcher(keyPlaceHolder); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid key request: " + keyPlaceHolder); } return repository.claimNextAvailableIndex(SPACE, source.toString()); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); @Override AttributeType getAttributeType(); @Override boolean isKeyPlaceHolder(final CharSequence s); @Override CIString getKeyPlaceholder(final CharSequence s); @Override X509KeycertId claim(final String key); @Override X509KeycertId generate(final String keyPlaceHolder, final RpslObject object); @Override boolean isApplicableFor(final RpslObject object); }
X509AutoKeyFactory implements AutoKeyFactory<X509KeycertId> { @Override public X509KeycertId generate(final String keyPlaceHolder, final RpslObject object) { Validate.notEmpty(object.getValueForAttribute(AttributeType.KEY_CERT).toString(), "Name must not be empty"); final Matcher matcher = AUTO_PATTERN.matcher(keyPlaceHolder); if (!matcher.matches()) { throw new IllegalArgumentException("Invalid key request: " + keyPlaceHolder); } return repository.claimNextAvailableIndex(SPACE, source.toString()); } @Autowired X509AutoKeyFactory(final X509Repository repository, @Value("${whois.source}") String source); @Override AttributeType getAttributeType(); @Override boolean isKeyPlaceHolder(final CharSequence s); @Override CIString getKeyPlaceholder(final CharSequence s); @Override X509KeycertId claim(final String key); @Override X509KeycertId generate(final String keyPlaceHolder, final RpslObject object); @Override boolean isApplicableFor(final RpslObject object); }
@Test public void resolveAutoKeys_key_create_auto() { RpslObject object = RpslObject.parse("" + "person: John Doe\n" + "nic-hdl: AUTO-1\n"); final RpslObject rpslObject = subject.resolveAutoKeys(object, update, updateContext, Action.CREATE); assertThat(rpslObject.toString(), is("" + "person: John Doe\n" + "nic-hdl: J1-RIPE\n")); verify(autoKeyFactory, times(1)).generate(anyString(), any(RpslObject.class)); }
public RpslObject resolveAutoKeys(final RpslObject object, final Update update, final UpdateContext updateContext, final Action action) { final Map<RpslAttribute, RpslAttribute> attributesToReplace = Maps.newHashMap(); if (Action.CREATE.equals(action)) { claimOrGenerateAutoKeys(update, object, updateContext, attributesToReplace); } resolveAutoKeyReferences(update, object, updateContext, attributesToReplace); if (attributesToReplace.isEmpty()) { return object; } return new RpslObjectBuilder(object).replaceAttributes(attributesToReplace).get(); }
AutoKeyResolver { public RpslObject resolveAutoKeys(final RpslObject object, final Update update, final UpdateContext updateContext, final Action action) { final Map<RpslAttribute, RpslAttribute> attributesToReplace = Maps.newHashMap(); if (Action.CREATE.equals(action)) { claimOrGenerateAutoKeys(update, object, updateContext, attributesToReplace); } resolveAutoKeyReferences(update, object, updateContext, attributesToReplace); if (attributesToReplace.isEmpty()) { return object; } return new RpslObjectBuilder(object).replaceAttributes(attributesToReplace).get(); } }
AutoKeyResolver { public RpslObject resolveAutoKeys(final RpslObject object, final Update update, final UpdateContext updateContext, final Action action) { final Map<RpslAttribute, RpslAttribute> attributesToReplace = Maps.newHashMap(); if (Action.CREATE.equals(action)) { claimOrGenerateAutoKeys(update, object, updateContext, attributesToReplace); } resolveAutoKeyReferences(update, object, updateContext, attributesToReplace); if (attributesToReplace.isEmpty()) { return object; } return new RpslObjectBuilder(object).replaceAttributes(attributesToReplace).get(); } @Autowired AutoKeyResolver(final AutoKeyFactory... autoKeyFactories); }
AutoKeyResolver { public RpslObject resolveAutoKeys(final RpslObject object, final Update update, final UpdateContext updateContext, final Action action) { final Map<RpslAttribute, RpslAttribute> attributesToReplace = Maps.newHashMap(); if (Action.CREATE.equals(action)) { claimOrGenerateAutoKeys(update, object, updateContext, attributesToReplace); } resolveAutoKeyReferences(update, object, updateContext, attributesToReplace); if (attributesToReplace.isEmpty()) { return object; } return new RpslObjectBuilder(object).replaceAttributes(attributesToReplace).get(); } @Autowired AutoKeyResolver(final AutoKeyFactory... autoKeyFactories); RpslObject resolveAutoKeys(final RpslObject object, final Update update, final UpdateContext updateContext, final Action action); }
AutoKeyResolver { public RpslObject resolveAutoKeys(final RpslObject object, final Update update, final UpdateContext updateContext, final Action action) { final Map<RpslAttribute, RpslAttribute> attributesToReplace = Maps.newHashMap(); if (Action.CREATE.equals(action)) { claimOrGenerateAutoKeys(update, object, updateContext, attributesToReplace); } resolveAutoKeyReferences(update, object, updateContext, attributesToReplace); if (attributesToReplace.isEmpty()) { return object; } return new RpslObjectBuilder(object).replaceAttributes(attributesToReplace).get(); } @Autowired AutoKeyResolver(final AutoKeyFactory... autoKeyFactories); RpslObject resolveAutoKeys(final RpslObject object, final Update update, final UpdateContext updateContext, final Action action); }