#5416 Add api endpoints for adding/removing user to group
Merged by ngompa. Opened by zlopez.
zlopez/pagure 5333  into  master

Download 5416.patch

This change will add new API endpoints that will allow users to add/remove new
members to group.

It also adds new ACL group_modify, which adds group add/remove ability to token.

Closes #5333

Signed-off-by: Michal Konecny mkonecny@redhat.com

I tried to test the changes in vagrant, but I didn't saw the ACL for some reason and the API endpoints in /api/0 page. From what I know everything should be set up correctly, but it's possible I'm missing something.

rebased onto cdc78a8e77d84bced1e92d04d06876b0351dbd7f

There are three failed tests, can you try to address them?

00:47:36  =========================== short test summary info ============================
00:47:36  FAILED tests/test_pagure_flask_api.py::PagureFlaskApitests::test_api_error_codes
00:47:36  FAILED tests/test_style.py::TestStyle::test_code_with_black - AssertionError:...
00:47:36  FAILED tests/test_style.py::TestStyle::test_code_with_flake8 - AssertionError...
00:47:36  ===== 3 failed, 1716 passed, 7 skipped, 4628 warnings in 978.06s (0:16:18) =====

None of those errors are related to changes in this PR. I didn't add any new error code and the formatting changes are related to files that are not part of this PR.

05:47:36  stderr: 
05:47:36  would reformat /pagure/pagure/ui/oidc_login.py
05:47:36  would reformat /pagure/pagure/ui/groups.py
05:47:36  would reformat /pagure/pagure/api/project.py
05:47:36  would reformat /pagure/pagure/ui/app.py

Same for flake8

05:47:36  ----------------------------- Captured stdout call -----------------------------
05:47:36  (b"/pagure/pagure/default_config.py:68:81: E501 line too long (98 > 80 characters)\n/pagure/pagure/api/project.py:1454:81: E501 line too long (87 > 80 characters)\n/pagure/pagure/ui/app.py:1056:1: W293 blank line contains whitespace\n/pagure/pagure/ui/app.py:1057:81: E501 line too long (87 > 80 characters)\n/pagure/pagure/ui/app.py:1058:24: E231 missing whitespace after ','\n/pagure/pagure/ui/app.py:1058:81: E501 line too long (98 > 80 characters)\n/pagure/pagure/ui/app.py:1061:5: E303 too many blank lines (2)\n/pagure/pagure/ui/groups.py:357:81: E501 line too long (87 > 80 characters)\n/pagure/pagure/ui/groups.py:358:24: E231 missing whitespace after ','\n/pagure/pagure/ui/groups.py:358:81: E501 line too long (96 > 80 characters)\n/pagure/pagure/ui/oidc_login.py:63:81: E501 line too long (86 > 80 characters)\n/pagure/pagure/ui/oidc_login.py:68:81: E501 line too long (96 > 80 characters)\n", None)

It would be best to address the errors in separate PR.

I can't even reproduce tests/test_pagure_flask_api_group.py failure by running run-tests-container.py locally. It just says ALL_TESTS_PASSED.

I fixed the failing fedora tests in https://pagure.io/pagure/pull-request/5418, but there are still more than 600 tests failing on CentOS

rebased onto dcd24783e9fc1ac243448eef90e09289c9faee16

rebased onto 9add00931913c69438ff202fb7781a607451961b

@zlopez I think the reason you're not seeing it in the generated web documentation is because your new API endpoints are not referenced in pagure/api/__init__.py. groups_methods = [group.api_groups, group.api_view_group] needs to be extended to include your new endpoints.

rebased onto 4766e853b1eb074e0de4c277c4e0e206b9e6c3e9

1 new commit added

  • Add new API group methods to index

@ngompa You were right. Adding the new endpoints to pagure/api/__init__.py. groups_methods enabled the method in api/0 and even allowed to create API tokens with the new ACL.

There was a style test failure:

09:16:22  tests/test_style.py:122: AssertionError
09:16:22  ----------------------------- Captured stdout call -----------------------------
09:16:22  stdout: 
09:16:22  --- /pagure/pagure/api/__init__.py    2023-12-04 13:57:01.463774 +0000
09:16:22  +++ /pagure/pagure/api/__init__.py    2023-12-04 14:15:57.761543 +0000
09:16:22  @@ -615,11 +615,11 @@
09:16:22   
09:16:22       groups_methods = [
09:16:22           group.api_groups,
09:16:22           group.api_view_group,
09:16:22           group.api_group_add_member,
09:16:22  -        group.api_group_remove_member
09:16:22  +        group.api_group_remove_member,
09:16:22       ]
09:16:22       sections.append(build_docs_section("groups", groups_methods))
09:16:22   
09:16:22       plugins_methods = [
09:16:22           plugins.api_install_plugin,
09:16:22  
09:16:22  stderr: 
09:16:22  would reformat /pagure/pagure/api/__init__.py
09:16:22  
09:16:22  Oh no! ๐Ÿ’ฅ ๐Ÿ’” ๐Ÿ’ฅ
09:16:22  1 file would be reformatted, 203 files would be left unchanged.

Could you fix this and squash the commits?

I must have missed that

rebased onto 1b7d305d06af42f0996ae54fea223ecc5a081b72

Looks good to me with the valid test suite run.

Pull-Request has been merged by ngompa

Metadata