When shutting down the web server, only use basic auth if there is a password -- this avoids warnings when running tests

This commit is contained in:
Micah Lee 2019-11-10 13:36:35 -08:00
parent 699884df80
commit 29620cb39c
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73

View File

@ -386,10 +386,15 @@ class Web:
# To stop flask, load http://shutdown:[shutdown_password]@127.0.0.1/[shutdown_password]/shutdown
# (We're putting the shutdown_password in the path as well to make routing simpler)
if self.running:
requests.get(
f"http://127.0.0.1:{port}/{self.shutdown_password}/shutdown",
auth=requests.auth.HTTPBasicAuth("onionshare", self.password),
)
if self.password:
requests.get(
f"http://127.0.0.1:{port}/{self.shutdown_password}/shutdown",
auth=requests.auth.HTTPBasicAuth("onionshare", self.password),
)
else:
requests.get(
f"http://127.0.0.1:{port}/{self.shutdown_password}/shutdown"
)
# Reset any password that was in use
self.password = None