Skip to content

Commit

Permalink
JunOS: link firewall-filters (#5509)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhalperi committed Feb 3, 2020
1 parent 70cd1b7 commit 3144fb4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ public final class JuniperConfiguration extends VendorConfiguration {
return String.format("%s %s", policyName, termName);
}

@VisibleForTesting
public static TraceElement matchingFirewallFilter(String filename, String filterName) {
return TraceElement.builder()
.add("Matched ")
.add(
String.format(
"%s %s", JuniperStructureType.FIREWALL_FILTER.getDescription(), filterName),
new VendorStructureId(
filename, JuniperStructureType.FIREWALL_FILTER.getDescription(), filterName))
.build();
}

/** Returns a trace element for a firewall filter term for the given test config. */
@VisibleForTesting
public static TraceElement matchingFirewallFilterTerm(
Expand Down Expand Up @@ -2340,9 +2352,8 @@ IpAccessList filterToIpAccessList(FirewallFilter f) throws VendorConversionExcep
ImmutableList.Builder<AclLine> lines = ImmutableList.builder();
for (FirewallFilter inner : filter.getInner()) {
String filterName = inner.getName();
String lineName = String.format("Match firewall filter %s", filterName);
String matchedDescription = String.format("Matched firewall filter %s", filterName);
lines.add(new AclAclLine(lineName, filterName, TraceElement.of(matchedDescription)));
lines.add(
new AclAclLine(filterName, filterName, matchingFirewallFilter(_filename, filterName)));
}
return IpAccessList.builder().setName(filter.getName()).setLines(lines.build()).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.batfish.representation.juniper.JuniperConfiguration.OSPF_DEAD_INTERVAL_HELLO_MULTIPLIER;
import static org.batfish.representation.juniper.JuniperConfiguration.buildScreen;
import static org.batfish.representation.juniper.JuniperConfiguration.getRouterId;
import static org.batfish.representation.juniper.JuniperConfiguration.matchingFirewallFilter;
import static org.batfish.representation.juniper.JuniperConfiguration.mergeIpAccessListLines;
import static org.batfish.representation.juniper.JuniperConfiguration.toOspfDeadInterval;
import static org.batfish.representation.juniper.JuniperConfiguration.toOspfHelloInterval;
Expand Down Expand Up @@ -174,7 +175,7 @@ public void testCompositeFirewallFilter() {

assertThat(
compositeAcl.getLines(),
contains(hasTraceElement(TraceElement.of("Matched firewall filter F"))));
contains(hasTraceElement(matchingFirewallFilter(config.getFilename(), "F"))));
}

/**
Expand Down

0 comments on commit 3144fb4

Please sign in to comment.