Skip to content

Commit

Permalink
Use the correct property for the github id. (#1971)
Browse files Browse the repository at this point in the history
No-Issue
  • Loading branch information
jctanner authored Nov 9, 2023
1 parent 847fd4e commit 054a720
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion galaxy_ng/app/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def get_github_id(self, obj):
social_user = UserSocialAuth.objects.filter(user=obj).first()
if not social_user:
return None
return social_user.id
return int(social_user.uid)
except Exception:
return None

Expand Down
61 changes: 61 additions & 0 deletions galaxy_ng/tests/integration/community/test_v1_user_github_ids.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""test_community.py - Tests related to the community featureset.
"""

import pytest

from ..utils import (
SocialGithubClient,
GithubAdminClient,
)
from ..utils.legacy import (
cleanup_social_user,
)

pytestmark = pytest.mark.qa # noqa: F821


def extract_default_config(ansible_config):
base_cfg = ansible_config('github_user_1')
cfg = {}
cfg['token'] = None
cfg['url'] = base_cfg.get('url')
cfg['auth_url'] = base_cfg.get('auth_url')
cfg['github_url'] = base_cfg.get('github_url')
cfg['github_api_url'] = base_cfg.get('github_api_url')
return cfg


@pytest.mark.deployment_community
def test_v1_user_github_ids(ansible_config):
"""" The github_id should show up in the v1 user serializer """

for x in range(0, 10):

github_user = 'deleteme' + str(x)
cleanup_social_user(github_user, ansible_config)

user_cfg = extract_default_config(ansible_config)
user_cfg['username'] = github_user
user_cfg['password'] = 'redhat'

# delete and recreate the github user ...
ga = GithubAdminClient()
try:
ga.delete_user(login=github_user)
except Exception:
pass
gdata = ga.create_user(
login=github_user,
password='redhat',
email=f'{github_user}@bar.com'
)

# Login with the user first to create the v1+v3 namespaces
with SocialGithubClient(config=user_cfg) as client:
me = client.get('_ui/v1/me/')
assert me.json()['username'] == github_user
uid = me.json()['id']

urr = client.get(f'v1/users/{uid}/')
udata = urr.json()
assert udata['github_id'] == gdata['id']

0 comments on commit 054a720

Please sign in to comment.