auth test, work in progress: get static login data from config / .env

This commit is contained in:
Helmut Merz 2024-08-13 16:38:39 +02:00
parent 0cd12b377b
commit 5c1838b347
6 changed files with 17 additions and 9 deletions

View file

@ -49,7 +49,6 @@
(let* ((key (str:concat prefix (string sl)))
(env-val (uiop:getenv key))
(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
(setf (gethash sl data) env-val)
(setf (gethash sl data) dotenv-val))))))

View file

@ -5,6 +5,7 @@
(:local-nicknames (:config :scopes/config)
(:message :scopes/core/message)
(:shape :scopes/shape)
(:util :scopes/util)
(:alx :alexandria))
(:export #:*root* #:default-setup #:default-actions
#:find-service #:setup-services

View file

@ -3,15 +3,21 @@
(defpackage :scopes-auth
(:use :common-lisp)
(:local-nicknames (:config :scopes/config)
(:core :scopes/core)
(:util :scopes/util))
(:import-from :scopes/web/dom #:div #:label)
(:export #:config
(:export #:config #:setup
#:login))
(in-package :scopes-auth)
(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)
(util:lgi cred))
(let ((srv (core:find-service :auth)))
(util:lgi cred (admin-credentials (core:config srv)))))

View file

@ -1,4 +1,4 @@
# lib/auth/test/.test.env - environment file for overriding config settings
SCOPES_ADMIN_LOGIN=admin
SCOPES_ADMIN_PASSWORD=sc0pes
SCOPES_ADMIN-LOGIN=admin
SCOPES_ADMIN-PASSWORD=sc0pes

View file

@ -16,6 +16,7 @@
:console nil)
(config:add :auth :class 'auth:config
:setup #'auth:setup
:admin-credentials `(:login ,(config:from-env :admin-login "admin")
:password ,(config:from-env :admin-password "secret")))

View file

@ -21,13 +21,14 @@
(let ((t:*current-system* :scopes-auth)
(t:*test-suite* (t:test-suite "auth")))
(load (t:test-path "config" ""))
(unwind-protect
;(unwind-protect
(progn
(core:setup-services)
(let ((server (core:find-service :server))
(client (core:find-service :client)))
(test-login))
(t:show-result)))))
(test-login)))
(core:shutdown)
(t:show-result)))
(deftest test-login ()
(let ((cred '(:login "admin" :password "secret")))