2008-03-03 03:19:36 -05:00
|
|
|
IN: http.server.sessions.tests
|
2008-03-15 07:22:47 -04:00
|
|
|
USING: tools.test http http.server.sessions
|
|
|
|
http.server.sessions.storage http.server.sessions.storage.assoc
|
2008-03-17 05:31:13 -04:00
|
|
|
http.server.actions http.server math namespaces kernel accessors
|
|
|
|
prettyprint io.streams.string splitting destructors sequences ;
|
2008-02-29 01:57:38 -05:00
|
|
|
|
2008-03-13 23:14:32 -04:00
|
|
|
[ H{ } ] [ H{ } add-session-id ] unit-test
|
|
|
|
|
2008-03-03 03:19:36 -05:00
|
|
|
: with-session \ session swap with-variable ; inline
|
|
|
|
|
2008-03-06 04:00:10 -05:00
|
|
|
TUPLE: foo ;
|
|
|
|
|
|
|
|
C: <foo> foo
|
|
|
|
|
2008-03-11 04:39:09 -04:00
|
|
|
M: foo init-session* drop 0 "x" sset ;
|
2008-03-06 04:00:10 -05:00
|
|
|
|
2008-03-15 07:22:47 -04:00
|
|
|
M: foo call-responder
|
|
|
|
2drop
|
|
|
|
"x" [ 1+ ] schange
|
|
|
|
"text/html" <content> [ "x" sget pprint ] >>body ;
|
|
|
|
|
|
|
|
[
|
|
|
|
"123" session-id set
|
|
|
|
H{ } clone session set
|
|
|
|
session-changed? off
|
|
|
|
|
2008-03-13 23:14:32 -04:00
|
|
|
[ H{ { "factorsessid" "123" } } ] [ H{ } add-session-id ] unit-test
|
|
|
|
|
2008-02-29 01:57:38 -05:00
|
|
|
[ ] [ 3 "x" sset ] unit-test
|
|
|
|
|
|
|
|
[ 9 ] [ "x" sget sq ] unit-test
|
|
|
|
|
|
|
|
[ ] [ "x" [ 1- ] schange ] unit-test
|
|
|
|
|
|
|
|
[ 4 ] [ "x" sget sq ] unit-test
|
2008-03-15 07:22:47 -04:00
|
|
|
|
|
|
|
[ t ] [ session-changed? get ] unit-test
|
|
|
|
] with-scope
|
2008-02-29 01:57:38 -05:00
|
|
|
|
|
|
|
[ t ] [ f <url-sessions> url-sessions? ] unit-test
|
|
|
|
[ t ] [ f <cookie-sessions> cookie-sessions? ] unit-test
|
|
|
|
|
|
|
|
[ ] [
|
2008-03-06 04:00:10 -05:00
|
|
|
<foo> <url-sessions>
|
2008-03-15 07:22:47 -04:00
|
|
|
<sessions-in-memory> >>sessions
|
2008-02-29 01:57:38 -05:00
|
|
|
"manager" set
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ { 5 0 } ] [
|
|
|
|
[
|
2008-03-15 07:22:47 -04:00
|
|
|
"manager" get begin-session drop
|
|
|
|
dup "manager" get sessions>> get-session [ 5 "a" sset ] with-session
|
|
|
|
dup "manager" get sessions>> get-session [ "a" sget , ] with-session
|
|
|
|
dup "manager" get sessions>> get-session [ "x" sget , ] with-session
|
|
|
|
"manager" get sessions>> get-session
|
|
|
|
"manager" get sessions>> delete-session
|
2008-02-29 01:57:38 -05:00
|
|
|
] { } make
|
|
|
|
] unit-test
|
2008-03-15 07:22:47 -04:00
|
|
|
|
|
|
|
[ ] [
|
|
|
|
<request>
|
|
|
|
"GET" >>method
|
|
|
|
request set
|
|
|
|
"/etc" "manager" get call-responder
|
|
|
|
response set
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ 307 ] [ response get code>> ] unit-test
|
|
|
|
|
|
|
|
[ ] [ response get "location" header "=" split1 nip "id" set ] unit-test
|
|
|
|
|
|
|
|
: url-responder-mock-test
|
|
|
|
[
|
|
|
|
<request>
|
2008-03-17 05:31:13 -04:00
|
|
|
"GET" >>method
|
|
|
|
"id" get session-id-key set-query-param
|
|
|
|
"/" >>path
|
2008-03-15 07:22:47 -04:00
|
|
|
request set
|
|
|
|
"/" "manager" get call-responder
|
|
|
|
[ write-response-body drop ] with-string-writer
|
|
|
|
] with-destructors ;
|
|
|
|
|
|
|
|
[ "1" ] [ url-responder-mock-test ] unit-test
|
|
|
|
[ "2" ] [ url-responder-mock-test ] unit-test
|
|
|
|
[ "3" ] [ url-responder-mock-test ] unit-test
|
|
|
|
[ "4" ] [ url-responder-mock-test ] unit-test
|
|
|
|
|
|
|
|
[ ] [
|
|
|
|
<foo> <cookie-sessions>
|
|
|
|
<sessions-in-memory> >>sessions
|
|
|
|
"manager" set
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[
|
|
|
|
<request>
|
|
|
|
"GET" >>method
|
|
|
|
"/" >>path
|
|
|
|
request set
|
|
|
|
"/etc" "manager" get call-responder response set
|
|
|
|
[ "1" ] [ [ response get write-response-body drop ] with-string-writer ] unit-test
|
|
|
|
response get
|
|
|
|
] with-destructors
|
|
|
|
response set
|
|
|
|
|
|
|
|
[ ] [ response get cookies>> "cookies" set ] unit-test
|
|
|
|
|
|
|
|
: cookie-responder-mock-test
|
|
|
|
[
|
|
|
|
<request>
|
2008-03-17 05:31:13 -04:00
|
|
|
"GET" >>method
|
|
|
|
"cookies" get >>cookies
|
|
|
|
"/" >>path
|
2008-03-15 07:22:47 -04:00
|
|
|
request set
|
|
|
|
"/" "manager" get call-responder
|
|
|
|
[ write-response-body drop ] with-string-writer
|
|
|
|
] with-destructors ;
|
|
|
|
|
|
|
|
[ "2" ] [ cookie-responder-mock-test ] unit-test
|
|
|
|
[ "3" ] [ cookie-responder-mock-test ] unit-test
|
|
|
|
[ "4" ] [ cookie-responder-mock-test ] unit-test
|
2008-03-17 05:31:13 -04:00
|
|
|
|
|
|
|
: <exiting-action>
|
|
|
|
<action>
|
|
|
|
[
|
|
|
|
"text/plain" <content> exit-with
|
|
|
|
] >>display ;
|
|
|
|
|
|
|
|
[
|
|
|
|
[ ] [
|
|
|
|
<request>
|
|
|
|
"GET" >>method
|
|
|
|
"id" get session-id-key set-query-param
|
|
|
|
"/" >>path
|
|
|
|
request set
|
|
|
|
|
|
|
|
[
|
|
|
|
"/" <exiting-action> <cookie-sessions>
|
|
|
|
call-responder
|
|
|
|
] with-destructors response set
|
|
|
|
] unit-test
|
|
|
|
|
|
|
|
[ "text/plain" ] [ response get "content-type" header ] unit-test
|
|
|
|
|
|
|
|
[ f ] [ response get cookies>> empty? ] unit-test
|
|
|
|
] with-scope
|