This is an automated email from the ASF dual-hosted git repository.
peryder pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 67ba28d Add additional routeResult URL instead of overwriting
existing URL list. (#3476)
new a27e551 Merge pull request #3482 from limited/TC-3476
67ba28d is described below
commit 67ba28ddc4977860bdcb5cf888f910fcf7270e72
Author: Eric Friedrich <[email protected]>
AuthorDate: Thu Apr 11 14:35:21 2019 -0400
Add additional routeResult URL instead of overwriting existing URL list.
(#3476)
Client Steering Delivery Services build up the list of target DS URLs in
the RouteResult object. This commit modified AnonymousBlocking and Regional Geo
Blocking to call setUrl() instead of addUrl() on the RouteResult. The incorrect
addUrl() call will clear out any pre-existing URLs from earlier target DSs.
---
CHANGELOG.md | 2 +
.../traffic_router/core/loc/AnonymousIp.java | 2 +-
.../traffic_router/core/loc/RegionalGeo.java | 2 +-
.../traffic_router/core/loc/RegionalGeoTest.java | 45 ++++++++++++++++++++++
4 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 24d1ebc..c4035e5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -40,6 +40,8 @@ The format is based on [Keep a
Changelog](http://keepachangelog.com/en/1.0.0/).
- Modified Traffic Router logging format to include an additional field for
DNS log entries, namely `rhi`. This defaults to '-' and is only used when EDNS0
client subnet extensions are enabled and a client subnet is present in the
request. When enabled and a subnet is present, the subnet appears in the `chi`
field and the resolver address is in the `rhi` field.
- Changed traffic_ops_ort.pl so that hdr_rw-<ds>.config files are compared
with strict ordering and line duplication when detecting configuration changes.
- Traffic Ops (golang), Traffic Monitor, Traffic Stats are now compiled using
Go version 1.11. Grove was already being compiled with this version which
improves performance for TLS when RSA certificates are used.
+- Issue 3476: Traffic Router returns partial result for CLIENT_STEERING
Delivery Services when Regional Geoblocking or Anonymous Blocking is enabled.
+
## [3.0.0] - 2018-10-30
### Added
diff --git
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/AnonymousIp.java
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/AnonymousIp.java
index 26f8fe9..b61af09 100644
---
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/AnonymousIp.java
+++
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/AnonymousIp.java
@@ -245,7 +245,7 @@ public final class AnonymousIp {
routeResult.setResponseCode(AnonymousIp.BLOCK_CODE);
track.setResult(ResultType.ANON_BLOCK);
if (AnonymousIp.getCurrentConfig().redirectUrl != null)
{
- routeResult.setUrl(new
URL(AnonymousIp.getCurrentConfig().redirectUrl));
+ routeResult.addUrl(new
URL(AnonymousIp.getCurrentConfig().redirectUrl));
}
}
}
diff --git
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/RegionalGeo.java
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/RegionalGeo.java
index 49db525..894cbef 100644
---
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/RegionalGeo.java
+++
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/RegionalGeo.java
@@ -357,7 +357,7 @@ public final class RegionalGeo {
if (result.getType() == DENIED) {
routeResult.setResponseCode(result.getHttpResponseCode());
} else {
- routeResult.setUrl(new URL(createRedirectURIString(httpRequest,
deliveryService, cache, result)));
+ routeResult.addUrl(new URL(createRedirectURIString(httpRequest,
deliveryService, cache, result)));
}
}
diff --git
a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/RegionalGeoTest.java
b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/RegionalGeoTest.java
index 37f8f5d..70441af 100644
---
a/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/RegionalGeoTest.java
+++
b/traffic_router/core/src/test/java/com/comcast/cdn/traffic_control/traffic_router/core/loc/RegionalGeoTest.java
@@ -17,13 +17,25 @@ package
com.comcast.cdn.traffic_control.traffic_router.core.loc;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
+import static org.powermock.api.mockito.PowerMockito.*;
import java.io.File;
import java.io.FileReader;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.regex.Pattern;
import java.util.Set;
import java.util.HashSet;
+import com.comcast.cdn.traffic_control.traffic_router.core.cache.Cache;
+import com.comcast.cdn.traffic_control.traffic_router.core.ds.DeliveryService;
+import com.comcast.cdn.traffic_control.traffic_router.core.request.HTTPRequest;
+import com.comcast.cdn.traffic_control.traffic_router.core.request.Request;
+import
com.comcast.cdn.traffic_control.traffic_router.core.router.HTTPRouteResult;
+import com.comcast.cdn.traffic_control.traffic_router.core.router.StatTracker;
+import
com.comcast.cdn.traffic_control.traffic_router.core.router.TrafficRouter;
+import com.comcast.cdn.traffic_control.traffic_router.geolocation.Geolocation;
+import
com.comcast.cdn.traffic_control.traffic_router.geolocation.GeolocationException;
import org.apache.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
@@ -190,5 +202,38 @@ public class RegionalGeoTest {
assertThat(result.getType(), equalTo(RegionalGeoResultType.ALLOWED));
assertThat(result.getUrl(), equalTo(url));
}
+
+ @Test
+ public void testEnforceWhiteListAllowedRouteResultMultipleUrls() throws
GeolocationException, MalformedURLException {
+ String clientIp = "129.100.254.2";
+ String requestUrl = "http://ds1.example.com/live4";
+
+ HTTPRequest request = new HTTPRequest();
+ request.setClientIP(clientIp);
+ request.setHostname("ds1.example.com");
+ request.applyUrl(new URL(requestUrl));
+
+ StatTracker.Track track = new StatTracker.Track();
+
+ Cache cache = mock(Cache.class);
+
+ DeliveryService ds = mock(DeliveryService.class);
+ when(ds.getId()).thenReturn("ds-geoblock-include");
+ when(ds.createURIString(request, cache)).thenReturn(requestUrl);
+
+ TrafficRouter tr = mock(TrafficRouter.class);
+ when(tr.getClientGeolocation(clientIp, track, ds)).thenReturn(new
Geolocation(42, -71));
+
+ HTTPRouteResult routeResult = new HTTPRouteResult(true);
+ String firstUrl = "http://example.com/url1.m3u8";
+ routeResult.addUrl(new URL(firstUrl));
+
+ RegionalGeo.enforce(tr, request, ds, cache, routeResult, track);
+
+ assertThat(routeResult.getUrls().size(), equalTo(2));
+ assertThat(routeResult.getUrls().get(1).toString(),
equalTo(requestUrl));
+ assertThat(routeResult.getUrls().get(0).toString(), equalTo(firstUrl));
+
+ }
}