-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce52bc6
commit ea2152e
Showing
8 changed files
with
96 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
defmodule PowPersistentSession.Phoenix.ControllerCallbacksTest do | ||
use PowPersistentSession.TestWeb.Phoenix.ConnCase | ||
|
||
alias Pow.Test.EtsCacheMock | ||
alias PowPersistentSession.Store.PersistentSessionCache | ||
|
||
@valid_params %{"email" => "[email protected]", "password" => "secret1234"} | ||
@max_age Integer.floor_div(:timer.hours(30) * 24, 1000) | ||
|
||
describe "Pow.Phoenix.SessionController.create/2" do | ||
test "generates cookie", %{conn: conn} do | ||
test "generates cookie", %{conn: conn, ets: ets} do | ||
conn = post conn, Routes.pow_session_path(conn, :create, %{"user" => @valid_params}) | ||
|
||
assert %{max_age: @max_age, path: "/", value: id} = conn.resp_cookies["persistent_session_cookie"] | ||
assert PersistentSessionCache.get([backend: EtsCacheMock], id) == 1 | ||
assert PersistentSessionCache.get([backend: ets], id) == 1 | ||
end | ||
|
||
test "with persistent_session param set to false", %{conn: conn} do | ||
|
@@ -32,13 +31,13 @@ defmodule PowPersistentSession.Phoenix.ControllerCallbacksTest do | |
end | ||
|
||
describe "Pow.Phoenix.SessionController.delete/2" do | ||
test "generates cookie", %{conn: conn} do | ||
test "generates cookie", %{conn: conn, ets: ets} do | ||
conn = post conn, Routes.pow_session_path(conn, :create, %{"user" => @valid_params}) | ||
%{value: id} = conn.resp_cookies["persistent_session_cookie"] | ||
conn = delete conn, Routes.pow_session_path(conn, :delete) | ||
|
||
assert %{max_age: -1, path: "/", value: ""} = conn.resp_cookies["persistent_session_cookie"] | ||
assert PersistentSessionCache.get([backend: EtsCacheMock], id) == :not_found | ||
assert PersistentSessionCache.get([backend: ets], id) == :not_found | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.