Skip to content

Commit

Permalink
DCOS-1521 Fix OAuth wording
Browse files Browse the repository at this point in the history
  • Loading branch information
jsancio committed May 28, 2015
1 parent e217628 commit 7fe6d0f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 24 deletions.
24 changes: 15 additions & 9 deletions cli/tests/integrations/cli/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ def test_when_authenticated():


def test_anonymous_login():
with patch('six.moves.input',
return_value=''), patch('uuid.uuid1',
return_value='anonymous@email'):
with patch('sys.stdin.readline', return_value='\n'), \
patch('uuid.uuid1', return_value='anonymous@email'):

assert _mock_dcos_run([util.which('dcos'),
'help'], False) == 0
Expand All @@ -35,17 +34,24 @@ def test_anonymous_login():


def _mock_dcos_run(args, authenticated=True):
env = _config_with_credentials() if authenticated else \
_config_without_credentials()
if authenticated:
env = _config_with_credentials()
else:
env = _config_without_credentials()

with patch('sys.argv', args), patch.dict(os.environ, env):
return main()


def _config_with_credentials():
return {constants.DCOS_CONFIG_ENV: os.path.join(
'tests', 'data', 'auth', 'dcos_with_credentials.toml')}
return {
constants.DCOS_CONFIG_ENV: os.path.join(
'tests', 'data', 'auth', 'dcos_with_credentials.toml')
}


def _config_without_credentials():
return {constants.DCOS_CONFIG_ENV: os.path.join(
'tests', 'data', 'auth', 'dcos_without_credentials.toml')}
return {
constants.DCOS_CONFIG_ENV: os.path.join(
'tests', 'data', 'auth', 'dcos_without_credentials.toml')
}
33 changes: 18 additions & 15 deletions dcos/auth.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import json
import os
import sys
import uuid

import pkg_resources
import toml
from dcos import config, constants, emitting, errors, http, jsonitem, util
from dcos.errors import DCOSException
from six import iteritems, moves
from six import iteritems

from oauth2client import client

Expand Down Expand Up @@ -69,29 +70,31 @@ def _run(flow):
:rtype: dict
"""

auth_url = flow.step1_get_authorize_url()
message = """Thank you for installing the Mesosphere DCOS CLI.
Please log in with your Mesosphere Account by pasting
the following URL into your browser to continue."""
emitter.publish(errors.DefaultError(
'{message}\n\n {url}\n\n'.format(message=message,
url=auth_url,)))
emitter.publish(
errors.DefaultError(
'\n\n\n{message}\n\n {url}\n\n'.format(
message='Go to the following link in your browser:',
url=flow.step1_get_authorize_url())))

code = moves.input('Please enter Mesosphere verification code: ').strip()
sys.stderr.write('Enter verification code: ')
code = sys.stdin.readline().strip()
if not code:
email = moves.input('Skipping authentication.'
' Please enter email address:').strip()
sys.stderr.write('Skipping authentication. Enter email address: ')

email = sys.stdin.readline().strip()
if not email:
emitter.publish(errors.DefaultError('Skipping email input,'
' using anonymous id:'))
emitter.publish(
errors.DefaultError(
'Skipping email input using anonymous id.'))
email = str(uuid.uuid1())

return {CORE_EMAIL_KEY: email}

return make_oauth_request(code, flow)


def check_if_user_authenticated():
""" check if user is authenticated already
"""Check if user is authenticated already
:returns user auth status
:rtype: boolean
Expand All @@ -102,7 +105,7 @@ def check_if_user_authenticated():


def force_auth():
""" Make user authentication process
"""Make user authentication process
:returns authentication process status
:rtype: boolean
Expand Down

0 comments on commit 7fe6d0f

Please sign in to comment.