14260: Fix tests.
[arvados.git] / services / api / test / integration / container_auth_test.rb
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}"}