diff --git a/lib/auth/auth.lisp b/lib/auth/auth.lisp index 55eae32..8b21483 100644 --- a/lib/auth/auth.lisp +++ b/lib/auth/auth.lisp @@ -2,8 +2,12 @@ (defpackage :scopes-auth (:use :common-lisp) - (:local-nicknames (:dom :scopes/web/dom)) + (:local-nicknames (:dom :scopes/web/dom) + (:util :scopes/util)) (:import-from :scopes/web/dom #:div #:label) (:export #:login)) (in-package :scopes-auth) + +(defun login (cred) + (util:lgi cred)) diff --git a/lib/auth/test/config.lisp b/lib/auth/test/config.lisp new file mode 100644 index 0000000..2a02f5c --- /dev/null +++ b/lib/auth/test/config.lisp @@ -0,0 +1,29 @@ +;;;; cl-scopes/lib/auth/test/config +;;;; use: `(let ((t:*current-system* :scopes-auth) ...) +;;;; `(load (t:test-path "config" "")))` +;;;; from scopes-auth/test + +(in-package :scopes-auth/test) + +(config:root :env-keys + '(:address :port + :db-name :db-user :db-password)) + +(config:add :logger :class 'logging:config + :loglevel :info + :logfile (t:test-path "scopes-test.log" "log") + :console nil) + +(config:add :server + :class 'server:config + :port "8899" + :routes + `((("hx") server:message-handler :html-responder cs-hx:response) + (() server:fileserver + :doc-root ,(t:test-path "" "docs")))) +(config:add-action '(:auth :login) #'auth:login) + +(config:add :client + :class 'client:config + :base-url "http://localhost:8899" + :doc-path "/" :api-path "/hx/") diff --git a/lib/auth/test/test-auth.lisp b/lib/auth/test/test-auth.lisp index 4a7ce91..3268421 100644 --- a/lib/auth/test/test-auth.lisp +++ b/lib/auth/test/test-auth.lisp @@ -3,7 +3,13 @@ (defpackage :scopes-auth/test (:use :common-lisp) (:local-nicknames (:auth :scopes-auth) - (:t :scopes/testing)) + (:client :scopes/web/client) + (:config :scopes/config) + (:core :scopes/core) + (:cs-hx :scopes/frontend/cs-hx) + (:logging :scopes/logging) + (:server :scopes/web/server) + (:t :scopes/testing)) (:import-from :scopes/testing #:deftest #:==) (:export #:run)) @@ -12,10 +18,18 @@ ;;;; test runner (defun run () - (let ((t:*test-suite* (t:test-suite "auth"))) + (let ((t:*current-system* :scopes-auth) + (t:*test-suite* (t:test-suite "auth"))) + (load (t:test-path "config" "")) (unwind-protect (progn - (test-login)) - (t:show-result)))) + (core:setup-services) + (let ((server (core:find-service :server)) + (client (core:find-service :client))) + (test-login)) + (t:show-result))))) -(deftest test-login ()) +(deftest test-login () + (let ((cred '(:login "admin" :password "secret"))) + (auth:login cred) + ))