Set default session cookie name.

This commit is contained in:
Jeff Baskin 2022-06-24 08:22:17 -04:00
parent 94ff8bdfb8
commit d68988b2d4
3 changed files with 13 additions and 7 deletions

View File

@ -20,10 +20,10 @@ async fn main() -> tide::Result<()> {
async fn app_setup() -> tide::Server<()> {
let mut app = tide::new();
app.at("/").get(home);
app.with(SessionMiddleware::new(
MemoryStore::new(),
b"361f953f-56ba-45e6-86ab-9efbf61b745d",
));
app.with(
SessionMiddleware::new(MemoryStore::new(), b"361f953f-56ba-45e6-86ab-9efbf61b745d")
.with_cookie_name("morethantext.sid"),
);
return app;
}

View File

@ -5,4 +5,4 @@ Feature: Session
Scenario: Session ID is set
Given a running server
When the home page is accessed
Then there is a session id
Then there is a default session id

View File

@ -19,7 +19,13 @@ def access_home_page(server, page):
page.request_url(url)
@then("there is a session id")
@then("there is a default session id")
def confirm_session(page):
"""Confirm session id exists."""
assert len(page.get_cookies()), "No cookies received."
cookies = page.get_cookies()
name = "morethantext.sid"
cookie = None
for holder in cookies:
if holder.name == name:
cookie = holder
assert cookie, f"Did not find cookie {name}, but retrieved {cookies}"