[ARVADOS] updated: 1.3.0-389-gebf4385ee

Git user git at public.curoverse.com
Tue Feb 26 13:46:54 EST 2019


Summary of changes:
 apps/workbench/app/views/layouts/body.html.erb       |  8 ++++----
 apps/workbench/config/application.default.yml        |  3 +++
 .../config/initializers/validate_wb2_url_config.rb   | 20 ++++++++++++++++++++
 .../test/integration/application_layout_test.rb      |  6 ++++++
 4 files changed, 33 insertions(+), 4 deletions(-)
 create mode 100644 apps/workbench/config/initializers/validate_wb2_url_config.rb

       via  ebf4385eee0408a357641254aac688ecc713be6f (commit)
      from  d1fcb330f81e0f3d3a2a817340cbd499a47b047e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit ebf4385eee0408a357641254aac688ecc713be6f
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date:   Tue Feb 26 15:43:31 2019 -0300

    14794: Validates workbench2_url config at startup.
    
    * In case of errors, a warning message is logged & config set to false.
    * Enhanced test set.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/apps/workbench/app/views/layouts/body.html.erb b/apps/workbench/app/views/layouts/body.html.erb
index c2ddda8c7..b2cd097f3 100644
--- a/apps/workbench/app/views/layouts/body.html.erb
+++ b/apps/workbench/app/views/layouts/body.html.erb
@@ -85,11 +85,11 @@ SPDX-License-Identifier: AGPL-3.0 %>
                 <% if Rails.configuration.workbench2_url %>
                 <li role="menuitem">
                   <%
-                    # Remove any trailing '/'
-                    r = /^(.*?)[\/]*$/
-                    wb2_url = r.match(Rails.configuration.workbench2_url)[1]
+                    wb2_url = Rails.configuration.workbench2_url
+                    wb2_url += '/' if wb2_url[-1] != '/'
+                    wb2_url += 'token'
                   %>
-                  <form action="<%= wb2_url %>/token" method="GET">
+                  <form action="<%= wb2_url %>" method="GET">
                     <input type="hidden" name="api_token" value="<%= Thread.current[:arvados_api_token] %>">
                     <button role="menuitem" type="submit">
                       <i class="fa fa-lg fa-share-square fa-fw"></i> Go to Workbench 2
diff --git a/apps/workbench/config/application.default.yml b/apps/workbench/config/application.default.yml
index 161e74540..ccc7e4bbd 100644
--- a/apps/workbench/config/application.default.yml
+++ b/apps/workbench/config/application.default.yml
@@ -330,4 +330,7 @@ common:
   #
   # Add an item to the user menu pointing to workbench2_url, if not false.
   #
+  # Example:
+  # workbench2_url: https://workbench2.qr1hi.arvadosapi.com
+  #
   workbench2_url: false
diff --git a/apps/workbench/config/initializers/validate_wb2_url_config.rb b/apps/workbench/config/initializers/validate_wb2_url_config.rb
new file mode 100644
index 000000000..9725e7d97
--- /dev/null
+++ b/apps/workbench/config/initializers/validate_wb2_url_config.rb
@@ -0,0 +1,20 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+require 'uri'
+
+if Rails.configuration.workbench2_url
+    begin
+        if !URI.parse(Rails.configuration.workbench2_url).is_a?(URI::HTTP)
+            Rails.logger.warn("workbench2_url config is not an HTTP URL: #{Rails.configuration.workbench2_url}")
+            Rails.configuration.workbench2_url = false
+        elsif /.*[\/]{2,}$/.match(Rails.configuration.workbench2_url)
+            Rails.logger.warn("workbench2_url config shouldn't have multiple trailing slashes: #{Rails.configuration.workbench2_url}")
+            Rails.configuration.workbench2_url = false
+        end
+    rescue URI::InvalidURIError
+        Rails.logger.warn("workbench2_url config invalid URL: #{Rails.configuration.workbench2_url}")
+        Rails.configuration.workbench2_url = false
+    end
+end
diff --git a/apps/workbench/test/integration/application_layout_test.rb b/apps/workbench/test/integration/application_layout_test.rb
index 75f2e836b..77b08368c 100644
--- a/apps/workbench/test/integration/application_layout_test.rb
+++ b/apps/workbench/test/integration/application_layout_test.rb
@@ -142,7 +142,13 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
 
   [
     [false, false],
+    ['http://wb2.example.org//', false],
+    ['ftp://wb2.example.org', false],
+    ['wb2.example.org', false],
     ['http://wb2.example.org', true],
+    ['https://wb2.example.org', true],
+    ['http://wb2.example.org/', true],
+    ['https://wb2.example.org/', true],
   ].each do |wb2_url_config, wb2_menu_appear|
     test "workbench2_url=#{wb2_url_config} should#{wb2_menu_appear ? '' : ' not'} show WB2 menu" do
       Rails.configuration.workbench2_url = wb2_url_config

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list