Add "create collection" integration test
authorTom Clegg <tom@curoverse.com>
Wed, 9 Apr 2014 03:34:25 +0000 (23:34 -0400)
committerTom Clegg <tom@curoverse.com>
Wed, 9 Apr 2014 03:47:56 +0000 (23:47 -0400)
services/api/test/integration/collections_api_test.rb
services/api/test/integration/permissions_test.rb
services/api/test/test_helper.rb

index 5a3250ea0d2dfc51af4d5e4ee4949057448f8d43..5fa77c3db9a23acf75d079a01bc3ab9886c9ee99 100644 (file)
@@ -4,35 +4,43 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
   fixtures :all
 
   test "should get index" do
-    get "/arvados/v1/collections", {:format => :json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+    get "/arvados/v1/collections", {:format => :json}, auth(:active)
     assert_response :success
     assert_equal "arvados#collectionList", jresponse['kind']
   end
 
   test "get index with filters= (empty string)" do
-    get "/arvados/v1/collections", {:format => :json, :filters => ''}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+    get "/arvados/v1/collections", {:format => :json, :filters => ''}, auth(:active)
     assert_response :success
     assert_equal "arvados#collectionList", jresponse['kind']
   end
 
   test "get index with where= (empty string)" do
-    get "/arvados/v1/collections", {:format => :json, :where => ''}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+    get "/arvados/v1/collections", {:format => :json, :where => ''}, auth(:active)
     assert_response :success
     assert_equal "arvados#collectionList", jresponse['kind']
   end
 
   test "controller 404 response is json" do
-    get "/arvados/v1/thingsthatdonotexist", {:format => :xml}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+    get "/arvados/v1/thingsthatdonotexist", {:format => :xml}, auth(:active)
     assert_response 404
     assert_equal 1, jresponse['errors'].length
     assert_equal true, jresponse['errors'][0].is_a?(String)
   end
 
   test "object 404 response is json" do
-    get "/arvados/v1/groups/zzzzz-j7d0g-o5ba971173cup4f", {}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+    get "/arvados/v1/groups/zzzzz-j7d0g-o5ba971173cup4f", {}, auth(:active)
     assert_response 404
     assert_equal 1, jresponse['errors'].length
     assert_equal true, jresponse['errors'][0].is_a?(String)
   end
 
+  test "store collection as json" do
+    post "/arvados/v1/collections", {
+      format: :json,
+      collection: "{\"manifest_text\":\". bad42fa702ae3ea7d888fef11b46f450+44 0:44:md5sum.txt\\n\",\"uuid\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}"
+    }, auth(:active)
+    assert_response 200
+    assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', jresponse['uuid']
+  end
 end
index 40a77e72c56b3c814ec28c098b7501a319667bb9..bd9685bd5fe099b88087c16c30a717afbb305753 100644 (file)
@@ -3,10 +3,6 @@ require 'test_helper'
 class PermissionsTest < ActionDispatch::IntegrationTest
   fixtures :users, :groups, :api_client_authorizations, :collections
 
-  def auth auth_fixture
-    {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(auth_fixture).api_token}"}
-  end
-
   test "adding and removing direct can_read links" do
     # try to read collection as spectator
     get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
index 8e3399523ea800a43c8afaafae38bc10e0066dbf..a81bfdf9e40c1bb03af90a274a1fe68645c534b0 100644 (file)
@@ -24,6 +24,9 @@ class ActionDispatch::IntegrationTest
   def jresponse
     @jresponse ||= ActiveSupport::JSON.decode @response.body
   end
+  def auth auth_fixture
+    {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(auth_fixture).api_token}"}
+  end
 end
 
 # Ensure permissions are computed from the test fixtures.