Skip to content

Commit

Permalink
The Debian package tool now uses proxy by default
Browse files Browse the repository at this point in the history
Use ./run.sh --proxy to connect to the proxy vm.
  • Loading branch information
kushaldas committed Oct 30, 2018
1 parent c707465 commit 1dd9570
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
11 changes: 8 additions & 3 deletions securedrop_client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def arg_parser() -> ArgumentParser:
type=expand_to_absolute,
help=('SecureDrop Client home directory for storing files and state. '
'(Default {})'.format(DEFAULT_SDC_HOME)))
parser.add_argument(
'--proxy', action='store_true',
help='Use proxy AppVM name to connect to server.')
return parser


Expand Down Expand Up @@ -139,7 +142,8 @@ def start_app(args, qt_args) -> None:
Session = sessionmaker(bind=engine)
session = Session()

client = Client("http://localhost:8081/", gui, session, args.sdc_home)
client = Client("http://localhost:8081/", gui, session,
args.sdc_home, args.proxy)
client.setup()

configure_signal_handlers(app)
Expand All @@ -151,13 +155,14 @@ def start_app(args, qt_args) -> None:


def run() -> None:
config_file = "/etc/securdrop-client/client.ini"
config_file = "/etc/securedrop-client/client.ini"
args, qt_args = arg_parser().parse_known_args()
if args.sdc_home == DEFAULT_SDC_HOME and \
if args.sdc_home == expand_to_absolute(DEFAULT_SDC_HOME) and \
os.path.exists(config_file): # pragma: no cover
config = configparser.ConfigParser()
config.read(config_file)
args.sdc_home = config["client"]["homedir"]
args.proxy = config["client"]["use_securedrop_proxy"]
# reinsert the program's name
qt_args.insert(0, 'securedrop-client')
start_app(args, qt_args)
7 changes: 5 additions & 2 deletions securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class Client(QObject):

finish_api_call = pyqtSignal() # Acknowledges reciept of an API call.

def __init__(self, hostname, gui, session, home: str) -> None:
def __init__(self, hostname, gui, session,
home: str, proxy: bool = False) -> None:
"""
The hostname, gui and session objects are used to coordinate with the
various other layers of the application: the location of the SecureDrop
Expand All @@ -103,6 +104,7 @@ def __init__(self, hostname, gui, session, home: str) -> None:
self.sync_flag = os.path.join(home, 'sync_flag')
self.home = home # The "home" directory for client files.
self.data_dir = os.path.join(self.home, 'data') # File data.
self.proxy = proxy

def setup(self):
"""
Expand Down Expand Up @@ -159,7 +161,8 @@ def login(self, username, password, totp):
Given a username, password and time based one-time-passcode (TOTP),
create a new instance representing the SecureDrop api and authenticate.
"""
self.api = sdclientapi.API(self.hostname, username, password, totp)
self.api = sdclientapi.API(self.hostname, username,
password, totp, self.proxy)
self.call_api(self.api.authenticate, self.on_authenticate,
self.on_login_timeout)

Expand Down
3 changes: 2 additions & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def test_start_app(safe_tmpdir):
mock_qt_args = mock.MagicMock()
sdc_home = str(safe_tmpdir)
mock_args.sdc_home = sdc_home
mock_args.proxy = False

with mock.patch('securedrop_client.app.configure_logging') as conf_log, \
mock.patch('securedrop_client.app.QApplication') as mock_app, \
Expand All @@ -68,7 +69,7 @@ def test_start_app(safe_tmpdir):
mock_win.assert_called_once_with()
mock_client.assert_called_once_with('http://localhost:8081/',
mock_win(), mock_session_class(),
sdc_home)
sdc_home, False)


PERMISSIONS_CASES = [
Expand Down

0 comments on commit 1dd9570

Please sign in to comment.