Skip to content

Commit

Permalink
Merge pull request #479 from mesosphere/bugfix2
Browse files Browse the repository at this point in the history
fix username/password for capabilities endpoint
  • Loading branch information
tamarrow committed Feb 19, 2016
2 parents 70b8a1a + bf7bfbc commit abb1a0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion dcos/cosmospackage.py
@@ -1,4 +1,5 @@
from dcos import emitting, http, util
from dcos.errors import DCOSException, DCOSHTTPException

from six.moves import urllib

Expand All @@ -18,12 +19,21 @@ def enabled(self):
:rtype: bool
"""

try:
url = urllib.parse.urljoin(self.cosmos_url, 'capabilities')
response = http.get(url,
headers=_get_cosmos_header("capabilities"))
except Exception:
# return `Authentication failed` error messages, but all other errors
# are treated as endpoint not available
except DCOSHTTPException:
return False
except DCOSException:
raise
except Exception as e:
logger.exception(e)
return False

return response.status_code == 200


Expand Down
2 changes: 1 addition & 1 deletion dcos/http.py
Expand Up @@ -120,7 +120,7 @@ def _request_with_auth(response,

i = 0
while i < 3 and response.status_code == 401:
parsed_url = urlparse(response.url)
parsed_url = urlparse(url)
hostname = parsed_url.hostname
auth_scheme, realm = get_auth_scheme(response)
creds = (hostname, auth_scheme, realm)
Expand Down

0 comments on commit abb1a0f

Please sign in to comment.