@Test public void testGenerateOutgoingFilter() { Vsys vsys = new Vsys(VSYS_NAME); Zone fromZone = new Zone(FROM_ZONE_NAME, vsys); fromZone.setType(Type.LAYER3); fromZone.getInterfaceNames().add(SRC_INTERFACE_NAME); vsys.getZones().put(FROM_ZONE_NAME, fromZone); IpAccessList generatedFilter = generateOutgoingFilter( new Zone(TO_ZONE_NAME, vsys), ImmutableList.of(), ImmutableList.of(vsys)); assertThat( generatedFilter, accepts( createFlow(SRC_IP, DST_IP, SRC_INTERFACE_NAME), SRC_INTERFACE_NAME, createIntraVsysCrossZoneFilters(), ImmutableMap.of())); assertThat( generatedFilter.getLines(), contains( hasTraceElement( zoneToZoneMatchTraceElement(FROM_ZONE_NAME, TO_ZONE_NAME, vsys.getName())), hasTraceElement( zoneToZoneRejectTraceElement(FROM_ZONE_NAME, TO_ZONE_NAME, vsys.getName())))); }
@VisibleForTesting static @Nonnull IpAccessList generateOutgoingFilter( Zone toZone, Collection<Vsys> sharedGateways, Collection<Vsys> virtualSystems) { Vsys vsys = toZone.getVsys(); List<AclLine> lines = vsys.getZones().values().stream() .flatMap( fromZone -> generateCrossZoneCalls(fromZone, toZone, sharedGateways, virtualSystems)) .collect(ImmutableList.toImmutableList()); return IpAccessList.builder() .setName(computeOutgoingFilterName(computeObjectName(vsys.getName(), toZone.getName()))) .setLines(lines) .build(); }
PaloAltoConfiguration extends VendorConfiguration { @VisibleForTesting static @Nonnull IpAccessList generateOutgoingFilter( Zone toZone, Collection<Vsys> sharedGateways, Collection<Vsys> virtualSystems) { Vsys vsys = toZone.getVsys(); List<AclLine> lines = vsys.getZones().values().stream() .flatMap( fromZone -> generateCrossZoneCalls(fromZone, toZone, sharedGateways, virtualSystems)) .collect(ImmutableList.toImmutableList()); return IpAccessList.builder() .setName(computeOutgoingFilterName(computeObjectName(vsys.getName(), toZone.getName()))) .setLines(lines) .build(); } }
PaloAltoConfiguration extends VendorConfiguration { @VisibleForTesting static @Nonnull IpAccessList generateOutgoingFilter( Zone toZone, Collection<Vsys> sharedGateways, Collection<Vsys> virtualSystems) { Vsys vsys = toZone.getVsys(); List<AclLine> lines = vsys.getZones().values().stream() .flatMap( fromZone -> generateCrossZoneCalls(fromZone, toZone, sharedGateways, virtualSystems)) .collect(ImmutableList.toImmutableList()); return IpAccessList.builder() .setName(computeOutgoingFilterName(computeObjectName(vsys.getName(), toZone.getName()))) .setLines(lines) .build(); } PaloAltoConfiguration(); }
PaloAltoConfiguration extends VendorConfiguration { @VisibleForTesting static @Nonnull IpAccessList generateOutgoingFilter( Zone toZone, Collection<Vsys> sharedGateways, Collection<Vsys> virtualSystems) { Vsys vsys = toZone.getVsys(); List<AclLine> lines = vsys.getZones().values().stream() .flatMap( fromZone -> generateCrossZoneCalls(fromZone, toZone, sharedGateways, virtualSystems)) .collect(ImmutableList.toImmutableList()); return IpAccessList.builder() .setName(computeOutgoingFilterName(computeObjectName(vsys.getName(), toZone.getName()))) .setLines(lines) .build(); } PaloAltoConfiguration(); void addHostnameMapping(String deviceId, String hostname); List<CryptoProfile> getCryptoProfiles(); CryptoProfile getCryptoProfileOrCreate(String name, CryptoProfile.Type cpType); @Override String getHostname(); @Nullable DeviceGroup getDeviceGroup(String name); DeviceGroup getOrCreateDeviceGroup(String name); Template getOrCreateTemplate(String name); TemplateStack getOrCreateTemplateStack(String name); SortedMap<String, Interface> getInterfaces(); Ip getMgmtIfaceAddress(); Ip getMgmtIfaceGateway(); Ip getMgmtIfaceNetmask(); @Nonnull SortedMap<String, Vsys> getSharedGateways(); @Nullable Template getTemplate(String name); SortedMap<String, VirtualRouter> getVirtualRouters(); SortedMap<String, Vsys> getVirtualSystems(); void setDnsServerPrimary(String dnsServerPrimary); void setDnsServerSecondary(String dnsServerSecondary); @Override void setHostname(String hostname); void setMgmtIfaceAddress(Ip ip); void setMgmtIfaceGateway(Ip ip); void setMgmtIfaceNetmask(Ip ip); void setNtpServerPrimary(String ntpServerPrimary); void setNtpServerSecondary(String ntpServerSecondary); @Override void setVendor(ConfigurationFormat format); static String computeObjectName(String vsysName, String objectName); static String computeObjectName(@Nullable Vsys vsys, String objectName); static String computeOutgoingFilterName(String interfaceOrZoneName); static String computePacketPolicyName(Zone zone); @VisibleForTesting static String computeServiceGroupMemberAclName(
      String vsysName, String serviceGroupMemberName); @VisibleForTesting List<PaloAltoConfiguration> getManagedConfigurations(); @Override List<Configuration> toVendorIndependentConfigurations(); @Nullable Vsys getPanorama(); @Nullable Vsys getShared(); void setPanorama(@Nullable Vsys panorama); void setShared(@Nullable Vsys shared); }
PaloAltoConfiguration extends VendorConfiguration { @VisibleForTesting static @Nonnull IpAccessList generateOutgoingFilter( Zone toZone, Collection<Vsys> sharedGateways, Collection<Vsys> virtualSystems) { Vsys vsys = toZone.getVsys(); List<AclLine> lines = vsys.getZones().values().stream() .flatMap( fromZone -> generateCrossZoneCalls(fromZone, toZone, sharedGateways, virtualSystems)) .collect(ImmutableList.toImmutableList()); return IpAccessList.builder() .setName(computeOutgoingFilterName(computeObjectName(vsys.getName(), toZone.getName()))) .setLines(lines) .build(); } PaloAltoConfiguration(); void addHostnameMapping(String deviceId, String hostname); List<CryptoProfile> getCryptoProfiles(); CryptoProfile getCryptoProfileOrCreate(String name, CryptoProfile.Type cpType); @Override String getHostname(); @Nullable DeviceGroup getDeviceGroup(String name); DeviceGroup getOrCreateDeviceGroup(String name); Template getOrCreateTemplate(String name); TemplateStack getOrCreateTemplateStack(String name); SortedMap<String, Interface> getInterfaces(); Ip getMgmtIfaceAddress(); Ip getMgmtIfaceGateway(); Ip getMgmtIfaceNetmask(); @Nonnull SortedMap<String, Vsys> getSharedGateways(); @Nullable Template getTemplate(String name); SortedMap<String, VirtualRouter> getVirtualRouters(); SortedMap<String, Vsys> getVirtualSystems(); void setDnsServerPrimary(String dnsServerPrimary); void setDnsServerSecondary(String dnsServerSecondary); @Override void setHostname(String hostname); void setMgmtIfaceAddress(Ip ip); void setMgmtIfaceGateway(Ip ip); void setMgmtIfaceNetmask(Ip ip); void setNtpServerPrimary(String ntpServerPrimary); void setNtpServerSecondary(String ntpServerSecondary); @Override void setVendor(ConfigurationFormat format); static String computeObjectName(String vsysName, String objectName); static String computeObjectName(@Nullable Vsys vsys, String objectName); static String computeOutgoingFilterName(String interfaceOrZoneName); static String computePacketPolicyName(Zone zone); @VisibleForTesting static String computeServiceGroupMemberAclName(
      String vsysName, String serviceGroupMemberName); @VisibleForTesting List<PaloAltoConfiguration> getManagedConfigurations(); @Override List<Configuration> toVendorIndependentConfigurations(); @Nullable Vsys getPanorama(); @Nullable Vsys getShared(); void setPanorama(@Nullable Vsys panorama); void setShared(@Nullable Vsys shared); static final String CATCHALL_APPLICATION_NAME; static final String CATCHALL_ENDPOINT_NAME; static final String CATCHALL_ZONE_NAME; static final String DEFAULT_VSYS_NAME; static final String NULL_VRF_NAME; static final String PANORAMA_VSYS_NAME; static final String SHARED_VSYS_NAME; }