From b264886c174173ce45b1d43eca0862bc8caa3e80 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Mon, 2 Sep 2024 16:23:21 +0200 Subject: [PATCH] auth/web: start with testing client login --- lib/auth/scopes-auth.asd | 3 +-- lib/auth/test/etc/config.lisp | 2 +- lib/auth/test/test-auth.lisp | 14 +++++++++++--- lib/auth/web.lisp | 6 ++++-- test/test-web.lisp | 3 ++- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/auth/scopes-auth.asd b/lib/auth/scopes-auth.asd index 1b579ac..3eed889 100644 --- a/lib/auth/scopes-auth.asd +++ b/lib/auth/scopes-auth.asd @@ -6,8 +6,7 @@ :version "0.0.1" :homepage "https://www.cyberconcepts.org" :description "Authentication services" - :depends-on (:scopes - :flexi-streams :ironclad :qbase64) + :depends-on (:scopes) :components ((:file "auth") (:file "web" :depends-on ("auth"))) :long-description "scopes framework: authentication services." diff --git a/lib/auth/test/etc/config.lisp b/lib/auth/test/etc/config.lisp index b0494bc..64bfc0d 100644 --- a/lib/auth/test/etc/config.lisp +++ b/lib/auth/test/etc/config.lisp @@ -26,7 +26,7 @@ `((("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-action '(:auth :login) #'web:login) (config:add :client :class 'client:config :base-url "http://localhost:8899" diff --git a/lib/auth/test/test-auth.lisp b/lib/auth/test/test-auth.lisp index 01b92c6..3a8e339 100644 --- a/lib/auth/test/test-auth.lisp +++ b/lib/auth/test/test-auth.lisp @@ -9,6 +9,7 @@ (:core :scopes/core) (:cs-hx :scopes/frontend/cs-hx) (:logging :scopes/logging) + (:message :scopes/core/message) (:server :scopes/web/server) (:shape :scopes/shape) (:t :scopes/testing)) @@ -28,7 +29,9 @@ (core:setup-services) (let ((server (core:find-service :server)) (client (core:find-service :client))) - (test-login))) + (sleep 0.1) + (test-login) + (test-client client))) (core:shutdown) (t:show-result)))) @@ -38,5 +41,10 @@ (== (auth:login cred) nil) (setf cred '(:name "admin" :password "sc0pes")) (setf pr1 (auth:login cred)) - (== (shape:head-value pr1 :name) :admin) - )) + (== (shape:head-value pr1 :name) :admin))) + +(deftest test-client (client) + (let ((msg (message:create + '(:auth :login) + :data '(:name "admin" :password "sc0pes")))) + (client:send-message client msg))) diff --git a/lib/auth/web.lisp b/lib/auth/web.lisp index a3deaf2..c147495 100644 --- a/lib/auth/web.lisp +++ b/lib/auth/web.lisp @@ -3,9 +3,11 @@ (defpackage :scopes-auth/web (:use :common-lisp) (:local-nicknames (:auth :scopes-auth) - (:config :scopes/config)) + (:config :scopes/config) + (:core :scopes/core)) (:export #:login)) (in-package :scopes-auth/web) - +(defun login (ctx msg) + (core:echo ctx msg)) diff --git a/test/test-web.lisp b/test/test-web.lisp index 17f8c3d..919d216 100644 --- a/test/test-web.lisp +++ b/test/test-web.lisp @@ -72,7 +72,8 @@ "
: test data
")) ; cs-hx:response ;"
info
test data
"))) ; default response (let ((msg (message:create '(:test :cookie) - :data '(:name "mycookie" :value "my_value")))) + :data '(:name "mycookie" :value "my_value" + :domain "localhost")))) (client:send-message client msg) (util:lgi client::*cookie-jar*)) )