     assert List.first(result.documents).project == "a"
   end
 
-  test "show geometries - all documents for user-1" do
-    conn = get_geometries "user-1", "pass-1"
+  @tag login: {"user-1", "pass-1"}
+  test "show geometries - all documents for user-1", context do
+    conn = get_geometries context.token
     result = Core.Utils.atomize(Poison.decode!(conn.resp_body))
     
     assert length(result.documents) == 2

    assert List.first(result.documents).project == "a"
  end

  test "show multiple documents - all documents for user-1" do
    conn = get_docs "user-1", "pass-1"
    result = Core.Utils.atomize(Poison.decode!(conn.resp_body))
    
    assert length(result.documents) == 2

  end

  defp get_doc id do
    get_doc id, nil
  end
  defp get_doc id, token do
    conn = call_get "/documents/" <> id, token
    { conn, Core.Utils.atomize(Poison.decode!(conn.resp_body)) }
  end
  defp get_docs do
    get_docs nil
  end
  defp get_docs token do
    call_get "/documents/", token
  end
  defp get_geometries do
    get_geometries nil
  end
  defp get_geometries token do
    call_get "/documents/map", token
  end
  defp show_rights token do
    (call_get("/auth/show", token).resp_body)
    |> Poison.decode!
    |> Core.Utils.atomize
    |> get_in([:rights, :readable_projects])
  end
  defp show_rights do
    show_rights nil
  end
  
  defp call_get path, token do
    conn = conn(:get, path)
    conn = if token == nil do conn else put_req_header(conn, "authorization", token) end
    Api.Router.call(conn, @opts)
  end
end
