[ARVADOS] created: 78fedce2fadbe985c5b7ec0dbe26ad8cddfb6cdb

Git user git at public.curoverse.com
Mon Sep 19 13:44:22 EDT 2016


        at  78fedce2fadbe985c5b7ec0dbe26ad8cddfb6cdb (commit)


commit 78fedce2fadbe985c5b7ec0dbe26ad8cddfb6cdb
Author: Lucas Di Pentima <lucas at curoverse.com>
Date:   Mon Sep 19 14:43:12 2016 -0300

    10029: Added test to check for client_session_id parameter existence and format.

diff --git a/apps/workbench/test/controllers/application_controller_test.rb b/apps/workbench/test/controllers/application_controller_test.rb
index ef2a989..99b80a0 100644
--- a/apps/workbench/test/controllers/application_controller_test.rb
+++ b/apps/workbench/test/controllers/application_controller_test.rb
@@ -334,6 +334,25 @@ class ApplicationControllerTest < ActionController::TestCase
     assert_response 404
   end
 
+  test "requesting to the API server includes client_session_id param" do
+    use_token :active do
+      fixture = api_fixture("collections")["foo_collection_in_aproject"]
+      c = Collection.find(fixture['uuid'])
+
+      got_query = nil
+      stub_api_calls
+      stub_api_client.expects(:post).with do |url, query, opts={}|
+        got_query = query
+        true
+      end.returns fake_api_response('{}', 200, {})
+      c.name = "name change for testing"
+      c.save
+
+      assert_includes got_query, 'client_session_id'
+      assert_match /\d{10}-\d{9}/, got_query['client_session_id']
+    end
+  end
+
   [".navbar .login-menu a",
    ".navbar .login-menu .dropdown-menu a"
   ].each do |css_selector|

commit b751f27e5dadf037003fe103bf170d6eef99154c
Author: Lucas Di Pentima <lucas at curoverse.com>
Date:   Fri Sep 16 14:59:12 2016 -0300

    10029: Added client_session_id to Workbench's client request log.

diff --git a/apps/workbench/config/initializers/lograge.rb b/apps/workbench/config/initializers/lograge.rb
index 24252c8..6d3d246 100644
--- a/apps/workbench/config/initializers/lograge.rb
+++ b/apps/workbench/config/initializers/lograge.rb
@@ -3,7 +3,8 @@ ArvadosWorkbench::Application.configure do
   config.lograge.formatter = Lograge::Formatters::Logstash.new
   config.lograge.custom_options = lambda do |event|
     exceptions = %w(controller action format id)
-    params = event.payload[:params].except(*exceptions)
+    params = {client_session_id: Thread.current[:client_session_id]}.
+             merge(event.payload[:params].except(*exceptions))
     params_s = Oj.dump(params)
     if params_s.length > 1000
       { params_truncated: params_s[0..1000] + "[...]" }

commit 4be4c3e8ee1645a59b5769ffd9ce7abdc6da03cd
Author: Lucas Di Pentima <lucas at curoverse.com>
Date:   Thu Sep 15 17:53:40 2016 -0300

    10029: Added a session id for every new workbench request, to be sent as a parameter to the API server.

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 10c33c3..cf9f223 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -18,6 +18,7 @@ class ApplicationController < ActionController::Base
   before_filter :check_user_profile, except: ERROR_ACTIONS
   before_filter :load_filters_and_paging_params, except: ERROR_ACTIONS
   before_filter :find_object_by_uuid, except: [:create, :index, :choose] + ERROR_ACTIONS
+  before_filter :set_client_session_id, except: ERROR_ACTIONS
   theme :select_theme
 
   begin
@@ -31,6 +32,12 @@ class ApplicationController < ActionController::Base
                 with: :render_exception)
   end
 
+  def set_client_session_id
+    # Session ID format: '<timestamp>-<9_digits_random_number>'
+    client_session_id = "#{Time.new.to_i}-#{sprintf('%09d', rand(0..10**9-1))}"
+    Thread.current[:client_session_id] = client_session_id
+  end
+
   def set_cache_buster
     response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
     response.headers["Pragma"] = "no-cache"
diff --git a/apps/workbench/app/models/arvados_api_client.rb b/apps/workbench/app/models/arvados_api_client.rb
index 13d4a24..df77786 100644
--- a/apps/workbench/app/models/arvados_api_client.rb
+++ b/apps/workbench/app/models/arvados_api_client.rb
@@ -114,6 +114,7 @@ class ArvadosApiClient
                            Thread.current[:reader_tokens] ||
                            []) +
                           [Rails.configuration.anonymous_user_token]).to_json,
+      'client_session_id' => (Thread.current[:client_session_id] || ''),
     }
     if !data.nil?
       data.each do |k,v|

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list