Skip to content

Conversation

@nejch
Copy link
Member

@nejch nejch commented Mar 22, 2020

Closes #1050.

The functional tests currently only test that the server returns the correct 404 response for unsigned commits, since creating signed commits without the API would be a bit convoluted, maybe this can be added later? https://gitlab.com/gitlab-org/gitlab/-/issues/19185 might also help with this.

However, I've tested this against real signed and unsigned commits on gitlab.com:

>>> import gitlab
>>> gl = gitlab.Gitlab("https://gitlab.com")
>>> project = gl.projects.get("gitlab-org/gitlab")
>>> signed_commit = project.commits.get("387572e7aa7768e2be539215e453d474d067e20d")
>>> signed_commit.signature()
{'gpg_key_id': None, 'gpg_key_primary_keyid': 'B89F5B74C808CB29', 'gpg_key_user_name': 'Daniel Paul Searles', 'gpg_key_user_email': 'dsearles@gitlab.com', 'verification_status': 'verified', 'gpg_key_subkey_id': 61400}
>>> unsigned_commit = project.commits.get("86b82a8ca235a886788581b0ff5bb24f4e4bfaa2")
>>> unsigned_commit.signature()
Traceback (most recent call last):
  File "/home/z003wwtz/repos/python-gitlab/gitlab/exceptions.py", line 271, in wrapped_f
    return f(*args, **kwargs)
  File "/home/z003wwtz/repos/python-gitlab/gitlab/v4/objects.py", line 2191, in signature
    return self.manager.gitlab.http_get(path, **kwargs)
  File "/home/z003wwtz/repos/python-gitlab/gitlab/__init__.py", line 598, in http_get
    "get", path, query_data=query_data, streamed=streamed, **kwargs
  File "/home/z003wwtz/repos/python-gitlab/gitlab/__init__.py", line 573, in http_request
    response_body=result.content,
gitlab.exceptions.GitlabHttpError: 404: 404 GPG Signature Not Found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/z003wwtz/repos/python-gitlab/gitlab/cli.py", line 43, in wrapped_f
    return f(*args, **kwargs)
  File "/home/z003wwtz/repos/python-gitlab/gitlab/exceptions.py", line 273, in wrapped_f
    raise error(e.error_message, e.response_code, e.response_body)
gitlab.exceptions.GitlabGetError: 404: 404 GPG Signature Not Found

@nejch nejch marked this pull request as ready for review March 22, 2020 16:12
@nejch nejch requested a review from max-wittig March 22, 2020 16:12
@max-wittig
Copy link
Member

Awesome quality, as always! 👍

@max-wittig max-wittig merged commit 1b8e748 into python-gitlab:master Mar 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for signature endpoint for commits

2 participants