Skip to content

Commit

Permalink
Merge pull request #5559 from DrGFreeman/5433-replace-platform.linux_…
Browse files Browse the repository at this point in the history
…distribution

5433 replace platform.linux distribution
  • Loading branch information
kushaldas authored Oct 7, 2020
2 parents 8b50a9e + c4f919b commit 43da794
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions securedrop/source_app/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import platform

from flask import Blueprint, current_app, make_response

Expand All @@ -8,6 +7,10 @@
import version


with open("/etc/lsb-release", "r") as f:
server_os = f.readlines()[1].split("=")[1].strip("\n")


def make_blueprint(config):
view = Blueprint('api', __name__)

Expand All @@ -17,7 +20,7 @@ def metadata():
'allow_document_uploads': current_app.instance_config.allow_document_uploads,
'gpg_fpr': config.JOURNALIST_KEY,
'sd_version': version.__version__,
'server_os': platform.linux_distribution()[1],
'server_os': server_os,
'supported_languages': config.SUPPORTED_LOCALES,
'v2_source_url': get_sourcev2_url(),
'v3_source_url': get_sourcev3_url()
Expand Down
3 changes: 1 addition & 2 deletions securedrop/tests/test_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,7 @@ def test_why_journalist_key(source_app):


def test_metadata_route(config, source_app):
with patch.object(source_app_api.platform, "linux_distribution") as mocked_platform:
mocked_platform.return_value = ("Ubuntu", "16.04", "xenial")
with patch.object(source_app_api, "server_os", new="16.04"):
with source_app.test_client() as app:
resp = app.get(url_for('api.metadata'))
assert resp.status_code == 200
Expand Down

0 comments on commit 43da794

Please sign in to comment.