diff options
author | Max Wittig <max.wittig@siemens.com> | 2020-04-07 10:39:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-07 10:39:46 +0200 |
commit | 5979750fcc953148fcca910c04258f56c3027bce (patch) | |
tree | 08ee6b2556dce3a53248895d040a580c8770b1b1 /gitlab/tests/test_gitlab.py | |
parent | 3396aa51e055b7e7d3bceddc1b91deed17323f3a (diff) | |
parent | 01de524ce39a67b549b3157bf4de827dd0568d6b (diff) | |
download | gitlab-5979750fcc953148fcca910c04258f56c3027bce.tar.gz |
Merge pull request #1052 from machine424/deploy-tokens-support
feat(api): add support for Gitlab Deploy Token API
Diffstat (limited to 'gitlab/tests/test_gitlab.py')
-rw-r--r-- | gitlab/tests/test_gitlab.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py index 8261cc6..6fc551c 100644 --- a/gitlab/tests/test_gitlab.py +++ b/gitlab/tests/test_gitlab.py @@ -903,6 +903,40 @@ class TestGitlab(unittest.TestCase): self.assertEqual(application.redirect_uri, "http://localhost:8080") self.assertEqual(application.scopes, ["api", "email"]) + def test_deploy_tokens(self): + @urlmatch( + scheme="http", + netloc="localhost", + path="/api/v4/projects/1/deploy_tokens", + method="post", + ) + def resp_deploy_token_create(url, request): + headers = {"content-type": "application/json"} + content = """{ + "id": 1, + "name": "test_deploy_token", + "username": "custom-user", + "expires_at": "2022-01-01T00:00:00.000Z", + "token": "jMRvtPNxrn3crTAGukpZ", + "scopes": [ "read_repository" ]}""" + content = content.encode("utf-8") + return response(200, content, headers, None, 5, request) + + with HTTMock(resp_deploy_token_create): + deploy_token = self.gl.projects.get(1, lazy=True).deploytokens.create( + { + "name": "test_deploy_token", + "expires_at": "2022-01-01T00:00:00.000Z", + "username": "custom-user", + "scopes": ["read_repository"], + } + ) + self.assertIsInstance(deploy_token, ProjectDeployToken) + self.assertEqual(deploy_token.id, 1), + self.assertEqual(deploy_token.expires_at, "2022-01-01T00:00:00.000Z"), + self.assertEqual(deploy_token.username, "custom-user") + self.assertEqual(deploy_token.scopes, ["read_repository"]) + def _default_config(self): fd, temp_path = tempfile.mkstemp() os.write(fd, valid_config) |