stop threading email and password around as arguments

This commit is contained in:
Taeer Bar-Yam 2024-09-10 08:50:50 -04:00
parent 03995ca922
commit bc47154895

View file

@ -3,6 +3,9 @@ let
lib = pkgs.lib; lib = pkgs.lib;
rebuildableTest = import ./rebuildableTest.nix pkgs; rebuildableTest = import ./rebuildableTest.nix pkgs;
email = "test@test.com";
password = "testtest";
# FIXME: Replace all the By.XPATH by By.CSS_SELECTOR. # FIXME: Replace all the By.XPATH by By.CSS_SELECTOR.
seleniumImports = '' seleniumImports = ''
@ -22,7 +25,7 @@ let
driver.set_window_size(1280, 960) driver.set_window_size(1280, 960)
''; '';
seleniumPixelfedLogin = email: password: '' seleniumPixelfedLogin = ''
print("Open login page...", file=sys.stderr) print("Open login page...", file=sys.stderr)
driver.get("http://pixelfed.localhost/login") driver.get("http://pixelfed.localhost/login")
print("Enter email...", file=sys.stderr) print("Enter email...", file=sys.stderr)
@ -56,7 +59,7 @@ let
from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support.wait import WebDriverWait
${seleniumSetup} ${seleniumSetup}
${seleniumPixelfedLogin "sys.argv[1]" "sys.argv[2]"} ${seleniumPixelfedLogin}
time.sleep(3) time.sleep(3)
media_path = os.environ['POST_MEDIA'] media_path = os.environ['POST_MEDIA']
@ -95,7 +98,7 @@ let
} '' } ''
${seleniumImports} ${seleniumImports}
${seleniumSetup} ${seleniumSetup}
${seleniumPixelfedLogin "sys.argv[1]" "sys.argv[2]"} ${seleniumPixelfedLogin}
img = driver.find_element( img = driver.find_element(
By.XPATH, By.XPATH,
@ -169,8 +172,7 @@ pkgs.nixosTest {
server.wait_for_unit("phpfpm-pixelfed.service") server.wait_for_unit("phpfpm-pixelfed.service")
with subtest("Account creation"): with subtest("Account creation"):
password = "testtest" server.succeed(f"pixelfed-manage user:create --name=test --username=test --email=${email} --password=${password} --confirm_email=1")
server.succeed(f"pixelfed-manage user:create --name=test --username=test --email=test@test.com --password={password} --confirm_email=1")
# NOTE: This could in theory give a false positive if pixelfed changes it's # NOTE: This could in theory give a false positive if pixelfed changes it's
# colorscheme to include pure green. (see same problem in pixelfed-garage.nix). # colorscheme to include pure green. (see same problem in pixelfed-garage.nix).
@ -178,7 +180,7 @@ pkgs.nixosTest {
# there, then post a green image and check that the green pixel IS there. # there, then post a green image and check that the green pixel IS there.
with subtest("Image displays"): with subtest("Image displays"):
server.succeed(f"su - selenium -c 'selenium-script-post-picture test@test.com {password}'") server.succeed(f"su - selenium -c 'selenium-script-post-picture ${email} ${password}'")
server.copy_from_vm("/home/selenium/screenshot.png", "") server.copy_from_vm("/home/selenium/screenshot.png", "")
displayed_colors = server.succeed("magick /home/selenium/screenshot.png -define histogram:unique-colors=true -format %c histogram:info:") displayed_colors = server.succeed("magick /home/selenium/screenshot.png -define histogram:unique-colors=true -format %c histogram:info:")
# check that the green image displayed somewhere # check that the green image displayed somewhere
@ -202,7 +204,7 @@ pkgs.nixosTest {
raise Exception("image stored in garage did not match image uploaded") raise Exception("image stored in garage did not match image uploaded")
with subtest("Check that image comes from garage"): with subtest("Check that image comes from garage"):
src = server.succeed(f"su - selenium -c 'selenium-script-get-src test@test.com {password}'") src = server.succeed(f"su - selenium -c 'selenium-script-get-src ${email} ${password}'")
if not src.startswith("http://pixelfed.web.garage.localhost:3902/"): if not src.startswith("http://pixelfed.web.garage.localhost:3902/"):
raise Exception("image does not come from garage") raise Exception("image does not come from garage")
''; '';