Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/api/v1/users?username=test throws server error (500) #1908

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/2731.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed ``username`` filter in ``/api/v1/users`` endpoint.
2 changes: 1 addition & 1 deletion galaxy_ng/app/api/v1/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Meta:

def username_filter(self, queryset, name, value):
username = self.request.query_params.get('username')
return queryset.filter(name=username)
return queryset.filter(username=username)


class LegacyRoleFilter(filterset.FilterSet):
Expand Down
39 changes: 39 additions & 0 deletions galaxy_ng/tests/integration/community/test_v1_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,42 @@ def test_v1_owner_username_filter_is_case_insensitive(ansible_config):

# cleanup
cleanup_social_user(github_user, ansible_config)


@pytest.mark.deployment_community
def test_v1_users_filter(ansible_config):
"""" Tests v1 users filter works as expected """

config = ansible_config("admin")
api_client = get_client(
config=config,
request_token=False,
require_auth=True
)

github_user = 'jctannerTEST'
# github_repo = 'role1'
cleanup_social_user(github_user, ansible_config)

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

# 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

resp = api_client('/api/v1/users/')

assert len(resp["results"]) > 0

resp = api_client(f'/api/v1/users/?username={github_user}')

assert resp["count"] == 1
assert resp["results"][0]["username"] == github_user

resp = api_client('/api/v1/users/?username=user_should_not_exist')
assert resp["count"] == 0

cleanup_social_user(github_user, ansible_config)
Loading