diff options
author | Max Wittig <max.wittig95@gmail.com> | 2020-03-01 23:24:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-01 23:24:19 +0100 |
commit | e5afb554bf4bcc28555bde4030f50558f175a53b (patch) | |
tree | ce89fa6b548a89e1dcceeef5711f714e7ca1f3b9 /gitlab | |
parent | fbcc8204a7f69405ec9a9a32b1e26256c7831e10 (diff) | |
parent | 4e12356d6da58c9ef3d8bf9ae67e8aef8fafac0a (diff) | |
download | gitlab-e5afb554bf4bcc28555bde4030f50558f175a53b.tar.gz |
Merge pull request #1034 from filipowm/feat/api-oauth-applications
feat(api): add support for GitLab OAuth Applications using Applications API
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",)) |