Skip to content

Commit 30b96ab

Browse files
authored
Merge pull request #11390 from CenterForOpenScience/develop
Merge develop into `feature/pbs-25-21`
2 parents 62812c7 + a920785 commit 30b96ab

File tree

9 files changed

+9
-53
lines changed

9 files changed

+9
-53
lines changed

admin/users/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def get_claim_links(self, user):
503503

504504
for guid, value in user.unclaimed_records.items():
505505
obj = Guid.load(guid)
506-
url = f'{DOMAIN}user/{user._id}/{guid}/claim/?token={value["token"]}'
506+
url = f'{DOMAIN}legacy/user/{user._id}/{guid}/claim/?token={value["token"]}'
507507
links.append(f'Claim URL for {obj.content_type.model} {obj._id}: {url}')
508508

509509
return links or ['User currently has no active unclaimed records for any nodes.']

api_tests/base/test_utils.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from django.conf import settings as django_conf_settings
66

77
from rest_framework import fields
8-
from rest_framework.exceptions import ValidationError
98

109
from api.base import utils as api_utils
1110
from osf.models.base import coerce_guid, Guid, GuidMixin, OptionalGuidMixin, VersionedGuidMixin, InvalidGuid
@@ -63,47 +62,6 @@ def test_push_status_message_no_response(self):
6362
except BaseException:
6463
assert False, f'Exception from push_status_message via API v2 with type "{status}".'
6564

66-
def test_push_status_message_expected_error(self):
67-
status_message = 'This is a message'
68-
try:
69-
push_status_message(status_message, kind='error')
70-
assert False, 'push_status_message() should have generated a ValidationError exception.'
71-
72-
except ValidationError as e:
73-
assert (
74-
e.detail[0] == status_message
75-
), 'push_status_message() should have passed along the message with the Exception.'
76-
77-
except RuntimeError:
78-
assert False, 'push_status_message() should have caught the runtime error and replaced it.'
79-
80-
except BaseException:
81-
assert False, 'Exception from push_status_message when called from the v2 API with type "error"'
82-
83-
@mock.patch('framework.status.get_session')
84-
def test_push_status_message_unexpected_error(self, mock_get_session):
85-
status_message = 'This is a message'
86-
exception_message = 'this is some very unexpected problem'
87-
mock_session = mock.Mock()
88-
mock_session.attach_mock(mock.Mock(side_effect=RuntimeError(exception_message)), 'get')
89-
mock_get_session.return_value = mock_session
90-
try:
91-
push_status_message(status_message, kind='error')
92-
assert False, 'push_status_message() should have generated a RuntimeError exception.'
93-
except ValidationError:
94-
assert False, 'push_status_message() should have re-raised the RuntimeError not gotten ValidationError.'
95-
except RuntimeError as e:
96-
assert str(e) == exception_message, (
97-
'push_status_message() should have re-raised the '
98-
'original RuntimeError with the original message.'
99-
)
100-
101-
except BaseException:
102-
assert False, (
103-
'Unexpected Exception from push_status_message when called '
104-
'from the v2 API with type "error"'
105-
)
106-
10765

10866
@pytest.mark.django_db
10967
class TestCoerceGuid:

api_tests/files/views/test_file_detail.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,8 @@ def test_file_with_wrong_guid(self, app, user):
121121
def test_file_guid_not_created_with_basic_auth(
122122
self, mock_allow, app, user, file_url):
123123
res = app.get(f'{file_url}?create_guid=1', auth=user.auth)
124-
guid = res.json['data']['attributes'].get('guid', None)
125124
assert res.status_code == 200
126125
assert mock_allow.call_count == 1
127-
assert guid is None
128126

129127
@mock.patch('api.base.throttling.CreateGuidThrottle.allow_request')
130128
def test_file_guid_created_with_cookie(

api_tests/metadata_records/test_custom_item_metadata.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ def test_with_write_permission(self, app, public_osfguid, private_osfguid, anybo
351351
resource_type_general='book-chapter',
352352
),
353353
auth=anybody_with_write_permission.auth,
354+
expect_errors=True,
354355
)
355356
assert res.status_code == 400
356357
expected.assert_expectations(db_record=db_record, api_record=None) # db unchanged

osf/models/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ def get_claim_url(self, project_id, external=False):
17011701
base_url = website_settings.DOMAIN if external else '/'
17021702
unclaimed_record = self.get_unclaimed_record(project_id)
17031703
token = unclaimed_record['token']
1704-
return f'{base_url}user/{uid}/{project_id}/claim/?token={token}'
1704+
return f'{base_url}legacy/user/{uid}/{project_id}/claim/?token={token}'
17051705

17061706
def is_affiliated_with_institution(self, institution):
17071707
"""Return if this user is affiliated with the given ``institution``."""

osf_tests/test_user.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ def test_get_claim_url(self, unreg_user, unreg_moderator, project, provider):
11511151
domain = settings.DOMAIN
11521152
assert (
11531153
unreg_user.get_claim_url(pid, external=True) ==
1154-
f'{domain}user/{uid}/{pid}/claim/?token={token}'
1154+
f'{domain}legacy/user/{uid}/{pid}/claim/?token={token}'
11551155
)
11561156

11571157
# test_unreg_moderator
@@ -1161,7 +1161,7 @@ def test_get_claim_url(self, unreg_user, unreg_moderator, project, provider):
11611161
domain = settings.DOMAIN
11621162
assert (
11631163
unreg_moderator.get_claim_url(pid, external=True) ==
1164-
f'{domain}user/{uid}/{pid}/claim/?token={token}'
1164+
f'{domain}legacy/user/{uid}/{pid}/claim/?token={token}'
11651165
)
11661166

11671167
def test_get_claim_url_raises_value_error_if_not_valid_pid(self, unreg_user, unreg_moderator):

tasks/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ def test_module(ctx, module=None, numprocesses=None, nocapture=False, params=Non
372372
'api_tests/guids',
373373
'api_tests/meetings',
374374
'api_tests/metadata_records',
375-
'api_tests/osf_groups',
376375
'api_tests/reviews',
377376
'api_tests/regions',
378377
'api_tests/search',

tests/test_adding_contributor_views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ def test_claim_user_already_registered_redirects_to_claim_user_registered(self,
626626

627627
# claim link for the now registered email is accessed while not logged in
628628
token = unregistered_user.get_unclaimed_record(self.project._primary_key)['token']
629-
claim_url = f'/user/{unregistered_user._id}/{self.project._id}/claim/?token={token}'
629+
claim_url = f'/legacy/user/{unregistered_user._id}/{self.project._id}/claim/?token={token}'
630630
res = self.app.get(claim_url)
631631

632632
# should redirect to 'claim_user_registered' view
@@ -668,7 +668,7 @@ def test_claim_user_already_registered_secondary_email_redirects_to_claim_user_r
668668

669669
# claim link for the now registered email is accessed while not logged in
670670
token = unregistered_user.get_unclaimed_record(self.project._primary_key)['token']
671-
claim_url = f'/user/{unregistered_user._id}/{self.project._id}/claim/?token={token}'
671+
claim_url = f'/legacy/user/{unregistered_user._id}/{self.project._id}/claim/?token={token}'
672672
res = self.app.get(claim_url)
673673

674674
# should redirect to 'claim_user_registered' view
@@ -854,7 +854,7 @@ def test_get_valid_form(self):
854854
def test_invalid_claim_form_raise_400(self):
855855
uid = self.user._primary_key
856856
pid = self.project._primary_key
857-
url = f'/user/{uid}/{pid}/claim/?token=badtoken'
857+
url = f'/legacy/user/{uid}/{pid}/claim/?token=badtoken'
858858
res = self.app.get(url, follow_redirects=True)
859859
assert res.status_code == 400
860860

website/routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ def make_url_map(app):
857857
# user will be required to set email and password
858858
# claim token must be present in query parameter
859859
Rule(
860-
['/user/<uid>/<pid>/claim/'],
860+
['/legacy/user/<uid>/<pid>/claim/'],
861861
['get', 'post'],
862862
project_views.contributor.claim_user_form,
863863
OsfWebRenderer('claim_account.mako', trust=False)

0 commit comments

Comments
 (0)