File tree 3 files changed +26
-11
lines changed
3 files changed +26
-11
lines changed Original file line number Diff line number Diff line change 36
36
# end delete
37
37
38
38
# enable
39
- deploy_key . enable ()
39
+ project . keys . enable (key_id )
40
40
# end enable
41
41
42
42
# disable
43
- deploy_key . disable ()
43
+ project . keys . disable (key_id )
44
44
# end disable
Original file line number Diff line number Diff line change @@ -1366,24 +1366,23 @@ class ProjectKey(GitlabObject):
1366
1366
requiredUrlAttrs = ['project_id' ]
1367
1367
requiredCreateAttrs = ['title' , 'key' ]
1368
1368
1369
- def enable (self ):
1369
+
1370
+ class ProjectKeyManager (BaseManager ):
1371
+ obj_cls = ProjectKey
1372
+
1373
+ def enable (self , key_id ):
1370
1374
"""Enable a deploy key for a project."""
1371
- url = '/projects/%s/deploy_keys/%s/enable' % (self .project_id , self .id )
1375
+ url = '/projects/%s/deploy_keys/%s/enable' % (self .parent .id , key_id )
1372
1376
r = self .gitlab ._raw_post (url )
1373
1377
raise_error_from_response (r , GitlabProjectDeployKeyError , 201 )
1374
1378
1375
- def disable (self ):
1379
+ def disable (self , key_id ):
1376
1380
"""Disable a deploy key for a project."""
1377
- url = '/projects/%s/deploy_keys/%s/disable' % (self .project_id ,
1378
- self .id )
1381
+ url = '/projects/%s/deploy_keys/%s/disable' % (self .parent .id , key_id )
1379
1382
r = self .gitlab ._raw_delete (url )
1380
1383
raise_error_from_response (r , GitlabProjectDeployKeyError , 200 )
1381
1384
1382
1385
1383
- class ProjectKeyManager (BaseManager ):
1384
- obj_cls = ProjectKey
1385
-
1386
-
1387
1386
class ProjectEvent (GitlabObject ):
1388
1387
_url = '/projects/%(project_id)s/events'
1389
1388
canGet = 'from_list'
Original file line number Diff line number Diff line change 12
12
"a6WP5lTi/HJIjAl6Hu+zHgdj1XVExeH+S52EwpZf/ylTJub0Bl5gHwf/siVE48mLMI"
13
13
"sqrukXTZ6Zg+8EHAIvIQwJ1dKcXe8P5IoLT7VKrbkgAnolS0I8J+uH7KtErZJb5oZh"
14
14
"S4OEwsNpaXMAr+6/wWSpircV2/e7sFLlhlKBC4Iq1MpqlZ7G3p foo@bar" )
15
+ DEPLOY_KEY = ("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFdRyjJQh+1niBpXqE2I8dzjG"
16
+ "MXFHlRjX9yk/UfOn075IdaockdU58sw2Ai1XIWFpZpfJkW7z+P47ZNSqm1gzeXI"
17
+ "rtKa9ZUp8A7SZe8vH4XVn7kh7bwWCUirqtn8El9XdqfkzOs/+FuViriUWoJVpA6"
18
+ "WZsDNaqINFKIA5fj/q8XQw+BcS92L09QJg9oVUuH0VVwNYbU2M2IRmSpybgC/gu"
19
+ "uWTrnCDMmLItksATifLvRZwgdI8dr+q6tbxbZknNcgEPrI2jT0hYN9ZcjNeWuyv"
20
+ "rke9IepE7SPBT41C+YtUX4dfDZDmczM1cE0YL/krdUCfuZHMa4ZS2YyNd6slufc"
21
+ "vn bar@foo" )
15
22
16
23
# login/password authentication
17
24
gl = gitlab .Gitlab ('http://localhost:8080' , email = LOGIN , password = PASSWORD )
183
190
archive2 = admin_project .repository_archive ('master' )
184
191
assert (archive1 == archive2 )
185
192
193
+ # deploy keys
194
+ deploy_key = admin_project .keys .create ({'title' : 'foo@bar' , 'key' : DEPLOY_KEY })
195
+ project_keys = admin_project .keys .list ()
196
+ assert (len (project_keys ) == 1 )
197
+ sudo_project .keys .enable (deploy_key .id )
198
+ assert (len (sudo_project .keys .list ()) == 1 )
199
+ sudo_project .keys .disable (deploy_key .id )
200
+ assert (len (sudo_project .keys .list ()) == 0 )
201
+
186
202
# labels
187
203
label1 = admin_project .labels .create ({'name' : 'label1' , 'color' : '#778899' })
188
204
label1 = admin_project .labels .get ('label1' )
You can’t perform that action at this time.
0 commit comments