API deploy_keys: can_push is not honoured
Summary
When I use the GitLab.com API for adding a Deploy Key,
and set can_push=true
according to the API docs in the request parameters,
then the resulting key is always read-only.
Notes:
- Using the value
can_push=false
leads to the very same result. - Using v3 of the API leads to the very same result.
Steps to reproduce
1. ) Prepare a POST
request against https://gitlab.com/api/v4/projects/2967925/deploy_keys with the following values set as request parameters:
access_token=2df...
key=ssh-rsa AAAA...
title=SSH Key Test ...
can_push=true
id=2967925
2.) Result: (wrapped for easier reading)
{
"id":1026467,
"title":"SSH Key Test using PyCharm",
"key":"ssh-rsa AAAAB3..........................RdWNpLrL peter@laptop",
"created_at":"2017-03-24T13:05:56.005Z",
"can_push":false
}
Example: (using curl)
curl --request POST --header "Content-Type: application/json" --data '{"access_token": "2df60.....112", "title": "My deploy key", "key": "ssh-rsa AAAA.....dAFNpLrWL peter@machine", "can_push": "true"}' "https://gitlab.com/api/v4/projects/2967925/deploy_keys/"
What is the current bug behavior?
The resulting key is always read-only.
What is the expected correct behavior?
The resulting key should be read-write when can_push
was true
in the request.
Relevant logs and/or screenshots
1.) Request:
(Note that this issue is reproducible also directly from the code; PyCharm REST client is only an example.)
2.) Response: (see "Steps to reproduce")
3.) Response headers:
HTTP/1.1 201 Created
Server: nginx
Date: Fri, 24 Mar 2017 13:15:38 GMT
Content-Type: application/json
Content-Length: 508
Cache-Control: max-age=0, private, must-revalidate
Etag: W/"e00e2f741eeb1fe4b3525f9e2e0c035f"
Vary: Origin
X-Request-Id: 8888b43a-63a8-4f63-94b3-1e800deca004
X-Runtime: 0.720086
Strict-Transport-Security: max-age=31536000
4.) Terminal output of Python code using Git for pushing a repo to GitLab: (after adding a r/w deploy key via the API as above)
Warning: Permanently added 'gitlab.com' (ECDSA) to the list of known hosts.
GitLab: This deploy key does not have write access to this project.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Output of checks
This bug happens on GitLab.com
Possible fixes
No fixes known. (My Ruby knowledge is limited.)
Potential source location: gitlab-ce:/lib/api/deploy_keys.rb