1
0
mirror of https://github.com/peeringdb/peeringdb.git synced 2024-05-11 05:55:09 +00:00
Files
peeringdb-peeringdb/ux-tests/test_profile.py
Stefan Pratter be9deaf2f8 Support 202309 (#1458)
* fixes #1260 - playwright tests
fixes #1394 - v2 search failing to find some names
fixes #1374 - Search to include new objects: Campus & Carrier
fixes #1164 - better rdap error reporting
fixes #1368 - Facility data export into Google Earth KMZ
fixes #1328 - Support web updates from a source of truth
fixes #1257 - Help text covers non-compliant email addresses
fixes #1313 - Improve email confirmation control - add 3 month option & maybe set new default value
fixes #1380 - Reset 'Social Media' to '[]' if field has no value

* linting

* remove target=_blank

* bump ES version to 8.10

* Cache and ES updates (#1459)

* elasticsearch major version pin and relock

* set decimal fields to python value on client save for load_data

* force use of redis password

* add default_meta to render

* add generated, clean up var names

* run pre-commit

* update ES for https and password

* rm cruft

* isort

---------

Co-authored-by: 20C <code@20c.com>
Co-authored-by: Matt Griswold <grizz@20c.com>
2023-10-24 12:17:03 -05:00

119 lines
3.8 KiB
Python

import pytest
from helpers import login
from playwright.sync_api import Page
TIMEOUT = 10000
def change_password(page: Page, old_password, new_password):
"""
This function changes the user's password.
"""
page.fill(
'#form-change-password input[data-edit-name="password_c"]',
old_password,
timeout=TIMEOUT,
)
page.fill(
'#form-change-password input[data-edit-name="password"]',
new_password,
timeout=TIMEOUT,
)
page.fill(
'#form-change-password input[data-edit-name="password_v"]',
new_password,
timeout=TIMEOUT,
)
page.click(
'#form-change-password a.btn[data-edit-action="submit"]', timeout=TIMEOUT
)
@pytest.mark.profile
def test_profile_add_api_key(config, page: Page, account):
"""
This function tests the functionality of adding an API key.
"""
page.goto(config["url"] + "/profile")
num_of_keys = len(
page.query_selector_all('.api-keys div[data-edit-component="list"] div.row')
)
# add api key
page.fill(
'.api-keys div[data-edit-name="name"] input',
config["test_add_api_key"]["description"],
timeout=TIMEOUT,
)
page.click('.api-keys a[data-edit-action="add"]', timeout=TIMEOUT)
# check if api key added to list
assert page.wait_for_selector(
".api-keys #api-key-popin-frame div.alert-success", timeout=TIMEOUT
)
assert num_of_keys + 1 == len(
page.query_selector_all('.api-keys div[data-edit-component="list"] div.row')
)
@pytest.mark.profile
def test_profile_delete_api_key(config, page: Page, account):
"""
This function tests the functionality of deleting an API key.
"""
# deletes an existing api key
page.goto(config["url"] + "/profile")
num_of_keys = len(
page.query_selector_all('.api-keys div[data-edit-component="list"] div.row')
)
page.on("dialog", lambda dialog: dialog.accept())
# remove key
description = config["test_delete_api_key"]["description"]
key_revoke_btn_selector = f'.api-keys div[data-edit-component="list"] div.row:has(span[data-edit-name="name"]:has-text("{description}")) a[data-edit-action="revoke"]'
page.wait_for_selector(key_revoke_btn_selector, timeout=TIMEOUT)
key_revoke_btn = page.query_selector(key_revoke_btn_selector)
key_revoke_btn.click()
page.goto(config["url"] + "/profile")
# check if key removed from list
assert num_of_keys - 1 == len(
page.query_selector_all('.api-keys div[data-edit-component="list"] div.row')
)
@pytest.mark.profile
def test_profile_change_password(config, page: Page, account_credentials, account):
"""
This function tests the functionality of changing the user's password.
"""
page.goto(config["url"] + "/profile", wait_until="load")
old_password = account_credentials["password"]
new_password = config["test_change_password"]["password"]
change_password(page, old_password, new_password)
# check for success message
assert page.wait_for_selector(
"#form-change-password #password-change-success", timeout=TIMEOUT
)
# re login
page.goto(config["url"], wait_until="load")
login(page, account_credentials["username"], new_password)
# change password back
page.goto(config["url"] + "/profile", wait_until="load")
change_password(page, new_password, old_password)
# check for success message
assert page.wait_for_selector(
"#form-change-password #password-change-success", timeout=TIMEOUT
)
# re login
page.goto(config["url"], wait_until="load")
login(page, account_credentials["username"], new_password)