Skip to content

Commit

Permalink
Fixes #1080 Various client related strings from test data
Browse files Browse the repository at this point in the history
  • Loading branch information
kushaldas committed May 4, 2020
1 parent ab8d4a0 commit fd8a0f2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions securedrop/bin/dev-shell
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ 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
31 changes: 28 additions & 3 deletions securedrop/create-dev-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,26 @@

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

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

]
)

def main(staging=False):
app = journalist_app.create_app(config)
Expand Down Expand Up @@ -66,6 +82,11 @@ 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 @@ -92,7 +113,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
source_index, source_count, num_submissions=2, num_replies=2, journalist_who_replied=None, client_test_data=False
):
# Store source in database
codename = current_app.crypto_util.genrandomid()
Expand All @@ -110,11 +131,15 @@ 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)
fpath = current_app.storage.save_message_submission(
source.filesystem_id,
source.interaction_count,
source.journalist_filename,
next(submissions)
submission_text
)
source.last_updated = datetime.datetime.utcnow()
submission = Submission(source, fpath)
Expand Down

0 comments on commit fd8a0f2

Please sign in to comment.