Merge branch '9857-cwl-acceptlist-re' refs #9857
[arvados.git] / services / api / test / unit / permission_test.rb
index c1b8943773b762e55bb6c664450cfd5bdee091dd..79fc1f29c7bf46a2f1efb3ae8f9dd298f0222015 100644 (file)
@@ -354,4 +354,26 @@ class PermissionTest < ActiveSupport::TestCase
     end
   end
 
+  def container_logs(container, user)
+    Log.readable_by(users(user)).
+      where(object_uuid: containers(container).uuid, event_type: "test")
+  end
+
+  test "container logs created by dispatch are visible to container requestor" do
+    set_user_from_auth :dispatch1
+    Log.create!(object_uuid: containers(:running).uuid,
+                event_type: "test")
+
+    assert_not_empty container_logs(:running, :admin)
+    assert_not_empty container_logs(:running, :active)
+    assert_empty container_logs(:running, :spectator)
+  end
+
+  test "container logs created by dispatch are public if container request is public" do
+    set_user_from_auth :dispatch1
+    Log.create!(object_uuid: containers(:running_older).uuid,
+                event_type: "test")
+
+    assert_not_empty container_logs(:running_older, :anonymous)
+  end
 end