Skip to content

Commit

Permalink
Add test for vault password
Browse files Browse the repository at this point in the history
  • Loading branch information
benbusby committed Sep 18, 2024
1 parent b2b31e3 commit bc25db1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<dialog data-dynamic="true" id="vault-pass-dialog">
<dialog data-testid="vault-pass-dialog" data-dynamic="true" id="vault-pass-dialog">
{{ if . }}
<h3>Set Vault Password</h3>
{{ else }}
<h3>Enter Vault Password</h3>
{{ end }}
<hr>
<label for="vault-pass">Password:</label>
<input id="vault-pass" type="password">
<input data-testid="vault-pass" id="vault-pass" type="password">
<br><br>
{{ if . }}
<span class="small-text">
Expand All @@ -18,6 +18,6 @@ <h3>Enter Vault Password</h3>
{{ end }}
<div class="align-items-right">
<button id="cancel-pass">Cancel</button>
<button id="submit-pass" class="accent-btn">Confirm</button>
<button data-testid="submit-pass" id="submit-pass" class="accent-btn">Confirm</button>
</div>
</dialog>
4 changes: 2 additions & 2 deletions backend/server/html/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ <h1>Log In</h1>
<a id="forgot-password" href="{{ .Base.Endpoints.Forgot }}">Forgot Password</a>
</div>

<details>
<details data-testid="advanced-login-options">
<summary>Advanced</summary>
<label for="vault-pass-cb">Set session-specific Vault password:</label>
<input type="checkbox" id="vault-pass-cb"><br>
<input data-testid="vault-pass-cb" type="checkbox" id="vault-pass-cb"><br>
</details>

{{ template "messages.html" . }}
Expand Down
33 changes: 33 additions & 0 deletions web/tests/test_single_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bc25db1

Please sign in to comment.