Skip to content

Commit

Permalink
Adds special test strings for client testing
Browse files Browse the repository at this point in the history
Fixes #1080
We have many test strings for testing the client text formatting.
  • Loading branch information
kushaldas committed Jun 11, 2020
1 parent 211a394 commit 2fca9dd
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 36 deletions.
1 change: 0 additions & 1 deletion securedrop/bin/dev-shell
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ function docker_run() {
-p "127.0.0.1:${SD_HOSTPORT_SI}:8080" \
-p "127.0.0.1:${SD_HOSTPORT_JI}:8081" \
-e NUM_SOURCES \
-e CLIENT_TEST_DATA \
-e LC_ALL=C.UTF-8 \
-e LANG=C.UTF-8 \
-e PAGE_LAYOUT_LOCALES \
Expand Down
39 changes: 4 additions & 35 deletions securedrop/create-dev-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,15 @@
from sdconfig import config
from db import db
from models import Journalist, Reply, Source, Submission
from specialstrings import submissions

submissions = cycle([
'This is a test submission without markup!',
'This is a test submission with markup and characters such as \, \\, \', \" and ". ' + # noqa: W605, E501
'<strong>This text should not be bold</strong>!'
])

replies = cycle([
'This is a test reply without markup!',
'This is a test reply with markup and characters such as \, \\, \', \" and ". ' + # noqa: W605, E501
'<strong>This text should not be bold</strong>!'
])

spcial_submissions = cycle([
"""~!@#$%^&*()_+{}|:"<>?~!@#$%^&*()_+{}|:"<>?~!@#$%^&*()_+{}|:"<>?~!@#$%""",
"""Ω≈ç√∫˜µ≤≥÷
åß∂ƒ©˙∆˚¬…æ
œ∑´®†¥¨ˆøπ“‘
¡™£¢∞§¶•ªº–≠
¸˛Ç◊ı˜Â¯˘¿
ÅÍÎÏ˝ÓÔÒÚÆ☃
Œ„´‰ˇÁ¨ˆØ∏”""",
"""!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!$""" # noqa: W605, E501
"""............................................................................................................................ .""", # noqa: W605, E501

"""thisisalongwordwithoutspacesordashesthisisalongwordwithoutspacesordashesthisisalongwordwithoutspacesordashesthisisalongwordwithoutspacesordashesthisisalongwordwithoutspacesordashesthisisalongwordwithoutspacesordashesthisisalongwordwithoutspacesordashesthisisalongwordwithoutspacesordashesthisisalongwordwithoutspacesordashesthisisalongwordwithoutspacesordashesthisisalongwordwithoutspacesordashesthisisalongwordwithoutspacesordashesthisisalongwordwithoutspacesordashesthisisalongwordwithoutspacesordashesthisisalongwordwit💩houtspacesordashes""", # noqa: W605, E501

"""😍😍😍😍🔥🔥🔥🔥🔥🖧Thelastwas3networkedcomuters📟📸longwordwit💩houtspacesordashes""" # noqa: W605, E501



]
)


def main(staging=False):
app = journalist_app.create_app(config)
Expand Down Expand Up @@ -78,7 +53,7 @@ def main(staging=False):
last_name="Kent")

# Add test sources and submissions
num_sources = int(os.getenv('NUM_SOURCES', 2))
num_sources = int(os.getenv('NUM_SOURCES', 43))
for i in range(1, num_sources + 1):
if i == 1:
# For the first source, the journalist who replied will be deleted
Expand All @@ -88,9 +63,6 @@ def main(staging=False):
continue
create_source_and_submissions(i, num_sources)

client_test = int(os.getenv('CLIENT_TEST_DATA', 0))
for i in range(1, client_test):
create_source_and_submissions(i, client_test, client_test_data=True)
# Now let us delete one journalist
db.session.delete(journalist_tobe_deleted)
db.session.commit()
Expand All @@ -117,7 +89,7 @@ def add_test_user(username, password, otp_secret, is_admin=False,


def create_source_and_submissions(
source_index, source_count, num_submissions=2, num_replies=2, journalist_who_replied=None, client_test_data=False # noqa: W605, E501
source_index, source_count, num_submissions=2, num_replies=2, journalist_who_replied=None # noqa: W605, E501
):
# Store source in database
codename = current_app.crypto_util.genrandomid()
Expand All @@ -135,10 +107,7 @@ def create_source_and_submissions(
# Generate some test submissions
for _ in range(num_submissions):
source.interaction_count += 1
if client_test_data:
submission_text = next(spcial_submissions)
else:
submission_text = next(submissions)
submission_text = next(submissions)
fpath = current_app.storage.save_message_submission(
source.filesystem_id,
source.interaction_count,
Expand Down
90 changes: 90 additions & 0 deletions securedrop/specialstrings.py

Large diffs are not rendered by default.

0 comments on commit 2fca9dd

Please sign in to comment.