mirror of
https://github.com/penpot/penpot.git
synced 2025-08-02 18:58:37 +02:00
🐛 More test fixes.
This commit is contained in:
parent
d546d1fdca
commit
4a395ec761
8 changed files with 76 additions and 105 deletions
42
backend/test/uxbox/tests/test_services_auth.clj
Normal file
42
backend/test/uxbox/tests/test_services_auth.clj
Normal file
|
@ -0,0 +1,42 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) 2019 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.tests.test-services-auth
|
||||
(:require
|
||||
[clojure.test :as t]
|
||||
[promesa.core :as p]
|
||||
[buddy.hashers :as hashers]
|
||||
[uxbox.db :as db]
|
||||
[uxbox.services.core :as sv]
|
||||
[uxbox.tests.helpers :as th]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
(t/use-fixtures :each th/database-reset)
|
||||
|
||||
(t/deftest test-failed-auth
|
||||
(let [user @(th/create-user db/pool 1)
|
||||
event {:username "user1"
|
||||
:type :login
|
||||
:password "foobar"
|
||||
:metadata "1"
|
||||
:scope "foobar"}
|
||||
[err res] (th/try-on
|
||||
(sv/mutation event))]
|
||||
(t/is (nil? res))
|
||||
(t/is (= (:type err) :validation))
|
||||
(t/is (= (:code err) :uxbox.services.auth/wrong-credentials))))
|
||||
|
||||
(t/deftest test-success-auth
|
||||
(let [user @(th/create-user db/pool 1)
|
||||
event {:username "user1"
|
||||
:type :login
|
||||
:password "123123"
|
||||
:metadata "1"
|
||||
:scope "foobar"}
|
||||
[err res] (th/try-on
|
||||
(sv/mutation event))]
|
||||
(t/is (= res (:id user)))
|
||||
(t/is (nil? err))))
|
Loading…
Add table
Add a link
Reference in a new issue