diff options
Diffstat (limited to 'gitlab')
-rw-r--r-- | gitlab/__init__.py | 1 | ||||
-rw-r--r-- | gitlab/tests/test_gitlab.py | 27 | ||||
-rw-r--r-- | gitlab/v4/objects.py | 11 |
3 files changed, 39 insertions, 0 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 96a3c13..7ea141e 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -144,6 +144,7 @@ class Gitlab(object): self.features = objects.FeatureManager(self) self.pagesdomains = objects.PagesDomainManager(self) self.user_activities = objects.UserActivitiesManager(self) + self.applications = objects.ApplicationManager(self) def __enter__(self): return self diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py index e7f1932..249d0c5 100644 --- a/gitlab/tests/test_gitlab.py +++ b/gitlab/tests/test_gitlab.py @@ -964,6 +964,33 @@ class TestGitlab(unittest.TestCase): self.assertEqual(ret["full_path"], "/".join((base_path, name))) self.assertTrue(ret["full_name"].endswith(name)) + def test_applications(self): + content = '{"name": "test_app", "redirect_uri": "http://localhost:8080", "scopes": ["api", "email"]}' + json_content = json.loads(content) + + @urlmatch( + scheme="http", + netloc="localhost", + path="/api/v4/applications", + method="post", + ) + def resp_application_create(url, request): + headers = {"content-type": "application/json"} + return response(200, json_content, headers, None, 5, request) + + with HTTMock(resp_application_create): + application = self.gl.applications.create( + { + "name": "test_app", + "redirect_uri": "http://localhost:8080", + "scopes": ["api", "email"], + "confidential": False, + } + ) + self.assertEqual(application.name, "test_app") + self.assertEqual(application.redirect_uri, "http://localhost:8080") + self.assertEqual(application.scopes, ["api", "email"]) + def _default_config(self): fd, temp_path = tempfile.mkstemp() os.write(fd, valid_config) diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 92650b1..a349aff 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -5141,3 +5141,14 @@ class GeoNodeManager(RetrieveMixin, UpdateMixin, DeleteMixin, RESTManager): list: The list of failures """ return self.gitlab.http_list("/geo_nodes/current/failures", **kwargs) + + +class Application(ObjectDeleteMixin, RESTObject): + _url = "/applications" + _short_print_attr = "name" + + +class ApplicationManager(ListMixin, CreateMixin, DeleteMixin, RESTManager): + _path = "/applications" + _obj_cls = Application + _create_attrs = (("name", "redirect_uri", "scopes"), ("confidential",)) |