Add full application management API, UI and test cases

This commit is contained in:
Joseph Schorr 2014-03-20 15:46:13 -04:00
parent a3eff7a2e8
commit f7c27f250b
16 changed files with 904 additions and 15 deletions

View file

@ -26,7 +26,9 @@ from endpoints.api.billing import (UserInvoiceList, UserCard, UserPlan, ListPlan
from endpoints.api.discovery import DiscoveryResource
from endpoints.api.organization import (OrganizationList, OrganizationMember,
OrgPrivateRepositories, OrgnaizationMemberList,
Organization, ApplicationInformation)
Organization, ApplicationInformation,
OrganizationApplications, OrganizationApplicationResource,
OrganizationApplicationResetClientSecret)
from endpoints.api.repository import RepositoryList, RepositoryVisibility, Repository
from endpoints.api.permission import (RepositoryUserPermission, RepositoryTeamPermission,
RepositoryTeamPermissionList, RepositoryUserPermissionList)
@ -2937,3 +2939,105 @@ class TestApplicationInformation3lgi(ApiTestCase):
def test_get_devtable(self):
self._run_test('GET', 404, 'devtable', None)
class TestOrganizationApplications(ApiTestCase):
def setUp(self):
ApiTestCase.setUp(self)
self._set_url(OrganizationApplications, orgname="buynlarge")
def test_get_anonymous(self):
self._run_test('GET', 401, None, None)
def test_get_freshuser(self):
self._run_test('GET', 403, 'freshuser', None)
def test_get_reader(self):
self._run_test('GET', 403, 'reader', None)
def test_get_devtable(self):
self._run_test('GET', 200, 'devtable', None)
def test_post_anonymous(self):
self._run_test('POST', 401, None, {u'name': 'foo'})
def test_post_freshuser(self):
self._run_test('POST', 403, 'freshuser', {u'name': 'foo'})
def test_post_reader(self):
self._run_test('POST', 403, 'reader', {u'name': 'foo'})
def test_post_devtable(self):
self._run_test('POST', 200, 'devtable', {u'name': 'foo'})
class TestOrganizationApplicationResource(ApiTestCase):
def setUp(self):
ApiTestCase.setUp(self)
self._set_url(OrganizationApplicationResource, orgname="buynlarge", client_id="deadbeef")
def test_get_anonymous(self):
self._run_test('GET', 401, None, None)
def test_get_freshuser(self):
self._run_test('GET', 403, 'freshuser', None)
def test_get_reader(self):
self._run_test('GET', 403, 'reader', None)
def test_get_devtable(self):
self._run_test('GET', 200, 'devtable', None)
def test_put_anonymous(self):
self._run_test('PUT', 401, None,
{u'name': 'foo', u'application_uri': 'foo', u'redirect_uri': 'foo'})
def test_put_freshuser(self):
self._run_test('PUT', 403, 'freshuser',
{u'name': 'foo', u'application_uri': 'foo', u'redirect_uri': 'foo'})
def test_put_reader(self):
self._run_test('PUT', 403, 'reader',
{u'name': 'foo', u'application_uri': 'foo', u'redirect_uri': 'foo'})
def test_put_devtable(self):
self._run_test('PUT', 200, 'devtable',
{u'name': 'foo', u'application_uri': 'foo', u'redirect_uri': 'foo'})
def test_delete_anonymous(self):
self._run_test('DELETE', 401, None, None)
def test_delete_freshuser(self):
self._run_test('DELETE', 403, 'freshuser', None)
def test_delete_reader(self):
self._run_test('DELETE', 403, 'reader', None)
def test_delete_devtable(self):
self._run_test('DELETE', 204, 'devtable', None)
class TestOrganizationApplicationResetClientSecret(ApiTestCase):
def setUp(self):
ApiTestCase.setUp(self)
self._set_url(OrganizationApplicationResetClientSecret,
orgname="buynlarge", client_id="deadbeef")
def test_post_anonymous(self):
self._run_test('POST', 401, None, None)
def test_post_freshuser(self):
self._run_test('POST', 403, 'freshuser', None)
def test_post_reader(self):
self._run_test('POST', 403, 'reader', None)
def test_post_devtable(self):
self._run_test('POST', 200, 'devtable', None)
if __name__ == '__main__':
unittest.main()