def test_submission_notifications_on_second_login(self, sd_servers_v2, tor_browser_web_driver): navigator = SourceAppNagivator( source_app_base_url=sd_servers_v2.source_app_base_url, web_driver=tor_browser_web_driver, ) # Given a source user who creates an account navigator.source_visits_source_homepage() navigator.source_clicks_submit_documents_on_homepage() navigator.source_continues_to_submit_page() source_codename = navigator.source_retrieves_codename_from_hint() assert source_codename # When they submit a message during their second login navigator.source_logs_out() navigator.source_visits_source_homepage() navigator.source_chooses_to_login() navigator.source_proceeds_to_login(codename=source_codename) # Then it succeeds confirmation_text_first_submission = navigator.source_submits_a_message() # And they see the expected confirmation messages for a first submission on second login assert self.FIRST_SUBMISSION_TEXT in confirmation_text_first_submission # And when they submit a second message confirmation_text_second_submission = navigator.source_submits_a_message() # Then they don't see the messages since it's not their first submission assert self.FIRST_SUBMISSION_TEXT not in confirmation_text_second_submission
def test_no_codename_hint_on_second_login(self, sd_servers_v2, tor_browser_web_driver): navigator = SourceAppNagivator( source_app_base_url=sd_servers_v2.source_app_base_url, web_driver=tor_browser_web_driver, ) # Given a source user who creates an account # When they first login navigator.source_visits_source_homepage() navigator.source_clicks_submit_documents_on_homepage() navigator.source_continues_to_submit_page() # Then they are able to retrieve their codename from the UI source_codename = navigator.source_retrieves_codename_from_hint() assert source_codename # And they are able to close the codename hint UI content = navigator.driver.find_element_by_id("codename-show-checkbox") assert content.get_attribute("checked") is not None navigator.nav_helper.safe_click_by_id("codename-show") assert content.get_attribute("checked") is None # And on their second login navigator.source_logs_out() navigator.source_visits_source_homepage() navigator.source_chooses_to_login() navigator.source_proceeds_to_login(codename=source_codename) # The codename hint UI is no longer present codename = navigator.driver.find_elements_by_css_selector("#codename-reminder") assert len(codename) == 0
def test_submit_and_retrieve_happy_path(self, sd_servers_v2_with_clean_state, tor_browser_web_driver, firefox_web_driver): # Given a source user accessing the app from their browser source_app_nav = SourceAppNagivator( source_app_base_url=sd_servers_v2_with_clean_state. source_app_base_url, web_driver=tor_browser_web_driver, ) # And they created an account source_app_nav.source_visits_source_homepage() source_app_nav.source_clicks_submit_documents_on_homepage() source_app_nav.source_continues_to_submit_page() # And the source user submitted a message submitted_message = "Confidential message with some international characters: éèö" source_app_nav.source_submits_a_message(message=submitted_message) source_app_nav.source_logs_out() # When a journalist logs in journ_app_nav = JournalistAppNavigator( journalist_app_base_url=sd_servers_v2_with_clean_state. journalist_app_base_url, web_driver=firefox_web_driver, ) journ_app_nav.journalist_logs_in( username=sd_servers_v2_with_clean_state.journalist_username, password=sd_servers_v2_with_clean_state.journalist_password, otp_secret=sd_servers_v2_with_clean_state.journalist_otp_secret, ) journ_app_nav.journalist_checks_messages() # And they try to download the message # Then it succeeds and the journalist sees correct message servers_sd_config = sd_servers_v2_with_clean_state.config_in_use retrieved_message = journ_app_nav.journalist_downloads_first_message( encryption_mgr_to_use_for_decryption=EncryptionManager( gpg_key_dir=Path(servers_sd_config.GPG_KEY_DIR), journalist_key_fingerprint=servers_sd_config.JOURNALIST_KEY, )) assert retrieved_message == submitted_message
def test_submit_and_retrieve_happy_path(self, locale, sd_servers_v2_with_clean_state, tor_browser_web_driver, firefox_web_driver): # Given a source user accessing the app from their browser locale_with_commas = locale.replace("_", "-") source_app_nav = SourceAppNagivator( source_app_base_url=sd_servers_v2_with_clean_state. source_app_base_url, web_driver=tor_browser_web_driver, accept_languages=locale_with_commas, ) # And they created an account source_app_nav.source_visits_source_homepage() source_app_nav.source_clicks_submit_documents_on_homepage() source_app_nav.source_continues_to_submit_page() source_codename = source_app_nav.source_retrieves_codename_from_hint() # And the source user submitted a file submitted_content = "Confidential file with some international characters: éèö" source_app_nav.source_submits_a_file(file_content=submitted_content) source_app_nav.source_logs_out() # And a journalist logs in journ_app_nav = JournalistAppNavigator( journalist_app_base_url=sd_servers_v2_with_clean_state. journalist_app_base_url, web_driver=firefox_web_driver, ) journ_app_nav.journalist_logs_in( username=sd_servers_v2_with_clean_state.journalist_username, password=sd_servers_v2_with_clean_state.journalist_password, otp_secret=sd_servers_v2_with_clean_state.journalist_otp_secret, ) journ_app_nav.journalist_checks_messages() # When they star and unstar the submission, then it succeeds self._journalist_stars_and_unstars_single_message(journ_app_nav) # And when they try to download the file # Then it succeeds and the journalist sees the correct content apps_sd_config = sd_servers_v2_with_clean_state.config_in_use retrieved_message = journ_app_nav.journalist_downloads_first_message( encryption_mgr_to_use_for_decryption=EncryptionManager( gpg_key_dir=Path(apps_sd_config.GPG_KEY_DIR), journalist_key_fingerprint=apps_sd_config.JOURNALIST_KEY, )) assert retrieved_message == submitted_content # And when they reply to the source, it succeeds journ_app_nav.journalist_sends_reply_to_source() # And when the source user comes back source_app_nav.source_visits_source_homepage() source_app_nav.source_chooses_to_login() source_app_nav.source_proceeds_to_login(codename=source_codename) save_screenshot_and_html(source_app_nav.driver, locale, "source-checks_for_reply") # When they delete the journalist's reply, it succeeds self._source_deletes_journalist_reply(source_app_nav) save_screenshot_and_html(source_app_nav.driver, locale, "source-deletes_reply")