This is an automated email from the ASF dual-hosted git repository.
rawlin pushed a commit to branch 4.1.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/4.1.x by this push:
new b7f8cf5 Fix atscfg ip_allow gen not using v6 number param (#4678)
(#4725)
b7f8cf5 is described below
commit b7f8cf5f17e0f3068d65cb745a093aa9abf5fc6f
Author: Rawlin Peters <[email protected]>
AuthorDate: Thu May 28 09:37:49 2020 -0600
Fix atscfg ip_allow gen not using v6 number param (#4678) (#4725)
(cherry picked from commit 228371c57103d017f34db55d88f8d9ffa346e8ab)
Co-authored-by: Robert O Butts <[email protected]>
---
CHANGELOG.md | 1 +
lib/go-atscfg/ipallowdotconfig.go | 2 +-
lib/go-atscfg/ipallowdotconfig_test.go | 87 ++++++++++++++++++++++++++++++++++
3 files changed, 89 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b478e67..745df50 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -58,6 +58,7 @@ The format is based on [Keep a
Changelog](http://keepachangelog.com/en/1.0.0/).
- Changed the `totalBytes` property of responses to GET requests to
`/deliveryservice_stats` to the more appropriate `totalKiloBytes` in API 2.x
- Fix to traffic_ops_ort to generate logging.yaml files correctly.
- Fixed issue #4650: add the "Vary: Accept-Encoding" header to all responses
from Traffic Ops
+- Fixed ORT config generation not using the coalesce_number_v6 Parameter.
### Deprecated/Removed
- The Traffic Ops `db/admin.pl` script has now been removed. Please use the
`db/admin` binary instead.
diff --git a/lib/go-atscfg/ipallowdotconfig.go
b/lib/go-atscfg/ipallowdotconfig.go
index 74b27c1..4593536 100644
--- a/lib/go-atscfg/ipallowdotconfig.go
+++ b/lib/go-atscfg/ipallowdotconfig.go
@@ -124,7 +124,7 @@ func MakeIPAllowDotConfig(
case ParamCoalesceNumberV6:
if vi, err := strconv.Atoi(val); err != nil {
log.Warnln("MakeIPAllowDotConfig got
param '" + name + "' val '" + val + "' not a number, ignoring!")
- } else if coalesceNumberV6 !=
DefaultCoalesceMaskLenV6 {
+ } else if coalesceNumberV6 !=
DefaultCoalesceNumberV6 {
log.Warnln("MakeIPAllowDotConfig got
multiple param '" + name + "' - ignoring val '" + val + "'!")
} else {
coalesceNumberV6 = vi
diff --git a/lib/go-atscfg/ipallowdotconfig_test.go
b/lib/go-atscfg/ipallowdotconfig_test.go
index a3560f2..428067b 100644
--- a/lib/go-atscfg/ipallowdotconfig_test.go
+++ b/lib/go-atscfg/ipallowdotconfig_test.go
@@ -202,3 +202,90 @@ func TestMakeIPAllowDotConfigEdge(t *testing.T) {
}
}
}
+
+func TestMakeIPAllowDotConfigNonDefaultV6Number(t *testing.T) {
+ serverName := tc.CacheName("server0")
+ serverType := tc.CacheTypeMid
+ toToolName := "to0"
+ toURL := "trafficops.example.net"
+ params := map[string][]string{
+ "purge_allow_ip": []string{"192.168.2.99"},
+ ParamCoalesceMaskLenV4: []string{"24"},
+ ParamCoalesceNumberV4: []string{"3"},
+ ParamCoalesceMaskLenV6: []string{"48"},
+ ParamCoalesceNumberV6: []string{"100"},
+ }
+ childServers := map[tc.CacheName]IPAllowServer{
+ "child0": IPAllowServer{
+ IPAddress: "192.168.2.1",
+ IP6Address: "2001:DB8:1::1/64",
+ },
+ "child1": IPAllowServer{
+ IPAddress: "192.168.2.100/30",
+ IP6Address: "2001:DB8:2::1/64",
+ },
+ "child2": IPAllowServer{
+ IPAddress: "192.168.2.150",
+ },
+ "child3": IPAllowServer{
+ IP6Address: "2001:DB8:2::2/64",
+ },
+ "child4": IPAllowServer{
+ IPAddress: "192.168.2.155/32",
+ },
+ "child5": IPAllowServer{
+ IP6Address: "2001:DB8:3::1",
+ },
+ "child6": IPAllowServer{
+ IP6Address: "2001:DB8:2::3",
+ },
+ "child7": IPAllowServer{
+ IP6Address: "2001:DB8:2::4",
+ },
+ "child8": IPAllowServer{
+ IP6Address: "2001:DB8:2::5/64",
+ },
+ }
+
+ expecteds := []string{
+ "127.0.0.1",
+ "::1",
+ "0.0.0.0-255.255.255.255",
+ "::-ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
+ "172.16.0.0-172.31.255.255",
+ "10.0.0.0-10.255.255.255",
+ "2001:db8:3::1",
+ "192.168.2.0-192.168.2.255",
+ "192.168.2.99",
+ "2001:db8:2::3",
+ "2001:db8:2::4",
+ }
+
+ txt := MakeIPAllowDotConfig(serverName, serverType, toToolName, toURL,
params, childServers)
+
+ lines := strings.Split(txt, "\n")
+
+ if len(lines) == 0 {
+ t.Fatalf("expected: lines actual: no lines\n")
+ }
+
+ commentLine := lines[0]
+ commentLine = strings.TrimSpace(commentLine)
+ if !strings.HasPrefix(commentLine, "#") {
+ t.Errorf("expected: comment line starting with '#', actual:
'%v'\n", commentLine)
+ }
+ if !strings.Contains(commentLine, toToolName) {
+ t.Errorf("expected: comment line containing toolName '%v',
actual: '%v'\n", toToolName, commentLine)
+ }
+ if !strings.Contains(commentLine, toURL) {
+ t.Errorf("expected: comment line containing toURL '%v', actual:
'%v'\n", toURL, commentLine)
+ }
+
+ lines = lines[1:] // remove comment line
+
+ for _, expected := range expecteds {
+ if !strings.Contains(txt, expected) {
+ t.Errorf("expected %+v actual '%v'\n", expected, txt)
+ }
+ }
+}