                          app)]
         (is (unauthorized? response))))))
 
-(defn- get-user-id [session]
-  (let [response (-> (request :get "/api/settings")
-                     (merge session)
-                     app)]
-    (assert (ok? response) {:response response})
-    (UUID/fromString (get-in (json/parse-string (:body response)) [:user :id]))))
-
-(defn- create-congregation! [name]
-  (db/with-db [conn {}]
-    (let [cong-id (UUID/randomUUID)]
-      (dispatcher/command! conn (projections/cached-state)
-                           {:command/type :congregation.command/create-congregation
-                            :command/time (Instant/now)
-                            :command/system "test"
-                            :congregation/id cong-id
-                            :congregation/name name})
-      cong-id)))
-
 (deftest super-user-test
-  (let [cong-id (create-congregation! "sudo test")
+  (let [cong-id (create-congregation-without-user! "sudo test")
         session (login! app)
         user-id (get-user-id session)]
 

      app
      (assert-response ok?)))


(deftest format-for-api-test
  (is (= {} (api/format-for-api {})))

(defn parse-json [body]
  (cond
    (nil? body) body
    (string? body) (json/parse-string body)
    :else (json/parse-string (slurp (io/reader body)))))

(defn read-body [response]
  (let [content-type (get-in response [:headers "Content-Type"])]
    (if (str/starts-with? content-type "application/json")
      (update response :body parse-json)
      response)))

(defn app [request]
  (-> request router/app read-body))
