@Test public void testBuildScreensPerInterface() { JuniperConfiguration config = createConfig(); Interface iface = new Interface("iface"); List<ScreenOption> screenOptionList = ImmutableList.of(IcmpLarge.INSTANCE, IpUnknownProtocol.INSTANCE, TcpFinNoAck.INSTANCE); Screen screen = new Screen("screen"); for (ScreenOption option : screenOptionList) { screen.getScreenOptions().add(option); } config.getMasterLogicalSystem().getScreens().put("screen", screen); Zone zone = new Zone("zone", null); zone.getScreens().add("screen"); config.getMasterLogicalSystem().getInterfaceZones().put(iface.getName(), zone); IpAccessList screenAcl = config.buildScreensPerInterface(iface); assertThat( screenAcl, equalTo( IpAccessList.builder() .setName("~SCREEN_INTERFACE~iface") .setLines( ImmutableList.of( ExprAclLine.accepting(new PermittedByAcl("~SCREEN_ZONE~zone")))) .build())); assertThat(config._c.getIpAccessLists().get("~SCREEN_ZONE~zone"), notNullValue()); }
@Nullable @VisibleForTesting IpAccessList buildScreensPerInterface(Interface iface) { Zone zone = _masterLogicalSystem.getInterfaceZones().get(iface.getName()); if (zone == null) { return null; } String zoneAclName = ACL_NAME_SCREEN_ZONE + zone.getName(); IpAccessList zoneAcl = _c.getIpAccessLists() .computeIfAbsent(zoneAclName, x -> buildScreensPerZone(zone, zoneAclName)); return zoneAcl == null ? null : IpAccessList.builder() .setName(ACL_NAME_SCREEN_INTERFACE + iface.getName()) .setLines(ImmutableList.of(ExprAclLine.accepting(new PermittedByAcl(zoneAclName)))) .build(); }
JuniperConfiguration extends VendorConfiguration { @Nullable @VisibleForTesting IpAccessList buildScreensPerInterface(Interface iface) { Zone zone = _masterLogicalSystem.getInterfaceZones().get(iface.getName()); if (zone == null) { return null; } String zoneAclName = ACL_NAME_SCREEN_ZONE + zone.getName(); IpAccessList zoneAcl = _c.getIpAccessLists() .computeIfAbsent(zoneAclName, x -> buildScreensPerZone(zone, zoneAclName)); return zoneAcl == null ? null : IpAccessList.builder() .setName(ACL_NAME_SCREEN_INTERFACE + iface.getName()) .setLines(ImmutableList.of(ExprAclLine.accepting(new PermittedByAcl(zoneAclName)))) .build(); } }
JuniperConfiguration extends VendorConfiguration { @Nullable @VisibleForTesting IpAccessList buildScreensPerInterface(Interface iface) { Zone zone = _masterLogicalSystem.getInterfaceZones().get(iface.getName()); if (zone == null) { return null; } String zoneAclName = ACL_NAME_SCREEN_ZONE + zone.getName(); IpAccessList zoneAcl = _c.getIpAccessLists() .computeIfAbsent(zoneAclName, x -> buildScreensPerZone(zone, zoneAclName)); return zoneAcl == null ? null : IpAccessList.builder() .setName(ACL_NAME_SCREEN_INTERFACE + iface.getName()) .setLines(ImmutableList.of(ExprAclLine.accepting(new PermittedByAcl(zoneAclName)))) .build(); } JuniperConfiguration(); }
JuniperConfiguration extends VendorConfiguration { @Nullable @VisibleForTesting IpAccessList buildScreensPerInterface(Interface iface) { Zone zone = _masterLogicalSystem.getInterfaceZones().get(iface.getName()); if (zone == null) { return null; } String zoneAclName = ACL_NAME_SCREEN_ZONE + zone.getName(); IpAccessList zoneAcl = _c.getIpAccessLists() .computeIfAbsent(zoneAclName, x -> buildScreensPerZone(zone, zoneAclName)); return zoneAcl == null ? null : IpAccessList.builder() .setName(ACL_NAME_SCREEN_INTERFACE + iface.getName()) .setLines(ImmutableList.of(ExprAclLine.accepting(new PermittedByAcl(zoneAclName)))) .build(); } JuniperConfiguration(); static @Nonnull String computeFirewallFilterTermName(
      @Nonnull String filterName, @Nonnull String termName); static @Nonnull String computeSecurityPolicyTermName(
      @Nonnull String policyName, @Nonnull String termName); @VisibleForTesting static TraceElement matchingFirewallFilter(String filename, String filterName); @VisibleForTesting static TraceElement matchingFirewallFilterTerm(
      String filename, String filterName, String termName); @VisibleForTesting static TraceElement matchingSecurityPolicyTerm(
      String filename, String policyName, String termName); static String computePeerExportPolicyName(Prefix remoteAddress); static String computeOspfExportPolicyName(String vrfName); Map<String, NodeDevice> getNodeDevices(); @Override void setVendor(ConfigurationFormat format); static String computeContributorRouteFilterListName(Prefix prefix); static String computeAggregatedRouteGenerationPolicyName(Prefix prefix); static String computeGeneratedRouteGenerationPolicyName(Prefix prefix); static String computeIsisExportPolicyName(String routingInstanceName); @Override List<Configuration> toVendorIndependentConfigurations(); static String computeLogicalSystemDefaultHostname(
      String masterHostname, String logicalSystemName); @Nonnull Map<String, LogicalSystem> getLogicalSystems(); LogicalSystem getMasterLogicalSystem(); @Override String getHostname(); @Override void setHostname(String hostname); }
JuniperConfiguration extends VendorConfiguration { @Nullable @VisibleForTesting IpAccessList buildScreensPerInterface(Interface iface) { Zone zone = _masterLogicalSystem.getInterfaceZones().get(iface.getName()); if (zone == null) { return null; } String zoneAclName = ACL_NAME_SCREEN_ZONE + zone.getName(); IpAccessList zoneAcl = _c.getIpAccessLists() .computeIfAbsent(zoneAclName, x -> buildScreensPerZone(zone, zoneAclName)); return zoneAcl == null ? null : IpAccessList.builder() .setName(ACL_NAME_SCREEN_INTERFACE + iface.getName()) .setLines(ImmutableList.of(ExprAclLine.accepting(new PermittedByAcl(zoneAclName)))) .build(); } JuniperConfiguration(); static @Nonnull String computeFirewallFilterTermName(
      @Nonnull String filterName, @Nonnull String termName); static @Nonnull String computeSecurityPolicyTermName(
      @Nonnull String policyName, @Nonnull String termName); @VisibleForTesting static TraceElement matchingFirewallFilter(String filename, String filterName); @VisibleForTesting static TraceElement matchingFirewallFilterTerm(
      String filename, String filterName, String termName); @VisibleForTesting static TraceElement matchingSecurityPolicyTerm(
      String filename, String policyName, String termName); static String computePeerExportPolicyName(Prefix remoteAddress); static String computeOspfExportPolicyName(String vrfName); Map<String, NodeDevice> getNodeDevices(); @Override void setVendor(ConfigurationFormat format); static String computeContributorRouteFilterListName(Prefix prefix); static String computeAggregatedRouteGenerationPolicyName(Prefix prefix); static String computeGeneratedRouteGenerationPolicyName(Prefix prefix); static String computeIsisExportPolicyName(String routingInstanceName); @Override List<Configuration> toVendorIndependentConfigurations(); static String computeLogicalSystemDefaultHostname(
      String masterHostname, String logicalSystemName); @Nonnull Map<String, LogicalSystem> getLogicalSystems(); LogicalSystem getMasterLogicalSystem(); @Override String getHostname(); @Override void setHostname(String hostname); static final String ACL_NAME_COMBINED_INCOMING; static final String ACL_NAME_GLOBAL_POLICY; static final String ACL_NAME_SCREEN; static final String ACL_NAME_SCREEN_INTERFACE; static final String ACL_NAME_SCREEN_ZONE; static final String ACL_NAME_SECURITY_POLICY; @VisibleForTesting static final int DEFAULT_ISIS_COST; }