From 8cbc9d945975d868cd7b813643e0e7301b75c671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Mon, 9 Oct 2023 20:16:45 +0200 Subject: [PATCH 1/3] Add support for removing users/groups from a project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nikola Forró --- ogr/abstract.py | 20 +- ogr/services/pagure/project.py | 9 +- ...ricCommands.test_add_and_remove_group.yaml | 271 ++++++++++++++++++ ...ericCommands.test_add_and_remove_user.yaml | 271 ++++++++++++++++++ .../GenericCommands.test_add_group.yaml | 163 ----------- .../GenericCommands.test_add_user.yaml | 164 ----------- .../pagure/test_generic_commands.py | 6 +- 7 files changed, 573 insertions(+), 331 deletions(-) create mode 100644 tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_and_remove_group.yaml create mode 100644 tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_and_remove_user.yaml delete mode 100644 tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_group.yaml delete mode 100644 tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_user.yaml diff --git a/ogr/abstract.py b/ogr/abstract.py index f20c336f..e941d00b 100644 --- a/ogr/abstract.py +++ b/ogr/abstract.py @@ -1525,6 +1525,15 @@ def add_user(self, user: str, access_level: AccessLevel) -> None: """ raise NotImplementedError() + def remove_user(self, user: str) -> None: + """ + Remove user from project. + + Args: + user: Username of the user. + """ + raise NotImplementedError() + def request_access(self) -> None: """ Request an access to the project (cannot specify access level to be granted; @@ -1540,7 +1549,16 @@ def add_group(self, group: str, access_level: AccessLevel) -> None: group: Name of the group. access_level: Permissions for the group. """ - raise NotImplementedError + raise NotImplementedError() + + def remove_group(self, group: str) -> None: + """ + Remove group from project. + + Args: + group: Name of the group. + """ + raise NotImplementedError() def get_issue_list( self, diff --git a/ogr/services/pagure/project.py b/ogr/services/pagure/project.py index 75a29d8e..1ac1d19c 100644 --- a/ogr/services/pagure/project.py +++ b/ogr/services/pagure/project.py @@ -364,11 +364,17 @@ def get_git_urls(self) -> Dict[str, str]: def add_user(self, user: str, access_level: AccessLevel) -> None: self.add_user_or_group(user, access_level, "user") + def remove_user(self, user: str) -> None: + self.add_user_or_group(user, None, "user") + def add_group(self, group: str, access_level: AccessLevel): self.add_user_or_group(group, access_level, "group") + def remove_group(self, group: str) -> None: + self.add_user_or_group(group, None, "group") + def add_user_or_group( - self, user: str, access_level: AccessLevel, user_type + self, user: str, access_level: Optional[AccessLevel], user_type: str ) -> None: access_dict = { AccessLevel.pull: "ticket", @@ -376,6 +382,7 @@ def add_user_or_group( AccessLevel.push: "commit", AccessLevel.admin: "commit", AccessLevel.maintain: "admin", + None: "", } response = self._call_project_api_raw( "git", diff --git a/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_and_remove_group.yaml b/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_and_remove_group.yaml new file mode 100644 index 00000000..47ad220f --- /dev/null +++ b/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_and_remove_group.yaml @@ -0,0 +1,271 @@ +_requre: + DataTypes: 1 + key_strategy: StorageKeysInspectSimple + version_storage_file: 3 +requests.sessions: + send: + POST: + https://pagure.io/api/0/-/whoami: + - metadata: + latency: 1.5459933280944824 + module_call_list: + - unittest.case + - requre.record_and_replace + - tests.integration.pagure.test_generic_commands + - ogr.abstract + - ogr.services.pagure.user + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - requests.sessions + - requre.objects + - requre.cassette + - requests.sessions + - send + output: + __store_indicator: 2 + _content: + username: nforro + _next: null + elapsed: 1.437793 + encoding: utf-8 + headers: + Connection: Upgrade, Keep-Alive + Content-Length: '27' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-YbTLzdpZsoRGvtdZ7DCMmOGdg'; + style-src 'self' 'nonce-YbTLzdpZsoRGvtdZ7DCMmOGdg'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; + Content-Type: application/json + Date: Mon, 09 Oct 2023 17:15:46 GMT + Keep-Alive: timeout=5, max=100 + Referrer-Policy: same-origin + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiODE0YTJhNWQ0YjQzOGM3OTY4YjQwYWJjM2RhZjQzOWQ3NDgyOTY5YiJ9.GAXGwg.cB5Z_0W9PEVmAL8KqI62vnD2It8; + Expires=Thu, 09-Nov-2023 17:15:46 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: max-age=31536000; includeSubDomains; preload + Upgrade: h2,h2c + X-Content-Type-Options: nosniff + X-Frame-Options: ALLOW-FROM https://pagure.io/ + X-Xss-Protection: 1; mode=block + raw: !!binary "" + reason: OK + status_code: 200 + - metadata: + latency: 0.21212029457092285 + module_call_list: + - unittest.case + - requre.record_and_replace + - tests.integration.pagure.test_generic_commands + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.user + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - requests.sessions + - requre.objects + - requre.cassette + - requests.sessions + - send + output: + __store_indicator: 2 + _content: + username: nforro + _next: null + elapsed: 0.211102 + encoding: utf-8 + headers: + Connection: Keep-Alive + Content-Length: '27' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-QDs6fDoljKPi1SC515oakfMHO'; + style-src 'self' 'nonce-QDs6fDoljKPi1SC515oakfMHO'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; + Content-Type: application/json + Date: Mon, 09 Oct 2023 17:15:47 GMT + Keep-Alive: timeout=5, max=99 + Referrer-Policy: same-origin + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiODE0YTJhNWQ0YjQzOGM3OTY4YjQwYWJjM2RhZjQzOWQ3NDgyOTY5YiJ9.GAXGww.OfCgXTkfPa8SPrlDwdSU5kZXu-Y; + Expires=Thu, 09-Nov-2023 17:15:47 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: max-age=31536000; includeSubDomains; preload + X-Content-Type-Options: nosniff + X-Frame-Options: ALLOW-FROM https://pagure.io/ + X-Xss-Protection: 1; mode=block + raw: !!binary "" + reason: OK + status_code: 200 + https://pagure.io/api/0/playground-nforro/git/modifyacls: + - metadata: + latency: 19.634831428527832 + module_call_list: + - unittest.case + - requre.record_and_replace + - tests.integration.pagure.test_generic_commands + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - requests.sessions + - requre.objects + - requre.cassette + - requests.sessions + - send + output: + __store_indicator: 2 + _content: + access_groups: + admin: [] + collaborator: [] + commit: + - packit-test-group + ticket: [] + access_users: + admin: [] + collaborator: [] + commit: [] + owner: + - nforro + ticket: [] + close_status: [] + custom_keys: [] + date_created: '1696871156' + date_modified: '1696871747' + description: playground-nforro + full_url: https://pagure.io/playground-nforro + fullname: playground-nforro + id: 17033 + milestones: {} + name: playground-nforro + namespace: null + parent: null + priorities: {} + tags: [] + url_path: playground-nforro + user: + full_url: https://pagure.io/user/nforro + fullname: "Nikola Forr\xF3" + name: nforro + url_path: user/nforro + _next: null + elapsed: 19.633572 + encoding: utf-8 + headers: + Connection: Keep-Alive + Content-Length: '864' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-mvNfk0cfS75DNM84tn2Fe8nyQ'; + style-src 'self' 'nonce-mvNfk0cfS75DNM84tn2Fe8nyQ'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; + Content-Type: application/json + Date: Mon, 09 Oct 2023 17:15:47 GMT + Keep-Alive: timeout=5, max=98 + Referrer-Policy: same-origin + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiODE0YTJhNWQ0YjQzOGM3OTY4YjQwYWJjM2RhZjQzOWQ3NDgyOTY5YiJ9.GAXG1g.y5tBPWMYVtlSSPKuDgmSGZTSDTM; + Expires=Thu, 09-Nov-2023 17:16:06 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: max-age=31536000; includeSubDomains; preload + X-Content-Type-Options: nosniff + X-Frame-Options: ALLOW-FROM https://pagure.io/ + X-Xss-Protection: 1; mode=block + raw: !!binary "" + reason: OK + status_code: 200 + - metadata: + latency: 0.5101637840270996 + module_call_list: + - unittest.case + - requre.record_and_replace + - tests.integration.pagure.test_generic_commands + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - requests.sessions + - requre.objects + - requre.cassette + - requests.sessions + - send + output: + __store_indicator: 2 + _content: + access_groups: + admin: [] + collaborator: [] + commit: [] + ticket: [] + access_users: + admin: [] + collaborator: [] + commit: [] + owner: + - nforro + ticket: [] + close_status: [] + custom_keys: [] + date_created: '1696871156' + date_modified: '1696871747' + description: playground-nforro + full_url: https://pagure.io/playground-nforro + fullname: playground-nforro + id: 17033 + milestones: {} + name: playground-nforro + namespace: null + parent: null + priorities: {} + tags: [] + url_path: playground-nforro + user: + full_url: https://pagure.io/user/nforro + fullname: "Nikola Forr\xF3" + name: nforro + url_path: user/nforro + _next: null + elapsed: 0.508932 + encoding: utf-8 + headers: + Connection: Keep-Alive + Content-Length: '833' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-Y9LXANSEnP79mFdqD9aKtJZDk'; + style-src 'self' 'nonce-Y9LXANSEnP79mFdqD9aKtJZDk'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; + Content-Type: application/json + Date: Mon, 09 Oct 2023 17:16:06 GMT + Keep-Alive: timeout=5, max=97 + Referrer-Policy: same-origin + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiODE0YTJhNWQ0YjQzOGM3OTY4YjQwYWJjM2RhZjQzOWQ3NDgyOTY5YiJ9.GAXG1w.n5c2qYiApdkTDkzQafv9-J8VM90; + Expires=Thu, 09-Nov-2023 17:16:07 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: max-age=31536000; includeSubDomains; preload + X-Content-Type-Options: nosniff + X-Frame-Options: ALLOW-FROM https://pagure.io/ + X-Xss-Protection: 1; mode=block + raw: !!binary "" + reason: OK + status_code: 200 diff --git a/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_and_remove_user.yaml b/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_and_remove_user.yaml new file mode 100644 index 00000000..3071833e --- /dev/null +++ b/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_and_remove_user.yaml @@ -0,0 +1,271 @@ +_requre: + DataTypes: 1 + key_strategy: StorageKeysInspectSimple + version_storage_file: 3 +requests.sessions: + send: + POST: + https://pagure.io/api/0/-/whoami: + - metadata: + latency: 0.507498025894165 + module_call_list: + - unittest.case + - requre.record_and_replace + - tests.integration.pagure.test_generic_commands + - ogr.abstract + - ogr.services.pagure.user + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - requests.sessions + - requre.objects + - requre.cassette + - requests.sessions + - send + output: + __store_indicator: 2 + _content: + username: nforro + _next: null + elapsed: 0.506372 + encoding: utf-8 + headers: + Connection: Upgrade, Keep-Alive + Content-Length: '27' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-3Lui4qJsKYSfjLEjNMfQIcXBY'; + style-src 'self' 'nonce-3Lui4qJsKYSfjLEjNMfQIcXBY'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; + Content-Type: application/json + Date: Mon, 09 Oct 2023 17:16:07 GMT + Keep-Alive: timeout=5, max=100 + Referrer-Policy: same-origin + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZmZjNmEyYzU0NjE3MTY1MjYwMzE2OTFkMWJlNGJmN2U4ZmM3MDlhZiJ9.GAXG1w.lElIqkjpZpGw_-HTzd8q2tgdCBY; + Expires=Thu, 09-Nov-2023 17:16:07 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: max-age=31536000; includeSubDomains; preload + Upgrade: h2,h2c + X-Content-Type-Options: nosniff + X-Frame-Options: ALLOW-FROM https://pagure.io/ + X-Xss-Protection: 1; mode=block + raw: !!binary "" + reason: OK + status_code: 200 + - metadata: + latency: 0.26828551292419434 + module_call_list: + - unittest.case + - requre.record_and_replace + - tests.integration.pagure.test_generic_commands + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.user + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - requests.sessions + - requre.objects + - requre.cassette + - requests.sessions + - send + output: + __store_indicator: 2 + _content: + username: nforro + _next: null + elapsed: 0.267138 + encoding: utf-8 + headers: + Connection: Keep-Alive + Content-Length: '27' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-2vonPTPKAQ53NpHpSzohqAVi4'; + style-src 'self' 'nonce-2vonPTPKAQ53NpHpSzohqAVi4'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; + Content-Type: application/json + Date: Mon, 09 Oct 2023 17:16:08 GMT + Keep-Alive: timeout=5, max=99 + Referrer-Policy: same-origin + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZmZjNmEyYzU0NjE3MTY1MjYwMzE2OTFkMWJlNGJmN2U4ZmM3MDlhZiJ9.GAXG2A._aKS7lcK-l-w7FD3-kV8Ng0BheQ; + Expires=Thu, 09-Nov-2023 17:16:08 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: max-age=31536000; includeSubDomains; preload + X-Content-Type-Options: nosniff + X-Frame-Options: ALLOW-FROM https://pagure.io/ + X-Xss-Protection: 1; mode=block + raw: !!binary "" + reason: OK + status_code: 200 + https://pagure.io/api/0/playground-nforro/git/modifyacls: + - metadata: + latency: 1.19520902633667 + module_call_list: + - unittest.case + - requre.record_and_replace + - tests.integration.pagure.test_generic_commands + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - requests.sessions + - requre.objects + - requre.cassette + - requests.sessions + - send + output: + __store_indicator: 2 + _content: + access_groups: + admin: [] + collaborator: [] + commit: [] + ticket: [] + access_users: + admin: [] + collaborator: [] + commit: + - lachmanfrantisek + owner: + - nforro + ticket: [] + close_status: [] + custom_keys: [] + date_created: '1696871156' + date_modified: '1696871768' + description: playground-nforro + full_url: https://pagure.io/playground-nforro + fullname: playground-nforro + id: 17033 + milestones: {} + name: playground-nforro + namespace: null + parent: null + priorities: {} + tags: [] + url_path: playground-nforro + user: + full_url: https://pagure.io/user/nforro + fullname: "Nikola Forr\xF3" + name: nforro + url_path: user/nforro + _next: null + elapsed: 1.19408 + encoding: utf-8 + headers: + Connection: Keep-Alive + Content-Length: '863' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-91EUUh1003N9dZxLJxRnZFyOg'; + style-src 'self' 'nonce-91EUUh1003N9dZxLJxRnZFyOg'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; + Content-Type: application/json + Date: Mon, 09 Oct 2023 17:16:08 GMT + Keep-Alive: timeout=5, max=98 + Referrer-Policy: same-origin + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZmZjNmEyYzU0NjE3MTY1MjYwMzE2OTFkMWJlNGJmN2U4ZmM3MDlhZiJ9.GAXG2Q.B5rGFepKO8gt-wM5rc9tmJ8aA2E; + Expires=Thu, 09-Nov-2023 17:16:09 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: max-age=31536000; includeSubDomains; preload + X-Content-Type-Options: nosniff + X-Frame-Options: ALLOW-FROM https://pagure.io/ + X-Xss-Protection: 1; mode=block + raw: !!binary "" + reason: OK + status_code: 200 + - metadata: + latency: 1.1453070640563965 + module_call_list: + - unittest.case + - requre.record_and_replace + - tests.integration.pagure.test_generic_commands + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - requests.sessions + - requre.objects + - requre.cassette + - requests.sessions + - send + output: + __store_indicator: 2 + _content: + access_groups: + admin: [] + collaborator: [] + commit: [] + ticket: [] + access_users: + admin: [] + collaborator: [] + commit: [] + owner: + - nforro + ticket: [] + close_status: [] + custom_keys: [] + date_created: '1696871156' + date_modified: '1696871768' + description: playground-nforro + full_url: https://pagure.io/playground-nforro + fullname: playground-nforro + id: 17033 + milestones: {} + name: playground-nforro + namespace: null + parent: null + priorities: {} + tags: [] + url_path: playground-nforro + user: + full_url: https://pagure.io/user/nforro + fullname: "Nikola Forr\xF3" + name: nforro + url_path: user/nforro + _next: null + elapsed: 1.144886 + encoding: utf-8 + headers: + Connection: Keep-Alive + Content-Length: '833' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-uq38gHfknPi3lGSZVj6HzVUCh'; + style-src 'self' 'nonce-uq38gHfknPi3lGSZVj6HzVUCh'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; + Content-Type: application/json + Date: Mon, 09 Oct 2023 17:16:09 GMT + Keep-Alive: timeout=5, max=97 + Referrer-Policy: same-origin + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZmZjNmEyYzU0NjE3MTY1MjYwMzE2OTFkMWJlNGJmN2U4ZmM3MDlhZiJ9.GAXG2g.yrRloYqoh4XNV3bBBuZKTgBA6qg; + Expires=Thu, 09-Nov-2023 17:16:10 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: max-age=31536000; includeSubDomains; preload + X-Content-Type-Options: nosniff + X-Frame-Options: ALLOW-FROM https://pagure.io/ + X-Xss-Protection: 1; mode=block + raw: !!binary "" + reason: OK + status_code: 200 diff --git a/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_group.yaml b/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_group.yaml deleted file mode 100644 index 028a492f..00000000 --- a/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_group.yaml +++ /dev/null @@ -1,163 +0,0 @@ -_requre: - DataTypes: 1 - key_strategy: StorageKeysInspectSimple - version_storage_file: 2 -requests.sessions: - send: - POST: - https://pagure.io/api/0/-/whoami: - - metadata: - latency: 0.8307294845581055 - module_call_list: - - unittest.case - - requre.online_replacing - - tests.integration.pagure.test_generic_commands - - ogr.services.pagure.user - - ogr.services.pagure.service - - requests.sessions - - requre.objects - - requre.cassette - - requests.sessions - - send - output: - __store_indicator: 2 - _content: - username: mfocko - _next: null - elapsed: 0.2 - encoding: null - headers: - Connection: Keep-Alive - Content-Length: '26' - Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne' - https://apps.fedoraproject.org; style-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne'; - object-src 'none';base-uri 'self';img-src 'self' https:; - Content-Type: application/json - Date: Fri, 01 Nov 2019 13-36-03 GMT - Keep-Alive: timeout=5, max=100 - Referrer-Policy: same-origin - Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips mod_wsgi/3.4 - Python/2.7.5 - Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmIjp7IiBiIjoiTlRZNU1UWTNNV00xTURrd1ltRmtZVGd5TkRrMU5UTTNaakJtT0dJMU56ZGhaRE13TXpnMk1RPT0ifX0.Ei5T1w.4kSOhQUh6IM8GIYpnGjdGyOWDh0; - Expires=Thu, 01-Oct-2020 09:26:47 GMT; Secure; HttpOnly; Path=/ - Strict-Transport-Security: max-age=31536000; includeSubDomains; preload - X-Content-Type-Options: nosniff - X-Frame-Options: ALLOW-FROM https://pagure.io/ - X-Xss-Protection: 1; mode=block - raw: !!binary "" - reason: OK - status_code: 200 - - metadata: - latency: 0.27506566047668457 - module_call_list: - - unittest.case - - requre.online_replacing - - tests.integration.pagure.test_generic_commands - - ogr.services.pagure.service - - ogr.services.pagure.user - - ogr.services.pagure.service - - requests.sessions - - requre.objects - - requre.cassette - - requests.sessions - - send - output: - __store_indicator: 2 - _content: - username: mfocko - _next: null - elapsed: 0.2 - encoding: null - headers: - Connection: Keep-Alive - Content-Length: '26' - Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne' - https://apps.fedoraproject.org; style-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne'; - object-src 'none';base-uri 'self';img-src 'self' https:; - Content-Type: application/json - Date: Fri, 01 Nov 2019 13-36-03 GMT - Keep-Alive: timeout=5, max=99 - Referrer-Policy: same-origin - Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips mod_wsgi/3.4 - Python/2.7.5 - Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmIjp7IiBiIjoiTlRZNU1UWTNNV00xTURrd1ltRmtZVGd5TkRrMU5UTTNaakJtT0dJMU56ZGhaRE13TXpnMk1RPT0ifX0.Ei5T2A.rsFPeccijtmG_ZwiN7C9Kq-jXZs; - Expires=Thu, 01-Oct-2020 09:26:48 GMT; Secure; HttpOnly; Path=/ - Strict-Transport-Security: max-age=31536000; includeSubDomains; preload - X-Content-Type-Options: nosniff - X-Frame-Options: ALLOW-FROM https://pagure.io/ - X-Xss-Protection: 1; mode=block - raw: !!binary "" - reason: OK - status_code: 200 - https://pagure.io/api/0/playground-mfocko/git/modifyacls: - - metadata: - latency: 0.5030710697174072 - module_call_list: - - unittest.case - - requre.online_replacing - - tests.integration.pagure.test_generic_commands - - ogr.services.pagure.project - - ogr.services.pagure.service - - requests.sessions - - requre.objects - - requre.cassette - - requests.sessions - - send - output: - __store_indicator: 2 - _content: - access_groups: - admin: [] - collaborator: [] - commit: - - packit-test-group - ticket: [] - access_users: - admin: [] - collaborator: [] - commit: [] - owner: - - mfocko - ticket: [] - close_status: [] - custom_keys: [] - date_created: '1598865928' - date_modified: '1598866008' - description: playground-mfocko - fullname: playground-mfocko - id: 8593 - milestones: {} - name: playground-mfocko - namespace: null - parent: null - priorities: {} - tags: [] - url_path: playground-mfocko - user: - fullname: Matej Focko - name: mfocko - url_path: user/mfocko - _next: null - elapsed: 0.2 - encoding: null - headers: - Connection: Keep-Alive - Content-Length: '727' - Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne' - https://apps.fedoraproject.org; style-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne'; - object-src 'none';base-uri 'self';img-src 'self' https:; - Content-Type: application/json - Date: Fri, 01 Nov 2019 13-36-03 GMT - Keep-Alive: timeout=5, max=98 - Referrer-Policy: same-origin - Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips mod_wsgi/3.4 - Python/2.7.5 - Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmIjp7IiBiIjoiTlRZNU1UWTNNV00xTURrd1ltRmtZVGd5TkRrMU5UTTNaakJtT0dJMU56ZGhaRE13TXpnMk1RPT0ifX0.Ei5T2A.rsFPeccijtmG_ZwiN7C9Kq-jXZs; - Expires=Thu, 01-Oct-2020 09:26:48 GMT; Secure; HttpOnly; Path=/ - Strict-Transport-Security: max-age=31536000; includeSubDomains; preload - X-Content-Type-Options: nosniff - X-Frame-Options: ALLOW-FROM https://pagure.io/ - X-Xss-Protection: 1; mode=block - raw: !!binary "" - reason: OK - status_code: 200 diff --git a/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_user.yaml b/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_user.yaml deleted file mode 100644 index d6339895..00000000 --- a/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_add_user.yaml +++ /dev/null @@ -1,164 +0,0 @@ -_requre: - DataTypes: 1 - key_strategy: StorageKeysInspectSimple - version_storage_file: 2 -requests.sessions: - send: - POST: - https://pagure.io/api/0/-/whoami: - - metadata: - latency: 0.716820240020752 - module_call_list: - - unittest.case - - requre.online_replacing - - tests.integration.pagure.test_generic_commands - - ogr.services.pagure.user - - ogr.services.pagure.service - - requests.sessions - - requre.objects - - requre.cassette - - requests.sessions - - send - output: - __store_indicator: 2 - _content: - username: mfocko - _next: null - elapsed: 0.2 - encoding: null - headers: - Connection: Keep-Alive - Content-Length: '26' - Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne' - https://apps.fedoraproject.org; style-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne'; - object-src 'none';base-uri 'self';img-src 'self' https:; - Content-Type: application/json - Date: Fri, 01 Nov 2019 13-36-03 GMT - Keep-Alive: timeout=5, max=100 - Referrer-Policy: same-origin - Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips mod_wsgi/3.4 - Python/2.7.5 - Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmIjp7IiBiIjoiWXpkbU16ZGxNVGM0WldNeE5EWTFNRFEyWmpabU5XVm1NakV3WW1Vd05qTmtZV0ZtTjJJek53PT0ifX0.Ei5T2Q.tYOFK_v_ukMScqejcEZto1_tO8Y; - Expires=Thu, 01-Oct-2020 09:26:49 GMT; Secure; HttpOnly; Path=/ - Strict-Transport-Security: max-age=31536000; includeSubDomains; preload - X-Content-Type-Options: nosniff - X-Frame-Options: ALLOW-FROM https://pagure.io/ - X-Xss-Protection: 1; mode=block - raw: !!binary "" - reason: OK - status_code: 200 - - metadata: - latency: 0.3589768409729004 - module_call_list: - - unittest.case - - requre.online_replacing - - tests.integration.pagure.test_generic_commands - - ogr.services.pagure.service - - ogr.services.pagure.user - - ogr.services.pagure.service - - requests.sessions - - requre.objects - - requre.cassette - - requests.sessions - - send - output: - __store_indicator: 2 - _content: - username: mfocko - _next: null - elapsed: 0.2 - encoding: null - headers: - Connection: Keep-Alive - Content-Length: '26' - Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne' - https://apps.fedoraproject.org; style-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne'; - object-src 'none';base-uri 'self';img-src 'self' https:; - Content-Type: application/json - Date: Fri, 01 Nov 2019 13-36-03 GMT - Keep-Alive: timeout=5, max=99 - Referrer-Policy: same-origin - Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips mod_wsgi/3.4 - Python/2.7.5 - Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmIjp7IiBiIjoiWXpkbU16ZGxNVGM0WldNeE5EWTFNRFEyWmpabU5XVm1NakV3WW1Vd05qTmtZV0ZtTjJJek53PT0ifX0.Ei5T2Q.tYOFK_v_ukMScqejcEZto1_tO8Y; - Expires=Thu, 01-Oct-2020 09:26:49 GMT; Secure; HttpOnly; Path=/ - Strict-Transport-Security: max-age=31536000; includeSubDomains; preload - X-Content-Type-Options: nosniff - X-Frame-Options: ALLOW-FROM https://pagure.io/ - X-Xss-Protection: 1; mode=block - raw: !!binary "" - reason: OK - status_code: 200 - https://pagure.io/api/0/playground-mfocko/git/modifyacls: - - metadata: - latency: 0.4910888671875 - module_call_list: - - unittest.case - - requre.online_replacing - - tests.integration.pagure.test_generic_commands - - ogr.services.pagure.project - - ogr.services.pagure.service - - requests.sessions - - requre.objects - - requre.cassette - - requests.sessions - - send - output: - __store_indicator: 2 - _content: - access_groups: - admin: [] - collaborator: [] - commit: - - packit-test-group - ticket: [] - access_users: - admin: [] - collaborator: [] - commit: - - lachmanfrantisek - owner: - - mfocko - ticket: [] - close_status: [] - custom_keys: [] - date_created: '1598865928' - date_modified: '1598866010' - description: playground-mfocko - fullname: playground-mfocko - id: 8593 - milestones: {} - name: playground-mfocko - namespace: null - parent: null - priorities: {} - tags: [] - url_path: playground-mfocko - user: - fullname: Matej Focko - name: mfocko - url_path: user/mfocko - _next: null - elapsed: 0.2 - encoding: null - headers: - Connection: Keep-Alive - Content-Length: '757' - Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne' - https://apps.fedoraproject.org; style-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne'; - object-src 'none';base-uri 'self';img-src 'self' https:; - Content-Type: application/json - Date: Fri, 01 Nov 2019 13-36-03 GMT - Keep-Alive: timeout=5, max=98 - Referrer-Policy: same-origin - Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips mod_wsgi/3.4 - Python/2.7.5 - Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmIjp7IiBiIjoiWXpkbU16ZGxNVGM0WldNeE5EWTFNRFEyWmpabU5XVm1NakV3WW1Vd05qTmtZV0ZtTjJJek53PT0ifX0.Ei5T2g.maozjm0AkeY0VirWN5HFpzf2Xhk; - Expires=Thu, 01-Oct-2020 09:26:50 GMT; Secure; HttpOnly; Path=/ - Strict-Transport-Security: max-age=31536000; includeSubDomains; preload - X-Content-Type-Options: nosniff - X-Frame-Options: ALLOW-FROM https://pagure.io/ - X-Xss-Protection: 1; mode=block - raw: !!binary "" - reason: OK - status_code: 200 diff --git a/tests/integration/pagure/test_generic_commands.py b/tests/integration/pagure/test_generic_commands.py index e9c88096..3f8cdf38 100644 --- a/tests/integration/pagure/test_generic_commands.py +++ b/tests/integration/pagure/test_generic_commands.py @@ -12,7 +12,7 @@ @record_requests_for_all_methods() class GenericCommands(PagureTests): - def test_add_user(self): + def test_add_and_remove_user(self): """ Create an empty `playground-$USER` repository with no other users/groups. """ @@ -21,8 +21,9 @@ def test_add_user(self): namespace=None, ) project.add_user("lachmanfrantisek", AccessLevel.admin) + project.remove_user("lachmanfrantisek") - def test_add_group(self): + def test_add_and_remove_group(self): """ Create an empty `playground-$USER` repository with no other users/groups. """ @@ -31,6 +32,7 @@ def test_add_group(self): namespace=None, ) project.add_group("packit-test-group", AccessLevel.admin) + project.remove_group("packit-test-group") def test_description(self): description = self.ogr_project.get_description() From 6de187440d6dee277ea07cef9d24de2f10e430ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Mon, 9 Oct 2023 20:18:21 +0200 Subject: [PATCH 2/3] Allow to check for groups with permissions to modify a PR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nikola Forró --- ogr/abstract.py | 7 + ogr/services/pagure/project.py | 7 + .../GenericCommands.test_pr_permissions.yaml | 314 +++++++++++++++--- .../pagure/test_generic_commands.py | 6 + 4 files changed, 290 insertions(+), 44 deletions(-) diff --git a/ogr/abstract.py b/ogr/abstract.py index e941d00b..868787e0 100644 --- a/ogr/abstract.py +++ b/ogr/abstract.py @@ -1505,6 +1505,13 @@ def who_can_merge_pr(self) -> Set[str]: """ raise NotImplementedError() + def which_groups_can_merge_pr(self) -> Set[str]: + """ + Returns: + Names of all groups that have permission to modify pull request. + """ + raise NotImplementedError() + def can_merge_pr(self, username: str) -> bool: """ Args: diff --git a/ogr/services/pagure/project.py b/ogr/services/pagure/project.py index 1ac1d19c..c333ec09 100644 --- a/ogr/services/pagure/project.py +++ b/ogr/services/pagure/project.py @@ -214,6 +214,13 @@ def who_can_merge_pr(self) -> Set[str]: users.update(project["access_users"]["owner"]) return users + def which_groups_can_merge_pr(self) -> Set[str]: + groups: Set[str] = set() + project = self.get_project_info() + groups.update(project["access_groups"]["admin"]) + groups.update(project["access_groups"]["commit"]) + return groups + def can_merge_pr(self, username) -> bool: return username in self.who_can_merge_pr() diff --git a/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_pr_permissions.yaml b/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_pr_permissions.yaml index 4d3fe0ce..d68bc651 100644 --- a/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_pr_permissions.yaml +++ b/tests/integration/pagure/test_data/test_generic_commands/GenericCommands.test_pr_permissions.yaml @@ -1,18 +1,28 @@ _requre: DataTypes: 1 key_strategy: StorageKeysInspectSimple - version_storage_file: 2 + version_storage_file: 3 requests.sessions: send: GET: https://pagure.io/api/0/ogr-tests: - metadata: - latency: 0.365617036819458 + latency: 0.218308687210083 module_call_list: - unittest.case - - requre.online_replacing + - requre.record_and_replace - tests.integration.pagure.test_generic_commands + - ogr.abstract - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract - ogr.services.pagure.service - requests.sessions - requre.objects @@ -29,9 +39,12 @@ requests.sessions: ticket: [] access_users: admin: + - jpopelka - jscotka - lbarczio - mfocko + - nforro + - nikromen collaborator: [] commit: [] owner: @@ -40,8 +53,9 @@ requests.sessions: close_status: [] custom_keys: [] date_created: '1570568389' - date_modified: '1570568529' + date_modified: '1696856843' description: Testing repository for python-ogr package. + full_url: https://pagure.io/ogr-tests fullname: ogr-tests id: 6826 milestones: {} @@ -52,26 +66,28 @@ requests.sessions: tags: [] url_path: ogr-tests user: + full_url: https://pagure.io/user/lachmanfrantisek fullname: "Franti\u0161ek Lachman" name: lachmanfrantisek url_path: user/lachmanfrantisek _next: null - elapsed: 0.2 - encoding: null + elapsed: 0.217262 + encoding: utf-8 headers: Connection: Keep-Alive - Content-Length: '793' - Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne' - https://apps.fedoraproject.org; style-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne'; - object-src 'none';base-uri 'self';img-src 'self' https:; + Content-Length: '982' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-1he9XDYl69LyT7PlBpVJqGayj'; + style-src 'self' 'nonce-1he9XDYl69LyT7PlBpVJqGayj'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; Content-Type: application/json - Date: Fri, 01 Nov 2019 13-36-03 GMT + Date: Mon, 09 Oct 2023 17:38:14 GMT Keep-Alive: timeout=5, max=99 Referrer-Policy: same-origin - Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips mod_wsgi/3.4 - Python/2.7.5 - Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmIjp7IiBiIjoiTlRjNU1HSTBaV0ZoTTJZME5qSTJOak00WVRneU9UQXlaall5TVRkbU1UbG1OR1ppTmprNFl3PT0ifX0.EikahA.l2SsqYgSMes66FY54weDlEhxpak; - Expires=Sun, 27-Sep-2020 10:20:52 GMT; Secure; HttpOnly; Path=/ + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZWY5NWQ5NzRmNmFjYmFkYzM0OTYzMDNjYjViZjRmOTE1ZTc3ZjVjMCJ9.GAXMBg.olzyd-GVUepDs3wzWzGGPXF_IGg; + Expires=Thu, 09-Nov-2023 17:38:14 GMT; Secure; HttpOnly; Path=/ Strict-Transport-Security: max-age=31536000; includeSubDomains; preload X-Content-Type-Options: nosniff X-Frame-Options: ALLOW-FROM https://pagure.io/ @@ -80,12 +96,24 @@ requests.sessions: reason: OK status_code: 200 - metadata: - latency: 0.24908685684204102 + latency: 0.22804784774780273 module_call_list: - unittest.case - - requre.online_replacing + - requre.record_and_replace - tests.integration.pagure.test_generic_commands + - ogr.abstract - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract - ogr.services.pagure.service - requests.sessions - requre.objects @@ -102,9 +130,12 @@ requests.sessions: ticket: [] access_users: admin: + - jpopelka - jscotka - lbarczio - mfocko + - nforro + - nikromen collaborator: [] commit: [] owner: @@ -113,8 +144,9 @@ requests.sessions: close_status: [] custom_keys: [] date_created: '1570568389' - date_modified: '1570568529' + date_modified: '1696856843' description: Testing repository for python-ogr package. + full_url: https://pagure.io/ogr-tests fullname: ogr-tests id: 6826 milestones: {} @@ -125,26 +157,113 @@ requests.sessions: tags: [] url_path: ogr-tests user: + full_url: https://pagure.io/user/lachmanfrantisek fullname: "Franti\u0161ek Lachman" name: lachmanfrantisek url_path: user/lachmanfrantisek _next: null - elapsed: 0.2 - encoding: null + elapsed: 0.22703 + encoding: utf-8 headers: Connection: Keep-Alive - Content-Length: '793' - Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne' - https://apps.fedoraproject.org; style-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne'; - object-src 'none';base-uri 'self';img-src 'self' https:; + Content-Length: '982' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-5LTu7bhmW4dXgC8SQ8EgFknre'; + style-src 'self' 'nonce-5LTu7bhmW4dXgC8SQ8EgFknre'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; Content-Type: application/json - Date: Fri, 01 Nov 2019 13-36-03 GMT + Date: Mon, 09 Oct 2023 17:38:14 GMT Keep-Alive: timeout=5, max=98 Referrer-Policy: same-origin - Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips mod_wsgi/3.4 - Python/2.7.5 - Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmIjp7IiBiIjoiTlRjNU1HSTBaV0ZoTTJZME5qSTJOak00WVRneU9UQXlaall5TVRkbU1UbG1OR1ppTmprNFl3PT0ifX0.EikahA.l2SsqYgSMes66FY54weDlEhxpak; - Expires=Sun, 27-Sep-2020 10:20:52 GMT; Secure; HttpOnly; Path=/ + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZWY5NWQ5NzRmNmFjYmFkYzM0OTYzMDNjYjViZjRmOTE1ZTc3ZjVjMCJ9.GAXMBg.olzyd-GVUepDs3wzWzGGPXF_IGg; + Expires=Thu, 09-Nov-2023 17:38:14 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: max-age=31536000; includeSubDomains; preload + X-Content-Type-Options: nosniff + X-Frame-Options: ALLOW-FROM https://pagure.io/ + X-Xss-Protection: 1; mode=block + raw: !!binary "" + reason: OK + status_code: 200 + https://pagure.io/api/0/playground-nforro: + - metadata: + latency: 0.22342777252197266 + module_call_list: + - unittest.case + - requre.record_and_replace + - tests.integration.pagure.test_generic_commands + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.project + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - requests.sessions + - requre.objects + - requre.cassette + - requests.sessions + - send + output: + __store_indicator: 2 + _content: + access_groups: + admin: [] + collaborator: [] + commit: + - packit-test-group + ticket: [] + access_users: + admin: [] + collaborator: [] + commit: [] + owner: + - nforro + ticket: [] + close_status: [] + custom_keys: [] + date_created: '1696871156' + date_modified: '1696872541' + description: playground-nforro + full_url: https://pagure.io/playground-nforro + fullname: playground-nforro + id: 17033 + milestones: {} + name: playground-nforro + namespace: null + parent: null + priorities: {} + tags: [] + url_path: playground-nforro + user: + full_url: https://pagure.io/user/nforro + fullname: "Nikola Forr\xF3" + name: nforro + url_path: user/nforro + _next: null + elapsed: 0.222285 + encoding: utf-8 + headers: + Connection: Keep-Alive + Content-Length: '864' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-FZ3ZrxItAhIgTzjAwuaKrG3ee'; + style-src 'self' 'nonce-FZ3ZrxItAhIgTzjAwuaKrG3ee'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; + Content-Type: application/json + Date: Mon, 09 Oct 2023 17:38:15 GMT + Keep-Alive: timeout=5, max=95 + Referrer-Policy: same-origin + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZWY5NWQ5NzRmNmFjYmFkYzM0OTYzMDNjYjViZjRmOTE1ZTc3ZjVjMCJ9.GAXMBw.zdcrtg0pkCth37ICGbcFX6pXPgU; + Expires=Thu, 09-Nov-2023 17:38:15 GMT; Secure; HttpOnly; Path=/ Strict-Transport-Security: max-age=31536000; includeSubDomains; preload X-Content-Type-Options: nosniff X-Frame-Options: ALLOW-FROM https://pagure.io/ @@ -155,14 +274,21 @@ requests.sessions: POST: https://pagure.io/api/0/-/whoami: - metadata: - latency: 0.8395748138427734 + latency: 0.8489458560943604 module_call_list: - unittest.case - - requre.online_replacing + - requre.record_and_replace - tests.integration.pagure.test_generic_commands - tests.integration.pagure.base + - ogr.abstract - ogr.services.pagure.service + - ogr.abstract - ogr.services.pagure.user + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract - ogr.services.pagure.service - requests.sessions - requre.objects @@ -172,24 +298,124 @@ requests.sessions: output: __store_indicator: 2 _content: - username: mfocko + username: nforro _next: null - elapsed: 0.2 - encoding: null + elapsed: 0.848332 + encoding: utf-8 headers: - Connection: Keep-Alive - Content-Length: '26' - Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne' - https://apps.fedoraproject.org; style-src 'self' 'nonce-YqLDC0BS8d7iY8mKO7VtBbIne'; - object-src 'none';base-uri 'self';img-src 'self' https:; + Connection: Upgrade, Keep-Alive + Content-Length: '27' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-pJOYEfHN6G35MiWwfRsVCxaFY'; + style-src 'self' 'nonce-pJOYEfHN6G35MiWwfRsVCxaFY'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; Content-Type: application/json - Date: Fri, 01 Nov 2019 13-36-03 GMT + Date: Mon, 09 Oct 2023 17:38:13 GMT Keep-Alive: timeout=5, max=100 Referrer-Policy: same-origin - Server: Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.2k-fips mod_wsgi/3.4 - Python/2.7.5 - Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmIjp7IiBiIjoiTlRjNU1HSTBaV0ZoTTJZME5qSTJOak00WVRneU9UQXlaall5TVRkbU1UbG1OR1ppTmprNFl3PT0ifX0.EikahA.l2SsqYgSMes66FY54weDlEhxpak; - Expires=Sun, 27-Sep-2020 10:20:52 GMT; Secure; HttpOnly; Path=/ + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZWY5NWQ5NzRmNmFjYmFkYzM0OTYzMDNjYjViZjRmOTE1ZTc3ZjVjMCJ9.GAXMBQ.fWunzSGXYMncsRX7kUwTqYQBl0k; + Expires=Thu, 09-Nov-2023 17:38:13 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: max-age=31536000; includeSubDomains; preload + Upgrade: h2,h2c + X-Content-Type-Options: nosniff + X-Frame-Options: ALLOW-FROM https://pagure.io/ + X-Xss-Protection: 1; mode=block + raw: !!binary "" + reason: OK + status_code: 200 + - metadata: + latency: 0.2468886375427246 + module_call_list: + - unittest.case + - requre.record_and_replace + - tests.integration.pagure.test_generic_commands + - ogr.abstract + - ogr.services.pagure.user + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - requests.sessions + - requre.objects + - requre.cassette + - requests.sessions + - send + output: + __store_indicator: 2 + _content: + username: nforro + _next: null + elapsed: 0.245788 + encoding: utf-8 + headers: + Connection: Keep-Alive + Content-Length: '27' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-pzSCmhdnC9Gd640J4yXfqrVkY'; + style-src 'self' 'nonce-pzSCmhdnC9Gd640J4yXfqrVkY'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; + Content-Type: application/json + Date: Mon, 09 Oct 2023 17:38:14 GMT + Keep-Alive: timeout=5, max=97 + Referrer-Policy: same-origin + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZWY5NWQ5NzRmNmFjYmFkYzM0OTYzMDNjYjViZjRmOTE1ZTc3ZjVjMCJ9.GAXMBg.olzyd-GVUepDs3wzWzGGPXF_IGg; + Expires=Thu, 09-Nov-2023 17:38:14 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: max-age=31536000; includeSubDomains; preload + X-Content-Type-Options: nosniff + X-Frame-Options: ALLOW-FROM https://pagure.io/ + X-Xss-Protection: 1; mode=block + raw: !!binary "" + reason: OK + status_code: 200 + - metadata: + latency: 0.2515885829925537 + module_call_list: + - unittest.case + - requre.record_and_replace + - tests.integration.pagure.test_generic_commands + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.user + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - ogr.abstract + - ogr.services.pagure.service + - requests.sessions + - requre.objects + - requre.cassette + - requests.sessions + - send + output: + __store_indicator: 2 + _content: + username: nforro + _next: null + elapsed: 0.250437 + encoding: utf-8 + headers: + Connection: Keep-Alive + Content-Length: '27' + Content-Security-Policy: default-src 'self';script-src 'self' 'nonce-wdFguAEX0F5xXBuuemGaVSrUz'; + style-src 'self' 'nonce-wdFguAEX0F5xXBuuemGaVSrUz'; object-src 'none';base-uri + 'self';img-src 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src + https://docs.pagure.org;frame-ancestors https://pagure.io; + Content-Type: application/json + Date: Mon, 09 Oct 2023 17:38:14 GMT + Keep-Alive: timeout=5, max=96 + Referrer-Policy: same-origin + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 + Python/3.6 + Set-Cookie: pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZWY5NWQ5NzRmNmFjYmFkYzM0OTYzMDNjYjViZjRmOTE1ZTc3ZjVjMCJ9.GAXMBg.olzyd-GVUepDs3wzWzGGPXF_IGg; + Expires=Thu, 09-Nov-2023 17:38:14 GMT; Secure; HttpOnly; Path=/ Strict-Transport-Security: max-age=31536000; includeSubDomains; preload X-Content-Type-Options: nosniff X-Frame-Options: ALLOW-FROM https://pagure.io/ diff --git a/tests/integration/pagure/test_generic_commands.py b/tests/integration/pagure/test_generic_commands.py index 3f8cdf38..762a0c6b 100644 --- a/tests/integration/pagure/test_generic_commands.py +++ b/tests/integration/pagure/test_generic_commands.py @@ -117,6 +117,12 @@ def test_pr_permissions(self): owners = self.ogr_project.who_can_merge_pr() assert "lachmanfrantisek" in owners assert self.ogr_project.can_merge_pr("lachmanfrantisek") + project = self.service.get_project( + repo=f"playground-{self.service.user.get_username()}", + namespace=None, + ) + groups = project.which_groups_can_merge_pr() + assert "packit-test-group" in groups def test_get_web_url(self): url = self.ogr_project.get_web_url() From 4ded59c1995d8a35b245539af2cfe5fc40560499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Tue, 10 Oct 2023 11:24:26 +0200 Subject: [PATCH 3/3] Update COMPATIBILITY.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nikola Forró --- COMPATIBILITY.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/COMPATIBILITY.md b/COMPATIBILITY.md index 9fe9f639..6da7a5e8 100644 --- a/COMPATIBILITY.md +++ b/COMPATIBILITY.md @@ -51,12 +51,16 @@ In case you find any error, please [create a new issue](https://github.com/packi ## Project -| | GitHub | GitLab | Pagure | -| -------------------- | :----: | :----: | :---------------------: | -| `change_token` | ✘ | ✔ | ✔ | -| `get_release` | ✔ | ✔ | ✘ | -| `get_latest_release` | ✔ | ✔ | ✘ | -| `is_private` | ✔ | ✔ | ✘ (may not be accurate) | +| | GitHub | GitLab | Pagure | +| --------------------------- | :----: | :----: | :---------------------: | +| `change_token` | ✘ | ✔ | ✔ | +| `get_release` | ✔ | ✔ | ✘ | +| `get_latest_release` | ✔ | ✔ | ✘ | +| `is_private` | ✔ | ✔ | ✘ (may not be accurate) | +| `remove_user` | ✘ | ✘ | ✔ | +| `add_group` | ✘ | ✘ | ✔ | +| `remove_group` | ✘ | ✘ | ✔ | +| `which_groups_can_merge_pr` | ✘ | ✘ | ✔ | ## User