Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7890237
set_user_session_id_plug_test.exs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
set_user_session_id_plug_test.exs
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Plugs.SetUserSessionIdPlugTest
do
use
Pleroma.Web.ConnCase
,
async
:
true
alias
Pleroma.Plugs.SetUserSessionIdPlug
alias
Pleroma.User
setup
%{
conn
:
conn
}
do
session_opts
=
[
store
:
:cookie
,
key
:
"_test"
,
signing_salt
:
"cooldude"
]
conn
=
conn
|>
Plug.Session
.
call
(
Plug.Session
.
init
(
session_opts
))
|>
fetch_session
%{
conn
:
conn
}
end
test
"doesn't do anything if the user isn't set"
,
%{
conn
:
conn
}
do
ret_conn
=
conn
|>
SetUserSessionIdPlug
.
call
(%{})
assert
ret_conn
==
conn
end
test
"sets the user_id in the session to the user id of the user assign"
,
%{
conn
:
conn
}
do
Code
.
ensure_compiled
(
Pleroma.User
)
conn
=
conn
|>
assign
(
:user
,
%
User
{
id
:
1
})
|>
SetUserSessionIdPlug
.
call
(%{})
id
=
get_session
(
conn
,
:user_id
)
assert
id
==
1
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 2, 3:02 AM (13 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
487042
Default Alt Text
set_user_session_id_plug_test.exs (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment