Repository: freedomofpress/securedrop

Issue:
Tor2Web warning issues
So there are some issues with how the Tor2Web warnings appear, namely that `.header-warning` sometimes appears multiple times, and can have styling errors:

![screenshot from 2014-03-30 23 54 09](https://cloud.githubusercontent.com/assets/452041/2563836/92e1dc66-b88c-11e3-99e9-a0a3d705ff12.png)

appeared on `https://poulsenjzbufll63.onion.to/lookup`



Discussion:

Resolving patch:
diff --git a/securedrop/journalist.py b/securedrop/journalist.py
--- a/securedrop/journalist.py
+++ b/securedrop/journalist.py
@@ -14,6 +14,7 @@
 import crypto_util
 import store
 import background
+import util
 from db import db_session, Source, Submission
 
 app = Flask(__name__, template_folder=config.JOURNALIST_TEMPLATES_DIR)
@@ -25,7 +26,7 @@
     app.jinja_env.globals['header_image'] = config.CUSTOM_HEADER_IMAGE
     app.jinja_env.globals['use_custom_header_image'] = True
 else:
-    app.jinja_env.globals['header_image'] = 'securedrop.png'
+    app.jinja_env.globals['header_image'] = 'logo.png'
     app.jinja_env.globals['use_custom_header_image'] = False
 
 @app.teardown_appcontext
@@ -151,7 +152,7 @@ def reply():
 
     crypto_util.encrypt(crypto_util.getkey(g.sid), msg, output=
                         store.path(g.sid, filename))
-    
+
     db_session.commit()
     return render_template('reply.html', sid=g.sid,
             codename=g.source.journalist_designation)
diff --git a/securedrop/source.py b/securedrop/source.py
--- a/securedrop/source.py
+++ b/securedrop/source.py
@@ -23,6 +23,7 @@
 import crypto_util
 import store
 import background
+import util
 from db import db_session, Source, Submission
 
 app = Flask(__name__, template_folder=config.SOURCE_TEMPLATES_DIR)
@@ -101,7 +102,7 @@ def check_tor2web():
         flash('<strong>WARNING:</strong> You appear to be using Tor2Web. '
               'This <strong>does not</strong> provide anonymity. '
               '<a href="/tor2web-warning">Why is this dangerous?</a>',
-              "header-warning")
+              "banner-warning")
 
 
 @app.route('/')
@@ -152,8 +153,8 @@ def lookup():
             except UnicodeDecodeError:
                 app.logger.error("Could not decode reply %s" % fn)
             else:
-                date = str(datetime.fromtimestamp(
-                           os.stat(store.path(g.sid, fn)).st_mtime))
+                d = datetime.fromtimestamp(os.stat(store.path(g.sid, fn)).st_mtime)
+                date = util.format_time(d)
                 replies.append(dict(id=fn, date=date, msg=msg))
 
     def async_genkey(sid, codename):
diff --git a/securedrop/util.py b/securedrop/util.py
new file mode 100644
--- /dev/null
+++ b/securedrop/util.py
@@ -0,0 +1,5 @@
+import datetime
+
+def format_time(d):
+    return d.strftime('%b %d, %Y %I:%M %p')
+


Test patch:
diff --git a/securedrop/tests/functional/source_navigation_steps.py b/securedrop/tests/functional/source_navigation_steps.py
--- a/securedrop/tests/functional/source_navigation_steps.py
+++ b/securedrop/tests/functional/source_navigation_steps.py
@@ -4,20 +4,20 @@ class SourceNavigationSteps():
     def _source_visits_source_homepage(self):
         self.driver.get(self.source_location)
 
-        self.assertEqual("SecureDrop", self.driver.title)
+        self.assertEqual("SecureDrop | Protecting Journalists and Sources", self.driver.title)
 
     def _source_chooses_to_submit_documents(self):
         self.driver.find_element_by_id('submit-documents-button').click()
 
-        code_name = self.driver.find_element_by_css_selector('#code-name')
+        codename = self.driver.find_element_by_css_selector('#codename')
 
-        self.assertTrue(len(code_name.text) > 0)
-        self.source_name = code_name.text
+        self.assertTrue(len(codename.text) > 0)
+        self.source_name = codename.text
 
     def _source_continues_to_submit_page(self):
         continue_button = self.driver.find_element_by_id('continue-button')
 
         continue_button.click()
         headline = self.driver.find_element_by_class_name('headline')
-        self.assertEqual('Submit a document, message, or both', headline.text)
+        self.assertEqual('You have three options to send data', headline.text)
 
diff --git a/securedrop/tests/unit_tests.py b/securedrop/tests/unit_tests.py
--- a/securedrop/tests/unit_tests.py
+++ b/securedrop/tests/unit_tests.py
@@ -75,7 +75,7 @@ def _find_codename(self, html):
         """Find a source codename (diceware passphrase) in HTML"""
         # Codenames may contain HTML escape characters, and the wordlist
         # contains various symbols.
-        codename_re = r'<p id="code-name" class="code-name">(?P<codename>[a-z0-9 &#;?:=@_.*+()\'"$%!-]+)</p>'
+        codename_re = r'<strong id="codename">(?P<codename>[a-z0-9 &#;?:=@_.*+()\'"$%!-]+)</strong>'
         codename_match = re.search(codename_re, html)
         self.assertIsNotNone(codename_match)
         return codename_match.group('codename')
@@ -85,7 +85,7 @@ def test_generate(self):
             rv = c.get('/generate')
             self.assertEqual(rv.status_code, 200)
             session_codename = session['codename']
-        self.assertIn("Submitting for the first time", rv.data)
+        self.assertIn("Remember this code and keep it secret", rv.data)
         self.assertIn(
             "To protect your identity, we're assigning you a unique code name.", rv.data)
         codename = self._find_codename(rv.data)
@@ -120,7 +120,7 @@ def test_create(self):
             rv = c.post('/create', follow_redirects=True)
             self.assertTrue(session['logged_in'])
             # should be redirected to /lookup
-            self.assertIn("Submit a document, message, or both", rv.data)
+            self.assertIn("You have three options to send data", rv.data)
 
     def _new_codename(self):
         """Helper function to go through the "generate codename" flow"""
@@ -136,7 +136,7 @@ def test_lookup(self):
         rv = self.client.post('login', data=dict(codename=codename),
                               follow_redirects=True)
         # redirects to /lookup
-        self.assertIn("Download journalist's public key", rv.data)
+        self.assertIn("journalist's public key", rv.data)
         # download the public key
         rv = self.client.get('journalist-key')
         self.assertIn("BEGIN PGP PUBLIC KEY BLOCK", rv.data)
@@ -144,14 +144,14 @@ def test_lookup(self):
     def test_login_and_logout(self):
         rv = self.client.get('/login')
         self.assertEqual(rv.status_code, 200)
-        self.assertIn("Already submitted something?", rv.data)
+        self.assertIn("Login to check for responses", rv.data)
 
         codename = self._new_codename()
         with self.client as c:
             rv = c.post('/login', data=dict(codename=codename),
                                   follow_redirects=True)
             self.assertEqual(rv.status_code, 200)
-            self.assertIn("Submit a document, message, or both", rv.data)
+            self.assertIn("You have three options to send data", rv.data)
             self.assertTrue(session['logged_in'])
             _logout(c)
 
@@ -315,7 +315,7 @@ def tearDown(self):
     def test_index(self):
         rv = self.client.get('/')
         self.assertEqual(rv.status_code, 200)
-        self.assertIn("Latest submissions", rv.data)
+        self.assertIn("Sources", rv.data)
         self.assertIn("No documents have been submitted!", rv.data)
 
     def test_bulk_download(self):
@@ -367,7 +367,7 @@ def test_submit_message(self):
 
         rv = self.journalist_app.get('/')
         self.assertEqual(rv.status_code, 200)
-        self.assertIn("Latest submissions", rv.data)
+        self.assertIn("Sources", rv.data)
         soup = BeautifulSoup(rv.data)
         col_url = soup.select('ul#cols > li a')[0]['href']
 
@@ -440,7 +440,7 @@ def test_submit_file(self):
 
         rv = self.journalist_app.get('/')
         self.assertEqual(rv.status_code, 200)
-        self.assertIn("Latest submissions", rv.data)
+        self.assertIn("Sources", rv.data)
         soup = BeautifulSoup(rv.data)
         col_url = soup.select('ul#cols > li a')[0]['href']
 
@@ -524,7 +524,7 @@ def helper_test_reply(self, test_reply, expected_success=True):
 
         rv = self.journalist_app.get('/')
         self.assertEqual(rv.status_code, 200)
-        self.assertIn("Latest submissions", rv.data)
+        self.assertIn("Sources", rv.data)
         soup = BeautifulSoup(rv.data)
         col_url = soup.select('ul#cols > li a')[0]['href']