Show More
@@ -259,7 +259,7 b' class _BaseTestApi(object):' | |||||
259 | self._compare_error(id_, expected, given=response.body) |
|
259 | self._compare_error(id_, expected, given=response.body) | |
260 |
|
260 | |||
261 | def test_api_pull_remote(self): |
|
261 | def test_api_pull_remote(self): | |
262 |
# Note: pulling from local repos is a mis |
|
262 | # Note: pulling from local repos is a misfeature - it will bypass access control | |
263 | # ... but ok, if the path already has been set in the database |
|
263 | # ... but ok, if the path already has been set in the database | |
264 | repo_name = 'test_pull' |
|
264 | repo_name = 'test_pull' | |
265 | r = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) |
|
265 | r = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
@@ -826,7 +826,7 b' class _BaseTestApi(object):' | |||||
826 | fixture.destroy_repo(repo_name) |
|
826 | fixture.destroy_repo(repo_name) | |
827 |
|
827 | |||
828 | def test_api_create_repo_clone_uri_local(self): |
|
828 | def test_api_create_repo_clone_uri_local(self): | |
829 |
# cloning from local repos was a mis |
|
829 | # cloning from local repos was a misfeature - it would bypass access control | |
830 | # TODO: introduce other test coverage of actual remote cloning |
|
830 | # TODO: introduce other test coverage of actual remote cloning | |
831 | clone_uri = os.path.join(base.TESTS_TMP_PATH, self.REPO) |
|
831 | clone_uri = os.path.join(base.TESTS_TMP_PATH, self.REPO) | |
832 | repo_name = 'api-repo' |
|
832 | repo_name = 'api-repo' | |
@@ -1003,9 +1003,10 b' class _BaseTestApi(object):' | |||||
1003 | ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), |
|
1003 | ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), | |
1004 | ('description', {'description': 'new description'}), |
|
1004 | ('description', {'description': 'new description'}), | |
1005 | ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail |
|
1005 | ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail | |
1006 |
('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis |
|
1006 | ('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a misfeature - it would bypass access control | |
1007 | ('clone_uri', {'clone_uri': None}), |
|
1007 | ('clone_uri', {'clone_uri': None}), | |
1008 | ('landing_rev', {'landing_rev': 'branch:master'}), |
|
1008 | ('landing_rev', {'landing_rev': 'branch:master'}), | |
|
1009 | ('private', {'private': True}), | |||
1009 | ('enable_statistics', {'enable_statistics': True}), |
|
1010 | ('enable_statistics', {'enable_statistics': True}), | |
1010 | ('enable_downloads', {'enable_downloads': True}), |
|
1011 | ('enable_downloads', {'enable_downloads': True}), | |
1011 | ('name', {'name': 'new_repo_name'}), |
|
1012 | ('name', {'name': 'new_repo_name'}), | |
@@ -1019,20 +1020,32 b' class _BaseTestApi(object):' | |||||
1019 |
|
1020 | |||
1020 | id_, params = _build_data(self.apikey, 'update_repo', |
|
1021 | id_, params = _build_data(self.apikey, 'update_repo', | |
1021 | repoid=repo_name, **updates) |
|
1022 | repoid=repo_name, **updates) | |
1022 | response = api_call(self, params) |
|
1023 | ||
1023 | if changing_attr == 'name': |
|
1024 | if changing_attr == 'name': | |
1024 | repo_name = updates['name'] |
|
1025 | repo_name = updates['name'] | |
1025 | if changing_attr == 'repo_group': |
|
1026 | if changing_attr == 'repo_group': | |
1026 | repo_name = '/'.join([updates['group'], repo_name]) |
|
1027 | repo_name = '/'.join([updates['group'], repo_name]) | |
|
1028 | expected = { | |||
|
1029 | 'msg': 'updated repo ID:%s %s' % (repo.repo_id, repo_name), | |||
|
1030 | 'repository': repo.get_api_data() | |||
|
1031 | } | |||
|
1032 | expected['repository'].update(updates) | |||
|
1033 | if changing_attr == 'clone_uri' and updates['clone_uri'] is None: | |||
|
1034 | expected['repository']['clone_uri'] = '' | |||
|
1035 | if changing_attr == 'landing_rev': | |||
|
1036 | expected['repository']['landing_rev'] = expected['repository']['landing_rev'].split(':', 1) | |||
|
1037 | if changing_attr == 'name': | |||
|
1038 | expected['repository']['repo_name'] = expected['repository'].pop('name') | |||
|
1039 | if changing_attr == 'repo_group': | |||
|
1040 | expected['repository']['repo_name'] = expected['repository'].pop('group') + '/' + repo.repo_name | |||
|
1041 | ||||
|
1042 | response = api_call(self, params) | |||
|
1043 | ||||
1027 | try: |
|
1044 | try: | |
1028 | if changing_attr == 'clone_uri' and updates['clone_uri']: |
|
1045 | if changing_attr == 'clone_uri' and updates['clone_uri']: | |
1029 | expected = 'failed to update repo `%s`' % repo_name |
|
1046 | expected = 'failed to update repo `%s`' % repo_name | |
1030 | self._compare_error(id_, expected, given=response.body) |
|
1047 | self._compare_error(id_, expected, given=response.body) | |
1031 | else: |
|
1048 | else: | |
1032 | expected = { |
|
|||
1033 | 'msg': 'updated repo ID:%s %s' % (repo.repo_id, repo_name), |
|
|||
1034 | 'repository': repo.get_api_data() |
|
|||
1035 | } |
|
|||
1036 | self._compare_ok(id_, expected, given=response.body) |
|
1049 | self._compare_ok(id_, expected, given=response.body) | |
1037 | finally: |
|
1050 | finally: | |
1038 | fixture.destroy_repo(repo_name) |
|
1051 | fixture.destroy_repo(repo_name) | |
@@ -1043,7 +1056,7 b' class _BaseTestApi(object):' | |||||
1043 | ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), |
|
1056 | ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}), | |
1044 | ('description', {'description': 'new description'}), |
|
1057 | ('description', {'description': 'new description'}), | |
1045 | ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail |
|
1058 | ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail | |
1046 |
('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis |
|
1059 | ('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a misfeature - it would bypass access control | |
1047 | ('clone_uri', {'clone_uri': None}), |
|
1060 | ('clone_uri', {'clone_uri': None}), | |
1048 | ('landing_rev', {'landing_rev': 'branch:master'}), |
|
1061 | ('landing_rev', {'landing_rev': 'branch:master'}), | |
1049 | ('enable_statistics', {'enable_statistics': True}), |
|
1062 | ('enable_statistics', {'enable_statistics': True}), |
General Comments 0
You need to be logged in to leave comments.
Login now