-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5257 from freedomofpress/5233-spring-cleaning-sup…
…port Make deletion of multiple sources asynchronous
- Loading branch information
Showing
23 changed files
with
378 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...-base/roles/build-securedrop-app-code-deb-pkg/templates/securedrop_source_deleter.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[Unit] | ||
Description=SecureDrop Source deleter | ||
|
||
[Service] | ||
Environment=PYTHONPATH="{{ securedrop_code }}:{{ securedrop_venv_site_packages }}" | ||
ExecStart={{ securedrop_venv_bin }}/python {{ securedrop_code }}/scripts/source_deleter --interval 10 | ||
PrivateDevices=yes | ||
PrivateTmp=yes | ||
ProtectSystem=full | ||
ReadOnlyDirectories=/ | ||
ReadWriteDirectories={{ securedrop_data }} | ||
Restart=always | ||
RestartSec=10s | ||
UMask=077 | ||
User=www-data | ||
WorkingDirectory={{ securedrop_code }} | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
molecule/testinfra/staging/app-code/test_securedrop_source_deleter_configuration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import pytest | ||
|
||
|
||
testinfra_hosts = ["app-staging"] | ||
|
||
|
||
def test_securedrop_source_deleter_service(host): | ||
""" | ||
Verify configuration of securedrop_source_deleter systemd service. | ||
""" | ||
securedrop_test_vars = pytest.securedrop_test_vars | ||
service_file = "/lib/systemd/system/securedrop_source_deleter.service" | ||
expected_content = "\n".join([ | ||
"[Unit]", | ||
"Description=SecureDrop Source deleter", | ||
"", | ||
"[Service]", | ||
'Environment=PYTHONPATH="{}:{}"'.format( | ||
securedrop_test_vars.securedrop_code, securedrop_test_vars.securedrop_venv_site_packages | ||
), | ||
"ExecStart={}/python /var/www/securedrop/scripts/source_deleter --interval 10".format( | ||
securedrop_test_vars.securedrop_venv_bin | ||
), | ||
"PrivateDevices=yes", | ||
"PrivateTmp=yes", | ||
"ProtectSystem=full", | ||
"ReadOnlyDirectories=/", | ||
"ReadWriteDirectories={}".format(securedrop_test_vars.securedrop_data), | ||
"Restart=always", | ||
"RestartSec=10s", | ||
"UMask=077", | ||
"User={}".format(securedrop_test_vars.securedrop_user), | ||
"WorkingDirectory={}".format(securedrop_test_vars.securedrop_code), | ||
"", | ||
"[Install]", | ||
"WantedBy=multi-user.target\n", | ||
]) | ||
|
||
f = host.file(service_file) | ||
assert f.is_file | ||
assert f.mode == 0o644 | ||
assert f.user == "root" | ||
assert f.group == "root" | ||
assert f.content_string == expected_content | ||
|
||
s = host.service("securedrop_source_deleter") | ||
assert s.is_enabled | ||
assert s.is_running |
32 changes: 32 additions & 0 deletions
32
securedrop/alembic/versions/35513370ba0d_add_source_deleted_at.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""add Source.deleted_at | ||
Revision ID: 35513370ba0d | ||
Revises: 523fff3f969c | ||
Create Date: 2020-05-06 22:28:01.214359 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '35513370ba0d' | ||
down_revision = '523fff3f969c' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('sources', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('deleted_at', sa.DateTime(), nullable=True)) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('sources', schema=None) as batch_op: | ||
batch_op.drop_column('deleted_at') | ||
|
||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.