diff --git a/galaxy_ng/app/api/v1/viewsets/sync.py b/galaxy_ng/app/api/v1/viewsets/sync.py index 7648bfa6e1..749bca1d28 100644 --- a/galaxy_ng/app/api/v1/viewsets/sync.py +++ b/galaxy_ng/app/api/v1/viewsets/sync.py @@ -46,5 +46,6 @@ def create(self, request): serializer.is_valid(raise_exception=True) kwargs = dict(serializer.validated_data) logger.debug(f'REQUEST kwargs: {kwargs}') + print(f'REQUEST kwargs: {kwargs}') task_id = self.legacy_dispatch(legacy_sync_from_upstream, kwargs=kwargs) return Response({'task': task_id}) diff --git a/galaxy_ng/app/utils/galaxy.py b/galaxy_ng/app/utils/galaxy.py index aee34f489e..4337478ffa 100644 --- a/galaxy_ng/app/utils/galaxy.py +++ b/galaxy_ng/app/utils/galaxy.py @@ -130,6 +130,7 @@ def get_namespace_owners_details(baseurl, ns_id): owners = [] next_owners_url = baseurl + f'/api/v1/namespaces/{ns_id}/owners/' while next_owners_url: + print(next_owners_url) o_data = safe_fetch(next_owners_url).json() for owner in o_data['results']: owners.append(owner) @@ -155,6 +156,7 @@ def upstream_namespace_iterator( if not baseurl.rstrip().endswith('/api/v1/namespaces'): baseurl = baseurl.rstrip() + '/api/v1/namespaces' logger.info(f'baseurl2: {baseurl}') + print(f'NS ITERATOR BASEURL {baseurl}') # normalize the upstream url parsed = urlparse(baseurl) @@ -413,6 +415,7 @@ def upstream_role_iterator( if baseurl is None or not baseurl: baseurl = 'https://old-galaxy.ansible.com/api/v1/roles' logger.info(f'baseurl2: {baseurl}') + print('ROLE ITERATOR BASEURL {baseurl}') # normalize the upstream url parsed = urlparse(baseurl) diff --git a/galaxy_ng/social/__init__.py b/galaxy_ng/social/__init__.py index da1388beaa..548feb2f09 100644 --- a/galaxy_ng/social/__init__.py +++ b/galaxy_ng/social/__init__.py @@ -63,6 +63,10 @@ def do_auth(self, access_token, *args, **kwargs): v3_namespace, v3_namespace_created = \ self.handle_v3_namespace(auth_response, email, login, gid) + print('-' * 100) + print(f'{login} v3 namespace: {v3_namespace}') + print('-' * 100) + # create a legacynamespace and bind to the v3 namespace? if v3_namespace: legacy_namespace, legacy_namespace_created = \ @@ -83,15 +87,18 @@ def handle_v3_namespace(self, session_user, session_email, session_login, github namespace_name = self.transform_namespace_name(session_login) logger.debug(f'TRANSFORMED NAME: {namespace_name}') + print(f'TRANSFORMED NAME: {namespace_name}') if not self.validate_namespace_name(namespace_name): logger.debug(f'DID NOT VALIDATE NAMESPACE NAME: {namespace_name}') + print(f'DID NOT VALIDATE NAMESPACE NAME: {namespace_name}') return False, False # does the namespace already exist? found_namespace = Namespace.objects.filter(name=namespace_name).first() logger.debug(f'FOUND NAMESPACE: {found_namespace}') + print(f'FOUND NAMESPACE: {found_namespace}') # is it owned by this userid? if found_namespace: @@ -102,9 +109,15 @@ def handle_v3_namespace(self, session_user, session_email, session_login, github if session_user in owners: return found_namespace, False + # FIXME - make one from the transformed name? + if not found_namespace: + namespace, namespace_created = self._ensure_namespace(namespace_name, session_user) + return namespace, namespace_created + # short circuit if the user does own at least one namespace ... owned_namespaces = rbac.get_owned_v3_namespaces(session_user) logger.debug(f'FOUND USER OWNED NAMESPACES: {owned_namespaces}') + print(f'FOUND USER OWNED NAMESPACES: {owned_namespaces}') if owned_namespaces: # does one resemble the desired namespace name? owned_namespaces = sorted(owned_namespaces) diff --git a/galaxy_ng/tests/integration/api/test_community.py b/galaxy_ng/tests/integration/api/test_community.py index 6ed793841b..e9431e2392 100644 --- a/galaxy_ng/tests/integration/api/test_community.py +++ b/galaxy_ng/tests/integration/api/test_community.py @@ -166,7 +166,7 @@ def test_me_social_with_v1_synced_user(ansible_config): ) # v1 sync the user's roles and namespace ... - pargs = json.dumps({"github_user": username, "limit": 1}).encode('utf-8') + pargs = json.dumps({"github_user": username, "limit": 1, "baseurl": "https://old-galaxy.ansible.com"}).encode('utf-8') resp = admin_client('/api/v1/sync/', method='POST', args=pargs) wait_for_v1_task(resp=resp, api_client=admin_client) @@ -430,6 +430,7 @@ def test_list_collections_social(ansible_config): validate_json(instance=resp.json(), schema=schema_objectlist) +@pytest.mark.skip(reason='switchover is complete') @pytest.mark.deployment_community def test_v1_sync_with_user_and_limit(ansible_config): """" Tests if v1 sync accepts a user&limit arg """ diff --git a/galaxy_ng/tests/integration/community/test_community_namespace_rbac.py b/galaxy_ng/tests/integration/community/test_community_namespace_rbac.py index a111bf5fed..2000013a44 100644 --- a/galaxy_ng/tests/integration/community/test_community_namespace_rbac.py +++ b/galaxy_ng/tests/integration/community/test_community_namespace_rbac.py @@ -241,15 +241,35 @@ def test_social_user_with_reclaimed_login(ansible_config): # the "bar" namespace will not belong to them # do they own -any- namespaces? + admin_config = ansible_config("admin") + admin_client = get_client( + config=admin_config, + request_token=False, + require_auth=True + ) + ga = GithubAdminClient() ga.delete_user(login='Wilk42') ga.delete_user(login='sean-m-sullivan') cleanup_social_user('Wilk42', ansible_config) cleanup_social_user('sean-m-sullivan', ansible_config) + cleanup_social_user('sean_m_sullivan', ansible_config) cleanup_social_user('sean-m-sullivan@redhat.com', ansible_config) default_cfg = extract_default_config(ansible_config) + nsmap = {} + next_url = '/api/v3/namespaces/' + while next_url: + resp = admin_client(next_url) + nsmap.update(dict((x['name'], x) for x in resp['data'])) + next_url = resp['links']['next'] + for nsname, nsdata in nsmap.items(): + if not nsname.lower().startswith('sean_m') and not nsname.lower().startswith('wilk42'): + continue + cleanup_social_user(nsname, ansible_config) + cleanup_namespace(nsname, api_client=admin_client) + old_login = 'Wilk42' email = 'sean-m-sullivan@redhat.com' user_a = ga.create_user(login=old_login, email=email) @@ -258,7 +278,6 @@ def test_social_user_with_reclaimed_login(ansible_config): # login once to make user with SocialGithubClient(config=user_a) as client: - a_resp = client.get('_ui/v1/me/') ns_resp = client.get('_ui/v1/my-namespaces/') ns_ds = ns_resp.json()