From bc25db138edc1678b97fd7452840d7101f1cdab1 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Tue, 17 Sep 2024 20:10:22 -0600 Subject: [PATCH] Add test for vault password --- .../items/vault-password-dialog.html | 6 ++-- backend/server/html/templates/login.html | 4 +-- web/tests/test_single_user.py | 33 +++++++++++++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/backend/server/html/templates/items/vault-password-dialog.html b/backend/server/html/templates/items/vault-password-dialog.html index 04bae7e..4b07ff8 100644 --- a/backend/server/html/templates/items/vault-password-dialog.html +++ b/backend/server/html/templates/items/vault-password-dialog.html @@ -1,4 +1,4 @@ - + {{ if . }}

Set Vault Password

{{ else }} @@ -6,7 +6,7 @@

Enter Vault Password

{{ end }}
- +

{{ if . }} @@ -18,6 +18,6 @@

Enter Vault Password

{{ end }}
- +
\ No newline at end of file diff --git a/backend/server/html/templates/login.html b/backend/server/html/templates/login.html index 8190e8c..54fe4b9 100644 --- a/backend/server/html/templates/login.html +++ b/backend/server/html/templates/login.html @@ -12,10 +12,10 @@

Log In

Forgot Password -
+
Advanced -
+
{{ template "messages.html" . }} diff --git a/web/tests/test_single_user.py b/web/tests/test_single_user.py index c8ec73d..593a245 100644 --- a/web/tests/test_single_user.py +++ b/web/tests/test_single_user.py @@ -231,6 +231,39 @@ def _upload_file(folder_id: str): _upload_file(new_folder_id) +def test_vault_password(browser_context: BrowserContext): + """Tests setting a unique session-specific vault password""" + global account_id + page: Page = browser_context.new_page() + page.goto(f"{base_page}/account") + page.on("dialog", lambda dialog: dialog.accept()) + page.get_by_test_id("logout-btn").click() + expect(page).to_have_title("YeetFile - Send") + + page.goto(f"{base_page}/login") + page.get_by_test_id("identifier").fill(account_id) + page.get_by_test_id("password").fill(user_password) + page.get_by_test_id("advanced-login-options").click() + page.get_by_test_id("vault-pass-cb").click() + page.get_by_test_id("login-btn").click() + + vault_password = "my_vault_password" + expect(page.get_by_test_id("vault-pass-dialog")).to_be_visible() + page.get_by_test_id("vault-pass").fill(vault_password) + page.get_by_test_id("submit-pass").click() + expect(page).to_have_title("YeetFile - My Account") + + page.goto(f"{base_page}/vault") + expect(page.get_by_test_id("table-body")).to_be_empty() + expect(page.get_by_test_id("vault-pass-dialog")).to_be_visible() + page.get_by_test_id("vault-pass").fill("WRONG") + page.get_by_test_id("submit-pass").click() + expect(page.get_by_test_id("vault-pass-dialog")).to_be_visible() + page.get_by_test_id("vault-pass").fill(vault_password) + page.get_by_test_id("submit-pass").click() + expect(page.get_by_test_id("vault-pass-dialog")).to_be_hidden() + + def test_delete_account(browser_context: BrowserContext): """Permanently deletes the test user account""" global account_id