|
8 | 8 | importresponses
|
9 | 9 |
|
10 | 10 | importgitlab
|
11 |
| -fromgitlab.v4.objectsimportGroupDescendantGroup,GroupLDAPGroupLink,GroupSubgroup |
| 11 | +fromgitlab.v4.objectsimport ( |
| 12 | +GroupDescendantGroup, |
| 13 | +GroupLDAPGroupLink, |
| 14 | +GroupSAMLGroupLink, |
| 15 | +GroupSubgroup, |
| 16 | +) |
12 | 17 | fromgitlab.v4.objects.projectsimportGroupProject,SharedProject
|
13 | 18 |
|
14 | 19 | content= {"name":"name","id":1,"path":"path"}
|
|
20 | 25 | "filter":"(memberOf=cn=some_group,ou=groups,ou=fake_ou,dc=sub_dc,dc=example,dc=tld)",
|
21 | 26 | }
|
22 | 27 | ]
|
| 28 | +saml_group_links_content= [{"name":"saml-group-1","access_level":10}] |
| 29 | +create_saml_group_link_request_body= { |
| 30 | +"saml_group_name":"saml-group-1", |
| 31 | +"access_level":10, |
| 32 | +} |
23 | 33 | projects_content= [
|
24 | 34 | {
|
25 | 35 | "id":9,
|
@@ -237,6 +247,75 @@ def resp_list_ldap_group_links(no_content):
|
237 | 247 | yieldrsps
|
238 | 248 |
|
239 | 249 |
|
| 250 | +@pytest.fixture |
| 251 | +defresp_list_saml_group_links(): |
| 252 | +withresponses.RequestsMock()asrsps: |
| 253 | +rsps.add( |
| 254 | +method=responses.GET, |
| 255 | +url="http://localhost/api/v4/groups/1/saml_group_links", |
| 256 | +json=saml_group_links_content, |
| 257 | +content_type="application/json", |
| 258 | +status=200, |
| 259 | + ) |
| 260 | +yieldrsps |
| 261 | + |
| 262 | + |
| 263 | +@pytest.fixture |
| 264 | +defresp_get_saml_group_link(): |
| 265 | +withresponses.RequestsMock()asrsps: |
| 266 | +rsps.add( |
| 267 | +method=responses.GET, |
| 268 | +url="http://localhost/api/v4/groups/1/saml_group_links/saml-group-1", |
| 269 | +json=saml_group_links_content[0], |
| 270 | +content_type="application/json", |
| 271 | +status=200, |
| 272 | + ) |
| 273 | +yieldrsps |
| 274 | + |
| 275 | + |
| 276 | +@pytest.fixture |
| 277 | +defresp_create_saml_group_link(): |
| 278 | +withresponses.RequestsMock()asrsps: |
| 279 | +rsps.add( |
| 280 | +method=responses.POST, |
| 281 | +url="http://localhost/api/v4/groups/1/saml_group_links", |
| 282 | +match=[ |
| 283 | +responses.matchers.json_params_matcher( |
| 284 | +create_saml_group_link_request_body |
| 285 | + ) |
| 286 | + ], |
| 287 | +json=saml_group_links_content[0], |
| 288 | +content_type="application/json", |
| 289 | +status=200, |
| 290 | + ) |
| 291 | +yieldrsps |
| 292 | + |
| 293 | + |
| 294 | +@pytest.fixture |
| 295 | +defresp_delete_saml_group_link(no_content): |
| 296 | +withresponses.RequestsMock()asrsps: |
| 297 | +rsps.add( |
| 298 | +method=responses.POST, |
| 299 | +url="http://localhost/api/v4/groups/1/saml_group_links", |
| 300 | +match=[ |
| 301 | +responses.matchers.json_params_matcher( |
| 302 | +create_saml_group_link_request_body |
| 303 | + ) |
| 304 | + ], |
| 305 | +json=saml_group_links_content[0], |
| 306 | +content_type="application/json", |
| 307 | +status=200, |
| 308 | + ) |
| 309 | +rsps.add( |
| 310 | +method=responses.DELETE, |
| 311 | +url="http://localhost/api/v4/groups/1/saml_group_links/saml-group-1", |
| 312 | +json=no_content, |
| 313 | +content_type="application/json", |
| 314 | +status=204, |
| 315 | + ) |
| 316 | +yieldrsps |
| 317 | + |
| 318 | + |
240 | 319 | deftest_get_group(gl,resp_groups):
|
241 | 320 | data=gl.groups.get(1)
|
242 | 321 | assertisinstance(data,gitlab.v4.objects.Group)
|
@@ -341,3 +420,36 @@ def test_update_group_push_rule(
|
341 | 420 | deftest_delete_group_push_rule(group,resp_delete_push_rules_group):
|
342 | 421 | pr=group.pushrules.get()
|
343 | 422 | pr.delete()
|
| 423 | + |
| 424 | + |
| 425 | +deftest_list_saml_group_links(group,resp_list_saml_group_links): |
| 426 | +saml_group_links=group.saml_group_links.list() |
| 427 | +assertisinstance(saml_group_links[0],GroupSAMLGroupLink) |
| 428 | +assertsaml_group_links[0].name==saml_group_links_content[0]["name"] |
| 429 | +assert ( |
| 430 | +saml_group_links[0].access_level==saml_group_links_content[0]["access_level"] |
| 431 | + ) |
| 432 | + |
| 433 | + |
| 434 | +deftest_get_saml_group_link(group,resp_get_saml_group_link): |
| 435 | +saml_group_link=group.saml_group_links.get("saml-group-1") |
| 436 | +assertisinstance(saml_group_link,GroupSAMLGroupLink) |
| 437 | +assertsaml_group_link.name==saml_group_links_content[0]["name"] |
| 438 | +assertsaml_group_link.access_level==saml_group_links_content[0]["access_level"] |
| 439 | + |
| 440 | + |
| 441 | +deftest_create_saml_group_link(group,resp_create_saml_group_link): |
| 442 | +saml_group_link=group.saml_group_links.create(create_saml_group_link_request_body) |
| 443 | +assertisinstance(saml_group_link,GroupSAMLGroupLink) |
| 444 | +assert ( |
| 445 | +saml_group_link.name==create_saml_group_link_request_body["saml_group_name"] |
| 446 | + ) |
| 447 | +assert ( |
| 448 | +saml_group_link.access_level |
| 449 | +==create_saml_group_link_request_body["access_level"] |
| 450 | + ) |
| 451 | + |
| 452 | + |
| 453 | +deftest_delete_saml_group_link(group,resp_delete_saml_group_link): |
| 454 | +saml_group_link=group.saml_group_links.create(create_saml_group_link_request_body) |
| 455 | +saml_group_link.delete() |