Commit dd43d6ac authored by Swergas's avatar Swergas

implement steps 'credential authority sends credentials to voters' and...

implement steps 'credential authority sends credentials to voters' and 'administrator invites trustees'
parent f5958091
......@@ -22,3 +22,10 @@ ADMINISTRATOR_USERNAME = "user1" # This value comes from file `demo/password_db.
ADMINISTRATOR_PASSWORD = "phiexoey" # This value comes from file `demo/password_db.csv`, first row, 4th column
GIT_REPOSITORY_ABSOLUTE_PATH = dirname(dirname(abspath(__file__)))
# These variables are used by Scenario 2 only
\ No newline at end of file
......@@ -229,14 +229,30 @@ def initialize_server():
return server
def initialize_browser():
def initialize_browser(for_scenario_2=False):
browser = None
if for_scenario_2:
# Test Scenario 2 requires users to download things from their browser.
# Define a custom profile for Firefox, to automatically download files that a page asks user to download, without asking. This is because Selenium can't control downloads.
profile = webdriver.FirefoxProfile()
profile.set_preference('', 2) # Can be set to either 0, 1, or 2. When set to 0, Firefox will save all files downloaded via the browser on the user's desktop. When set to 1, these downloads are stored in the Downloads folder. When set to 2, the location specified for the most recent download is utilized again.
profile.set_preference('', False)
profile.set_preference('', settings.BROWSER_DOWNLOAD_FOLDER)
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/plain')
from selenium.webdriver.firefox.options import Options
options = Options()
options.log.level = "trace"
if for_scenario_2:
browser = webdriver.Firefox(profile, options=options)
browser = webdriver.Firefox(options=options)
if for_scenario_2:
browser = webdriver.Firefox(profile)
browser = webdriver.Firefox()
browser.implicitly_wait(settings.WAIT_TIME_BETWEEN_EACH_STEP) # In seconds
This diff is collapsed.
......@@ -60,3 +60,28 @@ class FakeSentEmailsManager:
def uninstall_fake_sendmail_log_file(self):["rm", "-f", self.log_file_path]) # TODO: Execute a command that works on other OS, like `os.remove()`
def send_email(self, from_email_address, to_email_address, subject, content):
from datetime import datetime
username_and_email_format = "\"{username}\" <{email_address}>"
from_label = username_and_email_format.format(username=from_email_address, email_address=from_email_address)
to_label = username_and_email_format.format(username=to_email_address, email_address=to_email_address)
date_label ="%a, %d %b %Y %H:%M:%S %z")
full_content_format = """\
Content-type: text/plain; charset="UTF-8"
Content-transfer-encoding: quoted-printable
From: {from_label}
To: {to_label}
Subject: {subject}
MIME-Version: 1.0
X-Mailer: Belenios Automated Tests
Date: {date_label}
full_content = full_content_format.format(from_label=from_label, to_label=to_label, subject=subject, date_label=date_label, content=content)
with open(self.log_file_path, "a") as myfile:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment