Set default session cookie name.
This commit is contained in:
		@@ -20,10 +20,10 @@ async fn main() -> tide::Result<()> {
 | 
				
			|||||||
async fn app_setup() -> tide::Server<()> {
 | 
					async fn app_setup() -> tide::Server<()> {
 | 
				
			||||||
    let mut app = tide::new();
 | 
					    let mut app = tide::new();
 | 
				
			||||||
    app.at("/").get(home);
 | 
					    app.at("/").get(home);
 | 
				
			||||||
    app.with(SessionMiddleware::new(
 | 
					    app.with(
 | 
				
			||||||
        MemoryStore::new(),
 | 
					        SessionMiddleware::new(MemoryStore::new(), b"361f953f-56ba-45e6-86ab-9efbf61b745d")
 | 
				
			||||||
        b"361f953f-56ba-45e6-86ab-9efbf61b745d",
 | 
					            .with_cookie_name("morethantext.sid"),
 | 
				
			||||||
    ));
 | 
					    );
 | 
				
			||||||
    return app;
 | 
					    return app;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,4 +5,4 @@ Feature: Session
 | 
				
			|||||||
	Scenario: Session ID is set
 | 
						Scenario: Session ID is set
 | 
				
			||||||
		Given a running server
 | 
							Given a running server
 | 
				
			||||||
		When the home page is accessed
 | 
							When the home page is accessed
 | 
				
			||||||
		Then there is a session id
 | 
							Then there is a default session id
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,7 +19,13 @@ def access_home_page(server, page):
 | 
				
			|||||||
    page.request_url(url)
 | 
					    page.request_url(url)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@then("there is a session id")
 | 
					@then("there is a default session id")
 | 
				
			||||||
def confirm_session(page):
 | 
					def confirm_session(page):
 | 
				
			||||||
    """Confirm session id exists."""
 | 
					    """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}"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user