diff --git a/jira/client.py b/jira/client.py index af6bf498d..fec48d9cf 100644 --- a/jira/client.py +++ b/jira/client.py @@ -2634,6 +2634,10 @@ def my_permissions( ) -> Dict[str, Dict[str, Dict[str, str]]]: """Get a dict of all available permissions on the server. + ``permissions`` is a comma-separated value list of permission keys that is + required in Jira Cloud. For possible and allowable permission values, see + https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-permission-schemes/#built-in-permissions + Args: projectKey (Optional[str]): limit returned permissions to the specified project projectId (Optional[str]): limit returned permissions to the specified project diff --git a/jira/resilientsession.py b/jira/resilientsession.py index 039b449ed..fa138a36f 100644 --- a/jira/resilientsession.py +++ b/jira/resilientsession.py @@ -159,7 +159,7 @@ def _jira_prepare(self, **original_kwargs) -> dict: request_headers.update(original_kwargs.get("headers", {})) prepared_kwargs["headers"] = request_headers - data = original_kwargs.get("data", {}) + data = original_kwargs.get("data", None) if isinstance(data, dict): # mypy ensures we don't do this, # but for people subclassing we should preserve old behaviour diff --git a/tests/test_resilientsession.py b/tests/test_resilientsession.py index 22e875228..9191bcb0b 100644 --- a/tests/test_resilientsession.py +++ b/tests/test_resilientsession.py @@ -107,3 +107,22 @@ def test_passthrough_class(): # WHEN: the dict of request args are prepared # THEN: The exact same dict is returned assert passthrough_class.prepare(my_kwargs) is my_kwargs + + +@patch("requests.Session.request") +def test_unspecified_body_remains_unspecified(mocked_request_method: Mock): + # Disable retries for this test. + session = jira.resilientsession.ResilientSession(max_retries=0) + # Data is not specified here. + session.get(url="mocked_url") + kwargs = mocked_request_method.call_args.kwargs + assert "data" not in kwargs + + +@patch("requests.Session.request") +def test_nonempty_body_is_forwarded(mocked_request_method: Mock): + # Disable retries for this test. + session = jira.resilientsession.ResilientSession(max_retries=0) + session.get(url="mocked_url", data={"some": "fake-data"}) + kwargs = mocked_request_method.call_args.kwargs + assert kwargs["data"] == '{"some": "fake-data"}' diff --git a/tests/tests.py b/tests/tests.py index 0f6f1e897..7eeb346cf 100755 --- a/tests/tests.py +++ b/tests/tests.py @@ -157,8 +157,6 @@ def test_fields(self): class MyPermissionsServerTests(JiraTestCase): def setUp(self): super().setUp() - if self.jira._is_cloud: - self.skipTest("server only test class") self.issue_1 = self.test_manager.project_b_issue1 def test_my_permissions(self): @@ -214,6 +212,10 @@ def test_my_permissions_by_issue(self): ) self.assertEqual(len(perms["permissions"]), 3) + def test_missing_required_param_my_permissions_raises_exception(self): + with self.assertRaises(JIRAError): + self.jira.my_permissions() + def test_invalid_param_my_permissions_raises_exception(self): with self.assertRaises(JIRAError): self.jira.my_permissions("INVALID_PERMISSION")