14260: Fix tests.
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Mon, 15 Oct 2018 16:09:35 +0000 (12:09 -0400)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Mon, 15 Oct 2018 16:09:35 +0000 (12:09 -0400)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz@veritasgenetics.com>

apps/workbench/app/models/container_work_unit.rb
services/api/test/fixtures/containers.yml
services/api/test/functional/arvados/v1/containers_controller_test.rb
services/api/test/integration/container_auth_test.rb
services/api/test/unit/container_test.rb

index 964295619af4bf3b738b565ff401007fb203a72b..ef20a7f8f49cfd7ed72f7ff9c51774ca36ddaa74 100644 (file)
@@ -23,7 +23,7 @@ class ContainerWorkUnit < ProxyWorkUnit
     items = []
     container_uuid = if @proxied.is_a?(Container) then uuid else get(:container_uuid) end
     if container_uuid
-      cols = ContainerRequest.columns.map(&:name) - %w(id updated_at mounts secret_mounts)
+      cols = ContainerRequest.columns.map(&:name) - %w(id updated_at mounts secret_mounts runtime_token)
       my_children = @child_proxies || ContainerRequest.select(cols).where(requesting_container_uuid: container_uuid).results if !my_children
       my_child_containers = my_children.map(&:container_uuid).compact.uniq
       grandchildren = {}
index eefb0297c61650406a528e4c226d59f8634d99db..5c5d45f4bc0c5a880775d638bc133752992a454d 100644 (file)
@@ -263,7 +263,8 @@ running_to_be_deleted:
 runtime_token:
   uuid: zzzzz-dz642-20isqbkl8xwnsao
   owner_uuid: zzzzz-tpzed-000000000000000
-  state: Queued
+  state: Locked
+  locked_by_uuid: zzzzz-gj3su-jrriu629zljsnuf
   priority: 1
   created_at: 2016-01-11 11:11:11.111111111 Z
   updated_at: 2016-01-11 11:11:11.111111111 Z
index 8880967ba2e6a3eaa365c8cf21c7b2b834e202a2..452533b9e9a13e93b05f4c28be484e5c8ca23f98 100644 (file)
@@ -153,9 +153,8 @@ class Arvados::V1::ContainersControllerTest < ActionController::TestCase
   end
 
   test 'get runtime_token auth' do
-    authorize_with :dispatch1
+    authorize_with :dispatch2
     c = containers(:runtime_token)
-    assert c.lock, show_errors(c)
     get :auth, id: c.uuid
     assert_response :success
     assert_equal "v2/#{json_response['uuid']}/#{json_response['api_token']}", api_client_authorizations(:container_runtime_token).token
index bec8b5784a09ae77d450f62b87bc1ebdc40d24e2..552cce44b1b58115149cf006522468758d457b18 100644 (file)
@@ -7,14 +7,6 @@ require 'test_helper'
 class ContainerAuthTest < ActionDispatch::IntegrationTest
   fixtures :all
 
-  test "container token validate, Queued" do
-    get "/arvados/v1/containers/current", {
-      :format => :json
-        }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}/#{containers(:runtime_token).uuid}"}
-    # Container is Queued, token cannot be used
-    assert_response 401
-  end
-
   test "container token validate, Running, regular auth" do
     get "/arvados/v1/containers/current", {
       :format => :json
@@ -25,9 +17,6 @@ class ContainerAuthTest < ActionDispatch::IntegrationTest
   end
 
   test "container token validate, Locked, runtime_token" do
-    post "/arvados/v1/containers/#{containers(:runtime_token).uuid}/lock", {
-      :format => :json
-    }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:dispatch1).token}"}
     get "/arvados/v1/containers/current", {
       :format => :json
         }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}/#{containers(:runtime_token).uuid}"}
@@ -36,6 +25,19 @@ class ContainerAuthTest < ActionDispatch::IntegrationTest
     assert_equal containers(:runtime_token).uuid, json_response['uuid']
   end
 
+  test "container token validate, Cancelled, runtime_token" do
+    put "/arvados/v1/containers/#{containers(:runtime_token).uuid}", {
+          :format => :json,
+          :container => {:state => "Cancelled"}
+        }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:dispatch1).token}"}
+    assert_response :success
+    get "/arvados/v1/containers/current", {
+      :format => :json
+        }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}/#{containers(:runtime_token).uuid}"}
+    # Container is Queued, token cannot be used
+    assert_response 401
+  end
+
   test "container token validate, Running, without optional portion" do
     get "/arvados/v1/containers/current", {
       :format => :json
@@ -46,9 +48,6 @@ class ContainerAuthTest < ActionDispatch::IntegrationTest
   end
 
   test "container token validate, Locked, runtime_token, without optional portion" do
-    post "/arvados/v1/containers/#{containers(:runtime_token).uuid}/lock", {
-      :format => :json
-    }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:dispatch1).token}"}
     get "/arvados/v1/containers/current", {
       :format => :json
         }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}"}
@@ -57,9 +56,6 @@ class ContainerAuthTest < ActionDispatch::IntegrationTest
   end
 
   test "container token validate, wrong container uuid" do
-    post "/arvados/v1/containers/#{containers(:runtime_token).uuid}/lock", {
-      :format => :json
-    }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:dispatch1).token}"}
     get "/arvados/v1/containers/current", {
       :format => :json
         }, {'HTTP_AUTHORIZATION' => "Bearer #{api_client_authorizations(:container_runtime_token).token}/#{containers(:running).uuid}"}
index 39fde79a331cd78131bfdc8b094125a74c281e8d..491022ad8d5a9cd6e47e1cf7727a5cba92d54ce4 100644 (file)
@@ -671,7 +671,7 @@ class ContainerTest < ActiveSupport::TestCase
   end
 
   test "Container queued count" do
-    assert_equal 2, Container.readable_by(users(:active)).where(state: "Queued").count
+    assert_equal 1, Container.readable_by(users(:active)).where(state: "Queued").count
   end
 
   test "Container locked cancel" do