@Test public void testBuildDeniedTraceNewSessions() { NetworkFactory nf = new NetworkFactory(); Configuration c = nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CISCO_IOS).build(); Vrf vrf = nf.vrfBuilder().setOwner(c).build(); Flow flow = Flow.builder() .setDstIp(Ip.parse("1.1.1.1")) .setIngressNode(c.getHostname()) .setIngressVrf(vrf.getName()) .build(); List<TraceAndReverseFlow> traces = new ArrayList<>(); SessionMatchExpr dummySessionFlow = new SessionMatchExpr(IpProtocol.TCP, Ip.parse("1.1.1.1"), Ip.parse("2.2.2.2"), null, null); FirewallSessionTraceInfo sessionInfo = new FirewallSessionTraceInfo( "hostname", Accept.INSTANCE, ImmutableSet.of(), dummySessionFlow, null); ImmutableMap<String, Configuration> configs = ImmutableMap.of(c.getHostname(), c); TracerouteEngineImplContext ctxt = new TracerouteEngineImplContext( MockDataPlane.builder().build(), Topology.EMPTY, ImmutableSet.of(), ImmutableSet.of(), ImmutableMap.of(), false, configs); FlowTracer flowTracer = new FlowTracer( ctxt, c, null, new Node(c.getHostname()), new LegacyTraceRecorder(traces::add), NodeInterfacePair.of("node", "iface"), ImmutableList.of(sessionInfo), flow, vrf.getName(), new ArrayList<>(), ImmutableList.of(), new Stack<>(), flow, 0, 0); flowTracer.buildDeniedTrace(DENIED_IN); assertThat( traces, contains( allOf( hasTrace(hasDisposition(DENIED_IN)), hasNewFirewallSessions(contains(sessionInfo))))); }
@VisibleForTesting void buildDeniedTrace(FlowDisposition disposition) { _hops.add( failureHop( new Hop(_currentNode, _steps), _originalFlow, disposition, getHopSessionInfo(), getVisitedBreadcrumb())); _traceRecorder.recordTrace(_hops); }
FlowTracer { @VisibleForTesting void buildDeniedTrace(FlowDisposition disposition) { _hops.add( failureHop( new Hop(_currentNode, _steps), _originalFlow, disposition, getHopSessionInfo(), getVisitedBreadcrumb())); _traceRecorder.recordTrace(_hops); } }
FlowTracer { @VisibleForTesting void buildDeniedTrace(FlowDisposition disposition) { _hops.add( failureHop( new Hop(_currentNode, _steps), _originalFlow, disposition, getHopSessionInfo(), getVisitedBreadcrumb())); _traceRecorder.recordTrace(_hops); } @VisibleForTesting  FlowTracer(
      TracerouteEngineImplContext tracerouteContext,
      Configuration currentConfig,
      @Nullable String ingressInterface,
      Node currentNode,
      TraceRecorder traceRecorder,
      @Nullable NodeInterfacePair lastHopNodeAndOutgoingInterface,
      List<FirewallSessionTraceInfo> newSessions,
      Flow originalFlow,
      @Nonnull String vrfName,
      List<HopInfo> hops,
      List<Step<?>> steps,
      Stack<Breadcrumb> breadcrumbs,
      Flow currentFlow,
      int origNewSessionsSize,
      int origBreadcrumbsSize); }
FlowTracer { @VisibleForTesting void buildDeniedTrace(FlowDisposition disposition) { _hops.add( failureHop( new Hop(_currentNode, _steps), _originalFlow, disposition, getHopSessionInfo(), getVisitedBreadcrumb())); _traceRecorder.recordTrace(_hops); } @VisibleForTesting  FlowTracer(
      TracerouteEngineImplContext tracerouteContext,
      Configuration currentConfig,
      @Nullable String ingressInterface,
      Node currentNode,
      TraceRecorder traceRecorder,
      @Nullable NodeInterfacePair lastHopNodeAndOutgoingInterface,
      List<FirewallSessionTraceInfo> newSessions,
      Flow originalFlow,
      @Nonnull String vrfName,
      List<HopInfo> hops,
      List<Step<?>> steps,
      Stack<Breadcrumb> breadcrumbs,
      Flow currentFlow,
      int origNewSessionsSize,
      int origBreadcrumbsSize);  }
FlowTracer { @VisibleForTesting void buildDeniedTrace(FlowDisposition disposition) { _hops.add( failureHop( new Hop(_currentNode, _steps), _originalFlow, disposition, getHopSessionInfo(), getVisitedBreadcrumb())); _traceRecorder.recordTrace(_hops); } @VisibleForTesting  FlowTracer(
      TracerouteEngineImplContext tracerouteContext,
      Configuration currentConfig,
      @Nullable String ingressInterface,
      Node currentNode,
      TraceRecorder traceRecorder,
      @Nullable NodeInterfacePair lastHopNodeAndOutgoingInterface,
      List<FirewallSessionTraceInfo> newSessions,
      Flow originalFlow,
      @Nonnull String vrfName,
      List<HopInfo> hops,
      List<Step<?>> steps,
      Stack<Breadcrumb> breadcrumbs,
      Flow currentFlow,
      int origNewSessionsSize,
      int origBreadcrumbsSize);   }