-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the correct property for the github id. (#1971)
No-Issue
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
galaxy_ng/tests/integration/community/test_v1_user_github_ids.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |