def test_download_message(self, _sd_servers_v2_with_missing_file, firefox_web_driver): # Given an SD server with a submission whose file was deleted from disk # And a journalist logged into the journalist interface journ_app_nav = JournalistAppNavigator( journalist_app_base_url=_sd_servers_v2_with_missing_file. journalist_app_base_url, web_driver=firefox_web_driver, ) journ_app_nav.journalist_logs_in( username=_sd_servers_v2_with_missing_file.journalist_username, password=_sd_servers_v2_with_missing_file.journalist_password, otp_secret=_sd_servers_v2_with_missing_file.journalist_otp_secret, ) # When the journalist clicks on the individual message from the source page journ_app_nav.journalist_checks_messages() journ_app_nav.journalist_selects_the_first_source() journ_app_nav.nav_helper.wait_for( lambda: journ_app_nav.driver.find_element_by_css_selector( "table#submissions")) submissions = journ_app_nav.driver.find_elements_by_css_selector( "#submissions a") assert 1 == len(submissions) file_link = submissions[0] file_link.click() # Then they see the expected error message self._journalist_sees_missing_file_error_message(journ_app_nav) self._journalist_is_on_collection_page(journ_app_nav)
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")