Add organization collaborators API endpoint
Adds an API endpoint, `/v1/organization/<orgname>/collaborators`, that lists an organization's "outside collaborators", i.e. users that have direct permissions on one or more repositories belonging to the organization, but who aren't members of any teams in the organization.
This commit is contained in:
parent
32a473d23c
commit
e8429f9194
3 changed files with 76 additions and 1 deletions
|
@ -3,10 +3,12 @@ import pytest
|
|||
from data import model
|
||||
from endpoints.api import api
|
||||
from endpoints.api.test.shared import conduct_api_call
|
||||
from endpoints.api.organization import Organization
|
||||
from endpoints.api.organization import (Organization,
|
||||
OrganizationCollaboratorList)
|
||||
from endpoints.test.shared import client_with_identity
|
||||
from test.fixtures import *
|
||||
|
||||
|
||||
@pytest.mark.parametrize('expiration, expected_code', [
|
||||
(0, 200),
|
||||
(100, 400),
|
||||
|
@ -17,3 +19,20 @@ def test_change_tag_expiration(expiration, expected_code, client):
|
|||
conduct_api_call(cl, Organization, 'PUT', {'orgname': 'buynlarge'},
|
||||
body={'tag_expiration_s': expiration},
|
||||
expected_code=expected_code)
|
||||
|
||||
|
||||
def test_get_organization_collaborators(client):
|
||||
params = {'orgname': 'buynlarge'}
|
||||
|
||||
with client_with_identity('devtable', client) as cl:
|
||||
resp = conduct_api_call(cl, OrganizationCollaboratorList, 'GET', params)
|
||||
|
||||
collaborator_names = [c['name'] for c in resp.json['collaborators']]
|
||||
assert 'outsideorg' in collaborator_names
|
||||
assert 'devtable' not in collaborator_names
|
||||
assert 'reader' not in collaborator_names
|
||||
|
||||
for collaborator in resp.json['collaborators']:
|
||||
if collaborator['name'] == 'outsideorg':
|
||||
assert 'orgrepo' in collaborator['repositories']
|
||||
assert 'anotherorgrepo' not in collaborator['repositories']
|
||||
|
|
Reference in a new issue