This is an automated email from the ASF dual-hosted git repository.

elsloo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git

commit cd88a007ad02d8fe852670eb224f461ca58c7ca0
Author: PeterRyder <peter.w.ry...@gmail.com>
AuthorDate: Mon Dec 4 14:46:52 2017 -0500

    Initial commit of Anonymous Blocking in TO
---
 .../20171201000000_add_anonymous_blocking.sql         | 19 +++++++++++++++++++
 traffic_ops/app/lib/API/Deliveryservice.pm            |  9 +++++++++
 traffic_ops/app/lib/Fixtures/Deliveryservice.pm       |  6 ++++++
 .../Schema/Result/DeliveryServiceInfoForDomainList.pm |  4 +++-
 .../Schema/Result/DeliveryServiceInfoForServerList.pm |  4 +++-
 traffic_ops/app/lib/Schema/Result/Deliveryservice.pm  |  7 +++++++
 traffic_ops/app/lib/UI/DeliveryService.pm             |  3 +++
 traffic_ops/app/lib/UI/Topology.pm                    |  2 ++
 traffic_ops/app/t/api/1.2/deliveryservice.t           |  2 ++
 traffic_ops/app/t/deliveryservice.t                   |  7 ++++++-
 .../app/templates/delivery_service/_form.html.ep      | 15 +++++++++++++++
 .../app/templates/delivery_service/add.html.ep        |  4 ++++
 .../app/templates/delivery_service/edit.html.ep       |  4 ++++
 13 files changed, 83 insertions(+), 3 deletions(-)

diff --git 
a/traffic_ops/app/db/migrations/20171201000000_add_anonymous_blocking.sql 
b/traffic_ops/app/db/migrations/20171201000000_add_anonymous_blocking.sql
new file mode 100644
index 0000000..4aab170
--- /dev/null
+++ b/traffic_ops/app/db/migrations/20171201000000_add_anonymous_blocking.sql
@@ -0,0 +1,19 @@
+/*
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+      http://www.apache.org/licenses/LICENSE-2.0
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+*/
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+alter table deliveryservice add column anonymous_blocking_enabled int default 
0;
+
+-- +goose Down
+-- SQL section 'Down' is executed when this migration is rolled back
+alter table deliveryservice drop column anonymous_blocking_enabled;
diff --git a/traffic_ops/app/lib/API/Deliveryservice.pm 
b/traffic_ops/app/lib/API/Deliveryservice.pm
index 99a3b20..e64eaf8 100644
--- a/traffic_ops/app/lib/API/Deliveryservice.pm
+++ b/traffic_ops/app/lib/API/Deliveryservice.pm
@@ -101,6 +101,7 @@ sub index {
                push(
                        @data, {
                                "active"               => \$row->active,
+                               "anonymousBlockingEnabled" => 
$row->anonymous_blocking_enabled
                                "cacheurl"             => $row->cacheurl,
                                "ccrDnsTtl"            => $row->ccr_dns_ttl,
                                "cdnId"                => $row->cdn->id,
@@ -223,6 +224,7 @@ sub show {
                push(
                        @data, {
                                "active"               => \$row->active,
+                               "anonymousBlockingEnabled" => 
$row->anonymous_blocking_enabled,
                                "cacheurl"             => $row->cacheurl,
                                "ccrDnsTtl"            => $row->ccr_dns_ttl,
                                "cdnId"                => $row->cdn->id,
@@ -341,6 +343,7 @@ sub update {
 
        my $values = {
                active                 => $params->{active},
+               anonymous_blocking_enabled => 
$params->{anonymousBlockingEnabled},
                cacheurl               => $params->{cacheurl},
                ccr_dns_ttl            => $params->{ccrDnsTtl},
                cdn_id                 => $params->{cdnId},
@@ -439,6 +442,7 @@ sub update {
                push(
                        @response, {
                                "active"                   => $rs->active,
+                               "anonymousBlockingEnabled" => 
$rs->anonymous_blocking_enabled,
                                "cacheurl"                 => $rs->cacheurl,
                                "ccrDnsTtl"                => $rs->ccr_dns_ttl,
                                "cdnId"                    => $rs->cdn->id,
@@ -572,6 +576,7 @@ sub safe_update {
                push(
                        @response, {
                                "active"                   => $rs->active,
+                               "anonymousBlockingEnabled" => 
$rs->anonymous_blocking_enabled,
                                "cacheurl"                 => $rs->cacheurl,
                                "ccrDnsTtl"                => $rs->ccr_dns_ttl,
                                "cdnId"                    => $rs->cdn->id,
@@ -681,6 +686,7 @@ sub create {
 
        my $values = {
                active                 => $params->{active},
+               anonymous_blocking_enabled => 
$params->{anonymousBlockingEnabled},
                cacheurl               => $params->{cacheurl},
                ccr_dns_ttl            => $params->{ccrDnsTtl},
                cdn_id                 => $params->{cdnId},
@@ -790,6 +796,7 @@ sub create {
                push(
                        @response, {
                                "active"                   => $insert->active,
+                               "anonymousBlockingEnabled" => 
$insert->anonymous_blocking_enabled,
                                "cacheurl"                 => $insert->cacheurl,
                                "ccrDnsTtl"                => 
$insert->ccr_dns_ttl,
                                "cdnId"                    => $insert->cdn->id,
@@ -984,6 +991,7 @@ sub get_deliveryservices_by_serverId {
                        push(
                                @data, {
                                        "active"               => \$row->active,
+                                       "anonymousBlockingEnabled" => 
$row->anonymous_blocking_enabled,
                                        "cacheurl"             => 
$row->cacheurl,
                                        "ccrDnsTtl"            => 
$row->ccr_dns_ttl,
                                        "cdnId"                => $row->cdn->id,
@@ -1084,6 +1092,7 @@ sub get_deliveryservices_by_userId {
                        push(
                                @data, {
                                        "active"               => \$row->active,
+                                       "anonymousBlockingEnabled" => 
$row->anonymous_blocking_enabled,
                                        "cacheurl"             => 
$row->cacheurl,
                                        "ccrDnsTtl"            => 
$row->ccr_dns_ttl,
                                        "cdnId"                => $row->cdn->id,
diff --git a/traffic_ops/app/lib/Fixtures/Deliveryservice.pm 
b/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
index 7adbea7..b858932 100644
--- a/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Fixtures/Deliveryservice.pm
@@ -58,6 +58,7 @@ my %definition_for = (
                        initial_dispersion    => 1,
                        regional_geo_blocking => 1,
                        logs_enabled          => 1,
+                       anonymous_blocking_enabled => 1,
                },
        },
        ds_cdn2 => {
@@ -99,6 +100,7 @@ my %definition_for = (
                        regional_geo_blocking => 0,
                        ipv6_routing_enabled  => 0,
                        logs_enabled          => 0,
+                       anonymous_blocking_enabled => 0,
                },
        },
        ds_cdn3 => {
@@ -140,6 +142,7 @@ my %definition_for = (
                        regional_geo_blocking => 0,
                        ipv6_routing_enabled  => 0,
                        logs_enabled          => 0,
+                       anonymous_blocking_enabled => 0,
                },
        },
        ds_cdn4 => {
@@ -181,6 +184,7 @@ my %definition_for = (
                        regional_geo_blocking => 0,
                        ipv6_routing_enabled  => 0,
                        logs_enabled          => 1,
+                       anonymous_blocking_enabled => 0,
                },
        },
        ds_dns => {
@@ -222,6 +226,7 @@ my %definition_for = (
                        regional_geo_blocking => 0,
                        ipv6_routing_enabled  => 0,
                        logs_enabled          => 0,
+                       anonymous_blocking_enabled => 0,
                },
        },
        ds_http_no_cache => {
@@ -263,6 +268,7 @@ my %definition_for = (
                        regional_geo_blocking => 0,
                        ipv6_routing_enabled  => 0,
                        logs_enabled          => 0,
+                       anonymous_blocking_enabled => 0,
                },
        },
        steering_ds1 => {
diff --git 
a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm 
b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
index fe37913..e8d5ce9 100644
--- a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
+++ b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForDomainList.pm
@@ -61,7 +61,8 @@ SELECT
     deliveryservice.cacheurl,
     deliveryservice.remap_text,
     deliveryservice.protocol,
-    deliveryservice.profile
+    deliveryservice.profile,
+    deliveryservice.anonymous_blocking_enabled
 FROM
     deliveryservice
     JOIN deliveryservice_regex ON deliveryservice_regex.deliveryservice = 
deliveryservice.id
@@ -106,6 +107,7 @@ __PACKAGE__->add_columns(
        "fq_pacing_rate",              { data_type => "bigint",  is_nullable => 
0 },   
        "origin_shield",               { data_type => "varchar", is_nullable => 
0, size => 1024 },
        "profile",                     { data_type => "integer", is_nullable => 
1},
+    "anonymous_blocking_enabled",  { data_type => "tinyint", is_nullable => 1, 
size => 1 },
 );
 
 1;
diff --git 
a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm 
b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
index 2d84155..97c441f 100644
--- a/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
+++ b/traffic_ops/app/lib/Schema/Result/DeliveryServiceInfoForServerList.pm
@@ -61,7 +61,8 @@ SELECT
     deliveryservice.remap_text as remap_text,
     mid_header_rewrite as mid_header_rewrite,
     deliveryservice.protocol as protocol,
-    deliveryservice.profile as profile
+    deliveryservice.profile as profile,
+    deliveryservice.anonymous_blocking_enabled as anonymous_blocking_enabled
 FROM
     deliveryservice
         JOIN deliveryservice_regex ON deliveryservice_regex.deliveryservice = 
deliveryservice.id
@@ -99,6 +100,7 @@ __PACKAGE__->add_columns(
         "fq_pacing_rate",              { data_type => "bigint",  is_nullable 
=> 0},
        "origin_shield",               { data_type => "varchar", is_nullable => 
0, size => 1024 },
        "profile",                     { data_type => "integer", is_nullable => 
1},
+    "anonymous_blocking_enabled",  { data_type => "tinyint", is_nullable => 1, 
size => 1 },
 );
 
 1;
diff --git a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm 
b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
index f37e415..5eca585 100644
--- a/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
+++ b/traffic_ops/app/lib/Schema/Result/Deliveryservice.pm
@@ -41,6 +41,11 @@ __PACKAGE__->table("deliveryservice");
   default_value: false
   is_nullable: 0
 
+=head2 anonymous_blocking_enabled
+  data_type: 'integer'
+  default_value: 0
+  is_nullable: 1
+
 =head2 dscp
 
   data_type: 'bigint'
@@ -326,6 +331,8 @@ __PACKAGE__->add_columns(
   { data_type => "text", is_nullable => 0 },
   "active",
   { data_type => "boolean", default_value => \"false", is_nullable => 0 },
+  "anonymous_blocking_enabled",
+  { data_type => "integer", default_value => 0, is_nullable => 1 },
   "dscp",
   { data_type => "bigint", is_nullable => 0 },
   "signing_algorithm",
diff --git a/traffic_ops/app/lib/UI/DeliveryService.pm 
b/traffic_ops/app/lib/UI/DeliveryService.pm
index 4443349..a7e45a3 100644
--- a/traffic_ops/app/lib/UI/DeliveryService.pm
+++ b/traffic_ops/app/lib/UI/DeliveryService.pm
@@ -257,6 +257,7 @@ sub read {
                                "regional_geo_blocking"       => 
$row->regional_geo_blocking,
                                "logs_enabled"                => 
\$row->logs_enabled,
                                "deep_caching_type"           => 
$row->deep_caching_type,
+                               "anonymous_blocking_enabled"  => 
$row->anonymous_blocking_enabled,
                        }
                );
        }
@@ -846,6 +847,7 @@ sub update {
                        initial_dispersion => $self->paramAsScalar( 
'ds.initial_dispersion', 1 ),
                        logs_enabled       => 
$self->paramAsScalar('ds.logs_enabled'),
                        deep_caching_type  => 
$self->paramAsScalar('ds.deep_caching_type'),
+                       anonymous_blocking_enabled => 
$self->paramAsScalar('ds.anonymous_blocking_enabled'),
                );
 
                my $typename = $self->typename();
@@ -1088,6 +1090,7 @@ sub create {
                                logs_enabled       => 
$self->paramAsScalar('ds.logs_enabled'),
                                tenant_id => $tenant_id,
                                deep_caching_type  => 
$self->paramAsScalar('ds.deep_caching_type'),
+                               anonymous_blocking_enabled => 
$self->paramAsScalar('ds.anonymous_blocking_enabled'),
                };
 
                my $insert = 
$self->db->resultset('Deliveryservice')->create($new_ds);
diff --git a/traffic_ops/app/lib/UI/Topology.pm 
b/traffic_ops/app/lib/UI/Topology.pm
index ee0e750..be96d09 100644
--- a/traffic_ops/app/lib/UI/Topology.pm
+++ b/traffic_ops/app/lib/UI/Topology.pm
@@ -544,6 +544,8 @@ sub gen_crconfig_json {
         $data_obj->{'deliveryServices'}->{ $row->xml_id }->{'soa'}->{'admin'}  
 = $cdn_soa_admin;
         $data_obj->{'deliveryServices'}->{ $row->xml_id 
}->{'ip6RoutingEnabled'} = $row->ipv6_routing_enabled ? 'true' : 'false';
 
+        $data_obj->{'deliveryServices'}->{ $row->xml_id 
}->{'anonymousBlockingEnabled'} = $row->anonymous_blocking_enabled ? 'true' : 
'false';
+
     }
 
     my $rs_dns = $self->db->resultset('Staticdnsentry')->search(
diff --git a/traffic_ops/app/t/api/1.2/deliveryservice.t 
b/traffic_ops/app/t/api/1.2/deliveryservice.t
index c34eb76..f79abec 100644
--- a/traffic_ops/app/t/api/1.2/deliveryservice.t
+++ b/traffic_ops/app/t/api/1.2/deliveryservice.t
@@ -163,6 +163,7 @@ ok 
$t->get_ok("/api/1.2/deliveryservices?logsEnabled=true")->status_is(200)->or(
                                "typeId" => 36,
                                "tenantId" => $tenant_id,
                                "xmlId" => "ds_http",
+                               "anonymousBlockingEnabled" => 1,
                        })->status_is(200)->or( sub { diag 
$t->tx->res->content->asset->{content}; } )
                        ->json_is( "/response/0/active" => 0)
                        ->json_is( "/response/0/tenantId" => $tenant_id)
@@ -174,6 +175,7 @@ ok 
$t->get_ok("/api/1.2/deliveryservices?logsEnabled=true")->status_is(200)->or(
                        ->json_is( "/response/0/orgServerFqdn" => 
"http://10.75.168.91";)
                        ->json_is( "/response/0/protocol" => 1)
                        ->json_is( "/response/0/type" => "HTTP")
+                       ->json_is( "/response/0/anonymousBlockingEnabled" => 1)
                , 'Is the HTTP delivery service created?';
 
        ok $t->post_ok('/api/1.2/deliveryservices' => {Accept => 
'application/json'} => json => {
diff --git a/traffic_ops/app/t/deliveryservice.t 
b/traffic_ops/app/t/deliveryservice.t
index 5e017dc..b0f643c 100644
--- a/traffic_ops/app/t/deliveryservice.t
+++ b/traffic_ops/app/t/deliveryservice.t
@@ -99,6 +99,7 @@ ok $t->post_ok(
                'ds.display_name'                => 'display name 1',
                'ds.regional_geo_blocking'       => '1',
                'ds.geolimit_redirect_url'       => '',
+               'ds.anonymous_blocking_enabled'  => '0',
        }
 )->status_is(302), "create HTTP delivery service";
 my $t1_id = &get_ds_id('tst_xml_id_1');
@@ -151,6 +152,7 @@ ok $t->post_ok(
                'ds.display_name'                => 'display name 2',
                'ds.regional_geo_blocking'       => '0',
                'ds.geolimit_redirect_url'       => '',
+               'ds.anonymous_blocking_enabled'  => '1',
        }
 )->status_is(302), "create DNS DeliveryService";
 $t2_id = &get_ds_id('tst_xml_id_2');
@@ -206,6 +208,7 @@ ok $t->post_ok(
                'ds.display_name'                => 'display name 3',
                'ds.regional_geo_blocking'       => '0',
                'ds.geolimit_redirect_url'       => 'http://knutsel3.com',
+               'ds.anonymous_blocking_enabled'  => '0',
        }
 )->status_is(302), "create HTTP_NO_CACHE deliveryservice";
 
@@ -230,7 +233,9 @@ ok $t->get_ok('/datadeliveryservice')->
        ->json_is( '/0/display_name' => 'display name 1' )
        ->json_is( '/0/regional_geo_blocking' => '1' )
        ->json_is( '/0/regional_geo_blocking' => '1' )
-       ->json_is( '/1/regional_geo_blocking' => '0' ),
+       ->json_is( '/1/regional_geo_blocking' => '0' )
+       ->json_is( '/0/anonymous_blocking_enabled' => '0' )
+       ->json_is( '/1/anonymous_blocking_enabled' => '1' ),
        "validate delivery services were created";
 
 $t2_id = &get_ds_id('tst_xml_id_2');
diff --git a/traffic_ops/app/templates/delivery_service/_form.html.ep 
b/traffic_ops/app/templates/delivery_service/_form.html.ep
index 86def8d..35b72a5 100644
--- a/traffic_ops/app/templates/delivery_service/_form.html.ep
+++ b/traffic_ops/app/templates/delivery_service/_form.html.ep
@@ -598,6 +598,21 @@
                        <% } %>
         <% } %>
        </div>
+       <div class="block form-row" id='anonymous_blocking_enabled_row'>
+               <% unless (field('ds.anonymous_blocking_enabled')->valid) { %>
+                       <span class="field-with-error"><%= 
field('ds.anonymous_blocking_enabled')->error %></span>
+               <% } %>
+               %= label_for 'anonymous_blocking_enabled' => 'Anonymous 
Blocking', class => 'label'
+               <% if ($priv_level >= 20) { %>
+                       %= field('ds.anonymous_blocking_enabled')->select([ 
[Disabled => 0], [Enabled => 1]]);
+               <% } else { %>
+                       <% if ($ds->anonymous_blocking_enabled == 0) { %>
+                               %= 
field('ds.anonymous_blocking_enabled')->text(class => 'field', value =>  
'Disabled', readonly => 'readonly');
+                       <% } else { %>
+                               %= 
field('ds.anonymous_blocking_enabled')->text(class => 'field', value =>  
'Enabled', readonly => 'readonly');
+                       <% } %>
+               <% } %>
+  </div>
        <div class="block form-row" id="active_row">
                <% unless (field('ds.active')->valid) { %>
                        <span class="field-with-error"><%= 
field('ds.active')->error %></span>
diff --git a/traffic_ops/app/templates/delivery_service/add.html.ep 
b/traffic_ops/app/templates/delivery_service/add.html.ep
index e6cc5d8..bb8521b 100644
--- a/traffic_ops/app/templates/delivery_service/add.html.ep
+++ b/traffic_ops/app/templates/delivery_service/add.html.ep
@@ -143,6 +143,7 @@
             $('#regexp_add').show(speed);
             $('#geo_limit_countries_row').show(speed);
             check_geolimit_redirect_url_row_showhide(1, speed);
+            $('#anonymous_blocking_enabled_row').show(speed);
                }
                else if (type_selected.match(/^DNS/)) {
                        $("#regexp_selector 
:nth-child(3)").attr('disabled','disabled');
@@ -186,6 +187,7 @@
             $('#regexp_add').show(speed);
             $('#geo_limit_countries_row').show(speed);
             check_geolimit_redirect_url_row_showhide(0, speed);
+            $('#anonymous_blocking_enabled_row').show(speed);
                }
                else if (type_selected.match(/^ANY_MAP$/)) {
             $('#protocoli_row').hide(speed);
@@ -226,6 +228,7 @@
             $('#remap_text_row').show(speed);
             $('#regexp_add').show(speed);
             $('#geo_limit_countries_row').show(speed);
+            $('#anonymous_blocking_enabled_row').hide(speed);
                }
                else if (type_selected.match(/STEERING$/)) {
             $('#protocoli_row').show(speed);
@@ -272,6 +275,7 @@
             $('#regexp_add').hide(speed);
             $('#geo_limit_countries_row').show(speed);
             check_geolimit_redirect_url_row_showhide(0, speed);
+            $('#anonymous_blocking_enabled_row').hide(speed);
                }
                //
        }
diff --git a/traffic_ops/app/templates/delivery_service/edit.html.ep 
b/traffic_ops/app/templates/delivery_service/edit.html.ep
index 0c51145..76c83cb 100644
--- a/traffic_ops/app/templates/delivery_service/edit.html.ep
+++ b/traffic_ops/app/templates/delivery_service/edit.html.ep
@@ -236,6 +236,7 @@ function setup_form(speed) {
             $('#regexp_add').show(speed);
             $('#steering_button').hide(speed);
            check_geolimit_redirect_url_row_showhide(1, speed);
+            $('#anonymous_blocking_enabled_row').show(speed);
                }
                else if (type_selected.match(/^DNS/)) {
                        $("#regexp_selector 
:nth-child(3)").attr('disabled','disabled');
@@ -278,6 +279,7 @@ function setup_form(speed) {
             $('#regexp_add').show(speed);
             $('#steering_button').hide(speed);
            $('#geolimit_redirect_url_row').hide(speed);
+            $('#anonymous_blocking_enabled_row').show(speed);
                }
                else if (type_selected.match(/^ANY_MAP$/)) {
             $('#protocoli_row').hide(speed);
@@ -318,6 +320,7 @@ function setup_form(speed) {
             $('#regional_geo_blocking_row').show(speed);
             $('#regexp_add').show(speed);
             $('#steering_button').hide(speed);
+            $('#anonymous_blocking_enabled_row').hide(speed);
                }
                else if (type_selected.match(/STEERING$/)) {
             $('#protocoli_row').show(speed);
@@ -366,6 +369,7 @@ function setup_form(speed) {
             $('#server_assignment_button').hide(speed);
             $('#steering_button').show(speed);
             $('#geo_limit_countries_row').show(speed);
+            $('#anonymous_blocking_enabled_row').hide(speed);
                }
                //
        }

-- 
To stop receiving notification emails like this one, please contact
els...@apache.org.

Reply via email to