cl-scopes/lib/auth/test/test-auth.lisp

42 lines
1.3 KiB
Common Lisp

;;;; cl-scopes/lib/auth/test - tests for the scopes-auth system
(defpackage :scopes-auth/test
(:use :common-lisp)
(:local-nicknames (:auth :scopes-auth)
(:web :scopes-auth/web)
(:client :scopes/web/client)
(:config :scopes/config)
(:core :scopes/core)
(:cs-hx :scopes/frontend/cs-hx)
(:logging :scopes/logging)
(:server :scopes/web/server)
(:shape :scopes/shape)
(:t :scopes/testing))
(:import-from :scopes/testing #:deftest #:==)
(:export #:run))
(in-package :scopes-auth/test)
;;;; test runner
(defun run ()
(let ((t:*current-system* :scopes-auth)
(t:*test-suite* (t:test-suite "auth")))
(load (t:test-path "config" "etc"))
(unwind-protect
(progn
(core:setup-services)
(let ((server (core:find-service :server))
(client (core:find-service :client)))
(test-login)))
(core:shutdown)
(t:show-result))))
(deftest test-login ()
(let (cred pr1)
(setf cred '(:name "admin" :password "secret"))
(== (auth:login cred) nil)
(setf cred '(:name "admin" :password "sc0pes"))
(setf pr1 (auth:login cred))
(== (shape:head-value pr1 :name) :admin)
))