[ARVADOS] updated: 4466447bc02a0557304c9c41f036ca7cf1fa3763

git at public.curoverse.com git at public.curoverse.com
Fri Jun 20 17:07:51 EDT 2014


Summary of changes:
 .../app/controllers/application_controller.rb      |   8 +-
 .../app/views/layouts/application.html.erb         |   2 +-
 apps/workbench/app/views/projects/index.html.erb   |   2 +-
 .../test/integration/anonymous_user_test.rb        | 179 +++++++++++++++++++++
 .../test/integration/pipeline_instances_test.rb    |  64 +-------
 5 files changed, 192 insertions(+), 63 deletions(-)
 create mode 100644 apps/workbench/test/integration/anonymous_user_test.rb

       via  4466447bc02a0557304c9c41f036ca7cf1fa3763 (commit)
       via  c621f23ed0512c2125d2686e1566f2b42677729d (commit)
       via  51b21be9ad1cce39fd941e1f6c588be180d5ab63 (commit)
       via  c9c800c1e520dc6ae2e6fe9b3c40e15db7935635 (commit)
      from  fe098b887198e2eae3a90d2abbff26115ee916f1 (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 4466447bc02a0557304c9c41f036ca7cf1fa3763
Author: radhika <radhika at curoverse.com>
Date:   Fri Jun 20 17:07:13 2014 -0400

    2659: add integration tests for anonymous user configuration support

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index e71bf54..d92d673 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -498,6 +498,8 @@ class ApplicationController < ActionController::Base
           prefs: u.prefs
         }
         @@anonymous_user = u
+      else
+        @@anonymous_user = nil
       end
     elsif current_user && !current_user.andand.is_active
       previous_api_token = Thread.current[:arvados_api_token]
@@ -506,6 +508,8 @@ class ApplicationController < ActionController::Base
         valid_anonymous_token = verify_api_token
         if valid_anonymous_token
           @@anonymous_user = User.current
+        else
+          @@anonymous_user = nil
         end
         Thread.current[:arvados_api_token] = previous_api_token
         verify_api_token
@@ -934,7 +938,7 @@ class ApplicationController < ActionController::Base
   def anonymous_login_enabled
     # to avoid the case where bogus anonymous token is configured,
     # safer to check this object which is set after token verification
-    return @@anonymous_user
+    return @@anonymous_user && Rails.configuration.anonymous_user_token
   end
 
 end
diff --git a/apps/workbench/app/views/projects/index.html.erb b/apps/workbench/app/views/projects/index.html.erb
index 6c9f6f2..3fbbdc0 100644
--- a/apps/workbench/app/views/projects/index.html.erb
+++ b/apps/workbench/app/views/projects/index.html.erb
@@ -67,7 +67,7 @@
         <% else %>    <%# does not meet user agreements %>
           <div class="panel panel-default">
             <div class="panel-body">
-              <p> Please indicate that you have read and accepted the user agreement </p>
+              <p> Please indicate that you have read and accepted the user agreements </p>
             </div>
           </div>
         <% end %>
diff --git a/apps/workbench/test/integration/anonymous_user_test.rb b/apps/workbench/test/integration/anonymous_user_test.rb
new file mode 100644
index 0000000..bface33
--- /dev/null
+++ b/apps/workbench/test/integration/anonymous_user_test.rb
@@ -0,0 +1,179 @@
+require 'integration_helper'
+require 'selenium-webdriver'
+require 'headless'
+
+class AnonymousUserTest < ActionDispatch::IntegrationTest
+  setup do
+    headless = Headless.new
+    headless.start
+    Capybara.current_driver = :selenium
+
+    @anonymous_token = Rails.configuration.anonymous_user_token
+  end
+
+  teardown do
+    Rails.configuration.anonymous_user_token = @anonymous_token
+  end
+
+  def verify_homepage_anonymous_login_configured user, invited
+    within('.navbar-fixed-top') do
+     if user && user['is_active']
+        assert page.has_no_text? 'You are viewing public data'
+        assert page.has_no_link? "Log in"
+        assert page.has_link? "#{user['email']}"
+        find('a', text: "#{user['email']}").click
+        within('.dropdown-menu') do
+          page.has_link? ('Logout')
+          page.has_no_link? ('Inactive')
+          page.has_link? ('Manage ssh keys')
+          page.has_link? ('Manage API tokens')
+        end
+      else
+        assert page.has_text? 'You are viewing public data'
+        if !user
+          assert page.has_link? "Log in"
+        else
+          assert page.has_no_link? 'Log in'
+          assert page.has_link? "#{user['email']}"
+          find('a', text: "#{user['email']}").click
+          within('.dropdown-menu') do
+            page.has_link? ('Logout')
+            page.has_link? ('Inactive')
+            page.has_no_link? ('Manage ssh keys')
+            page.has_no_link? ('Manage API tokens')
+          end
+        end
+      end
+    end
+
+    assert page.has_text? 'Projects shared with me'
+    assert page.has_text? 'A Project'
+    assert page.has_text? 'Unrestricted public data'
+
+    if user && user['is_active']
+      assert page.has_no_text? 'After you assure Google that you want to log in here with your Google account'
+      assert page.has_no_text? 'Please indicate that you have read and accepted the user agreements'
+      assert page.has_no_text? 'You account is inactive'
+      assert page.has_no_text? 'Welcome'
+      assert page.has_text? 'My projects'
+      assert page.has_button? 'Add new project'
+    else
+      assert page.has_text? 'Welcome'
+      assert page.has_no_text? 'My projects'
+      assert page.has_no_button? 'Add new project'
+      if !user
+        assert page.has_text? 'After you assure Google that you want to log in here with your Google account'
+      elsif invited
+        assert page.has_text? 'Please indicate that you have read and accepted the user agreements'
+      else
+        assert page.has_text? 'Your account is inactive'
+      end
+    end
+
+    find('.arv-project-list a,button', text: 'Unrestricted public data').click
+    page.has_text? ('An anonymously accessible project')
+
+    find('a', text: 'Projects').click
+    within('.dropdown-menu') do
+      if user && user['is_active']
+        page.has_text? ('New project')
+      else
+        page.has_no_text? ('New project')
+      end
+      page.has_text? ('Projects shared with me')
+    end
+
+    assert page.has_text? 'A Project'
+    find('a', text: 'A Project').click
+    page.has_text? ('Test project belonging to active user')
+
+    #find('tr[data-kind="arvados#pipelineInstance"]', text: 'New pipeline instance').
+    #  find('a', text: 'Show').click
+  end
+
+  def verify_homepage_anonymous_login_not_configured user, invited
+    within('.navbar-fixed-top') do
+      assert page.has_no_text? 'You are viewing public data'
+      if !user
+        assert page.has_link? 'Log in'
+      else
+        assert page.has_link? "#{user['email']}"
+        find('a', text: "#{user['email']}").click
+        within('.dropdown-menu') do
+          page.has_link? ('Logout')
+          page.has_no_link? ('Inactive')
+        end
+      end
+    end
+
+    if !user
+      assert page.has_text? 'Please log in'
+      assert page.has_text? 'The "Log in" button below will show you a Google sign-in page'
+      assert page.has_no_text? 'My projects'
+      assert page.has_link? "Log in to #{Rails.configuration.site_name}"
+    elsif user['is_active']
+      assert page.has_text? 'My projects'
+      assert page.has_text? 'Projects shared with me'
+    elsif invited
+      assert page.has_text? 'Please check the box below to indicate that you have read and accepted the user agreement'
+    else
+      assert page.has_text? 'Your account is inactive'
+    end
+  end
+
+  [
+    [nil, nil, false],
+    ['anonymous', nil, false],
+    ['inactive', api_fixture('users')['inactive'], true],
+    ['inactive_uninvited', api_fixture('users')['inactive_uninvited'], false],
+    ['active', api_fixture('users')['active'], true]
+  ].each do |token, user, invited|
+    test "visit home page when anonymous login configured for user #{token}" do
+      Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token']
+
+      if !token
+        visit ('/')
+      else
+        visit page_with_token(token)
+      end
+      verify_homepage_anonymous_login_configured user, invited
+    end
+  end
+
+  [
+    [nil, nil, false],
+    ['inactive', api_fixture('users')['inactive'], true],
+    ['inactive_uninvited', api_fixture('users')['inactive_uninvited'], false],
+    ['active', api_fixture('users')['active'], true]
+  ].each do |token, user, invited|
+    test "visit home page when anonymous login configured with bogus token for user #{token}" do
+      Rails.configuration.anonymous_user_token = false
+
+      if !token
+        visit ('/')
+      else
+        visit page_with_token(token)
+      end
+      verify_homepage_anonymous_login_not_configured user, invited
+    end
+  end
+
+  [
+    [nil, nil, false],
+    ['inactive', api_fixture('users')['inactive'], true],
+    ['inactive_uninvited', api_fixture('users')['inactive_uninvited'], false],
+    ['active', api_fixture('users')['active'], true]
+  ].each do |token, user, invited|
+    test "visit home page when anonymous login not configured for user #{token}" do
+      Rails.configuration.anonymous_user_token = false
+
+      if !token
+        visit ('/')
+      else
+        visit page_with_token(token)
+      end
+      verify_homepage_anonymous_login_not_configured user, invited
+    end
+  end
+
+end
diff --git a/apps/workbench/test/integration/pipeline_instances_test.rb b/apps/workbench/test/integration/pipeline_instances_test.rb
index 4fe4631..e339445 100644
--- a/apps/workbench/test/integration/pipeline_instances_test.rb
+++ b/apps/workbench/test/integration/pipeline_instances_test.rb
@@ -83,10 +83,6 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest
 
   # Create a pipeline instance from within a project and run
   test 'Create pipeline inside a project and run' do
-    add_a_collection_and_pipeline_to_project
-  end
-
-  def add_a_collection_and_pipeline_to_project
     visit page_with_token('active_trustedclient')
 
     # Go over to the collections page and select something
@@ -97,7 +93,7 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest
     find('#persistent-selection-count').click
 
     # Add this collection to the project using collections menu from top nav
-    visit '/'
+    visit '/projects'
     find('.arv-project-list a,button', text: 'A Project').click
 
     find('li.selection-menu > a').click
@@ -150,56 +146,4 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest
     assert page.has_text? 'script_version'
   end
 
-  # Visit project as anonymous user and verify that pipeline cannot be modified
-  test 'visit shared project as anonymous user' do
-    add_a_collection_and_pipeline_to_project
-
-    # login as anonymous user and verify that top nav
-    visit page_with_token('anonymous')
-    
-    within('.navbar-fixed-top') do
-      assert page.has_text? 'You are viewing public data'
-      assert page.has_link? 'Log in'
-    end
-
-    assert page.has_text? 'Welcome'
-    assert page.has_no_text? 'My projects'
-    assert page.has_no_button? 'Add new project'
-    assert page.has_text? 'Projects shared with me'
-    assert page.has_text? 'A Project'
-    assert page.has_text? 'Unrestricted public data'
-
-    find('.arv-project-list a,button', text: 'Unrestricted public data').click
-    page.has_text? ('An anonymously accessible project')
-
-    find('a', text: 'Projects').click
-    within('.dropdown-menu') do
-      page.has_no_text? ('New project')
-      page.has_text? ('Projects shared with me')
-    end
-
-    # as anonymous user verify the shared project is accessible
-    visit page_with_token('anonymous')
-    assert page.has_text? 'A Project'
-    find('a', text: 'A Project').click
-    page.has_text? ('Test project belonging to active user')
-
-    #find('tr[data-kind="arvados#pipelineInstance"]', text: 'New pipeline instance').
-    #  find('a', text: 'Show').click
-
-    # as inactive user "A Project" is accessible
-    visit page_with_token('inactive')
-    assert page.has_text? 'A Project'
-    find('.arv-project-list a,button', text: 'Unrestricted public data').click
-    page.has_text? ('An anonymously accessible project')
-    find('a', text: 'Projects').click
-    find('a', text: 'A Project').click
-    page.has_text? ('Test project belonging to active user')
-    find('a', text: 'Projects').click
-    within('.dropdown-menu') do
-      page.has_text? ('New project')
-      page.has_text? ('Projects shared with me')
-    end
-  end
-
 end

commit c621f23ed0512c2125d2686e1566f2b42677729d
Author: radhika <radhika at curoverse.com>
Date:   Fri Jun 20 14:15:42 2014 -0400

    2659: address case when visiting site with anonymous user token

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index 531f286..e71bf54 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -512,6 +512,8 @@ class ApplicationController < ActionController::Base
         if valid_anonymous_token
           Thread.current[:arvados_api_token] = anonymous_user_token
         end
+      else
+        @@anonymous_user = User.current
       end
     end
   end
diff --git a/apps/workbench/app/views/layouts/application.html.erb b/apps/workbench/app/views/layouts/application.html.erb
index dc36d54..c0740ad 100644
--- a/apps/workbench/app/views/layouts/application.html.erb
+++ b/apps/workbench/app/views/layouts/application.html.erb
@@ -53,7 +53,7 @@
           <span class="icon-bar"></span>
         </button>
         <a class="navbar-brand" href="/"><%= Rails.configuration.site_name.downcase rescue Rails.application.class.parent_name %>
-          <% if current_user && !current_user.is_active && anonymous_login_enabled %> . You are viewing public data. <% end %>
+          <% if current_user && !current_user.is_active && anonymous_login_enabled %>  You are viewing public data. <% end %>
         </a>
       </div>
 

commit 51b21be9ad1cce39fd941e1f6c588be180d5ab63
Merge: fe098b8 c9c800c
Author: radhika <radhika at curoverse.com>
Date:   Fri Jun 20 13:17:15 2014 -0400

    Merge branch 'master' into 2659-anonymous-group


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


hooks/post-receive
-- 




More information about the arvados-commits mailing list