Ejemplo n.º 1
0
 private void setSsoSessionToContext(final UpdateContext updateContext, final String ssoToken) {
   if (!StringUtils.isBlank(ssoToken)) {
     try {
       updateContext.setUserSession(ssoTokenTranslator.translateSsoToken(ssoToken));
     } catch (CrowdClientException e) {
       loggerContext.log(new Message(Messages.Type.ERROR, e.getMessage()));
       updateContext.addGlobalMessage(RestMessages.ssoAuthIgnored());
     }
   }
 }
Ejemplo n.º 2
0
  private void validateIntersections(
      final PreparedUpdate update,
      final UpdateContext updateContext,
      final IpInterval ipInterval,
      final IpTree ipTree) {
    final List<IpEntry> parent = ipTree.findFirstLessSpecific(ipInterval);
    Validate.notEmpty(parent, "Should always have a parent");

    Interval firstIntersecting = null;
    final List<IpEntry> childEntries =
        ipTree.findFirstMoreSpecific((IpInterval) parent.get(0).getKey());
    for (final IpEntry childEntry : childEntries) {
      final Interval child = childEntry.getKey();

      if (child.intersects(ipInterval)
          && !(child.contains(ipInterval) || ipInterval.contains(child))) {
        if (firstIntersecting == null
            || firstIntersecting
                    .singletonIntervalAtLowerBound()
                    .compareUpperBound(child.singletonIntervalAtLowerBound())
                > 0) {
          firstIntersecting = child;
        }
      }
    }

    if (firstIntersecting != null) {
      updateContext.addMessage(update, UpdateMessages.intersectingRange(firstIntersecting));
    }
  }
Ejemplo n.º 3
0
 @Override
 public void validate(final PreparedUpdate update, final UpdateContext updateContext) {
   if (update.hasOriginalObject()
       && !RpslObjectFilter.ignoreGeneratedAttributesEqual(
           update.getReferenceObject(), update.getUpdatedObject())) {
     updateContext.addMessage(
         update, UpdateMessages.objectMismatch(update.getUpdatedObject().getFormattedKey()));
   }
 }
Ejemplo n.º 4
0
  @Test
  public void logUpdateResult_create_success_dryRun() {
    final RpslObject maintainer = RpslObject.parse("mntner: TST-MNT");
    final UpdateResult updateResult =
        new UpdateResult(
            maintainer,
            maintainer,
            Action.CREATE,
            UpdateStatus.SUCCESS,
            new ObjectMessages(),
            0,
            true);
    when(update.getCredentials()).thenReturn(new Credentials());
    when(updateContext.createUpdateResult(update)).thenReturn(updateResult);

    subject.logUpdateResult(updateRequest, updateContext, update, stopwatch);

    verify(logger)
        .info(
            matches(
                "\\[\\s*0\\] 0[,.]000 ns   DRY CREATE mntner       TST-MNT                        \\(1\\) SUCCESS               : <E0,W0,I0> AUTH  - null"));
  }