Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api_tests/users/views/test_user_confirm_external_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def payload(self, user_one):
'attributes': {
'uid': user_one._id,
'token': user_one.get_confirmation_token(user_one.username),
'destination': 'dashboard',
'destination': 'my_projects',
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions framework/auth/campaigns.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_campaigns():
newest_campaigns.update({
'agu_conference_2023': {
'system_tag': CampaignSourceTags.AguConference2023.value,
'redirect_url': furl(DOMAIN).add(path='dashboard/').url,
'redirect_url': furl(DOMAIN).add(path='my_projects/').url,
'confirmation_email_template': mails.CONFIRM_EMAIL_AGU_CONFERENCE_2023,
'login_type': 'native',
}
Expand All @@ -103,7 +103,7 @@ def get_campaigns():
newest_campaigns.update({
'agu_conference': {
'system_tag': CampaignSourceTags.AguConference.value,
'redirect_url': furl(DOMAIN).add(path='dashboard/').url,
'redirect_url': furl(DOMAIN).add(path='my_projects/').url,
'confirmation_email_template': mails.CONFIRM_EMAIL_AGU_CONFERENCE,
'login_type': 'native',
}
Expand Down
24 changes: 12 additions & 12 deletions framework/auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def _reset_password_get(auth, uid=None, token=None, institutional=False):
}
raise HTTPError(http_status.HTTP_400_BAD_REQUEST, data=error_data)

# override routes.py login_url to redirect to dashboard
service_url = web_url_for('dashboard', _absolute=True)
# override routes.py login_url to redirect to myprojects
service_url = web_url_for('my_projects', _absolute=True)

return {
'uid': user_obj._id,
Expand Down Expand Up @@ -174,9 +174,9 @@ def forgot_password_get(auth):
if auth.logged_in:
return auth_logout(redirect_url=request.url)

#overriding the routes.py sign in url to redirect to the dashboard after login
#overriding the routes.py sign in url to redirect to the myprojects after login
context = {}
context['login_url'] = web_url_for('dashboard', _absolute=True)
context['login_url'] = web_url_for('my_projects', _absolute=True)

return context

Expand Down Expand Up @@ -320,7 +320,7 @@ def login_and_register_handler(auth, login=True, campaign=None, next_url=None, l
# unlike other campaigns, institution login serves as an alternative for authentication
if campaign == 'institution':
if next_url is None:
next_url = web_url_for('dashboard', _absolute=True)
next_url = web_url_for('my_projects', _absolute=True)
data['status_code'] = http_status.HTTP_302_FOUND
if auth.logged_in:
data['next_url'] = next_url
Expand Down Expand Up @@ -387,7 +387,7 @@ def login_and_register_handler(auth, login=True, campaign=None, next_url=None, l
# `/login/` or `/register/` without any parameter
if auth.logged_in:
data['status_code'] = http_status.HTTP_302_FOUND
data['next_url'] = web_url_for('dashboard', _absolute=True)
data['next_url'] = web_url_for('my_projects', _absolute=True)

return data

Expand All @@ -404,7 +404,7 @@ def auth_login(auth):
if campaign and logged out, go to campaign register page (with next_url if presents)
if next_url and logged in, go to next url
if next_url and logged out, go to cas login page with current request url as service parameter
if none, go to `/dashboard` which is decorated by `@must_be_logged_in`
if none, go to `/myprojects` which is decorated by `@must_be_logged_in`

:param auth: the auth context
:return: redirects
Expand All @@ -431,7 +431,7 @@ def auth_register(auth):
if next_url and logged in, go to next url
if next_url and logged out, go to cas login page with current request url as service parameter
if next_url and logout flag, log user out first and then go to the next_url
if none, go to `/dashboard` which is decorated by `@must_be_logged_in`
if none, go to `/myprojects` which is decorated by `@must_be_logged_in`

:param auth: the auth context
:return: land, redirect or `auth_logout`
Expand Down Expand Up @@ -541,7 +541,7 @@ def auth_email_logout(token, user):
When a user is adding an email or merging an account, add the email to the user and log them out.
"""

redirect_url = cas.get_logout_url(service_url=cas.get_login_url(service_url=web_url_for('index', _absolute=True)))
redirect_url = cas.get_logout_url(service_url=cas.get_login_url(service_url=web_url_for('auth_login', _absolute=True)))
try:
unconfirmed_email = user.get_unconfirmed_email_for_token(token)
except InvalidTokenError:
Expand Down Expand Up @@ -610,7 +610,7 @@ def external_login_confirm_email_get(auth, uid, token):
return redirect(campaign_url)
if new:
status.push_status_message(language.WELCOME_MESSAGE, kind='default', jumbotron=True, trust=True, id='welcome_message')
return redirect(web_url_for('dashboard'))
return redirect(web_url_for('my_projects'))

# token is invalid
if token not in user.email_verifications:
Expand Down Expand Up @@ -988,7 +988,7 @@ def resend_confirmation_post(auth):
try:
send_confirm_email(user, clean_email, renew=True)
except KeyError:
# already confirmed, redirect to dashboard
# already confirmed, redirect to myprojects
status_message = f'This email {clean_email} has already been confirmed.'
kind = 'warning'
user.email_last_sent = timezone.now()
Expand Down Expand Up @@ -1048,7 +1048,7 @@ def external_login_email_post():
service_url = session.get('service_url', None)

# TODO: @cslzchen use user tags instead of destination
destination = 'dashboard'
destination = 'my_projects'
for campaign in campaigns.get_campaigns():
if campaign != 'institution':
# Handle different url encoding schemes between `furl` and `urlparse/urllib`.
Expand Down
4 changes: 2 additions & 2 deletions osf_tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ def test_add_blocked_domain_unconfirmed_email(self, user):
def test_get_confirmation_url_for_external_service(self, random_string):
random_string.return_value = 'abcde'
u = UnconfirmedUserFactory()
assert (u.get_confirmation_url(u.username, external_id_provider='service', destination='dashboard') ==
f'{settings.DOMAIN}confirm/external/{u._id}/abcde/?destination=dashboard')
assert (u.get_confirmation_url(u.username, external_id_provider='service', destination='my_projects') ==
f'{settings.DOMAIN}confirm/external/{u._id}/abcde/?destination=my_projects')

@mock.patch('website.security.random_string')
def test_get_confirmation_token(self, random_string):
Expand Down
27 changes: 2 additions & 25 deletions tests/test_addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ def test_redirects_to_guid(self):
)

assert resp.status_code == 302
assert resp.location == f'/{guid._id}/'
assert resp.location == f'{settings.DOMAIN}{guid._id}/'

def test_action_download_redirects_to_download_with_param(self):
file_node = self.get_test_file()
Expand Down Expand Up @@ -1426,17 +1426,14 @@ def test_head_returns_url_and_redirect(self):
guid = file_node.get_guid(create=True)

resp = self.app.head(f'/{guid._id}/', auth=self.user.auth)
assert resp.status_code == 200
assert resp.status_code == 302

def test_head_returns_url_with_version_and_redirect(self):
file_node = self.get_test_file()
guid = file_node.get_guid(create=True)

resp = self.app.head(f'/{guid._id}/?revision=1&foo=bar', auth=self.user.auth)
location = furl(resp.location)
# Note: version is added but us but all other url params are added as well
assert resp.status_code == 302
assert_urls_equal(location.url, file_node.generate_waterbutler_url(direct=None, revision=1, version='', foo='bar'))

def test_nonexistent_addons_raise(self):
path = 'cloudfiles'
Expand Down Expand Up @@ -1474,26 +1471,6 @@ def test_unauth_addons_raise(self):
self.assertEqual(resp.status_code, 401)
assert resp.status_code == 401

def test_resolve_folder_raise(self):
folder = OsfStorageFolder(
name='folder',
target=self.project,
path='/test/folder/',
materialized_path='/test/folder/',
)
folder.save()
resp = self.app.get(
self.project.web_url_for(
'addon_view_or_download_file',
path=folder._id,
provider='osfstorage',
),
auth=self.user.auth,

)

assert resp.status_code == 400

def test_delete_action_creates_trashed_file_node(self):
file_node = self.get_test_file()
payload = {
Expand Down
8 changes: 4 additions & 4 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_get_user_with_wrong_password_returns_false(self):
assert not auth.get_user(email=user.username, password='wrong')

def test_get_user_by_external_info(self):
service_url = 'http://localhost:5000/dashboard/'
service_url = 'http://localhost:5000/my_projects/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test assertions use /my_projects/ but actual route is /myprojects/

user, validated_credentials, cas_resp = generate_external_user_with_resp(service_url)
user.save()
assert auth.get_user(external_id_provider=validated_credentials['provider'], external_id=validated_credentials['id']) == user
Expand All @@ -133,7 +133,7 @@ def test_get_user_by_external_info(self):
@mock.patch('framework.auth.cas.CasClient.service_validate')
def test_successful_external_login_cas_redirect(self, mock_service_validate, mock_get_user_from_cas_resp):
# TODO: check in qa url encoding
service_url = 'http://localhost:5000/dashboard/'
service_url = 'http://localhost:5000/my_projects/'
user, validated_credentials, cas_resp = generate_external_user_with_resp(service_url)
mock_service_validate.return_value = cas_resp
mock_get_user_from_cas_resp.return_value = (user, validated_credentials, 'authenticate')
Expand All @@ -148,7 +148,7 @@ def test_successful_external_login_cas_redirect(self, mock_service_validate, moc
@mock.patch('framework.auth.cas.get_user_from_cas_resp')
@mock.patch('framework.auth.cas.CasClient.service_validate')
def test_successful_external_first_login(self, mock_service_validate, mock_get_user_from_cas_resp):
service_url = 'http://localhost:5000/dashboard/'
service_url = 'http://localhost:5000/my_projects/'
_, validated_credentials, cas_resp = generate_external_user_with_resp(service_url, user=False)
mock_service_validate.return_value = cas_resp
mock_get_user_from_cas_resp.return_value = (None, validated_credentials, 'external_first_login')
Expand All @@ -161,7 +161,7 @@ def test_successful_external_first_login(self, mock_service_validate, mock_get_u
@mock.patch('framework.auth.cas.get_user_from_cas_resp')
@mock.patch('framework.auth.cas.CasClient.service_validate')
def test_successful_external_first_login_without_attributes(self, mock_service_validate, mock_get_user_from_cas_resp, mock_external_first_login_authenticate):
service_url = 'http://localhost:5000/dashboard/'
service_url = 'http://localhost:5000/my_projects/'
user, validated_credentials, cas_resp = generate_external_user_with_resp(service_url, user=False, release=False)
mock_service_validate.return_value = cas_resp
mock_get_user_from_cas_resp.return_value = (None, validated_credentials, 'external_first_login')
Expand Down
18 changes: 9 additions & 9 deletions tests/test_auth_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,25 +551,25 @@ def test_osf_login_with_auth(self):
# login: user with auth
data = login_and_register_handler(self.auth)
assert data.get('status_code') == http_status.HTTP_302_FOUND
assert data.get('next_url') == web_url_for('dashboard', _absolute=True)
assert data.get('next_url') == web_url_for('my_projects', _absolute=True)

def test_osf_login_without_auth(self):
# login: user without auth
data = login_and_register_handler(self.no_auth)
assert data.get('status_code') == http_status.HTTP_302_FOUND
assert data.get('next_url') == web_url_for('dashboard', _absolute=True)
assert data.get('next_url') == web_url_for('my_projects', _absolute=True)

def test_osf_register_with_auth(self):
# register: user with auth
data = login_and_register_handler(self.auth, login=False)
assert data.get('status_code') == http_status.HTTP_302_FOUND
assert data.get('next_url') == web_url_for('dashboard', _absolute=True)
assert data.get('next_url') == web_url_for('my_projects', _absolute=True)

def test_osf_register_without_auth(self):
# register: user without auth
data = login_and_register_handler(self.no_auth, login=False)
assert data.get('status_code') == http_status.HTTP_200_OK
assert data.get('next_url') == web_url_for('dashboard', _absolute=True)
assert data.get('next_url') == web_url_for('my_projects', _absolute=True)

def test_next_url_login_with_auth(self):
# next_url login: user with auth
Expand Down Expand Up @@ -603,13 +603,13 @@ def test_institution_login_with_auth(self):
# institution login: user with auth
data = login_and_register_handler(self.auth, campaign='institution')
assert data.get('status_code') == http_status.HTTP_302_FOUND
assert data.get('next_url') == web_url_for('dashboard', _absolute=True)
assert data.get('next_url') == web_url_for('my_projects', _absolute=True)

def test_institution_login_without_auth(self):
# institution login: user without auth
data = login_and_register_handler(self.no_auth, campaign='institution')
assert data.get('status_code') == http_status.HTTP_302_FOUND
assert data.get('next_url') == cas.get_login_url(web_url_for('dashboard', _absolute=True),
assert data.get('next_url') == cas.get_login_url(web_url_for('my_projects', _absolute=True),
campaign='institution')

def test_institution_login_next_url_with_auth(self):
Expand All @@ -628,13 +628,13 @@ def test_institution_register_with_auth(self):
# institution register: user with auth
data = login_and_register_handler(self.auth, login=False, campaign='institution')
assert data.get('status_code') == http_status.HTTP_302_FOUND
assert data.get('next_url') == web_url_for('dashboard', _absolute=True)
assert data.get('next_url') == web_url_for('my_projects', _absolute=True)

def test_institution_register_without_auth(self):
# institution register: user without auth
data = login_and_register_handler(self.no_auth, login=False, campaign='institution')
assert data.get('status_code') == http_status.HTTP_302_FOUND
assert data.get('next_url') == cas.get_login_url(web_url_for('dashboard', _absolute=True), campaign='institution')
assert data.get('next_url') == cas.get_login_url(web_url_for('my_projects', _absolute=True), campaign='institution')

def test_campaign_login_with_auth(self):
for campaign in get_campaigns():
Expand Down Expand Up @@ -775,7 +775,7 @@ def setUp(self):
super().setUp()
self.goodbye_url = web_url_for('goodbye', _absolute=True)
self.redirect_url = web_url_for('forgot_password_get', _absolute=True)
self.valid_next_url = web_url_for('dashboard', _absolute=True)
self.valid_next_url = web_url_for('my_projects', _absolute=True)
self.invalid_next_url = 'http://localhost:1234/abcde'
self.auth_user = AuthUserFactory()

Expand Down
2 changes: 1 addition & 1 deletion tests/test_campaigns.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def setUp(self):
super().setUp()
self.url_login = web_url_for('auth_login', campaign='institution')
self.url_register = web_url_for('auth_register', campaign='institution')
self.service_url = web_url_for('dashboard', _absolute=True)
self.service_url = web_url_for('my_projects', _absolute=True)

# go to CAS institution login page if not logged in
def test_institution_not_logged_in(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_comfirmation_view_block_bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_external_login_confirm_email_get_create_user(self):
create_url = user.get_confirmation_url(
user.username,
external_id_provider='service',
destination='dashboard'
destination='my_projects'
)

res = self.app.get(
Expand All @@ -179,7 +179,7 @@ def test_external_login_confirm_email_get_link_user(self):
link_url = user.get_confirmation_url(
user.username,
external_id_provider='service',
destination='dashboard'
destination='my_projects'
)

res = self.app.get(
Expand Down
10 changes: 5 additions & 5 deletions tests/test_misc_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def test_external_login_email_get_with_invalid_session(self):
def test_external_login_confirm_email_get_with_another_user_logged_in(self):
# TODO: check in qa url encoding
another_user = AuthUserFactory()
url = self.user.get_confirmation_url(self.user.username, external_id_provider='orcid', destination='dashboard')
url = self.user.get_confirmation_url(self.user.username, external_id_provider='orcid', destination='my_projects')
res = self.app.get(url, auth=another_user.auth)
assert res.status_code == 302, 'redirects to cas logout'
assert '/logout?service=' in res.location
Expand All @@ -408,7 +408,7 @@ def test_external_login_confirm_email_get_without_destination(self):
def test_external_login_confirm_email_get_create(self):
# TODO: check in qa url encoding
assert not self.user.is_registered
url = self.user.get_confirmation_url(self.user.username, external_id_provider='orcid', destination='dashboard')
url = self.user.get_confirmation_url(self.user.username, external_id_provider='orcid', destination='my_projects')
res = self.app.get(url)
assert res.status_code == 302, 'redirects to cas login'
assert '/login?service=' in res.location
Expand All @@ -425,7 +425,7 @@ def test_external_login_confirm_email_get_link(self):
self.user.external_identity['orcid'][self.provider_id] = 'LINK'
self.user.save()
assert not self.user.is_registered
url = self.user.get_confirmation_url(self.user.username, external_id_provider='orcid', destination='dashboard')
url = self.user.get_confirmation_url(self.user.username, external_id_provider='orcid', destination='my_projects')
res = self.app.get(url)
assert res.status_code == 302, 'redirects to cas login'
assert 'You should be redirected automatically' in str(res.html)
Expand All @@ -442,7 +442,7 @@ def test_external_login_confirm_email_get_link(self):
def test_external_login_confirm_email_get_duped_id(self):
dupe_user = UserFactory(external_identity={'orcid': {self.provider_id: 'CREATE'}})
assert dupe_user.external_identity == self.user.external_identity
url = self.user.get_confirmation_url(self.user.username, external_id_provider='orcid', destination='dashboard')
url = self.user.get_confirmation_url(self.user.username, external_id_provider='orcid', destination='my_projects')
res = self.app.get(url)
assert res.status_code == 302, 'redirects to cas login'
assert 'You should be redirected automatically' in str(res.html)
Expand All @@ -458,7 +458,7 @@ def test_external_login_confirm_email_get_duped_id(self):

def test_external_login_confirm_email_get_duping_id(self):
dupe_user = UserFactory(external_identity={'orcid': {self.provider_id: 'VERIFIED'}})
url = self.user.get_confirmation_url(self.user.username, external_id_provider='orcid', destination='dashboard')
url = self.user.get_confirmation_url(self.user.username, external_id_provider='orcid', destination='my_projects')
res = self.app.get(url)
assert res.status_code == 403, 'only allows one user to link an id'

Expand Down
Loading