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 transform_key_inetrtr_with_trailing_dot() { final RpslObject rpslObject = RpslObject.parse("" + "inet-rtr: test.ripe.net.\n" + "alias: alias.ripe.net"); final CIString result = attributeSanitizer.sanitizeKey(rpslObject); assertThat(result.toString(), is("test.ripe.net")); verifyNoMoreInteractions(objectMessages); }
public CIString sanitizeKey(final RpslObject originalObject) { final List<RpslAttribute> keyRelatedAttributes = getKeyRelatedAttributes(originalObject); return new RpslObject(sanitizeKeyAttributes(keyRelatedAttributes)).getKey(); }
AttributeSanitizer { public CIString sanitizeKey(final RpslObject originalObject) { final List<RpslAttribute> keyRelatedAttributes = getKeyRelatedAttributes(originalObject); return new RpslObject(sanitizeKeyAttributes(keyRelatedAttributes)).getKey(); } }
AttributeSanitizer { public CIString sanitizeKey(final RpslObject originalObject) { final List<RpslAttribute> keyRelatedAttributes = getKeyRelatedAttributes(originalObject); return new RpslObject(sanitizeKeyAttributes(keyRelatedAttributes)).getKey(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); }
AttributeSanitizer { public CIString sanitizeKey(final RpslObject originalObject) { final List<RpslAttribute> keyRelatedAttributes = getKeyRelatedAttributes(originalObject); return new RpslObject(sanitizeKeyAttributes(keyRelatedAttributes)).getKey(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); CIString sanitizeKey(final RpslObject originalObject); RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages); }
AttributeSanitizer { public CIString sanitizeKey(final RpslObject originalObject) { final List<RpslAttribute> keyRelatedAttributes = getKeyRelatedAttributes(originalObject); return new RpslObject(sanitizeKeyAttributes(keyRelatedAttributes)).getKey(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); CIString sanitizeKey(final RpslObject originalObject); RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages); }
@Test public void validate_asBlock_child_exists() { when(updateContext.getSubject(update)).thenReturn(subjectObject); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("as-block: AS10 - AS15")); when(rpslObjectDao.findAsBlock(1L, 20L)).thenReturn(RpslObject.parse("as-block: AS10 - AS15")); subject.validate(update, updateContext); verify(updateContext, never()).addMessage(update, UpdateMessages.asblockChildAlreadyExists()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } }
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } } }
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } } @Autowired AsblockHierarchyValidator(final RpslObjectDao rpslObjectDao); }
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } } @Autowired AsblockHierarchyValidator(final RpslObjectDao rpslObjectDao); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); }
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } } @Autowired AsblockHierarchyValidator(final RpslObjectDao rpslObjectDao); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); }
@Test public void validate_asBlock_intersects_on_boundaries() { when(updateContext.getSubject(update)).thenReturn(subjectObject); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("as-block: AS10 - AS15")); when(rpslObjectDao.findAsBlock(10L, 20L)).thenReturn(RpslObject.parse("as-block: AS10 - AS15")); subject.validate(update, updateContext); verify(updateContext, never()).addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } }
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } } }
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } } @Autowired AsblockHierarchyValidator(final RpslObjectDao rpslObjectDao); }
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } } @Autowired AsblockHierarchyValidator(final RpslObjectDao rpslObjectDao); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); }
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } } @Autowired AsblockHierarchyValidator(final RpslObjectDao rpslObjectDao); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); }
@Test public void validate_already_exists() { when(updateContext.getSubject(update)).thenReturn(subjectObject); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("as-block: AS10 - AS15")); when(rpslObjectDao.findAsBlock(10L, 15L)).thenReturn(RpslObject.parse("as-block: AS10 - AS15")); subject.validate(update, updateContext); verify(updateContext, never()).addMessage(update, UpdateMessages.asblockAlreadyExists()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } }
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } } }
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } } @Autowired AsblockHierarchyValidator(final RpslObjectDao rpslObjectDao); }
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } } @Autowired AsblockHierarchyValidator(final RpslObjectDao rpslObjectDao); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); }
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { AsBlockRange asBlockNew = AsBlockRange.parse(update.getUpdatedObject().getKey().toString()); final List<RpslObject> intersections = rpslObjectDao.findAsBlockIntersections(asBlockNew.getBegin(), asBlockNew.getEnd()); for (final RpslObject intersection : intersections) { final AsBlockRange asBlockExisting = AsBlockRange.parse(intersection.getKey().toString()); if (asBlockExisting.equals(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockAlreadyExists()); } else if (asBlockExisting.contains(asBlockNew)) { updateContext.addMessage(update, UpdateMessages.asblockParentAlreadyExists()); } else if (asBlockNew.contains(asBlockExisting)) { updateContext.addMessage(update, UpdateMessages.asblockChildAlreadyExists()); } else { updateContext.addMessage(update, UpdateMessages.intersectingAsblockAlreadyExists()); } } } @Autowired AsblockHierarchyValidator(final RpslObjectDao rpslObjectDao); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); }
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE, Action.MODIFY)); }
@Override public ImmutableList<Action> getActions() { return ACTIONS; }
PoemHasOnlyPublicMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
PoemHasOnlyPublicMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
PoemHasOnlyPublicMaintainerValidator 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(); }
PoemHasOnlyPublicMaintainerValidator 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.POEM)); }
@Override public ImmutableList<ObjectType> getTypes() { return TYPES; }
PoemHasOnlyPublicMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
PoemHasOnlyPublicMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
PoemHasOnlyPublicMaintainerValidator 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(); }
PoemHasOnlyPublicMaintainerValidator 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_LIM_MNT() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "poem: POEM-FORM-LIMERICK\n" + "mnt-by: LIM-MNT\n")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslAttribute mntByAttribute = update.getUpdatedObject().findAttribute(AttributeType.MNT_BY); if (!mntByAttribute.getCleanValue().equals(POEM_MAINTAINER)) { updateContext.addMessage(update, mntByAttribute, UpdateMessages.poemRequiresPublicMaintainer()); } }
PoemHasOnlyPublicMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslAttribute mntByAttribute = update.getUpdatedObject().findAttribute(AttributeType.MNT_BY); if (!mntByAttribute.getCleanValue().equals(POEM_MAINTAINER)) { updateContext.addMessage(update, mntByAttribute, UpdateMessages.poemRequiresPublicMaintainer()); } } }
PoemHasOnlyPublicMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslAttribute mntByAttribute = update.getUpdatedObject().findAttribute(AttributeType.MNT_BY); if (!mntByAttribute.getCleanValue().equals(POEM_MAINTAINER)) { updateContext.addMessage(update, mntByAttribute, UpdateMessages.poemRequiresPublicMaintainer()); } } }
PoemHasOnlyPublicMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslAttribute mntByAttribute = update.getUpdatedObject().findAttribute(AttributeType.MNT_BY); if (!mntByAttribute.getCleanValue().equals(POEM_MAINTAINER)) { updateContext.addMessage(update, mntByAttribute, UpdateMessages.poemRequiresPublicMaintainer()); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
PoemHasOnlyPublicMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslAttribute mntByAttribute = update.getUpdatedObject().findAttribute(AttributeType.MNT_BY); if (!mntByAttribute.getCleanValue().equals(POEM_MAINTAINER)) { updateContext.addMessage(update, mntByAttribute, UpdateMessages.poemRequiresPublicMaintainer()); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_other_maintainer() { final RpslObject poem = RpslObject.parse("" + "poem: POEM-FORM-LIMERICK\n" + "mnt-by: DEV-MNT\n"); when(update.getUpdatedObject()).thenReturn(poem); subject.validate(update, updateContext); verify(updateContext).addMessage(update, poem.findAttribute(AttributeType.MNT_BY), UpdateMessages.poemRequiresPublicMaintainer()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslAttribute mntByAttribute = update.getUpdatedObject().findAttribute(AttributeType.MNT_BY); if (!mntByAttribute.getCleanValue().equals(POEM_MAINTAINER)) { updateContext.addMessage(update, mntByAttribute, UpdateMessages.poemRequiresPublicMaintainer()); } }
PoemHasOnlyPublicMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslAttribute mntByAttribute = update.getUpdatedObject().findAttribute(AttributeType.MNT_BY); if (!mntByAttribute.getCleanValue().equals(POEM_MAINTAINER)) { updateContext.addMessage(update, mntByAttribute, UpdateMessages.poemRequiresPublicMaintainer()); } } }
PoemHasOnlyPublicMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslAttribute mntByAttribute = update.getUpdatedObject().findAttribute(AttributeType.MNT_BY); if (!mntByAttribute.getCleanValue().equals(POEM_MAINTAINER)) { updateContext.addMessage(update, mntByAttribute, UpdateMessages.poemRequiresPublicMaintainer()); } } }
PoemHasOnlyPublicMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslAttribute mntByAttribute = update.getUpdatedObject().findAttribute(AttributeType.MNT_BY); if (!mntByAttribute.getCleanValue().equals(POEM_MAINTAINER)) { updateContext.addMessage(update, mntByAttribute, UpdateMessages.poemRequiresPublicMaintainer()); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
PoemHasOnlyPublicMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslAttribute mntByAttribute = update.getUpdatedObject().findAttribute(AttributeType.MNT_BY); if (!mntByAttribute.getCleanValue().equals(POEM_MAINTAINER)) { updateContext.addMessage(update, mntByAttribute, UpdateMessages.poemRequiresPublicMaintainer()); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void ipv6_exact_match_bogon() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("route6: 2001:2::/48\norigin: AS3333\nsource: TEST")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.bogonPrefixNotAllowed("2001:2::/48")); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void ipv4_exact_match_bogon() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("route: 192.0.2.0/24\norigin: AS3333\nsource: TEST")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.bogonPrefixNotAllowed("192.0.2.0/24")); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void ipv6_more_specific_bogon() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("route6: 2001:2:0:1::/64\norigin: AS3333\nsource: TEST")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.bogonPrefixNotAllowed("2001:2:0:1::/64")); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void transform_invalid() { final RpslObject rpslObject = RpslObject.parse("" + "inetnum: test.ripe.net"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getValueForAttribute(AttributeType.INETNUM).toString(), is("test.ripe.net")); verifyNoMoreInteractions(objectMessages); }
public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); CIString sanitizeKey(final RpslObject originalObject); RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages); }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); CIString sanitizeKey(final RpslObject originalObject); RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages); }
@Test public void ipv4_more_specific_bogon() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("route: 192.0.2.1/32\norigin: AS3333\nsource: TEST")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.bogonPrefixNotAllowed("192.0.2.1/32")); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void ipv6_not_bogon() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("route6: 2002:1:2:3::/64\norigin: AS3333\nsource: TEST")); subject.validate(update, updateContext); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void ipv4_not_bogon() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("route: 193.201.1.0/24\norigin: AS3333\nsource: TEST")); subject.validate(update, updateContext); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
BogonValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } getPrefix(updatedObject).ifPresent(prefix -> { if (isBogon(prefix.toString())) { updateContext.addMessage(update, UpdateMessages.bogonPrefixNotAllowed(prefix.toString())); } }); } @Autowired BogonValidator(@Value("${ipranges.bogons:}") final String ... bogons); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void testGetActions() throws Exception { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE, Action.MODIFY)); }
@Override public ImmutableList<Action> getActions() { return ACTIONS; }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
ValueWithinPrefixValidator 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(); }
ValueWithinPrefixValidator 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 testGetTypes() throws Exception { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.ROUTE, ObjectType.ROUTE6)); }
@Override public ImmutableList<ObjectType> getTypes() { return TYPES; }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
ValueWithinPrefixValidator 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(); }
ValueWithinPrefixValidator 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 route_with_one_holes_attribute_outside_prefixrange() { final RpslObject route = RpslObject.parse("route:195.190.20.0/24\norigin:AS43746\nholes:94.73.128.0/24"); when(update.getUpdatedObject()).thenReturn(route); subject.validate(update, updateContext); verify(updateContext, times(1)).addMessage(update, route.findAttribute(AttributeType.HOLES), UpdateMessages.invalidRouteRange("94.73.128.0/24")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route_with_many_holes_attributes_outside_prefixrange() { final RpslObject route = RpslObject.parse("route:195.190.20.0/24\norigin:AS43746\nholes:94.73.128.0/24\nholes:94.73.134.0/24"); when(update.getUpdatedObject()).thenReturn(route); subject.validate(update, updateContext); List<RpslAttribute> rpslAttributes = route.findAttributes(AttributeType.HOLES); verify(updateContext, times(1)).addMessage(update, rpslAttributes.get(0), UpdateMessages.invalidRouteRange("94.73.128.0/24")); verify(updateContext, times(1)).addMessage(update, rpslAttributes.get(1), UpdateMessages.invalidRouteRange("94.73.134.0/24")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route_with_holes_attribute_list_outside_prefixrange() { final RpslObject route = RpslObject.parse("route:195.190.20.0/24\norigin:AS43746\nholes:94.73.128.0/24,94.73.134.0/24"); when(update.getUpdatedObject()).thenReturn(route); subject.validate(update, updateContext); verify(updateContext, times(1)).addMessage(update, route.findAttribute(AttributeType.HOLES), UpdateMessages.invalidRouteRange("94.73.128.0/24")); verify(updateContext, times(1)).addMessage(update, route.findAttribute(AttributeType.HOLES), UpdateMessages.invalidRouteRange("94.73.134.0/24")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route_with_holes_attribute_list_inside_prefixrange() { final RpslObject route = RpslObject.parse("route:94.73.128.0/18\norigin:AS43746\nholes:94.73.129.0/24, 94.73.131.0/24\nholes:94.73.137.0/24"); when(update.getUpdatedObject()).thenReturn(route); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route6_with_one_holes_attribute_outside_prefixrange() { final RpslObject route6 = RpslObject.parse("route6:2a02:2a98::/32\norigin:AS43746\nholes:2a01:568:4000::/36"); when(update.getUpdatedObject()).thenReturn(route6); subject.validate(update, updateContext); verify(updateContext, times(1)).addMessage(update, route6.findAttribute(AttributeType.HOLES), UpdateMessages.invalidRouteRange("2a01:568:4000::/36")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void transform_changed() { when(dateTimeProvider.getCurrentDate()).thenReturn(LocalDate.of(2013, 02, 25)); final RpslObject rpslObject = RpslObject.parse("inet6num: 2001::/16\n" + "changed: [email protected] 20120601\n" + "changed: [email protected]\n" + "remarks: changed"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); final List<RpslAttribute> changed = result.findAttributes(AttributeType.CHANGED); assertThat(changed.get(0).getCleanValue().toString(), is("[email protected] 20120601")); assertThat(changed.get(1).getCleanValue().toString(), is("[email protected] 20130225")); verifyZeroInteractions(objectMessages); }
public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); CIString sanitizeKey(final RpslObject originalObject); RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages); }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); CIString sanitizeKey(final RpslObject originalObject); RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages); }
@Test public void route6_with_many_holes_attributes_outside_prefixrange() { final RpslObject route6 = RpslObject.parse("route6:2a02:2a98::/32\norigin:AS43746\nholes:2a01:758:4000::/48\nholes:2a01:758:5000::/48"); when(update.getUpdatedObject()).thenReturn(route6); subject.validate(update, updateContext); List<RpslAttribute> rpslAttributes = route6.findAttributes(AttributeType.HOLES); verify(updateContext, times(1)).addMessage(update, rpslAttributes.get(0), UpdateMessages.invalidRouteRange("2a01:758:4000::/48")); verify(updateContext, times(1)).addMessage(update, rpslAttributes.get(1), UpdateMessages.invalidRouteRange("2a01:758:5000::/48")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route6_with_holes_attribute_list_outside_prefixrange() { final RpslObject route6 = RpslObject.parse("route6:2a02:2a98::/32\norigin:AS43746\nholes:2a01:758:4000::/48,2a01:758:5000::/48"); when(update.getUpdatedObject()).thenReturn(route6); subject.validate(update, updateContext); verify(updateContext, times(1)).addMessage(update, route6.findAttribute(AttributeType.HOLES), UpdateMessages.invalidRouteRange("2a01:758:4000::/48")); verify(updateContext, times(1)).addMessage(update, route6.findAttribute(AttributeType.HOLES), UpdateMessages.invalidRouteRange("2a01:758:5000::/48")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route6_with_holes_attribute_list_inside_prefixrange() { final RpslObject route6 = RpslObject.parse("route6:2a02:2020::/32\norigin:AS43746\nholes:2A02:2020:0000:0000::/48,2A02:2020:0001:0000::/48\nholes:2A02:2020:0002:0000::/48"); when(update.getUpdatedObject()).thenReturn(route6); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route6_with_one_pingable_attribute_outside_prefixrange() { final RpslObject route6 = RpslObject.parse("route6:2a02:2a98::/32\norigin:AS43746\npingable:2a00:9e80::1"); when(update.getUpdatedObject()).thenReturn(route6); subject.validate(update, updateContext); verify(updateContext, times(1)).addMessage(update, route6.findAttribute(AttributeType.PINGABLE), UpdateMessages.invalidRouteRange("2a00:9e80::1")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route6_with_many_pingable_attributes_outside_prefixrange() { final RpslObject route6 = RpslObject.parse("route6:2a02:2a98::/32\norigin:AS43746\npingable:2a00:1e88:e::4\npingable:2a00:1e88:e::5"); when(update.getUpdatedObject()).thenReturn(route6); subject.validate(update, updateContext); List<RpslAttribute> pingableAttribute = route6.findAttributes(AttributeType.PINGABLE); verify(updateContext, times(1)).addMessage(update, pingableAttribute.get(0), UpdateMessages.invalidRouteRange("2a00:1e88:e::4")); verify(updateContext, times(1)).addMessage(update, pingableAttribute.get(1), UpdateMessages.invalidRouteRange("2a00:1e88:e::5")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route6_with_pingable_attribute_list_inside_prefixrange() { final RpslObject route6 = RpslObject.parse("route6:2a00:1e88::/32\norigin:AS43746\npingable:2a00:1e88:e::4\npingable:2a00:1e88:e::5"); when(update.getUpdatedObject()).thenReturn(route6); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route_with_one_pingable_attribute_outside_prefixrange() { final RpslObject route = RpslObject.parse("route: 84.40.47.0/24\norigin:AS43746\npingable:93.191.209.1"); when(update.getUpdatedObject()).thenReturn(route); subject.validate(update, updateContext); verify(updateContext, times(1)).addMessage(update, route.findAttribute(AttributeType.PINGABLE), UpdateMessages.invalidRouteRange("93.191.209.1")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route_with_many_pingable_attributes_outside_prefixrange() { final RpslObject route = RpslObject.parse("route:84.40.47.0/24\norigin:AS43746\npingable:95.180.201.1\npingable:93.191.209.1"); when(update.getUpdatedObject()).thenReturn(route); subject.validate(update, updateContext); List<RpslAttribute> pingableAttribute = route.findAttributes(AttributeType.PINGABLE); verify(updateContext, times(1)).addMessage(update, pingableAttribute.get(0), UpdateMessages.invalidRouteRange("95.180.201.1")); verify(updateContext, times(1)).addMessage(update, pingableAttribute.get(1), UpdateMessages.invalidRouteRange("93.191.209.1")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route_with_pingable_attribute_list_inside_prefixrange() { final RpslObject route = RpslObject.parse("route:93.191.209.0/24\norigin:AS43746\npingable:93.191.209.1\npingable:93.191.209.2"); when(update.getUpdatedObject()).thenReturn(route); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route_with_pingable_and_holes_attribute_list_inside_prefixrange() { final RpslObject route = RpslObject.parse("route:93.191.209.0/24\norigin:AS43746\npingable:93.191.209.1\npingable:93.191.209.2\nholes:93.191.209.0/31"); when(update.getUpdatedObject()).thenReturn(route); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void transform_type_and_key() { final RpslObject rpslObject = RpslObject.parse("" + "person: some # with\n" + "+ person\n" + "+ # remark\n" + "nic-hdl: TEST-PN\n" + "+ # another\n" + "+ #\n" + "+ # remark\n"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.findAttribute(AttributeType.PERSON).getValue(), is("some person # with remark")); assertThat(result.findAttribute(AttributeType.NIC_HDL).getValue(), is("TEST-PN # another remark")); verify(objectMessages).addMessage(result.getTypeAttribute(), ValidationMessages.continuationLinesRemoved()); verify(objectMessages).addMessage(result.getTypeAttribute(), ValidationMessages.remarksReformatted()); verify(objectMessages).addMessage(result.findAttribute(AttributeType.NIC_HDL), ValidationMessages.continuationLinesRemoved()); verify(objectMessages).addMessage(result.findAttribute(AttributeType.NIC_HDL), ValidationMessages.remarksReformatted()); verifyNoMoreInteractions(objectMessages); }
public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); CIString sanitizeKey(final RpslObject originalObject); RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages); }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); CIString sanitizeKey(final RpslObject originalObject); RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages); }
@Test public void route_too_large() { final RpslObject route = RpslObject.parse("route:92.0.0.0/7\norigin:AS43746"); when(update.getUpdatedObject()).thenReturn(route); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.invalidRoutePrefix("route")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route_not_too_large() { final RpslObject route = RpslObject.parse("route:92.0.0.0/8\norigin:AS43746"); when(update.getUpdatedObject()).thenReturn(route); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route6_too_large() { final RpslObject route = RpslObject.parse("route6:2a02:2a98::/11\norigin:AS43746"); when(update.getUpdatedObject()).thenReturn(route); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.invalidRoutePrefix("route6")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void route6_not_too_large() { final RpslObject route = RpslObject.parse("route6:2a02:2a98::/12\norigin:AS43746"); when(update.getUpdatedObject()).thenReturn(route); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ValueWithinPrefixValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedRouteObject = update.getUpdatedObject(); final AttributeType attributeType = findAttributeType(updatedRouteObject); final CIString prefix = updatedRouteObject.findAttribute(attributeType).getCleanValue(); for (final RpslAttribute holeAttribute : updatedRouteObject.findAttributes(AttributeType.HOLES)) { for (final CIString hole : holeAttribute.getCleanValues()) { validatePrefixForHolesAttribute(update, updateContext, AddressPrefixRange.parse(hole), prefix, holeAttribute); } } for (final RpslAttribute pingableAttribute : updatedRouteObject.findAttributes(AttributeType.PINGABLE)) { for (final CIString pingable : pingableAttribute.getCleanValues()) { validatePrefixForPingableAttribute(update, updateContext, pingable, prefix, pingableAttribute); } } final IpInterval ipInterval = IpInterval.parse(prefix); if ((ipInterval.getPrefixLength() < 8 && attributeType == AttributeType.ROUTE) || (ipInterval.getPrefixLength() < 12 && attributeType == AttributeType.ROUTE6)) { updateContext.addMessage(update, UpdateMessages.invalidRoutePrefix(attributeType.getName())); } } @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; }
MaintainerNameValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
MaintainerNameValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
MaintainerNameValidator 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(); }
MaintainerNameValidator 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.CREATE, Action.MODIFY)); }
@Override public ImmutableList<Action> getActions() { return ACTIONS; }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @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.values())); }
@Override public ImmutableList<ObjectType> getTypes() { return TYPES; }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_no_rs_auth_no_rs_maintainer_added() { when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(false); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-by: DEV-MNT\n")); when(update.getDifferences(AttributeType.MNT_BY)).thenReturn(ciSet("DEV-MNT")); subject.validate(update, updateContext); verify(updateContext, never()).addMessage(eq(update), any(Message.class)); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_no_rs_auth_rs_maintainer_added() { when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(false); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-by: RS-MNT\n")); when(update.getDifferences(AttributeType.MNT_BY)).thenReturn(ciSet("RS-MNT")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.authorisationRequiredForChangingRipeMaintainer()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_no_rs_auth_rs_maintainer_added_mnt_domains() { when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(false); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-domains: RS-MNT\n")); when(update.getDifferences(AttributeType.MNT_DOMAINS)).thenReturn(ciSet("RS-MNT")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.authorisationRequiredForChangingRipeMaintainer()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void transform_source_to_upper() { final RpslObject rpslObject = RpslObject.parse("person: Person A\nnic-hdl: tst-test\nsource: Test"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.findAttribute(AttributeType.SOURCE).getValue(), is("TEST")); }
public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); CIString sanitizeKey(final RpslObject originalObject); RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages); }
AttributeSanitizer { public RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages) { final Map<RpslAttribute, RpslAttribute> replacements = Maps.newHashMap(); for (final RpslAttribute attribute : object.getAttributes()) { final AttributeType type = attribute.getType(); String newValue = null; final Sanitizer sanitizer = SANITIZER_MAP.get(type); if (sanitizer == null) { continue; } try { newValue = sanitizer.sanitize(attribute); } catch (IllegalArgumentException ignored) { LOGGER.debug("{}: {}", ignored.getClass().getName(), ignored.getMessage()); } if (newValue == null) { continue; } final List<Message> attributeMessages = Lists.newArrayList(); if (!sanitizer.silent() && !attribute.getCleanValue().toString().equals(newValue)) { attributeMessages.add(ValidationMessages.attributeValueConverted(attribute.getCleanValue(), newValue)); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('\n') != -1) { attributeMessages.add(ValidationMessages.continuationLinesRemoved()); } if (keyAttributes.contains(type) && attribute.getValue().indexOf('#') != -1) { attributeMessages.add(ValidationMessages.remarksReformatted()); } final String replacement = newValue + getCommentReplacement(attribute); final RpslAttribute transformed = new RpslAttribute(attribute.getKey(), replacement); replacements.put(attribute, transformed); for (final Message attributeMessage : attributeMessages) { objectMessages.addMessage(transformed, attributeMessage); } } return new RpslObjectBuilder(object).replaceAttributes(replacements).get(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); CIString sanitizeKey(final RpslObject originalObject); RpslObject sanitize(final RpslObject object, final ObjectMessages objectMessages); }
@SuppressWarnings("unchecked") @Test public void write() throws IOException { subject.write(RpslObject.parse("mntner: DEV-MNT1"), Collections.EMPTY_LIST); subject.write(RpslObject.parse("mntner: DEV-MNT2"), Collections.EMPTY_LIST); subject.write(RpslObject.parse("mntner: DEV-MNT3"), Collections.EMPTY_LIST); subject.write(RpslObject.parse("mntner: DEV-MNT4"), Collections.EMPTY_LIST); subject.write(RpslObject.parse("inetnum: 193.0.0.0 - 193.0.0.10"), Collections.EMPTY_LIST); subject.write(RpslObject.parse("route: 193.0.0.0 - 193.0.0.10\norigin: AS12"), Lists.newArrayList(new Tag(CIString.ciString("foo"), 3, "bar"))); subject.close(); final File[] files = folder.getRoot().listFiles(); Assert.assertNotNull(files); Assert.assertThat(files.length, Matchers.is(21)); for (final File file : files) { final String fileName = file.getName(); if (fileName.endsWith("mntner.gz")) { checkFile(file, "" + "mntner: DEV-MNT1\n" + "\n" + "mntner: DEV-MNT2\n" + "\n" + "mntner: DEV-MNT3\n" + "\n" + "mntner: DEV-MNT4\n"); } else if (fileName.endsWith("inetnum.gz")) { checkFile(file, "" + "inetnum: 193.0.0.0 - 193.0.0.10\n"); } else if (fileName.endsWith("route.gz")) { checkFile(file, "" + "route: 193.0.0.0 - 193.0.0.10\n" + "origin: AS12\n\n" + QueryMessages.tagInfoStart("193.0.0.0 - 193.0.0.10AS12") + QueryMessages.tagInfo("foo", "bar")); } } }
public void write(final RpslObject object, final List<Tag> tags) throws IOException { if (exportFilter.shouldExport(object)) { final String filename = filenameStrategy.getFilename(object.getType()); if (filename != null) { final Writer writer = getWriter(filename); final RpslObject decoratedObject = decorationStrategy.decorate(object); if (decoratedObject != null) { writer.write('\n'); decoratedObject.writeTo(writer); if (!tags.isEmpty()) { writer.write('\n'); writer.write(new TagResponseObject(decoratedObject.getKey(), tags).toString()); } } } } }
ExportFileWriter { public void write(final RpslObject object, final List<Tag> tags) throws IOException { if (exportFilter.shouldExport(object)) { final String filename = filenameStrategy.getFilename(object.getType()); if (filename != null) { final Writer writer = getWriter(filename); final RpslObject decoratedObject = decorationStrategy.decorate(object); if (decoratedObject != null) { writer.write('\n'); decoratedObject.writeTo(writer); if (!tags.isEmpty()) { writer.write('\n'); writer.write(new TagResponseObject(decoratedObject.getKey(), tags).toString()); } } } } } }
ExportFileWriter { public void write(final RpslObject object, final List<Tag> tags) throws IOException { if (exportFilter.shouldExport(object)) { final String filename = filenameStrategy.getFilename(object.getType()); if (filename != null) { final Writer writer = getWriter(filename); final RpslObject decoratedObject = decorationStrategy.decorate(object); if (decoratedObject != null) { writer.write('\n'); decoratedObject.writeTo(writer); if (!tags.isEmpty()) { writer.write('\n'); writer.write(new TagResponseObject(decoratedObject.getKey(), tags).toString()); } } } } } ExportFileWriter(final File baseDir, final FilenameStrategy filenameStrategy, final DecorationStrategy decorationStrategy, final ExportFilter exportFilter); }
ExportFileWriter { public void write(final RpslObject object, final List<Tag> tags) throws IOException { if (exportFilter.shouldExport(object)) { final String filename = filenameStrategy.getFilename(object.getType()); if (filename != null) { final Writer writer = getWriter(filename); final RpslObject decoratedObject = decorationStrategy.decorate(object); if (decoratedObject != null) { writer.write('\n'); decoratedObject.writeTo(writer); if (!tags.isEmpty()) { writer.write('\n'); writer.write(new TagResponseObject(decoratedObject.getKey(), tags).toString()); } } } } } ExportFileWriter(final File baseDir, final FilenameStrategy filenameStrategy, final DecorationStrategy decorationStrategy, final ExportFilter exportFilter); void write(final RpslObject object, final List<Tag> tags); void close(); }
ExportFileWriter { public void write(final RpslObject object, final List<Tag> tags) throws IOException { if (exportFilter.shouldExport(object)) { final String filename = filenameStrategy.getFilename(object.getType()); if (filename != null) { final Writer writer = getWriter(filename); final RpslObject decoratedObject = decorationStrategy.decorate(object); if (decoratedObject != null) { writer.write('\n'); decoratedObject.writeTo(writer); if (!tags.isEmpty()) { writer.write('\n'); writer.write(new TagResponseObject(decoratedObject.getKey(), tags).toString()); } } } } } ExportFileWriter(final File baseDir, final FilenameStrategy filenameStrategy, final DecorationStrategy decorationStrategy, final ExportFilter exportFilter); void write(final RpslObject object, final List<Tag> tags); void close(); }
@Test public void validate_no_rs_auth_rs_maintainer_added_mnt_lower() { when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(false); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-lower: RS-MNT\n")); when(update.getDifferences(AttributeType.MNT_LOWER)).thenReturn(ciSet("RS-MNT")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.authorisationRequiredForChangingRipeMaintainer()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_no_rs_auth_rs_maintainer_added_mnt_routes() { when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(false); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-routes: RS-MNT ANY\n")); when(update.getDifferences(AttributeType.MNT_ROUTES)).thenReturn(ciSet("RS-MNT ANY")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.authorisationRequiredForChangingRipeMaintainer()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_rs_auth_rs_maintainer_added() { when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(true); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-by: RS-MNT\n")); when(update.getDifferences(AttributeType.MNT_BY)).thenReturn(ciSet("RS-MNT")); subject.validate(update, updateContext); verify(updateContext, never()).addMessage(eq(update), any(Message.class)); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_dbm_auth_dbm_maintainer_added() { when(authSubject.hasPrincipal(Principal.DBM_MAINTAINER)).thenReturn(true); when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(false); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-by: DBM-MNT\n" + "mnt-lower: HM-MNT\n")); when(update.getDifferences(AttributeType.MNT_BY)).thenReturn(ciSet("DBM-MNT")); when(update.getDifferences(AttributeType.MNT_LOWER)).thenReturn(ciSet("HM-MNT")); subject.validate(update, updateContext); verify(updateContext, never()).addMessage(eq(update), any(Message.class)); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_dbm_auth_dbm_maintainer_added_by_rs_maintainer() { when(authSubject.hasPrincipal(Principal.DBM_MAINTAINER)).thenReturn(false); when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(true); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-by: DBM-MNT\n" + "mnt-lower: HM-MNT\n")); when(update.getDifferences(AttributeType.MNT_BY)).thenReturn(ciSet("DBM-MNT")); when(update.getDifferences(AttributeType.MNT_LOWER)).thenReturn(ciSet("HM-MNT")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.authorisationRequiredForChangingRipeMaintainer()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_no_rs_auth_rs_maintainer_added_mnt_ref() { when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(false); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-ref: RS-MNT\n")); when(update.getDifferences(AttributeType.MNT_REF)).thenReturn(ciSet("RS-MNT")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.authorisationRequiredForChangingRipeMaintainer()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_no_dbm_auth_dbm_maintainer_added_mnt_ref() { when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(false); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-ref: RS-MNT\n")); when(update.getDifferences(AttributeType.MNT_REF)).thenReturn(ciSet("DBM-MNT")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.authorisationRequiredForChangingRipeMaintainer()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_added_override() { when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(false); when(authSubject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)).thenReturn(true); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-routes: RS-MNT ANY\n")); when(update.getDifferences(AttributeType.MNT_ROUTES)).thenReturn(ciSet("RS-MNT")); subject.validate(update, updateContext); verify(updateContext, never()).addMessage(eq(update), any(Message.class)); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } validateForSpecialMaintainer(Principal.RS_MAINTAINER, maintainers.getRsMaintainers(), update, updateContext); validateForSpecialMaintainer(Principal.DBM_MAINTAINER, maintainers.getDbmMaintainers(), update, updateContext); } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void no_abuse_c() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("inetnum: 192.168.0.0 - 192.168.255.255\nsource: TEST")); subject.validate(update, updateContext); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void has_abuse_c_but_no_org() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("inetnum: 192.168.0.0 - 192.168.255.255\nabuse-c: AA1-TEST\nsource: TEST")); subject.validate(update, updateContext); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void dummify_organisation() { final RpslObject before = RpslObject.parse( "organisation: ORG-RIEN1-TEST\n" + "org-name: Reseaux IP Europeens Network Coordination Centre (RIPE NCC)\n" + "org-type: LIR\n" + "descr: RIPE NCC Operations\n" + "address: Singel 256\n" + "address: Amsterdam\n" + "address: Netherlands\n" + "phone: +31205552222\n" + "fax-no: +31205552266\n" + "admin-c: AC1-TEST\n" + "admin-c: AC2-TEST\n" + "abuse-c: AR1-TEST\n" + "mnt-ref: TEST-MNT\n" + "mnt-by: TEST-MNT\n" + "created: 1970-01-01T00:00:00Z\n" + "last-modified: 2020-09-22T09:00:00Z\n" + "source: TEST"); final RpslObject after = subject.dummify(3, before); assertThat(after.toString(), is( "organisation: ORG-RIEN1-TEST\n" + "org-name: Dummy org-name for ORG-RIEN1-TEST\n" + "org-type: LIR\n" + "descr: ***\n" + "address: ***\n" + "address: ***\n" + "address: Netherlands\n" + "phone: +31205......\n" + "fax-no: +31205......\n" + "admin-c: AC1-TEST\n" + "admin-c: AC2-TEST\n" + "abuse-c: AR1-TEST\n" + "mnt-ref: TEST-MNT\n" + "mnt-by: TEST-MNT\n" + "created: 1970-01-01T00:00:00Z\n" + "last-modified: 2020-09-22T09:00:00Z\n" + "source: TEST\n")); }
@Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } @Override RpslObject dummify(final int version, final RpslObject rpslObject); }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } @Override RpslObject dummify(final int version, final RpslObject rpslObject); }
@Test public void org_abuse_c_matches_inetnum_abuse_c() { when(update.getUpdatedObject()).thenReturn( RpslObject.parse( "inetnum: 192.168.0.0 - 192.168.255.255\n" + "org: ORG-AA1-TEST\n" + "abuse-c: AA1-TEST\n" + "source: TEST")); when(rpslObjectDao.getByKeyOrNull(ObjectType.ORGANISATION, CIString.ciString("ORG-AA1-TEST"))).thenReturn( RpslObject.parse( "organisation: ORG-AA1-TEST\n" + "org-name: Any Any\n" + "abuse-c: AA1-TEST\n" + "source: TEST")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.duplicateAbuseC(CIString.ciString("AA1-TEST"), CIString.ciString("ORG-AA1-TEST"))); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void org_abuse_c_does_not_match_inetnum_abuse_c() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("inetnum: 192.168.0.0 - 192.168.255.255\norg: ORG-AA1-TEST\nabuse-c: AA1-TEST\nsource: TEST")); when(rpslObjectDao.getByKeyOrNull(ObjectType.ORGANISATION, CIString.ciString("ORG-AA1-TEST"))).thenReturn( RpslObject.parse( "organisation: ORG-AA1-TEST\n" + "org-name: Any Any\n" + "abuse-c: BB1-TEST\n" + "source: TEST")); subject.validate(update, updateContext); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void org_abuse_c_matches_inet6num_abuse_c() { when(update.getUpdatedObject()).thenReturn( RpslObject.parse( "inet6num: 2001:67c:2e8::/48\n" + "org: ORG-AA1-TEST\n" + "abuse-c: AA1-TEST\n" + "source: TEST")); when(rpslObjectDao.getByKeyOrNull(ObjectType.ORGANISATION, CIString.ciString("ORG-AA1-TEST"))).thenReturn( RpslObject.parse( "organisation: ORG-AA1-TEST\n" + "org-name: Any Any\n" + "abuse-c: AA1-TEST\n" + "source: TEST")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.duplicateAbuseC(CIString.ciString("AA1-TEST"), CIString.ciString("ORG-AA1-TEST"))); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void org_abuse_c_matches_autnum_abuse_c() { when(update.getUpdatedObject()).thenReturn( RpslObject.parse( "aut-num: AS3333\n" + "org: ORG-AA1-TEST\n" + "abuse-c: AA1-TEST\n" + "source: TEST")); when(rpslObjectDao.getByKeyOrNull(ObjectType.ORGANISATION, CIString.ciString("ORG-AA1-TEST"))).thenReturn( RpslObject.parse( "organisation: ORG-AA1-TEST\n" + "org-name: Any Any\n" + "abuse-c: AA1-TEST\n" + "source: TEST")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.duplicateAbuseC(CIString.ciString("AA1-TEST"), CIString.ciString("ORG-AA1-TEST"))); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void org_abuse_c_matches_parent_inetnum_abuse_c() { when(update.getUpdatedObject()).thenReturn( RpslObject.parse( "inetnum: 192.168.0.0 - 192.168.255.255\n" + "abuse-c: AA1-TEST\n" + "source: TEST")); when(ipv4Tree.findFirstLessSpecific(Ipv4Resource.parse("192.168.0.0/16"))).thenReturn( Collections.singletonList( new Ipv4Entry(Ipv4Resource.parse("192.168.0.0/16"), 101))); when(rpslObjectDao.getById(101)).thenReturn( RpslObject.parse( "inetnum: 192.0.0.0 - 192.255.255.255\n" + "org: ORG-AA1-TEST\n" + "source: TEST")); when(rpslObjectDao.getByKeyOrNull(ObjectType.ORGANISATION, CIString.ciString("ORG-AA1-TEST"))).thenReturn( RpslObject.parse( "organisation: ORG-AA1-TEST\n" + "org-name: Any Any\n" + "abuse-c: AA1-TEST\n" + "source: TEST")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.duplicateAbuseC(CIString.ciString("AA1-TEST"), CIString.ciString("ORG-AA1-TEST"))); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void org_abuse_c_matches_parent_inet6num_abuse_c() { when(update.getUpdatedObject()).thenReturn( RpslObject.parse( "inet6num: 2001:67c:2e8::/48\n" + "abuse-c: AA1-TEST\n" + "source: TEST")); when(ipv6Tree.findFirstLessSpecific(Ipv6Resource.parse("2001:67c:2e8::/48"))).thenReturn( Collections.singletonList( new Ipv6Entry(Ipv6Resource.parse("2001:67c::/32"), 102))); when(rpslObjectDao.getById(102)).thenReturn( RpslObject.parse( "inet6num: 2001:67c::/32\n" + "org: ORG-AA1-TEST\n" + "source: TEST")); when(rpslObjectDao.getByKeyOrNull(ObjectType.ORGANISATION, CIString.ciString("ORG-AA1-TEST"))).thenReturn( RpslObject.parse( "organisation: ORG-AA1-TEST\n" + "org-name: Any Any\n" + "abuse-c: AA1-TEST\n" + "source: TEST")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.duplicateAbuseC(CIString.ciString("AA1-TEST"), CIString.ciString("ORG-AA1-TEST"))); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
AbuseCDuplicateValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final CIString abuseC = update.getUpdatedObject().getValueOrNullForAttribute(AttributeType.ABUSE_C); if (abuseC == null) { return; } final RpslObject orgAbuseCObject = findOrgAbuseC(update.getUpdatedObject()); if (orgAbuseCObject == null) { return; } if (orgAbuseCObject.getValueForAttribute(AttributeType.ABUSE_C).equals(abuseC)) { updateContext.addMessage(update, UpdateMessages.duplicateAbuseC(abuseC, orgAbuseCObject.getKey())); } } @Autowired AbuseCDuplicateValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @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; }
DeleteRsMaintainedObjectValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
DeleteRsMaintainedObjectValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); }
DeleteRsMaintainedObjectValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
DeleteRsMaintainedObjectValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); @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.values())); }
@Override public ImmutableList<ObjectType> getTypes() { return TYPES; }
DeleteRsMaintainedObjectValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
DeleteRsMaintainedObjectValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); }
DeleteRsMaintainedObjectValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
DeleteRsMaintainedObjectValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_no_rs_auth_no_rs_maintainer() { when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(false); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-by: DEV-MNT\n")); subject.validate(update, updateContext); verify(updateContext, never()).addMessage(eq(update), any(Message.class)); verify(maintainers).isRsMaintainer(ciSet("DEV-MNT")); verifyNoMoreInteractions(maintainers); }
@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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_no_rs_auth_rs_maintainer() { when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(false); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-by: DEV-MNT\n" + "mnt-by: RS-MNT\n")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); verify(maintainers).isRsMaintainer(ciSet("DEV-MNT", "RS-MNT")); verifyNoMoreInteractions(maintainers); }
@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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void dummify_role() { final RpslObject before = RpslObject.parse( "role: Abuse Contact\n" + "descr: RIPE NCC Operations\n" + "address: Singel 256\n" + "address: Amsterdam\n" + "address: Netherlands\n" + "e-mail: [email protected]\n" + "nic-hdl: AC1-TEST\n" + "remarks: Abuse\n" + "+Contact\n" + "\tRole\n" + "abuse-mailbox: [email protected]\n" + "mnt-by: TEST-MNT\n" + "created: 1970-01-01T00:00:00Z\n" + "last-modified: 2020-09-22T09:00:00Z\n" + "source: TEST"); final RpslObject after = subject.dummify(3, before); assertThat(after.toString(), is( "role: Abuse Contact\n" + "descr: ***\n" + "address: Singel 256\n" + "address: Amsterdam\n" + "address: Netherlands\n" + "e-mail: ***@ripe.net\n" + "nic-hdl: AC1-TEST\n" + "remarks: ***\n" + "abuse-mailbox: [email protected]\n" + "mnt-by: TEST-MNT\n" + "created: 1970-01-01T00:00:00Z\n" + "last-modified: 2020-09-22T09:00:00Z\n" + "source: TEST\n")); }
@Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } @Override RpslObject dummify(final int version, final RpslObject rpslObject); }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } @Override RpslObject dummify(final int version, final RpslObject rpslObject); }
@Test public void validate_no_rs_auth_rs_maintainer_override() { when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(false); when(authSubject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)).thenReturn(true); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-by: DEV-MNT\n" + "mnt-by: RS-MNT\n")); subject.validate(update, updateContext); verify(updateContext, never()).addMessage(eq(update), any(Message.class)); verifyZeroInteractions(maintainers); }
@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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_rs_auth_rs_maintainer() { when(authSubject.hasPrincipal(Principal.RS_MAINTAINER)).thenReturn(true); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "mntner: DEV-MNT\n" + "mnt-by: DEV-MNT\n" + "mnt-by: RS-MNT\n")); subject.validate(update, updateContext); verify(updateContext, never()).addMessage(eq(update), any(Message.class)); verifyZeroInteractions(maintainers); }
@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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
DeleteRsMaintainedObjectValidator 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 Set<CIString> mntBys = update.getUpdatedObject().getValuesForAttribute(AttributeType.MNT_BY); if (maintainers.isRsMaintainer(mntBys)) { updateContext.addMessage(update, UpdateMessages.authorisationRequiredForDeleteRsMaintainedObject()); } } @Autowired DeleteRsMaintainedObjectValidator(final Maintainers maintainers); @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; }
ReservedWordValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
ReservedWordValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
ReservedWordValidator 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(); }
ReservedWordValidator 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 not_reserved_word() { mockUpdate("mntner: OWNER-MNT\nsource: TEST"); subject.validate(update, updateContext); verifyOk(); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void reserved_word_as_any_not_ok() { mockUpdate("as-set: AS-ANy\nsource: TEST"); subject.validate(update, updateContext); verifyReservedName("as-any"); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void reserved_prefix_as_not_ok() { mockUpdate("mntner: AS-TEST\nsource: TEST"); subject.validate(update, updateContext); verifyReservedPrefixUsed("as-", ObjectType.AS_SET); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void reserved_prefix_org_not_ok() { mockUpdate("mntner: ORG-TEST\nsource: TEST"); subject.validate(update, updateContext); verifyReservedPrefixUsed("org-", ObjectType.ORGANISATION); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void reserved_prefix_as_ok() { mockUpdate("as-set: AS-TEST\nsource: TEST"); subject.validate(update, updateContext); verifyOk(); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ReservedWordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } final CIString primaryKey = updatedObject.getKey(); if (RESERVED_WORDS.contains(primaryKey)) { updateContext.addMessage(update, UpdateMessages.reservedNameUsed(primaryKey.toLowerCase())); return; } for (Map.Entry<CIString, ObjectType> entry : RESERVED_PREFIXES.entrySet()) { if (primaryKey.startsWith(entry.getKey()) && (!updatedObject.getType().equals(entry.getValue()))) { updateContext.addMessage(update, UpdateMessages.reservedPrefixUsed(entry.getKey(), entry.getValue())); return; } } } @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; }
MaintainedReferencedMaintainerPersonRolesValidator extends AbstractObjectIsMaintainedValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
MaintainedReferencedMaintainerPersonRolesValidator extends AbstractObjectIsMaintainedValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MaintainedReferencedMaintainerPersonRolesValidator(final RpslObjectDao rpslObjectDao); }
MaintainedReferencedMaintainerPersonRolesValidator extends AbstractObjectIsMaintainedValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MaintainedReferencedMaintainerPersonRolesValidator(final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MaintainedReferencedMaintainerPersonRolesValidator extends AbstractObjectIsMaintainedValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MaintainedReferencedMaintainerPersonRolesValidator(final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void getActions() { assertThat(subject.getActions(), contains(Action.CREATE, Action.MODIFY)); }
@Override public ImmutableList<Action> getActions() { return ACTIONS; }
MntRoutesValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
MntRoutesValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
MntRoutesValidator 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(); }
MntRoutesValidator 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 dummify_aut_num() { final RpslObject before = RpslObject.parse( "aut-num: AS3333\n" + "descr: RIPE NCC Operations\n" + "as-name: RIPE_NCC_AS_NAME\n" + "admin-c: AC1-TEST\n" + "tech-c: TC1-TEST\n" + "mnt-by: TEST-MNT\n" + "created: 1970-01-01T00:00:00Z\n" + "last-modified: 2020-09-22T09:00:00Z\n" + "source: TEST"); final RpslObject after = subject.dummify(3, before); assertThat(after.toString(), is( "aut-num: AS3333\n" + "descr: ***\n" + "as-name: ***\n" + "admin-c: AC1-TEST\n" + "tech-c: TC1-TEST\n" + "mnt-by: TEST-MNT\n" + "created: 1970-01-01T00:00:00Z\n" + "last-modified: 2020-09-22T09:00:00Z\n" + "source: TEST\n")); }
@Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } @Override RpslObject dummify(final int version, final RpslObject rpslObject); }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } @Override RpslObject dummify(final int version, final RpslObject rpslObject); }
@Test public void getTypes() { assertThat(subject.getTypes(), contains(ObjectType.INET6NUM, ObjectType.INETNUM, ObjectType.ROUTE, ObjectType.ROUTE6)); }
@Override public ImmutableList<ObjectType> getTypes() { return TYPES; }
MntRoutesValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
MntRoutesValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
MntRoutesValidator 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(); }
MntRoutesValidator 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_single_valid_any() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "route: 20.13.0.0/16\n" + "origin: AS3000\n" + "mnt-routes: EXACT-MR-MNT any\n" + "source: TEST\n")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_single_valid_range() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "route: 20.13.0.0/16\n" + "origin: AS3000\n" + "mnt-routes: EXACT-MR-MNT {20.13.0.0/16^+}\n" + "source: TEST\n")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_single_invalid() { final RpslObject rpslObject = RpslObject.parse("" + "route: 20.13.0.0/16\n" + "origin: AS3000\n" + "mnt-routes: EXACT-MR-MNT {any, 20.13.0.0/16^+}\n" + "source: TEST\n"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); verify(updateContext).addMessage(update, rpslObject.findAttribute(AttributeType.MNT_ROUTES), new Message(Messages.Type.ERROR, "Syntax error in EXACT-MR-MNT {any, 20.13.0.0/16^+} (ANY can only occur as a single value)")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_multiple_valid_any() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "route: 20.13.0.0/16\n" + "origin: AS3000\n" + "mnt-routes: EXACT-MR-MNT any\n" + "mnt-routes: EXACT-MR-MNT any\n" + "source: TEST\n")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_lots_valid_any() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "route: 20.13.0.0/16\n" + "origin: AS3000\n" + "mnt-routes: EXACT-MR-MNT any\n" + "mnt-routes: EXACT-MR-MNT any\n" + "mnt-routes: EXACT-MR-MNT any\n" + "mnt-routes: EXACT-MR-MNT any\n" + "source: TEST\n")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_multiple_valid_range() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("" + "route: 20.13.0.0/16\n" + "origin: AS3000\n" + "mnt-routes: EXACT-MR-MNT {20.13.0.0/16^+}\n" + "mnt-routes: EXACT-MR-MNT {20.13.0.0/16}\n" + "source: TEST\n")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_multiple_invalid_range() { final RpslObject rpslObject = RpslObject.parse("" + "route: 20.13.0.0/16\n" + "origin: AS3000\n" + "mnt-routes: EXACT-MR-MNT {20.13.0.0/16^+}\n" + "mnt-routes: EXACT-MR-MNT any\n" + "source: TEST\n"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); final List<RpslAttribute> attributes = rpslObject.findAttributes(AttributeType.MNT_ROUTES); verify(updateContext).addMessage(update, attributes.get(0), new Message(Messages.Type.ERROR, "Syntax error in EXACT-MR-MNT {20.13.0.0/16^+} (ANY can only occur as a single value)")); verify(updateContext).addMessage(update, attributes.get(1), new Message(Messages.Type.ERROR, "Syntax error in EXACT-MR-MNT any (ANY can only occur as a single value)")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_multiple_different_maintainers() { final RpslObject rpslObject = RpslObject.parse("" + "route: 20.13.0.0/16\n" + "origin: AS3000\n" + "mnt-routes: EXACT-MR-MNT1 {20.13.0.0/16^+}\n" + "mnt-routes: EXACT-MR-MNT2 any\n" + "source: TEST\n"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MntRoutesValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Map<MntRoutes, RpslAttribute> mntRoutesMap = Maps.newHashMap(); for (final RpslAttribute attribute : update.getUpdatedObject().findAttributes(AttributeType.MNT_ROUTES)) { for (final CIString mntRoutesValue : attribute.getCleanValues()) { try { final MntRoutes mntRoutes = MntRoutes.parse(mntRoutesValue); for (final Map.Entry<MntRoutes, RpslAttribute> mntRoutesEntry : mntRoutesMap.entrySet()) { final MntRoutes otherMntRoutes = mntRoutesEntry.getKey(); if (mntRoutes.getMaintainer().equals(otherMntRoutes.getMaintainer()) && mntRoutes.isAnyRange() != otherMntRoutes.isAnyRange()) { final RpslAttribute otherAttribute = mntRoutesEntry.getValue(); syntaxError(update, updateContext, otherAttribute); syntaxError(update, updateContext, attribute); } } mntRoutesMap.put(mntRoutes, attribute); } catch (AttributeParseException e) { syntaxError(update, updateContext, attribute); } } } } @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; }
NewKeywordValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
NewKeywordValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
NewKeywordValidator 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(); }
NewKeywordValidator 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 dummify_keycert() { final RpslObject before = RpslObject.parse( "key-cert: PGPKEY-57639544\n" + "method: PGP\n" + "owner: Test Person <[email protected]>\n" + "fingerpr: 2A4F DFBE F26C 1951 449E B450 73BB 96F8 5763 9544\n" + "certif: -----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "certif: -----END PGP PUBLIC KEY BLOCK-----\n" + "notify: [email protected]\n" + "mnt-by: TEST-MNT\n" + "source: TEST\n"); final RpslObject after = subject.dummify(3, before); assertThat(after.toString(), is( "key-cert: PGPKEY-57639544\n" + "method: PGP\n" + "owner: ***\n" + "fingerpr: 2A4F DFBE F26C 1951 449E B450 73BB 96F8 5763 9544\n" + "certif: -----BEGIN PGP PUBLIC KEY BLOCK-----\n" + "certif: -----END PGP PUBLIC KEY BLOCK-----\n" + "notify: ***@ripe.net\n" + "mnt-by: TEST-MNT\n" + "source: TEST\n")); }
@Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } @Override RpslObject dummify(final int version, final RpslObject rpslObject); }
DummifierRC extends DummifierCurrent { @Override public RpslObject dummify(final int version, final RpslObject rpslObject) { final List<RpslAttribute> attributes = Lists.newArrayList(rpslObject.getAttributes()); for (int i = 0; i < attributes.size(); i++) { RpslAttribute replacement = attributes.get(i); replacement = dummifyOrgName(rpslObject, replacement); replacement = dummifyDescr(replacement); replacement = dummifyRemarks(replacement); replacement = dummifyAsName(replacement); replacement = dummifyOwner(replacement); attributes.set(i, replacement); } return super.dummify(version, new RpslObject(rpslObject, attributes)); } @Override RpslObject dummify(final int version, final RpslObject rpslObject); }
@Test public void validate_create_with_existing() { when(preparedUpdate.getAction()).thenReturn(Action.CREATE); when(preparedUpdate.hasOriginalObject()).thenReturn(true); subject.validate(preparedUpdate, updateContext); verify(updateContext).addMessage(preparedUpdate, UpdateMessages.newKeywordAndObjectExists()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (update.hasOriginalObject()) { updateContext.addMessage(update, UpdateMessages.newKeywordAndObjectExists()); } }
NewKeywordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (update.hasOriginalObject()) { updateContext.addMessage(update, UpdateMessages.newKeywordAndObjectExists()); } } }
NewKeywordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (update.hasOriginalObject()) { updateContext.addMessage(update, UpdateMessages.newKeywordAndObjectExists()); } } }
NewKeywordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (update.hasOriginalObject()) { updateContext.addMessage(update, UpdateMessages.newKeywordAndObjectExists()); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NewKeywordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (update.hasOriginalObject()) { updateContext.addMessage(update, UpdateMessages.newKeywordAndObjectExists()); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_create_without() { when(preparedUpdate.getAction()).thenReturn(Action.CREATE); when(preparedUpdate.hasOriginalObject()).thenReturn(false); subject.validate(preparedUpdate, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (update.hasOriginalObject()) { updateContext.addMessage(update, UpdateMessages.newKeywordAndObjectExists()); } }
NewKeywordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (update.hasOriginalObject()) { updateContext.addMessage(update, UpdateMessages.newKeywordAndObjectExists()); } } }
NewKeywordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (update.hasOriginalObject()) { updateContext.addMessage(update, UpdateMessages.newKeywordAndObjectExists()); } } }
NewKeywordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (update.hasOriginalObject()) { updateContext.addMessage(update, UpdateMessages.newKeywordAndObjectExists()); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
NewKeywordValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (update.hasOriginalObject()) { updateContext.addMessage(update, UpdateMessages.newKeywordAndObjectExists()); } } @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; }
MaintainedReferencedPersonRolesValidator extends AbstractObjectIsMaintainedValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
MaintainedReferencedPersonRolesValidator extends AbstractObjectIsMaintainedValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MaintainedReferencedPersonRolesValidator(final RpslObjectDao rpslObjectDao); }
MaintainedReferencedPersonRolesValidator extends AbstractObjectIsMaintainedValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MaintainedReferencedPersonRolesValidator(final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
MaintainedReferencedPersonRolesValidator extends AbstractObjectIsMaintainedValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MaintainedReferencedPersonRolesValidator(final RpslObjectDao rpslObjectDao); @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; }
SourceCommentValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
SourceCommentValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
SourceCommentValidator 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(); }
SourceCommentValidator 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.values())); }
@Override public ImmutableList<ObjectType> getTypes() { return TYPES; }
SourceCommentValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
SourceCommentValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } }
SourceCommentValidator 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(); }
SourceCommentValidator 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 source_attribute_has_comment() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("mntner: TEST-MNT\nsource: TEST # comment")); subject.validate(update, updateContext); verify(updateContext).addMessage(update, UpdateMessages.commentInSourceNotAllowed()); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final String source = update.getUpdatedObject().findAttribute(SOURCE).getValue(); if (REMARK_PATTERN.matcher(source).matches()) { updateContext.addMessage(update, UpdateMessages.commentInSourceNotAllowed()); } }
SourceCommentValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final String source = update.getUpdatedObject().findAttribute(SOURCE).getValue(); if (REMARK_PATTERN.matcher(source).matches()) { updateContext.addMessage(update, UpdateMessages.commentInSourceNotAllowed()); } } }
SourceCommentValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final String source = update.getUpdatedObject().findAttribute(SOURCE).getValue(); if (REMARK_PATTERN.matcher(source).matches()) { updateContext.addMessage(update, UpdateMessages.commentInSourceNotAllowed()); } } }
SourceCommentValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final String source = update.getUpdatedObject().findAttribute(SOURCE).getValue(); if (REMARK_PATTERN.matcher(source).matches()) { updateContext.addMessage(update, UpdateMessages.commentInSourceNotAllowed()); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
SourceCommentValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final String source = update.getUpdatedObject().findAttribute(SOURCE).getValue(); if (REMARK_PATTERN.matcher(source).matches()) { updateContext.addMessage(update, UpdateMessages.commentInSourceNotAllowed()); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void source_attribute_has_no_comment() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("mntner: TEST-MNT\nsource: TEST")); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final String source = update.getUpdatedObject().findAttribute(SOURCE).getValue(); if (REMARK_PATTERN.matcher(source).matches()) { updateContext.addMessage(update, UpdateMessages.commentInSourceNotAllowed()); } }
SourceCommentValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final String source = update.getUpdatedObject().findAttribute(SOURCE).getValue(); if (REMARK_PATTERN.matcher(source).matches()) { updateContext.addMessage(update, UpdateMessages.commentInSourceNotAllowed()); } } }
SourceCommentValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final String source = update.getUpdatedObject().findAttribute(SOURCE).getValue(); if (REMARK_PATTERN.matcher(source).matches()) { updateContext.addMessage(update, UpdateMessages.commentInSourceNotAllowed()); } } }
SourceCommentValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final String source = update.getUpdatedObject().findAttribute(SOURCE).getValue(); if (REMARK_PATTERN.matcher(source).matches()) { updateContext.addMessage(update, UpdateMessages.commentInSourceNotAllowed()); } } @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
SourceCommentValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final String source = update.getUpdatedObject().findAttribute(SOURCE).getValue(); if (REMARK_PATTERN.matcher(source).matches()) { updateContext.addMessage(update, UpdateMessages.commentInSourceNotAllowed()); } } @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; }
ReferencedObjectsExistValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } }
ReferencedObjectsExistValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired ReferencedObjectsExistValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); }
ReferencedObjectsExistValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired ReferencedObjectsExistValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ReferencedObjectsExistValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired ReferencedObjectsExistValidator(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_invalid_references() { when(rpslObjectUpdateDao.getInvalidReferences(object)).thenReturn(Collections.<RpslAttribute, Set<CIString>>emptyMap()); subject.validate(update, updateContext); verify(updateContext).getMessages(update); verifyNoMoreInteractions(updateContext); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Map<RpslAttribute, Set<CIString>> invalidReferences = rpslObjectUpdateDao.getInvalidReferences(updatedObject); final ObjectMessages objectMessages = updateContext.getMessages(update); for (final Map.Entry<RpslAttribute, Set<CIString>> invalidReferenceEntry : invalidReferences.entrySet()) { final RpslAttribute attribute = invalidReferenceEntry.getKey(); if (objectMessages.getMessages(attribute).getErrors().isEmpty()) { updateContext.addMessage(update, attribute, UpdateMessages.unknownObjectReferenced(StringUtils.join(invalidReferenceEntry.getValue(), ','))); } } }
ReferencedObjectsExistValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Map<RpslAttribute, Set<CIString>> invalidReferences = rpslObjectUpdateDao.getInvalidReferences(updatedObject); final ObjectMessages objectMessages = updateContext.getMessages(update); for (final Map.Entry<RpslAttribute, Set<CIString>> invalidReferenceEntry : invalidReferences.entrySet()) { final RpslAttribute attribute = invalidReferenceEntry.getKey(); if (objectMessages.getMessages(attribute).getErrors().isEmpty()) { updateContext.addMessage(update, attribute, UpdateMessages.unknownObjectReferenced(StringUtils.join(invalidReferenceEntry.getValue(), ','))); } } } }
ReferencedObjectsExistValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Map<RpslAttribute, Set<CIString>> invalidReferences = rpslObjectUpdateDao.getInvalidReferences(updatedObject); final ObjectMessages objectMessages = updateContext.getMessages(update); for (final Map.Entry<RpslAttribute, Set<CIString>> invalidReferenceEntry : invalidReferences.entrySet()) { final RpslAttribute attribute = invalidReferenceEntry.getKey(); if (objectMessages.getMessages(attribute).getErrors().isEmpty()) { updateContext.addMessage(update, attribute, UpdateMessages.unknownObjectReferenced(StringUtils.join(invalidReferenceEntry.getValue(), ','))); } } } @Autowired ReferencedObjectsExistValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); }
ReferencedObjectsExistValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Map<RpslAttribute, Set<CIString>> invalidReferences = rpslObjectUpdateDao.getInvalidReferences(updatedObject); final ObjectMessages objectMessages = updateContext.getMessages(update); for (final Map.Entry<RpslAttribute, Set<CIString>> invalidReferenceEntry : invalidReferences.entrySet()) { final RpslAttribute attribute = invalidReferenceEntry.getKey(); if (objectMessages.getMessages(attribute).getErrors().isEmpty()) { updateContext.addMessage(update, attribute, UpdateMessages.unknownObjectReferenced(StringUtils.join(invalidReferenceEntry.getValue(), ','))); } } } @Autowired ReferencedObjectsExistValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ReferencedObjectsExistValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Map<RpslAttribute, Set<CIString>> invalidReferences = rpslObjectUpdateDao.getInvalidReferences(updatedObject); final ObjectMessages objectMessages = updateContext.getMessages(update); for (final Map.Entry<RpslAttribute, Set<CIString>> invalidReferenceEntry : invalidReferences.entrySet()) { final RpslAttribute attribute = invalidReferenceEntry.getKey(); if (objectMessages.getMessages(attribute).getErrors().isEmpty()) { updateContext.addMessage(update, attribute, UpdateMessages.unknownObjectReferenced(StringUtils.join(invalidReferenceEntry.getValue(), ','))); } } } @Autowired ReferencedObjectsExistValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
@Test public void validate_invalid_references() { final RpslAttribute invalidAttribute = object.getAttributes().get(1); final Map<RpslAttribute, Set<CIString>> invalidReferences = Maps.newHashMap(); invalidReferences.put(invalidAttribute, invalidAttribute.getCleanValues()); when(updateContext.getMessages(update)).thenReturn(new ObjectMessages()); when(rpslObjectUpdateDao.getInvalidReferences(object)).thenReturn(invalidReferences); subject.validate(update, updateContext); verify(updateContext).addMessage(update, invalidAttribute, UpdateMessages.unknownObjectReferenced("ADMIN_NC")); }
@Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Map<RpslAttribute, Set<CIString>> invalidReferences = rpslObjectUpdateDao.getInvalidReferences(updatedObject); final ObjectMessages objectMessages = updateContext.getMessages(update); for (final Map.Entry<RpslAttribute, Set<CIString>> invalidReferenceEntry : invalidReferences.entrySet()) { final RpslAttribute attribute = invalidReferenceEntry.getKey(); if (objectMessages.getMessages(attribute).getErrors().isEmpty()) { updateContext.addMessage(update, attribute, UpdateMessages.unknownObjectReferenced(StringUtils.join(invalidReferenceEntry.getValue(), ','))); } } }
ReferencedObjectsExistValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Map<RpslAttribute, Set<CIString>> invalidReferences = rpslObjectUpdateDao.getInvalidReferences(updatedObject); final ObjectMessages objectMessages = updateContext.getMessages(update); for (final Map.Entry<RpslAttribute, Set<CIString>> invalidReferenceEntry : invalidReferences.entrySet()) { final RpslAttribute attribute = invalidReferenceEntry.getKey(); if (objectMessages.getMessages(attribute).getErrors().isEmpty()) { updateContext.addMessage(update, attribute, UpdateMessages.unknownObjectReferenced(StringUtils.join(invalidReferenceEntry.getValue(), ','))); } } } }
ReferencedObjectsExistValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Map<RpslAttribute, Set<CIString>> invalidReferences = rpslObjectUpdateDao.getInvalidReferences(updatedObject); final ObjectMessages objectMessages = updateContext.getMessages(update); for (final Map.Entry<RpslAttribute, Set<CIString>> invalidReferenceEntry : invalidReferences.entrySet()) { final RpslAttribute attribute = invalidReferenceEntry.getKey(); if (objectMessages.getMessages(attribute).getErrors().isEmpty()) { updateContext.addMessage(update, attribute, UpdateMessages.unknownObjectReferenced(StringUtils.join(invalidReferenceEntry.getValue(), ','))); } } } @Autowired ReferencedObjectsExistValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); }
ReferencedObjectsExistValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Map<RpslAttribute, Set<CIString>> invalidReferences = rpslObjectUpdateDao.getInvalidReferences(updatedObject); final ObjectMessages objectMessages = updateContext.getMessages(update); for (final Map.Entry<RpslAttribute, Set<CIString>> invalidReferenceEntry : invalidReferences.entrySet()) { final RpslAttribute attribute = invalidReferenceEntry.getKey(); if (objectMessages.getMessages(attribute).getErrors().isEmpty()) { updateContext.addMessage(update, attribute, UpdateMessages.unknownObjectReferenced(StringUtils.join(invalidReferenceEntry.getValue(), ','))); } } } @Autowired ReferencedObjectsExistValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }
ReferencedObjectsExistValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final Map<RpslAttribute, Set<CIString>> invalidReferences = rpslObjectUpdateDao.getInvalidReferences(updatedObject); final ObjectMessages objectMessages = updateContext.getMessages(update); for (final Map.Entry<RpslAttribute, Set<CIString>> invalidReferenceEntry : invalidReferences.entrySet()) { final RpslAttribute attribute = invalidReferenceEntry.getKey(); if (objectMessages.getMessages(attribute).getErrors().isEmpty()) { updateContext.addMessage(update, attribute, UpdateMessages.unknownObjectReferenced(StringUtils.join(invalidReferenceEntry.getValue(), ','))); } } } @Autowired ReferencedObjectsExistValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); }