auth test, work in progress: get static login data from config / .env
This commit is contained in:
parent
0cd12b377b
commit
5c1838b347
6 changed files with 17 additions and 9 deletions
|
@ -49,7 +49,6 @@
|
||||||
(let* ((key (str:concat prefix (string sl)))
|
(let* ((key (str:concat prefix (string sl)))
|
||||||
(env-val (uiop:getenv key))
|
(env-val (uiop:getenv key))
|
||||||
(dotenv-val (if dotenv-data (gethash key dotenv-data))))
|
(dotenv-val (if dotenv-data (gethash key dotenv-data))))
|
||||||
;(format t "~&init after config:root key: ~s, env-val ~s~%" key dotenv-val)
|
|
||||||
(if env-val
|
(if env-val
|
||||||
(setf (gethash sl data) env-val)
|
(setf (gethash sl data) env-val)
|
||||||
(setf (gethash sl data) dotenv-val))))))
|
(setf (gethash sl data) dotenv-val))))))
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
(:local-nicknames (:config :scopes/config)
|
(:local-nicknames (:config :scopes/config)
|
||||||
(:message :scopes/core/message)
|
(:message :scopes/core/message)
|
||||||
(:shape :scopes/shape)
|
(:shape :scopes/shape)
|
||||||
|
(:util :scopes/util)
|
||||||
(:alx :alexandria))
|
(:alx :alexandria))
|
||||||
(:export #:*root* #:default-setup #:default-actions
|
(:export #:*root* #:default-setup #:default-actions
|
||||||
#:find-service #:setup-services
|
#:find-service #:setup-services
|
||||||
|
|
|
@ -3,15 +3,21 @@
|
||||||
(defpackage :scopes-auth
|
(defpackage :scopes-auth
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
(:local-nicknames (:config :scopes/config)
|
(:local-nicknames (:config :scopes/config)
|
||||||
|
(:core :scopes/core)
|
||||||
(:util :scopes/util))
|
(:util :scopes/util))
|
||||||
(:import-from :scopes/web/dom #:div #:label)
|
(:import-from :scopes/web/dom #:div #:label)
|
||||||
(:export #:config
|
(:export #:config #:setup
|
||||||
#:login))
|
#:login))
|
||||||
|
|
||||||
(in-package :scopes-auth)
|
(in-package :scopes-auth)
|
||||||
|
|
||||||
(defclass config (config:base)
|
(defclass config (config:base)
|
||||||
((admin-credentials :initarg :admin-credentials)))
|
((admin-credentials :reader admin-credentials :initarg :admin-credentials)))
|
||||||
|
|
||||||
|
(defun setup (cfg)
|
||||||
|
(core:default-setup cfg))
|
||||||
|
|
||||||
(defun login (cred)
|
(defun login (cred)
|
||||||
(util:lgi cred))
|
(let ((srv (core:find-service :auth)))
|
||||||
|
(util:lgi cred (admin-credentials (core:config srv)))))
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# lib/auth/test/.test.env - environment file for overriding config settings
|
# lib/auth/test/.test.env - environment file for overriding config settings
|
||||||
|
|
||||||
SCOPES_ADMIN_LOGIN=admin
|
SCOPES_ADMIN-LOGIN=admin
|
||||||
SCOPES_ADMIN_PASSWORD=sc0pes
|
SCOPES_ADMIN-PASSWORD=sc0pes
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
:console nil)
|
:console nil)
|
||||||
|
|
||||||
(config:add :auth :class 'auth:config
|
(config:add :auth :class 'auth:config
|
||||||
|
:setup #'auth:setup
|
||||||
:admin-credentials `(:login ,(config:from-env :admin-login "admin")
|
:admin-credentials `(:login ,(config:from-env :admin-login "admin")
|
||||||
:password ,(config:from-env :admin-password "secret")))
|
:password ,(config:from-env :admin-password "secret")))
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,14 @@
|
||||||
(let ((t:*current-system* :scopes-auth)
|
(let ((t:*current-system* :scopes-auth)
|
||||||
(t:*test-suite* (t:test-suite "auth")))
|
(t:*test-suite* (t:test-suite "auth")))
|
||||||
(load (t:test-path "config" ""))
|
(load (t:test-path "config" ""))
|
||||||
(unwind-protect
|
;(unwind-protect
|
||||||
(progn
|
(progn
|
||||||
(core:setup-services)
|
(core:setup-services)
|
||||||
(let ((server (core:find-service :server))
|
(let ((server (core:find-service :server))
|
||||||
(client (core:find-service :client)))
|
(client (core:find-service :client)))
|
||||||
(test-login))
|
(test-login)))
|
||||||
(t:show-result)))))
|
(core:shutdown)
|
||||||
|
(t:show-result)))
|
||||||
|
|
||||||
(deftest test-login ()
|
(deftest test-login ()
|
||||||
(let ((cred '(:login "admin" :password "secret")))
|
(let ((cred '(:login "admin" :password "secret")))
|
||||||
|
|
Loading…
Add table
Reference in a new issue