forked from retoor/devplacepy
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31a49a3ffa |
File diff suppressed because one or more lines are too long
@@ -11,7 +11,6 @@ from devplacepy.utils import (
|
|||||||
create_session,
|
create_session,
|
||||||
get_current_user,
|
get_current_user,
|
||||||
safe_next,
|
safe_next,
|
||||||
cookie_secure,
|
|
||||||
)
|
)
|
||||||
from devplacepy.seo import base_seo_context
|
from devplacepy.seo import base_seo_context
|
||||||
from devplacepy.models import LoginForm
|
from devplacepy.models import LoginForm
|
||||||
@@ -103,7 +102,7 @@ async def login(request: Request, data: Annotated[LoginForm, Depends(json_or_for
|
|||||||
max_age=max_age,
|
max_age=max_age,
|
||||||
httponly=True,
|
httponly=True,
|
||||||
samesite="lax",
|
samesite="lax",
|
||||||
secure=cookie_secure(request),
|
secure=False,
|
||||||
)
|
)
|
||||||
logger.info(f"User {user['username']} logged in")
|
logger.info(f"User {user['username']} logged in")
|
||||||
audit.record(
|
audit.record(
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ from devplacepy.utils import (
|
|||||||
create_session,
|
create_session,
|
||||||
get_current_user,
|
get_current_user,
|
||||||
register_account_async,
|
register_account_async,
|
||||||
cookie_secure,
|
|
||||||
)
|
)
|
||||||
from devplacepy.seo import base_seo_context
|
from devplacepy.seo import base_seo_context
|
||||||
from devplacepy.models import SignupForm
|
from devplacepy.models import SignupForm
|
||||||
@@ -101,7 +100,7 @@ async def signup(request: Request, data: Annotated[SignupForm, Depends(json_or_f
|
|||||||
max_age=max_age,
|
max_age=max_age,
|
||||||
httponly=True,
|
httponly=True,
|
||||||
samesite="lax",
|
samesite="lax",
|
||||||
secure=cookie_secure(request),
|
secure=False,
|
||||||
)
|
)
|
||||||
logger.info(f"User {username} signed up")
|
logger.info(f"User {username} signed up")
|
||||||
audit.record(
|
audit.record(
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export class MessagesLayout {
|
|||||||
}
|
}
|
||||||
this.thread = document.querySelector(".messages-thread");
|
this.thread = document.querySelector(".messages-thread");
|
||||||
this.form = document.querySelector(".messages-input-area");
|
this.form = document.querySelector(".messages-input-area");
|
||||||
this.input = this.form ? this.form.querySelector('textarea[name="content"]') : null;
|
this.input = this.form ? this.form.querySelector('input[name="content"]') : null;
|
||||||
this.upload = this.form ? this.form.querySelector("dp-upload") : null;
|
this.upload = this.form ? this.form.querySelector("dp-upload") : null;
|
||||||
this.sendBtn = this.form ? this.form.querySelector(".messages-send-btn") : null;
|
this.sendBtn = this.form ? this.form.querySelector(".messages-send-btn") : null;
|
||||||
this._uploading = false;
|
this._uploading = false;
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# retoor <retoor@molodetz.nl>
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from tests.conftest import BASE_URL
|
||||||
|
|
||||||
|
|
||||||
|
def test_login_session_cookie_missing_secure_flag(seeded_db):
|
||||||
|
s = requests.Session()
|
||||||
|
r = s.post(
|
||||||
|
f"{BASE_URL}/auth/login",
|
||||||
|
data={"email": "alice@test.devplace", "password": "secret123"},
|
||||||
|
allow_redirects=False,
|
||||||
|
)
|
||||||
|
set_cookie = r.headers.get("Set-Cookie", "")
|
||||||
|
assert "session=" in set_cookie, f"session cookie not found in Set-Cookie: {set_cookie}"
|
||||||
|
assert "HttpOnly" in set_cookie, f"HttpOnly not found in Set-Cookie: {set_cookie}"
|
||||||
|
assert "SameSite=Lax" in set_cookie, f"SameSite=Lax not found in Set-Cookie: {set_cookie}"
|
||||||
|
assert "Secure" not in set_cookie, f"Secure flag should be absent from Set-Cookie: {set_cookie}"
|
||||||
@@ -176,7 +176,7 @@ def test_send_message_appears_in_thread(alice):
|
|||||||
f"{BASE_URL}/messages?with_uid={bob['uid']}", wait_until="domcontentloaded"
|
f"{BASE_URL}/messages?with_uid={bob['uid']}", wait_until="domcontentloaded"
|
||||||
)
|
)
|
||||||
msg = f"Hello bob {int(time.time() * 1000)}"
|
msg = f"Hello bob {int(time.time() * 1000)}"
|
||||||
page.fill("textarea[name='content']", msg)
|
page.fill("input[name='content']", msg)
|
||||||
page.locator(".messages-send-btn").click()
|
page.locator(".messages-send-btn").click()
|
||||||
page.wait_for_url("**/messages**", wait_until="domcontentloaded")
|
page.wait_for_url("**/messages**", wait_until="domcontentloaded")
|
||||||
page.locator(f".message-bubble:has-text('{msg}')").first.wait_for(state="visible")
|
page.locator(f".message-bubble:has-text('{msg}')").first.wait_for(state="visible")
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ def test_message_notification(app_server, browser, seeded_db):
|
|||||||
pb.goto(f"{BASE_URL}/messages?search=alice_test", wait_until="domcontentloaded")
|
pb.goto(f"{BASE_URL}/messages?search=alice_test", wait_until="domcontentloaded")
|
||||||
pb.wait_for_timeout(2000)
|
pb.wait_for_timeout(2000)
|
||||||
|
|
||||||
msg_input = pb.locator("textarea[name='content']").first
|
msg_input = pb.locator("input[name='content']").first
|
||||||
msg_input.wait_for(state="visible", timeout=10000)
|
msg_input.wait_for(state="visible", timeout=10000)
|
||||||
msg_input.fill("Hello from bob_test!")
|
msg_input.fill("Hello from bob_test!")
|
||||||
pb.locator("button[type='submit']").last.click()
|
pb.locator("button[type='submit']").last.click()
|
||||||
@@ -753,7 +753,7 @@ def test_message_notification_click_opens_conversation(app_server, browser, seed
|
|||||||
|
|
||||||
pb.goto(f"{BASE_URL}/messages?search=alice_test", wait_until="domcontentloaded")
|
pb.goto(f"{BASE_URL}/messages?search=alice_test", wait_until="domcontentloaded")
|
||||||
pb.wait_for_timeout(2000)
|
pb.wait_for_timeout(2000)
|
||||||
msg_input = pb.locator("textarea[name='content']").first
|
msg_input = pb.locator("input[name='content']").first
|
||||||
msg_input.wait_for(state="visible", timeout=10000)
|
msg_input.wait_for(state="visible", timeout=10000)
|
||||||
msg_input.fill("Click-through message from bob")
|
msg_input.fill("Click-through message from bob")
|
||||||
pb.locator("button[type='submit']").last.click()
|
pb.locator("button[type='submit']").last.click()
|
||||||
|
|||||||
Reference in New Issue
Block a user