src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
AutomaticPermanentBlocksCleanup implements DailyScheduledTask { @Override @Scheduled(cron = "0 0 0 * * *") @SchedulerLock(name = "AutomaticPermanentBlocksCleanup") public void run() { final LocalDate eventRemoveDate = dateTimeProvider.getCurrentDate().minusMonths(3); LOGGER.debug("Removing block events before {}", even...
@Test public void run() { final LocalDate now = LocalDate.now(); when(dateTimeProvider.getCurrentDate()).thenReturn(now); subject.run(); verify(accessControlListDao, times(1)).removePermanentBlocksBefore(argThat(new BaseMatcher<LocalDate>() { @Override public boolean matches(Object item) { return item.equals(now.minusY...
SsoTranslator { public RpslObject translateFromCacheAuthToUuid(final UpdateContext updateContext, final RpslObject rpslObject) { return translateAuthFromCache(updateContext, rpslObject); } @Autowired SsoTranslator(final CrowdClient crowdClient); void populateCacheAuthToUsername(final UpdateContext updateContext, final...
@Test public void translate_to_uuid_username_not_stored_in_context() { final RpslObject object = RpslObject.parse("mntner: TEST-MNT\nauth: SSO username@test.net"); when(updateContext.getSsoTranslationResult("username@test.net")).thenReturn("BBBB-1234-CCCC-DDDD"); final RpslObject result = subject.translateFromCacheAuth...
SsoTranslator { public void populateCacheAuthToUuid(final UpdateContext updateContext, final Update update) { final RpslObject submittedObject = update.getSubmittedObject(); SsoHelper.translateAuth(submittedObject, new AuthTranslator() { @Override @CheckForNull public RpslAttribute translate(final String authType, fina...
@Test public void populate_not_maintainer_object() { final RpslObject object = RpslObject.parse("aut-num: AS1234"); when(update.getSubmittedObject()).thenReturn(object); subject.populateCacheAuthToUuid(updateContext, update); verifyZeroInteractions(updateContext); } @Test public void populate_no_sso_auth() { final Rpsl...
MntRoutesAttributeTransformer implements Transformer { public RpslObject transform(final RpslObject rpslObject, final Update update, final UpdateContext updateContext, final Action action) { if ((rpslObject.getType() != ObjectType.AUT_NUM) || !rpslObject.containsAttribute(AttributeType.MNT_ROUTES)) { return rpslObject;...
@Test public void filter_mnt_routes_from_autnum() { final RpslObject autnum = RpslObject.parse( "aut-num: AS3333\n" + "as-name: TEST-AS\n" + "org: ORG-TEST1-TEST\n" + " # Transit:\n" + "import: from AS3333 action pref=700; accept ANY # preserve \n" + "export: to AS3333 announce AS3333:AS-TEST # formatting \n" + "admin-...
ShortFormatTransformer implements Transformer { @Override public RpslObject transform(final RpslObject rpslObject, final Update update, final UpdateContext updateContext, final Action action) { final RpslObjectBuilder builder = new RpslObjectBuilder(rpslObject); boolean updated = false; final ListIterator<RpslAttribute...
@Test public void dont_transform_no_short_format_attributes() { final RpslObject mntner = RpslObject.parse( "mntner: MINE-MNT\n" + "admin-c: AA1-TEST\n" + "auth: MD5-PW $1$/7f2XnzQ$p5ddbI7SXq4z4yNrObFS/0 # emptypassword\n" + "mnt-by: MINE-MNT\n" + "source: TEST\n"); final RpslObject updatedObject = subject.transform(mn...
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;...
@Test public void transform_inetnum_prefix() { final RpslObject rpslObject = RpslObject.parse("inetnum: 193/8"); final RpslObject result = attributeSanitizer.sanitize(rpslObject, objectMessages); assertThat(result.getValueForAttribute(AttributeType.INETNUM).toString(), is("193.0.0.0 - 193.255.255.255")); verify(objectM...
ResponseFactory { public String createExceptionResponse(final UpdateContext updateContext, final Origin origin) { final VelocityContext velocityContext = new VelocityContext(); return createResponse(TEMPLATE_EXCEPTION, updateContext, velocityContext, origin); } @Autowired ResponseFactory( final DateTimeProvide...
@Test public void getException() { final String response = subject.createExceptionResponse(updateContext, origin); assertThat(response, containsString("" + "> From: Andre Kampert <cac37ak@ripe.net>\n" + "> Subject: delete route 194.39.132.0/24\n" + "> Date: Thu, 14 Jun 2012 10:04:42 +0200\n" + "> Reply-To: cac37ak@ripe...
ResponseFactory { public String createAckResponse(final UpdateContext updateContext, final Origin origin, final Ack ack) { final VelocityContext velocityContext = new VelocityContext(); velocityContext.put("ack", ack); velocityContext.put("updateContext", updateContext); return createResponse(TEMPLATE_ACK, updateContex...
@Test public void getAck_no_errors() { final RpslObject rpslObject = RpslObject.parse("mntner: DEV-ROOT-MNT"); updateResults.add(new UpdateResult(rpslObject, rpslObject, Action.DELETE, UpdateStatus.SUCCESS, new ObjectMessages(), 0, false)); final Ack ack = new Ack(updateResults, ignoredParagraphs); final String respons...
ResponseFactory { public String createHelpResponse(final UpdateContext updateContext, final Origin origin) { final VelocityContext velocityContext = new VelocityContext(); return createResponse(TEMPLATE_HELP, updateContext, velocityContext, origin); } @Autowired ResponseFactory( final DateTimeProvider dateTime...
@Test public void createHelpResponse() { final String response = subject.createHelpResponse(updateContext, origin); assertThat(response, containsString("" + "> From: Andre Kampert <cac37ak@ripe.net>\n" + "> Subject: delete route 194.39.132.0/24\n" + "> Date: Thu, 14 Jun 2012 10:04:42 +0200\n" + "> Reply-To: cac37ak@rip...
ResponseFactory { public ResponseMessage createNotification(final UpdateContext updateContext, final Origin origin, final Notification notification) { final String ssoUserEmail = updateContext.getUserSession() != null ? updateContext.getUserSession().getUsername() : ""; final VelocityContext velocityContext = new Veloc...
@Test public void notification_success() { final RpslObject object1 = RpslObject.parse("mntner: DEV-ROOT1-MNT"); final Update update1 = new Update(new Paragraph(object1.toString()), Operation.UNSPECIFIED, Lists.<String>newArrayList(), object1); final PreparedUpdate create1 = new PreparedUpdate(update1, null, object1, A...
SetNotReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired SetNotReferencedValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Acti...
@Test public void testGetActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.DELETE)); }
SetNotReferencedValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired SetNotReferencedValidator(final RpslObjectDao objectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Acti...
@Test public void testGetTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.AS_SET, ObjectType.ROUTE_SET, ObjectType.RTR_SET)); }
SetNotReferencedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final List<RpslObjectInfo> incomingReferences = objectDao.findMemberOfByObjectTypeWithoutMbrsByRef(upd...
@Test public void set_that_has_incoming_references() { final RpslObject routeSet = RpslObject.parse("route-set: rs-AH"); when(update.getUpdatedObject()).thenReturn(routeSet); when(objectDao.findMemberOfByObjectTypeWithoutMbrsByRef(ObjectType.ROUTE_SET, "rs-AH")).thenReturn(Lists.newArrayList(new RpslObjectInfo(1, Objec...
PeeringSetAttributeMustBePresent implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } PeeringSetAttributeMustBePresent(); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override...
@Test public void testGetActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE, Action.MODIFY)); }
PeeringSetAttributeMustBePresent implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } PeeringSetAttributeMustBePresent(); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions(); @Override...
@Test public void testGetTypes() { assertThat(subject.getTypes(), Matchers.contains(ObjectType.PEERING_SET, ObjectType.FILTER_SET)); }
PeeringSetAttributeMustBePresent implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final ObjectType objectType = update.getType(); final List<AttributeType> attributeTypes = attr...
@Test public void mpPeering_and_peering_present() { when(update.getType()).thenReturn(ObjectType.PEERING_SET); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("peering-set: prng-ripe\ndescr: description\npeering: AS6845 at 194.102.255.254\nmp-peering: AS702:PRNG-AT-CUSTOMER")); subject.validate(update, upda...
SetnameMustExistValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired SetnameMustExistValidator(final RpslObjectDao objectDao, final AuthenticationModule authenticationModule); @Override void validate(final P...
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE)); }
SetnameMustExistValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired SetnameMustExistValidator(final RpslObjectDao objectDao, final AuthenticationModule authenticationModule); @Override void validate(final P...
@Test public void getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.AS_SET, ObjectType.FILTER_SET, ObjectType.PEERING_SET, ObjectType.ROUTE_SET, ObjectType.RTR_SET)); }
SetnameMustExistValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final String key = update.getUpdatedObject().getTypeAttribute().getC...
@Test public void validate_missing_parent() { when(update.getType()).thenReturn(ObjectType.FILTER_SET); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("filter-set: FLTR-RIPE:FLTR-ALLOCBNDR:FLTR-IPV6:fltr-something")); when(objectDao.getByKeys(eq(ObjectType.FILTER_SET), anyCollection())).thenReturn(Lists.<R...
OrganisationTypeValidator 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().size(), is(2)); assertThat(subject.getActions().contains(Action.MODIFY), is(true)); assertThat(subject.getActions().contains(Action.CREATE), is(true)); }
OrganisationTypeValidator 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 getTypes() { assertThat(subject.getTypes().size(), is(1)); assertThat(subject.getTypes().get(0), is(ObjectType.ORGANISATION)); }
OrganisationTypeValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final RpslAttribute orgTypeAttribut...
@Test public void update_is_override() { when(authenticationSubject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)).thenReturn(true); subject.validate(update, updateContext); verify(updateContext).getSubject(any(UpdateContainer.class)); verifyNoMoreInteractions(update); verifyNoMoreInteractions(updateContext); } @Test pub...
OrgNameNotChangedValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired OrgNameNotChangedValidator(final RpslObjectUpdateDao objectUpdateDao, final RpslObjectDao objectDao, final Maintainers maintainers); @Override void validate(final PreparedUpd...
@Test public void getActions() { assertThat(subject.getActions(), contains(Action.MODIFY)); }
OrgNameNotChangedValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired OrgNameNotChangedValidator(final RpslObjectUpdateDao objectUpdateDao, final RpslObjectDao objectDao, final Maintainers maintainers); @Override void validate(final PreparedUpd...
@Test public void getTypes() { assertThat(subject.getTypes(), contains(ObjectType.ORGANISATION)); }
OrgNameNotChangedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject originalObject = update.getReferenceObject(); final RpslObject updatedObject = update.getUpdatedObject(); if (isLir(originalObject)) { return; }...
@Test public void orgname_not_changed() { when(update.getReferenceObject()).thenReturn(ORIGINAL_ORG); when(update.getUpdatedObject()).thenReturn(UPDATED_ORG_SAME_NAME); subject.validate(update, updateContext); verify(updateContext, never()).addMessage(Matchers.<Update>anyObject(), Matchers.<Message>anyObject()); verify...
AbuseValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); if (updatedObject == null) { return; } validateAbuseC(updatedObject, update, updateContext); validateAbuseCRemove...
@Test public void has_no_abusec() { when(update.getUpdatedObject()).thenReturn(OTHER_ORG_WITHOUT_ABUSE_C); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); } @Test public void references_role_without_abuse_mailbox() { when(update.getUpdatedObject()).thenReturn(OTHER_ORG_WITH_ABUSE_C); whe...
LirUserMaintainedAttributesValidator 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> getT...
@Test public void getActions() { assertThat(subject.getActions().size(), is(1)); assertTrue(subject.getActions().contains(Action.MODIFY)); }
LirUserMaintainedAttributesValidator 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> getT...
@Test public void getTypes() { assertThat(subject.getTypes().size(), is(1)); assertTrue(subject.getTypes().contains(ObjectType.ORGANISATION)); }
LirUserMaintainedAttributesValidator 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.ALL...
@Test public void update_of_non_lir() { when(update.getReferenceObject()).thenReturn(NON_LIR_ORG); when(authenticationSubject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)).thenReturn(false); when(authenticationSubject.hasPrincipal(Principal.ALLOC_MAINTAINER)).thenReturn(false); when(update.getUpdatedObject()).thenReturn...
AbuseCNoLimitWarningValidator 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)); }
AbuseCNoLimitWarningValidator 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 getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.ROLE)); }
AbuseCNoLimitWarningValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (update.getUpdatedObject().containsAttribute(AttributeType.ABUSE_MAILBOX) && (!update.hasOriginalObject() || !update.getReferenceObject().containsAttribute...
@Test public void role_has_added_abuse_mailbox_create() { final RpslObject role = RpslObject.parse("role: Some Role\nnic-hdl: TEST-NIC\nabuse-mailbox: abuse@ripe.net"); when(update.hasOriginalObject()).thenReturn(false); when(update.getReferenceObject()).thenReturn(role); when(update.getUpdatedObject()).thenReturn(role...
LirMntByAttributeCountValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired LirMntByAttributeCountValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override Immuta...
@Test public void getActions() { assertThat(subject.getActions().size(), is(2)); assertTrue(subject.getActions().contains(Action.CREATE)); assertTrue(subject.getActions().contains(Action.MODIFY)); }
LirMntByAttributeCountValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired LirMntByAttributeCountValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override Immuta...
@Test public void getTypes() { assertThat(subject.getTypes().size(), is(1)); assertTrue(subject.getTypes().contains(ObjectType.ORGANISATION)); }
LirMntByAttributeCountValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject originalObject = update.getReferenceObject(); if (!isLir(originalObject)) { return; } final RpslObject updatedObject = update.getUpdatedObj...
@Test public void update_of_not_lir_with_single_mntner() { when(update.getReferenceObject()).thenReturn(NON_LIR_ORG); when(authenticationSubject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)).thenReturn(false); when(update.getUpdatedObject()).thenReturn(NON_LIR_ORG_SINGLE_USER_MNTNER); subject.validate(update, updateCont...
ExportFileWriterFactory { public boolean isExportDir(final File dir) { final File[] files = dir.listFiles(); if (files == null) { return false; } for (final File file : files) { if (file.isFile()) { return false; } final String fileName = file.getName(); if (! (fileName.equals(externalExportDir) || fileName.equals(inte...
@Test public void isExportDir_empty() { assertThat(subject.isExportDir(folder.getRoot()), Matchers.is(true)); } @Test public void isExportDir_home() { final File homeDir = new File(System.getProperty("user.home")); assertThat(homeDir.exists(), Matchers.is(true)); assertThat(homeDir.isDirectory(), Matchers.is(true)); as...
LirRipeMaintainedAttributesValidator 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> getT...
@Test public void getActions() { assertThat(subject.getActions().size(), is(1)); assertTrue(subject.getActions().contains(Action.MODIFY)); }
LirRipeMaintainedAttributesValidator 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> getT...
@Test public void getTypes() { assertThat(subject.getTypes().size(), is(1)); assertTrue(subject.getTypes().contains(ObjectType.ORGANISATION)); }
LirRipeMaintainedAttributesValidator 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.ALL...
@Test public void update_of_non_lir() { when(update.getReferenceObject()).thenReturn(NON_LIR_ORG); when(authenticationSubject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)).thenReturn(false); when(authenticationSubject.hasPrincipal(Principal.ALLOC_MAINTAINER)).thenReturn(false); when(update.getUpdatedObject()).thenReturn...
AggregatedByLirStatusValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired AggregatedByLirStatusValidator(final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updat...
@Test public void getActions() { assertThat(subject.getActions(), contains(Action.CREATE, Action.MODIFY)); }
AggregatedByLirStatusValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired AggregatedByLirStatusValidator(final Ipv6Tree ipv6Tree, final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext updat...
@Test public void getTypes() { assertThat(subject.getTypes(), contains(ObjectType.INET6NUM)); }
AggregatedByLirStatusValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (update.getAction()== CREATE) { validateCreate(update, updateContext); } else { validateModify(update, updateContext); } } @Autowired AggregatedByLirStat...
@Test public void validate_no_aggregated_by_lir() { final RpslObject object = RpslObject.parse("" + "inet6num: 2001:0658:021A::/48\n" + "status: ASSIGNED"); when(update.getUpdatedObject()).thenReturn(object); when(update.getAction()).thenReturn(Action.CREATE); subject.validate(update, updateContext); verifyZeroInteract...
SponsoringOrgValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired SponsoringOrgValidator(final RpslObjectDao objectDao, final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Ov...
@Test public void getActions() { assertThat(subject.getActions(), contains(CREATE, MODIFY)); }
SponsoringOrgValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired SponsoringOrgValidator(final RpslObjectDao objectDao, final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Ov...
@Test public void getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(INETNUM, INET6NUM, AUT_NUM)); }
StatusValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (update.getAction() == DELETE) { if (update.getType().equals(INETNUM)) { validateDelete(update, updateContext, ipv4Tree); } else { validateDelete(update, updateContext, ...
@Test public void delete_inetnum_w_legacy_not_allowed_under_unspecified_w_non_rs_maintainer() { when(update.getAction()).thenReturn(Action.DELETE); when(ipv4Tree.findFirstLessSpecific(any(Ipv4Resource.class))).thenReturn(Lists.newArrayList(new Ipv4Entry(Ipv4Resource.parse("0/0"), 1))); when(objectDao.getById(1)).thenRe...
MntRouteRangeValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject updatedObject = update.getUpdatedObject(); final IpInterval<?> ipInterval = IpInterval.parse(updatedObject.getKey()); for (final RpslAttribute attri...
@Test public void is_inside_range() { final RpslObject rpslObject = RpslObject.parse("" + "inetnum:192.0.0.0 - 192.0.255.255\n" + "mnt-routes: DEV-MNT {192.0.0.0/24}"); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(update, updateContext); verifyZeroInteractions(updateContext); } @Test public ...
MntRouteRangeValidator 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 supports() { final List<ObjectType> supportedTypes = subject.getTypes(); assertThat(supportedTypes, containsInAnyOrder(ObjectType.INETNUM, ObjectType.INET6NUM)); }
MntRouteRangeValidator 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 supports_actions_create_modify() { final List<Action> actions = subject.getActions(); assertThat(actions.size(), is(2)); assertThat(actions.contains(Action.CREATE), is(true)); assertThat(actions.contains(Action.MODIFY), is(true)); }
LirMntByValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired LirMntByValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions()...
@Test public void getActions() { assertThat(subject.getActions(), contains(Action.MODIFY)); }
LirMntByValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired LirMntByValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override ImmutableList<Action> getActions()...
@Test public void getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.INETNUM, ObjectType.INET6NUM)); }
LirMntByValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); final RpslObject originalObject = update.getReferenceObject(); final RpslObject updatedObject = update.getUpdate...
@Test public void modify_mntby_on_inetnum_with_lir() { final RpslObject rpslOriginalObject = RpslObject.parse("" + "inetnum: 192.168.0.0 - 192.169.255.255\n" + "status: ALLOCATED PA\n" + "mnt-by: RIPE-NCC-HM-MNT\n" + "mnt-by: TEST-MNT"); final RpslObject rpslUpdatedlObject = RpslObject.parse("" + "inetnum: 192.168.0.0 ...
ReferenceCheck implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { if (updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } final InetStatus inetStatus = getStatus(update); final List<RpslAttribute> upda...
@Test public void modify_org_reference_missing() { when(update.getAction()).thenReturn(Action.MODIFY); when(update.getType()).thenReturn(ObjectType.INETNUM); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("inetnum: 192.0/24\nstatus: ALLOCATED PA")); subject.validate(update, updateContext); verify(updateCon...
IntersectionValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired IntersectionValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override Immutab...
@Test public void getActions() { assertThat(subject.getActions(), contains(Action.CREATE)); }
IntersectionValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired IntersectionValidator(final Ipv4Tree ipv4Tree, final Ipv6Tree ipv6Tree); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override Immutab...
@Test public void getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.INETNUM, ObjectType.INET6NUM)); }
IntersectionValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final IpInterval ipInterval = IpInterval.parse(update.getReferenceObject().getKey()); if (ipInterval instanceof Ipv4Resource) { validateIntersections(update, updateCo...
@Test public void validate_no_children_ipv4() { final RpslObject object = RpslObject.parse("inetnum: 193.0.0.0"); when(ipv4Tree.findFirstMoreSpecific(parentIpv4Key)).thenReturn(Lists.<Ipv4Entry>newArrayList()); when(update.getReferenceObject()).thenReturn(object); subject.validate(update, updateContext); verifyZeroInte...
EndUserMaintainerChecks implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } if (subject.hasPrincipal(Principal.EN...
@Test public void modify_has_no_endusermntner() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("inetnum: 192.0/24\nstatus: ASSIGNED ANYCAST\nmnt-by: TEST-MNT")); when(updateContext.getSubject(update)).thenReturn(principalSubject); when(principalSubject.hasPrincipal(Principal.ENDUSER_MAINTAINER)).thenRetu...
OrgAttributeNotChangedValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired OrgAttributeNotChangedValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override Immuta...
@Test public void getActions() { assertThat(subject.getActions(), contains(Action.MODIFY)); }
OrgAttributeNotChangedValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired OrgAttributeNotChangedValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Override Immuta...
@Test public void getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.INETNUM, ObjectType.INET6NUM, ObjectType.AUT_NUM)); }
OrgAttributeNotChangedValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final RpslObject originalObject = update.getReferenceObject(); final CIString originalOrg = originalObject.getValueOrNullForAttribute(AttributeType.ORG); fi...
@Test public void validate_org_attribute_not_changed_for_aut_num() { final RpslObject rpslObject = RpslObject.parse("" + "aut-num: AS123\n" + "org: ORG-RT-TEST\n" + "mnt-by: TEST-MNT"); when(update.getReferenceObject()).thenReturn(rpslObject); when(update.getUpdatedObject()).thenReturn(rpslObject); subject.validate(upd...
ExportFileWriterFactory { public List<ExportFileWriter> createExportFileWriters(final File baseDir, final int lastSerial) { final File fullDir = new File(baseDir, legacyExternalExportDir); final File fullDirNew = new File(baseDir, externalExportDir); final File splitDir = new File(baseDir, legacyExternalExportDir + Fil...
@Test public void isLastSerialFile_created() throws IOException { subject.createExportFileWriters(folder.getRoot(), LAST_SERIAL); final File currentSerialFile = new File(folder.getRoot(), "dbase/RIPE.CURRENTSERIAL"); assertThat(currentSerialFile.exists(), Matchers.is(true)); final String savedSerial = new String(FileCo...
StrictStatusValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { validateCreate(update, updateContext); } @Autowired StrictStatusValidator( final RpslObjectDao objectDao, final Ipv4Tree ipv4Tree, ...
@Test public void invalid_child_status_fails_ipv4() { when(update.getType()).thenReturn(INETNUM); when(authenticationSubject.hasPrincipal(Principal.ALLOC_MAINTAINER)).thenReturn(true); final Ipv4Resource ipv4Resource = Ipv4Resource.parse("192.0/32"); final Ipv4Entry child = new Ipv4Entry(ipv4Resource, 1); when(ipv4Tree...
MntLowerAddedRemoved implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final Subject subject = updateContext.getSubject(update); if (subject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)) { return; } if (ObjectType.INETNUM.equals(update.get...
@Test public void status_does_not_require_endMntnerAuthorisation_inetnum() { when(update.getType()).thenReturn(ObjectType.INETNUM); when(update.getReferenceObject()).thenReturn(RpslObject.parse("inetnum: 192.0/24\nstatus: ALLOCATED PA")); when(update.getUpdatedObject()).thenReturn(RpslObject.parse("inetnum: 192.0/24\ns...
AttributeSanitizer { public CIString sanitizeKey(final RpslObject originalObject) { final List<RpslAttribute> keyRelatedAttributes = getKeyRelatedAttributes(originalObject); return new RpslObject(sanitizeKeyAttributes(keyRelatedAttributes)).getKey(); } @Autowired AttributeSanitizer(DateTimeProvider dateTimeProvider); ...
@Test public void transform_key_inetrtr_no_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);...
AsblockByRsMaintainersOnlyValidator 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> getTy...
@Test public void testGetActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE, Action.MODIFY)); }
AsblockByRsMaintainersOnlyValidator 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> getTy...
@Test public void testGetTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.AS_BLOCK)); }
AsblockByRsMaintainersOnlyValidator implements BusinessRuleValidator { @Override public void validate(final PreparedUpdate update, final UpdateContext updateContext) { final boolean authenticatedByOverride = updateContext.getSubject(update).hasPrincipal(Principal.OVERRIDE_MAINTAINER); final boolean authenticatedByDbmMa...
@Test public void validate_override_succeeds() { when(update.isOverride()).thenReturn(true); when(updateContext.getSubject(update)).thenReturn(subjectObject); when(subjectObject.hasPrincipal(Principal.OVERRIDE_MAINTAINER)).thenReturn(true); subject.validate(update, updateContext); verify(updateContext, never()).addMess...
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired AsblockHierarchyValidator(final RpslObjectDao rpslObjectDao); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); @Override void vali...
@Test public void testGetActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE)); }
AsblockHierarchyValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired AsblockHierarchyValidator(final RpslObjectDao rpslObjectDao); @Override ImmutableList<Action> getActions(); @Override ImmutableList<ObjectType> getTypes(); @Override void vali...
@Test public void testGetTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.AS_BLOCK)); }
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.findAsBlockInter...
@Test public void validate_asBlock_Parent_exists() { when(update.getUpdatedObject()).thenReturn(RpslObject.parse("as-block: AS10 - AS20")); when(updateContext.getSubject(update)).thenReturn(subjectObject); when(rpslObjectDao.findAsBlockIntersections(10L, 20L)).thenReturn(Lists.newArrayList(RpslObject.parse("as-block: A...
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> getT...
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE, Action.MODIFY)); }
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> getT...
@Test public void getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.POEM)); }
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_MAI...
@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); } @Test public void validate_other_maintainer() { final RpslObject poem = RpslObje...
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...
@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...
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 testGetActions() throws Exception { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE, Action.MODIFY)); }
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 testGetTypes() throws Exception { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.ROUTE, ObjectType.ROUTE6)); }
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...
@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...
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)); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Ove...
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE, Action.MODIFY)); }
AddOrRemoveRipeNccMaintainerValidator implements BusinessRuleValidator { @Override public ImmutableList<ObjectType> getTypes() { return TYPES; } @Autowired AddOrRemoveRipeNccMaintainerValidator(final Maintainers maintainers); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); @Ove...
@Test public void getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.values())); }
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, ma...
@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("DE...
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 = ...
@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.wri...
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 orgAbuseCObje...
@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); } @Test public void has_abuse_c_but_no_org() { when(update.getUpdatedObject()).thenRetu...
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 = d...
@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: Netherla...
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 Im...
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.DELETE)); }
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 Im...
@Test public void getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.values())); }
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_MAI...
@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()).addM...
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 getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE)); }
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_WO...
@Test public void not_reserved_word() { mockUpdate("mntner: OWNER-MNT\nsource: TEST"); subject.validate(update, updateContext); verifyOk(); } @Test public void reserved_word_as_any_not_ok() { mockUpdate("as-set: AS-ANy\nsource: TEST"); subject.validate(update, updateContext); verifyReservedName("as-any"); } @Test publi...
MaintainedReferencedMaintainerPersonRolesValidator extends AbstractObjectIsMaintainedValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MaintainedReferencedMaintainerPersonRolesValidator(final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update,...
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE, Action.MODIFY)); }
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 getActions() { assertThat(subject.getActions(), contains(Action.CREATE, Action.MODIFY)); }
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 getTypes() { assertThat(subject.getTypes(), contains(ObjectType.INET6NUM, ObjectType.INETNUM, ObjectType.ROUTE, ObjectType.ROUTE6)); }
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_ROU...
@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); } @Test public void valid...
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 getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE)); }
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...
@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()); } @Tes...
MaintainedReferencedPersonRolesValidator extends AbstractObjectIsMaintainedValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired MaintainedReferencedPersonRolesValidator(final RpslObjectDao rpslObjectDao); @Override void validate(final PreparedUpdate update, final UpdateContext...
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE, Action.MODIFY)); }
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 getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE, Action.MODIFY)); }
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 getTypes() { assertThat(subject.getTypes(), containsInAnyOrder(ObjectType.values())); }
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, Up...
@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()); } @Test public void source_attribute...
ReferencedObjectsExistValidator implements BusinessRuleValidator { @Override public ImmutableList<Action> getActions() { return ACTIONS; } @Autowired ReferencedObjectsExistValidator(final RpslObjectUpdateDao rpslObjectUpdateDao); @Override void validate(final PreparedUpdate update, final UpdateContext updateContext); ...
@Test public void getActions() { assertThat(subject.getActions(), containsInAnyOrder(Action.CREATE, Action.MODIFY)); }
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.getInvalidRefere...
@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); } @Test public void v...