From 0c4c4c78c701ec2b764668421eafdd640183f6bb Mon Sep 17 00:00:00 2001 From: jakedt Date: Tue, 18 Mar 2014 16:48:09 -0400 Subject: [PATCH] Switch the security tests over to the new test format which is generated. --- test/specs.py | 442 +----- test/test_api_security.py | 2965 ++++++++++++++++++++++++++++++++++++- 2 files changed, 2900 insertions(+), 507 deletions(-) diff --git a/test/specs.py b/test/specs.py index 8506a9342..c8f53a376 100644 --- a/test/specs.py +++ b/test/specs.py @@ -1,10 +1,10 @@ import json from flask import url_for -from collections import OrderedDict from uuid import uuid4 from base64 import b64encode + NO_REPO = None PUBLIC_REPO = 'public/publicrepo' PRIVATE_REPO = 'devtable/shared' @@ -72,446 +72,6 @@ UPDATE_REPO_DETAILS = { } -class TestSpec(object): - def __init__(self, url, anon_code=401, no_access_code=403, read_code=403, - admin_code=200): - self._url = url - self._data = None - self._method = 'GET' - - self.anon_code = anon_code - self.no_access_code = no_access_code - self.read_code = read_code - self.admin_code = admin_code - - def set_data_from_obj(self, json_serializable): - self._data = json.dumps(json_serializable) - return self - - def set_method(self, method): - self._method = method - return self - - def get_client_args(self): - kwargs = { - 'method': self._method - } - - if self._data or self._method == 'POST' or self._method == 'PUT': - kwargs['data'] = self._data if self._data else '{}' - kwargs['content_type'] = 'application/json' - - return self._url, kwargs - - -def build_specs(): - return [ - TestSpec(url_for('api.welcome'), 200, 200, 200, 200), - - TestSpec(url_for('api.list_plans'), 200, 200, 200, 200), - - TestSpec(url_for('api.get_logged_in_user'), 200, 200, 200, 200), - - TestSpec(url_for('api.change_user_details'), - 401, 200, 200, 200).set_method('PUT'), - - TestSpec(url_for('api.create_new_user'), 201, 201, 201, - 201).set_method('POST').set_data_from_obj(NEW_USER_DETAILS), - - TestSpec(url_for('api.signin_user'), 200, 200, 200, - 200).set_method('POST').set_data_from_obj(SIGNIN_DETAILS), - - TestSpec(url_for('api.request_recovery_email'), 201, 201, 201, - 201).set_method('POST').set_data_from_obj(SEND_RECOVERY_DETAILS), - - TestSpec(url_for('api.get_matching_users', prefix='dev'), - 401, 200, 200, 200), - - TestSpec(url_for('api.get_matching_entities', prefix='dev'), 401, 200, 200, - 200), - - TestSpec(url_for('api.get_organization', orgname=ORG), 401, 403, 200, 200), - - TestSpec(url_for('api.get_organization_private_allowed', orgname=ORG)), - - TestSpec(url_for('api.update_organization_team', orgname=ORG, - teamname=ORG_OWNERS)).set_method('PUT'), - TestSpec(url_for('api.update_organization_team', orgname=ORG, - teamname=ORG_READERS)).set_method('PUT'), - - TestSpec(url_for('api.delete_organization_team', orgname=ORG, - teamname=ORG_OWNERS), - admin_code=400).set_method('DELETE'), - TestSpec(url_for('api.delete_organization_team', orgname=ORG, - teamname=ORG_READERS), - admin_code=204).set_method('DELETE'), - - TestSpec(url_for('api.get_organization_team_members', orgname=ORG, - teamname=ORG_OWNERS)), - TestSpec(url_for('api.get_organization_team_members', orgname=ORG, - teamname=ORG_READERS), read_code=200), - - TestSpec(url_for('api.update_organization_team_member', orgname=ORG, - teamname=ORG_OWNERS, membername=ORG_OWNER), - admin_code=400).set_method('PUT'), - TestSpec(url_for('api.update_organization_team_member', orgname=ORG, - teamname=ORG_READERS, - membername=ORG_OWNER)).set_method('PUT'), - - TestSpec(url_for('api.delete_organization_team_member', orgname=ORG, - teamname=ORG_OWNERS, membername=ORG_OWNER), - admin_code=400).set_method('DELETE'), - TestSpec(url_for('api.delete_organization_team_member', orgname=ORG, - teamname=ORG_READERS, membername=ORG_OWNER), - admin_code=400).set_method('DELETE'), - - (TestSpec(url_for('api.create_repo')) - .set_method('POST') - .set_data_from_obj(NEW_ORG_REPO_DETAILS)), - - TestSpec(url_for('api.find_repos'), 200, 200, 200, 200), - - TestSpec(url_for('api.list_repos'), 200, 200, 200, 200), - - TestSpec(url_for('api.update_repo', repository=PUBLIC_REPO), - admin_code=403).set_method('PUT'), - (TestSpec(url_for('api.update_repo', repository=ORG_REPO)) - .set_method('PUT') - .set_data_from_obj(UPDATE_REPO_DETAILS)), - (TestSpec(url_for('api.update_repo', repository=PRIVATE_REPO)) - .set_method('PUT') - .set_data_from_obj(UPDATE_REPO_DETAILS)), - - (TestSpec(url_for('api.change_repo_visibility', repository=PUBLIC_REPO), - admin_code=403).set_method('POST') - .set_data_from_obj(CHANGE_VISIBILITY_DETAILS)), - (TestSpec(url_for('api.change_repo_visibility', repository=ORG_REPO)) - .set_method('POST').set_data_from_obj(CHANGE_VISIBILITY_DETAILS)), - (TestSpec(url_for('api.change_repo_visibility', repository=PRIVATE_REPO)) - .set_method('POST').set_data_from_obj(CHANGE_VISIBILITY_DETAILS)), - - TestSpec(url_for('api.delete_repository', repository=PUBLIC_REPO), - admin_code=403).set_method('DELETE'), - TestSpec(url_for('api.delete_repository', repository=ORG_REPO), - admin_code=204).set_method('DELETE'), - TestSpec(url_for('api.delete_repository', repository=PRIVATE_REPO), - admin_code=204).set_method('DELETE'), - - TestSpec(url_for('api.get_repo', repository=PUBLIC_REPO), - 200, 200, 200,200), - TestSpec(url_for('api.get_repo', repository=ORG_REPO), - 403, 403, 200, 200), - TestSpec(url_for('api.get_repo', repository=PRIVATE_REPO), - 403, 403, 200, 200), - - TestSpec(url_for('api.get_repo_builds', repository=PUBLIC_REPO), - 200, 200, 200, 200), - TestSpec(url_for('api.get_repo_builds', repository=ORG_REPO), - 403, 403, 200, 200), - TestSpec(url_for('api.get_repo_builds', repository=PRIVATE_REPO), - 403, 403, 200, 200), - - TestSpec(url_for('api.get_filedrop_url'), 401, 200, 200, - 200).set_method('POST').set_data_from_obj(FILE_DROP_DETAILS), - - (TestSpec(url_for('api.request_repo_build', repository=PUBLIC_REPO), - admin_code=403).set_method('POST') - .set_data_from_obj(CREATE_BUILD_DETAILS)), - (TestSpec(url_for('api.request_repo_build', repository=ORG_REPO), - admin_code=201).set_method('POST') - .set_data_from_obj(CREATE_BUILD_DETAILS)), - (TestSpec(url_for('api.request_repo_build', repository=PRIVATE_REPO), - admin_code=201).set_method('POST') - .set_data_from_obj(CREATE_BUILD_DETAILS)), - - TestSpec(url_for('api.create_webhook', repository=PUBLIC_REPO), - admin_code=403).set_method('POST'), - TestSpec(url_for('api.create_webhook', - repository=ORG_REPO)).set_method('POST'), - TestSpec(url_for('api.create_webhook', - repository=PRIVATE_REPO)).set_method('POST'), - - TestSpec(url_for('api.get_webhook', repository=PUBLIC_REPO, - public_id=FAKE_WEBHOOK), admin_code=403), - TestSpec(url_for('api.get_webhook', repository=ORG_REPO, - public_id=FAKE_WEBHOOK), admin_code=404), - TestSpec(url_for('api.get_webhook', repository=PRIVATE_REPO, - public_id=FAKE_WEBHOOK), admin_code=404), - - TestSpec(url_for('api.list_webhooks', repository=PUBLIC_REPO), - admin_code=403), - TestSpec(url_for('api.list_webhooks', repository=ORG_REPO)), - TestSpec(url_for('api.list_webhooks', repository=PRIVATE_REPO)), - - TestSpec(url_for('api.delete_webhook', repository=PUBLIC_REPO, - public_id=FAKE_WEBHOOK), - admin_code=403).set_method('DELETE'), - TestSpec(url_for('api.delete_webhook', repository=ORG_REPO, - public_id=FAKE_WEBHOOK), - admin_code=400).set_method('DELETE'), - TestSpec(url_for('api.delete_webhook', repository=PRIVATE_REPO, - public_id=FAKE_WEBHOOK), - admin_code=400).set_method('DELETE'), - - TestSpec(url_for('api.list_repository_images', repository=PUBLIC_REPO), - 200, 200, 200, 200), - TestSpec(url_for('api.list_repository_images', repository=ORG_REPO), - 403, 403, 200, 200), - TestSpec(url_for('api.list_repository_images', repository=PRIVATE_REPO), - 403, 403, 200, 200), - - TestSpec(url_for('api.get_image', repository=PUBLIC_REPO, - image_id=FAKE_IMAGE_ID), 404, 404, 404, 404), - TestSpec(url_for('api.get_image', repository=ORG_REPO, - image_id=FAKE_IMAGE_ID), 403, 403, 404, 404), - TestSpec(url_for('api.get_image', repository=PRIVATE_REPO, - image_id=FAKE_IMAGE_ID), 403, 403, 404, 404), - - TestSpec(url_for('api.get_image_changes', repository=PUBLIC_REPO, - image_id=FAKE_IMAGE_ID), 404, 404, 404, 404), - TestSpec(url_for('api.get_image_changes', repository=ORG_REPO, - image_id=FAKE_IMAGE_ID), 403, 403, 404, 404), - TestSpec(url_for('api.get_image_changes', repository=PRIVATE_REPO, - image_id=FAKE_IMAGE_ID), 403, 403, 404, 404), - - TestSpec(url_for('api.list_tag_images', repository=PUBLIC_REPO, - tag=FAKE_TAG_NAME), 404, 404, 404, 404), - TestSpec(url_for('api.list_tag_images', repository=ORG_REPO, - tag=FAKE_TAG_NAME), 403, 403, 404, 404), - TestSpec(url_for('api.list_tag_images', repository=PRIVATE_REPO, - tag=FAKE_TAG_NAME), 403, 403, 404, 404), - - TestSpec(url_for('api.list_repo_team_permissions', repository=PUBLIC_REPO), - admin_code=403), - TestSpec(url_for('api.list_repo_team_permissions', repository=ORG_REPO)), - TestSpec(url_for('api.list_repo_team_permissions', - repository=PRIVATE_REPO)), - - TestSpec(url_for('api.list_repo_user_permissions', repository=PUBLIC_REPO), - admin_code=403), - TestSpec(url_for('api.list_repo_user_permissions', repository=ORG_REPO)), - TestSpec(url_for('api.list_repo_user_permissions', - repository=PRIVATE_REPO)), - - TestSpec(url_for('api.get_user_permissions', repository=PUBLIC_REPO, - username=FAKE_USERNAME), admin_code=403), - TestSpec(url_for('api.get_user_permissions', repository=ORG_REPO, - username=FAKE_USERNAME), admin_code=400), - TestSpec(url_for('api.get_user_permissions', repository=PRIVATE_REPO, - username=FAKE_USERNAME), admin_code=400), - - TestSpec(url_for('api.get_team_permissions', repository=PUBLIC_REPO, - teamname=ORG_OWNERS), admin_code=403), - TestSpec(url_for('api.get_team_permissions', repository=PUBLIC_REPO, - teamname=ORG_READERS), admin_code=403), - TestSpec(url_for('api.get_team_permissions', repository=ORG_REPO, - teamname=ORG_OWNERS), admin_code=400), - TestSpec(url_for('api.get_team_permissions', repository=ORG_REPO, - teamname=ORG_READERS)), - TestSpec(url_for('api.get_team_permissions', repository=PRIVATE_REPO, - teamname=ORG_OWNERS), admin_code=400), - TestSpec(url_for('api.get_team_permissions', repository=PRIVATE_REPO, - teamname=ORG_READERS), admin_code=400), - - TestSpec(url_for('api.change_user_permissions', repository=PUBLIC_REPO, - username=FAKE_USERNAME), - admin_code=403).set_method('PUT'), - TestSpec(url_for('api.change_user_permissions', repository=ORG_REPO, - username=FAKE_USERNAME), - admin_code=400).set_method('PUT'), - TestSpec(url_for('api.change_user_permissions', repository=PRIVATE_REPO, - username=FAKE_USERNAME), - admin_code=400).set_method('PUT'), - - (TestSpec(url_for('api.change_team_permissions', repository=PUBLIC_REPO, - teamname=ORG_OWNERS), admin_code=403) - .set_method('PUT') - .set_data_from_obj(CHANGE_PERMISSION_DETAILS)), - (TestSpec(url_for('api.change_team_permissions', repository=PUBLIC_REPO, - teamname=ORG_READERS), admin_code=403) - .set_method('PUT') - .set_data_from_obj(CHANGE_PERMISSION_DETAILS)), - (TestSpec(url_for('api.change_team_permissions', repository=ORG_REPO, - teamname=ORG_OWNERS)) - .set_method('PUT') - .set_data_from_obj(CHANGE_PERMISSION_DETAILS)), - (TestSpec(url_for('api.change_team_permissions', repository=ORG_REPO, - teamname=ORG_READERS)) - .set_method('PUT') - .set_data_from_obj(CHANGE_PERMISSION_DETAILS)), - (TestSpec(url_for('api.change_team_permissions', repository=PRIVATE_REPO, - teamname=ORG_OWNERS), admin_code=400) - .set_method('PUT') - .set_data_from_obj(CHANGE_PERMISSION_DETAILS)), - (TestSpec(url_for('api.change_team_permissions', repository=PRIVATE_REPO, - teamname=ORG_READERS), admin_code=400) - .set_method('PUT') - .set_data_from_obj(CHANGE_PERMISSION_DETAILS)), - - TestSpec(url_for('api.delete_user_permissions', repository=PUBLIC_REPO, - username=FAKE_USERNAME), - admin_code=403).set_method('DELETE'), - TestSpec(url_for('api.delete_user_permissions', repository=ORG_REPO, - username=FAKE_USERNAME), - admin_code=400).set_method('DELETE'), - TestSpec(url_for('api.delete_user_permissions', repository=PRIVATE_REPO, - username=FAKE_USERNAME), - admin_code=400).set_method('DELETE'), - - TestSpec(url_for('api.delete_team_permissions', repository=PUBLIC_REPO, - teamname=ORG_OWNERS), - admin_code=403).set_method('DELETE'), - TestSpec(url_for('api.delete_team_permissions', repository=PUBLIC_REPO, - teamname=ORG_READERS), - admin_code=403).set_method('DELETE'), - TestSpec(url_for('api.delete_team_permissions', repository=ORG_REPO, - teamname=ORG_OWNERS), - admin_code=400).set_method('DELETE'), - TestSpec(url_for('api.delete_team_permissions', repository=ORG_REPO, - teamname=ORG_READERS), - admin_code=204).set_method('DELETE'), - TestSpec(url_for('api.delete_team_permissions', repository=PRIVATE_REPO, - teamname=ORG_OWNERS), - admin_code=400).set_method('DELETE'), - TestSpec(url_for('api.delete_team_permissions', repository=PRIVATE_REPO, - teamname=ORG_READERS), - admin_code=400).set_method('DELETE'), - - TestSpec(url_for('api.list_repo_tokens', repository=PUBLIC_REPO), - admin_code=403), - TestSpec(url_for('api.list_repo_tokens', repository=ORG_REPO)), - TestSpec(url_for('api.list_repo_tokens', repository=PRIVATE_REPO)), - - TestSpec(url_for('api.get_tokens', repository=PUBLIC_REPO, - code=FAKE_TOKEN), admin_code=403), - TestSpec(url_for('api.get_tokens', repository=ORG_REPO, code=FAKE_TOKEN), - admin_code=404), - TestSpec(url_for('api.get_tokens', repository=PRIVATE_REPO, - code=FAKE_TOKEN), admin_code=404), - - TestSpec(url_for('api.create_token', repository=PUBLIC_REPO), - admin_code=403).set_method('POST'), - (TestSpec(url_for('api.create_token', repository=ORG_REPO), - admin_code=201).set_method('POST') - .set_data_from_obj(CREATE_TOKEN_DETAILS)), - (TestSpec(url_for('api.create_token', repository=PRIVATE_REPO), - admin_code=201).set_method('POST') - .set_data_from_obj(CREATE_TOKEN_DETAILS)), - - TestSpec(url_for('api.change_token', repository=PUBLIC_REPO, - code=FAKE_TOKEN), admin_code=403).set_method('PUT'), - TestSpec(url_for('api.change_token', repository=ORG_REPO, code=FAKE_TOKEN), - admin_code=400).set_method('PUT'), - TestSpec(url_for('api.change_token', repository=PRIVATE_REPO, - code=FAKE_TOKEN), admin_code=400).set_method('PUT'), - - TestSpec(url_for('api.delete_token', repository=PUBLIC_REPO, - code=FAKE_TOKEN), admin_code=403).set_method('DELETE'), - TestSpec(url_for('api.delete_token', repository=ORG_REPO, code=FAKE_TOKEN), - admin_code=400).set_method('DELETE'), - TestSpec(url_for('api.delete_token', repository=PRIVATE_REPO, - code=FAKE_TOKEN), admin_code=400).set_method('DELETE'), - - TestSpec(url_for('api.update_user_subscription'), - 401, 400, 400, 400).set_method('PUT'), - - TestSpec(url_for('api.update_org_subscription', orgname=ORG), - 401, 403, 403, 400).set_method('PUT'), - - TestSpec(url_for('api.get_user_subscription'), 401, 200, 200, 200), - - TestSpec(url_for('api.get_org_subscription', orgname=ORG)), - - TestSpec(url_for('api.list_repo_logs', repository=PUBLIC_REPO), - admin_code=403), - TestSpec(url_for('api.list_repo_logs', repository=ORG_REPO)), - TestSpec(url_for('api.list_repo_logs', repository=PRIVATE_REPO)), - - TestSpec(url_for('api.list_org_logs', orgname=ORG)), - - - TestSpec(url_for('api.get_repo_build_status', repository=PUBLIC_REPO, - build_uuid=BUILD_UUID), 400, 400, 400, 400), - TestSpec(url_for('api.get_repo_build_status', repository=ORG_REPO, - build_uuid=BUILD_UUID), 403, 403, 400, 400), - TestSpec(url_for('api.get_repo_build_status', repository=PRIVATE_REPO, - build_uuid=BUILD_UUID), 403, 403, 400, 400), - - TestSpec(url_for('api.get_repo_build_archive_url', repository=PUBLIC_REPO, - build_uuid=BUILD_UUID), 403, 403, 403, 403), - TestSpec(url_for('api.get_repo_build_archive_url', repository=ORG_REPO, - build_uuid=BUILD_UUID), 403, 403, 403, 400), - TestSpec(url_for('api.get_repo_build_archive_url', repository=PRIVATE_REPO, - build_uuid=BUILD_UUID), 403, 403, 403, 400), - - TestSpec(url_for('api.get_repo_build_logs', repository=PUBLIC_REPO, - build_uuid=BUILD_UUID), 403, 403, 403, 403), - TestSpec(url_for('api.get_repo_build_logs', repository=ORG_REPO, - build_uuid=BUILD_UUID), 403, 403, 403, 400), - TestSpec(url_for('api.get_repo_build_logs', repository=PRIVATE_REPO, - build_uuid=BUILD_UUID), 403, 403, 403, 400), - - TestSpec(url_for('api.get_build_trigger', repository=PUBLIC_REPO, - trigger_uuid=TRIGGER_UUID), admin_code=403), - TestSpec(url_for('api.get_build_trigger', repository=ORG_REPO, - trigger_uuid=TRIGGER_UUID), admin_code=404), - TestSpec(url_for('api.get_build_trigger', repository=PRIVATE_REPO, - trigger_uuid=TRIGGER_UUID), admin_code=404), - - TestSpec(url_for('api.list_build_trigger_subdirs', repository=PUBLIC_REPO, - trigger_uuid=TRIGGER_UUID), 403, 403, 403, 403), - TestSpec(url_for('api.list_build_trigger_subdirs', repository=ORG_REPO, - trigger_uuid=TRIGGER_UUID), 403, 403, 403, 404), - TestSpec(url_for('api.list_build_trigger_subdirs', repository=PRIVATE_REPO, - trigger_uuid=TRIGGER_UUID), 403, 403, 403, 404), - - TestSpec(url_for('api.activate_build_trigger', repository=PUBLIC_REPO, - trigger_uuid=TRIGGER_UUID), 403, 403, 403, 403), - TestSpec(url_for('api.activate_build_trigger', repository=ORG_REPO, - trigger_uuid=TRIGGER_UUID), 403, 403, 403, 404), - TestSpec(url_for('api.activate_build_trigger', repository=PRIVATE_REPO, - trigger_uuid=TRIGGER_UUID), 403, 403, 403, 404), - - TestSpec(url_for('api.manually_start_build_trigger', - repository=PUBLIC_REPO, trigger_uuid=TRIGGER_UUID), - 403, 403, 403, 403), - TestSpec(url_for('api.manually_start_build_trigger', - repository=ORG_REPO, trigger_uuid=TRIGGER_UUID), - 403, 403, 403, 404), - TestSpec(url_for('api.manually_start_build_trigger', - repository=PRIVATE_REPO, trigger_uuid=TRIGGER_UUID), - 403, 403, 403, 404), - - TestSpec(url_for('api.list_trigger_recent_builds', repository=PUBLIC_REPO, - trigger_uuid=TRIGGER_UUID), admin_code=403), - TestSpec(url_for('api.list_trigger_recent_builds', repository=ORG_REPO, - trigger_uuid=TRIGGER_UUID)), - TestSpec(url_for('api.list_trigger_recent_builds', repository=PRIVATE_REPO, - trigger_uuid=TRIGGER_UUID)), - - TestSpec(url_for('api.list_trigger_build_sources', repository=PUBLIC_REPO, - trigger_uuid=TRIGGER_UUID), admin_code=403), - TestSpec(url_for('api.list_trigger_build_sources', repository=ORG_REPO, - trigger_uuid=TRIGGER_UUID), admin_code=404), - TestSpec(url_for('api.list_trigger_build_sources', repository=PRIVATE_REPO, - trigger_uuid=TRIGGER_UUID), admin_code=404), - - TestSpec(url_for('api.list_build_triggers', repository=PUBLIC_REPO, - trigger_uuid=TRIGGER_UUID), admin_code=403), - TestSpec(url_for('api.list_build_triggers', repository=ORG_REPO, - trigger_uuid=TRIGGER_UUID)), - TestSpec(url_for('api.list_build_triggers', repository=PRIVATE_REPO, - trigger_uuid=TRIGGER_UUID)), - - TestSpec(url_for('api.delete_build_trigger', repository=PUBLIC_REPO, - trigger_uuid=TRIGGER_UUID), admin_code=403), - TestSpec(url_for('api.delete_build_trigger', repository=ORG_REPO, - trigger_uuid=TRIGGER_UUID), admin_code=404), - TestSpec(url_for('api.delete_build_trigger', repository=PRIVATE_REPO, - trigger_uuid=TRIGGER_UUID), admin_code=404), - ] - - class IndexTestSpec(object): def __init__(self, url, sess_repo=None, anon_code=403, no_access_code=403, read_code=200, admin_code=200): diff --git a/test/test_api_security.py b/test/test_api_security.py index 78cb7d3a7..5e0e5ab5a 100644 --- a/test/test_api_security.py +++ b/test/test_api_security.py @@ -1,20 +1,72 @@ import unittest +import json -from endpoints.api import api from app import app from initdb import setup_database_for_testing, finished_database_for_testing -from specs import build_specs +from endpoints.api import api_bp, api + +from endpoints.api.team import TeamMember, TeamMemberList, OrganizationTeam +from endpoints.api.tag import RepositoryTagImages, RepositoryTag +from endpoints.api.search import FindRepositories, EntitySearch +from endpoints.api.image import RepositoryImageChanges, RepositoryImage, RepositoryImageList +from endpoints.api.build import (FileDropResource, RepositoryBuildStatus, RepositoryBuildLogs, + RepositoryBuildList) +from endpoints.api.robot import UserRobotList, OrgRobot, OrgRobotList, UserRobot +from endpoints.api.trigger import (BuildTriggerActivate, BuildTriggerSources, BuildTriggerSubdirs, + TriggerBuildList, ActivateBuildTrigger, BuildTrigger, + BuildTriggerList) +from endpoints.api.webhook import Webhook, WebhookList +from endpoints.api.user import (PrivateRepositories, ConvertToOrganization, Recovery, Signout, + Signin, User) +from endpoints.api.repotoken import RepositoryToken, RepositoryTokenList +from endpoints.api.prototype import PermissionPrototype, PermissionPrototypeList +from endpoints.api.logs import UserLogs, OrgLogs, RepositoryLogs +from endpoints.api.billing import (UserInvoiceList, UserCard, UserPlan, ListPlans, + OrgnaizationInvoiceList, OrganizationCard, OrganizationPlan) +from endpoints.api.discovery import DiscoveryResource +from endpoints.api.organization import (OrganizationList, OrganizationMember, + OrgPrivateRepositories, OrgnaizationMemberList, + Organization) +from endpoints.api.repository import RepositoryList, RepositoryVisibility, Repository +from endpoints.api.permission import (RepositoryUserPermission, RepositoryTeamPermission, + RepositoryTeamPermissionList, RepositoryUserPermissionList) -app.register_blueprint(api, url_prefix='/api') - - -NO_ACCESS_USER = 'freshuser' -READ_ACCESS_USER = 'reader' -ADMIN_ACCESS_USER = 'devtable' +app.register_blueprint(api_bp, url_prefix='/api') class ApiTestCase(unittest.TestCase): + def _set_url(self, resource, **url_params): + with app.test_request_context(): + self.url = api.url_for(resource, **url_params) + + def _run_test(self, method, expected_status, auth_username=None, request_body=None): + with app.test_client() as client: + if auth_username: + # Temporarily remove the teardown functions + teardown_funcs = [] + if None in app.teardown_request_funcs: + teardown_funcs = app.teardown_request_funcs[None] + app.teardown_request_funcs[None] = [] + + with client.session_transaction() as sess: + sess['user_id'] = auth_username + + # Restore the teardown functions + app.teardown_request_funcs[None] = teardown_funcs + + open_kwargs = { + 'method': method + } + + open_kwargs.update({ + 'data': json.dumps(request_body), + 'content_type': 'application/json', + }) + rv = client.open(self.url, **open_kwargs) + msg = '%s %s: %s expected: %s' % (method, self.url, rv.status_code, expected_status) + self.assertEqual(rv.status_code, expected_status, msg) + def setUp(self): setup_database_for_testing(self) @@ -22,78 +74,2859 @@ class ApiTestCase(unittest.TestCase): finished_database_for_testing(self) -class _SpecTestBuilder(type): - @staticmethod - def _test_generator(url, expected_status, open_kwargs, auth_username=None): - def test(self): - with app.test_client() as c: - if auth_username: - # Temporarily remove the teardown functions - teardown_funcs = [] - if None in app.teardown_request_funcs: - teardown_funcs = app.teardown_request_funcs[None] - app.teardown_request_funcs[None] = [] +class TestFindRepositories(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(FindRepositories) - with c.session_transaction() as sess: - sess['user_id'] = auth_username - sess['identity.id'] = auth_username - sess['identity.auth_type'] = 'username' + def test_get_anonymous(self): + self._run_test('GET', 403, None, None) - # Restore the teardown functions - app.teardown_request_funcs[None] = teardown_funcs + def test_get_freshuser(self): + self._run_test('GET', 403, 'freshuser', None) - rv = c.open(url, **open_kwargs) - msg = '%s %s: %s expected: %s' % (open_kwargs['method'], url, - rv.status_code, expected_status) - self.assertEqual(rv.status_code, expected_status, msg) - return test + 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 __new__(cls, name, bases, attrs): - with app.test_request_context() as ctx: - specs = attrs['spec_func']() - for test_spec in specs: - url, open_kwargs = test_spec.get_client_args() - expected_status = getattr(test_spec, attrs['result_attr']) - test = _SpecTestBuilder._test_generator(url, expected_status, - open_kwargs, - attrs['auth_username']) +class TestUserInvoiceList(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(UserInvoiceList) - test_name_url = url.replace('/', '_').replace('-', '_') - test_name = 'test_%s_%s' % (open_kwargs['method'].lower(), - test_name_url) - attrs[test_name] = test + def test_get_anonymous(self): + self._run_test('GET', 403, None, None) - return type(name, bases, attrs) + 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) -class TestAnonymousAccess(ApiTestCase): - __metaclass__ = _SpecTestBuilder - spec_func = build_specs - result_attr = 'anon_code' - auth_username = None +class TestPrivateRepositories(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(PrivateRepositories) + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) -class TestNoAccess(ApiTestCase): - __metaclass__ = _SpecTestBuilder - spec_func = build_specs - result_attr = 'no_access_code' - auth_username = NO_ACCESS_USER +class TestConvertToOrganization(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(ConvertToOrganization) + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {u'plan': 'GRBK', u'adminUser': 'DLYU', u'adminPassword': 'MLXB'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'plan': 'GRBK', u'adminUser': 'DLYU', u'adminPassword': 'MLXB'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'plan': 'GRBK', u'adminUser': 'DLYU', u'adminPassword': 'MLXB'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'plan': 'GRBK', u'adminUser': 'DLYU', u'adminPassword': 'MLXB'}) -class TestReadAccess(ApiTestCase): - __metaclass__ = _SpecTestBuilder - spec_func = build_specs - result_attr = 'read_code' - auth_username = READ_ACCESS_USER +class TestUserRobotList(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(UserRobotList) + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) -class TestAdminAccess(ApiTestCase): - __metaclass__ = _SpecTestBuilder - spec_func = build_specs - result_attr = 'admin_code' - auth_username = ADMIN_ACCESS_USER +class TestUserCard(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(UserCard) + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'token': 'RP9X'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'token': 'RP9X'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'token': 'RP9X'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'token': 'RP9X'}) + + +class TestUserPlan(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(UserPlan) + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'plan': 'EUM0'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'plan': 'EUM0'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'plan': 'EUM0'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'plan': 'EUM0'}) + + +class TestUserLogs(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(UserLogs) + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestOrganizationList(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(OrganizationList) + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {u'name': 'F0N6', u'email': 'O08K'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'name': 'F0N6', u'email': 'O08K'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'name': 'F0N6', u'email': 'O08K'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'name': 'F0N6', u'email': 'O08K'}) + + +class TestRepositoryList(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryList) + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'visibility': u'public', u'repository': 'G8DC', u'description': '29A8'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'visibility': u'public', u'repository': 'G8DC', u'description': '29A8'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'visibility': u'public', u'repository': 'G8DC', u'description': '29A8'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'visibility': u'public', u'repository': 'G8DC', u'description': '29A8'}) + + +class TestDiscoveryResource(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(DiscoveryResource) + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestFileDropResource(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(FileDropResource) + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {u'mimeType': 'P0M8'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'mimeType': 'P0M8'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'mimeType': 'P0M8'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'mimeType': 'P0M8'}) + + +class TestRecovery(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(Recovery) + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {u'email': 'DCIO'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'email': 'DCIO'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'email': 'DCIO'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'email': 'DCIO'}) + + +class TestSignout(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(Signout) + + def test_post_anonymous(self): + self._run_test('POST', 403, 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', 201, 'devtable', None) + + +class TestSignin(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(Signin) + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {u'username': 'WQ9N', u'password': 'ZGHZ'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'username': 'WQ9N', u'password': 'ZGHZ'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'username': 'WQ9N', u'password': 'ZGHZ'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'username': 'WQ9N', u'password': 'ZGHZ'}) + + +class TestListPlans(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(ListPlans) + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestUser(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(User) + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {}) + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {u'username': 'GUAZ', u'password': 'FCSN', u'email': 'YE7T'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'username': 'GUAZ', u'password': 'FCSN', u'email': 'YE7T'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'username': 'GUAZ', u'password': 'FCSN', u'email': 'YE7T'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'username': 'GUAZ', u'password': 'FCSN', u'email': 'YE7T'}) + + +class TestTeamMemberBuynlargeDevtableReaders(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(TeamMember, orgname="buynlarge", membername="devtable", teamname="readers") + + def test_put_anonymous(self): + self._run_test('PUT', 403, None, None) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', None) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', None) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', None) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestTeamMemberBuynlargeDevtableOwners(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(TeamMember, orgname="buynlarge", membername="devtable", teamname="owners") + + def test_put_anonymous(self): + self._run_test('PUT', 403, None, None) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', None) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', None) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', None) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestTeamMemberListBuynlargeReaders(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(TeamMemberList, orgname="buynlarge", teamname="readers") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestTeamMemberListBuynlargeOwners(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(TeamMemberList, orgname="buynlarge", teamname="owners") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryUserPermissionNscdPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryUserPermission, username="NSCD", repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'role': u'read'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'read'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'read'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'read'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryUserPermissionNscdDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryUserPermission, username="NSCD", repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'role': u'read'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'read'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'read'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'read'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryUserPermissionNscdBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryUserPermission, username="NSCD", repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'role': u'read'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'read'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'read'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'read'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryTeamPermissionReadersPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTeamPermission, teamname="readers", repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'role': u'read'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'read'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'read'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'read'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryTeamPermissionReadersDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTeamPermission, teamname="readers", repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'role': u'read'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'read'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'read'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'read'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryTeamPermissionReadersBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTeamPermission, teamname="readers", repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'role': u'read'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'read'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'read'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'read'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryTeamPermissionOwnersPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTeamPermission, teamname="owners", repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'role': u'read'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'read'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'read'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'read'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryTeamPermissionOwnersDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTeamPermission, teamname="owners", repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'role': u'read'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'read'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'read'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'read'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryTeamPermissionOwnersBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTeamPermission, teamname="owners", repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'role': u'read'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'read'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'read'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'read'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestBuildTriggerActivateV5p0PublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTriggerActivate, trigger_uuid="V5P0", repository="public/publicrepo") + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {}) + + +class TestBuildTriggerActivateV5p0DevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTriggerActivate, trigger_uuid="V5P0", repository="devtable/shared") + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {}) + + +class TestBuildTriggerActivateV5p0BuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTriggerActivate, trigger_uuid="V5P0", repository="buynlarge/orgrepo") + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {}) + + +class TestBuildTriggerSourcesPnofPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTriggerSources, trigger_uuid="PNOF", repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestBuildTriggerSourcesPnofDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTriggerSources, trigger_uuid="PNOF", repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestBuildTriggerSourcesPnofBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTriggerSources, trigger_uuid="PNOF", repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestBuildTriggerSubdirsDabwPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTriggerSubdirs, trigger_uuid="DABW", repository="public/publicrepo") + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {}) + + +class TestBuildTriggerSubdirsDabwDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTriggerSubdirs, trigger_uuid="DABW", repository="devtable/shared") + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {}) + + +class TestBuildTriggerSubdirsDabwBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTriggerSubdirs, trigger_uuid="DABW", repository="buynlarge/orgrepo") + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {}) + + +class TestTriggerBuildListTamcPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(TriggerBuildList, trigger_uuid="TAMC", repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestTriggerBuildListTamcDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(TriggerBuildList, trigger_uuid="TAMC", repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestTriggerBuildListTamcBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(TriggerBuildList, trigger_uuid="TAMC", repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestActivateBuildTriggerD4egPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(ActivateBuildTrigger, trigger_uuid="D4EG", repository="public/publicrepo") + + def test_post_anonymous(self): + self._run_test('POST', 403, 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', 201, 'devtable', None) + + +class TestActivateBuildTriggerD4egDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(ActivateBuildTrigger, trigger_uuid="D4EG", repository="devtable/shared") + + def test_post_anonymous(self): + self._run_test('POST', 403, 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', 201, 'devtable', None) + + +class TestActivateBuildTriggerD4egBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(ActivateBuildTrigger, trigger_uuid="D4EG", repository="buynlarge/orgrepo") + + def test_post_anonymous(self): + self._run_test('POST', 403, 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', 201, 'devtable', None) + + +class TestRepositoryImageChangesNsgqPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryImageChanges, image_id="NSGQ", repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryImageChangesNsgqDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryImageChanges, image_id="NSGQ", repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryImageChangesNsgqBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryImageChanges, image_id="NSGQ", repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryBuildStatusMtmsPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryBuildStatus, build_uuid="MTMS", repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryBuildStatusMtmsDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryBuildStatus, build_uuid="MTMS", repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryBuildStatusMtmsBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryBuildStatus, build_uuid="MTMS", repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryBuildLogsBzmkPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryBuildLogs, build_uuid="BZMK", repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryBuildLogsBzmkDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryBuildLogs, build_uuid="BZMK", repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryBuildLogsBzmkBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryBuildLogs, build_uuid="BZMK", repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryTagImagesSrlmPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTagImages, tag="SRLM", repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryTagImagesSrlmDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTagImages, tag="SRLM", repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryTagImagesSrlmBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTagImages, tag="SRLM", repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestPermissionPrototypeBuynlarge505l(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(PermissionPrototype, orgname="buynlarge", prototypeid="505L") + + def test_put_anonymous(self): + self._run_test('PUT', 403, None, {u'role': u'read'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'read'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'read'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'read'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestOrganizationMemberBuynlargeDevtable(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(OrganizationMember, orgname="buynlarge", membername="devtable") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestOrgRobotBuynlargeN7i6(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(OrgRobot, orgname="buynlarge", robot_shortname="N7I6") + + def test_put_anonymous(self): + self._run_test('PUT', 403, None, None) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', None) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', None) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', None) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestOrganizationTeamBuynlargeReaders(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(OrganizationTeam, orgname="buynlarge", teamname="readers") + + def test_put_anonymous(self): + self._run_test('PUT', 403, None, {u'role': u'member'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'member'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'member'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'member'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestOrganizationTeamBuynlargeOwners(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(OrganizationTeam, orgname="buynlarge", teamname="owners") + + def test_put_anonymous(self): + self._run_test('PUT', 403, None, {u'role': u'member'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'member'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'member'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'member'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryTeamPermissionListPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTeamPermissionList, repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryTeamPermissionListDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTeamPermissionList, repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryTeamPermissionListBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTeamPermissionList, repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryUserPermissionListPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryUserPermissionList, repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryUserPermissionListDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryUserPermissionList, repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryUserPermissionListBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryUserPermissionList, repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestBuildTriggerTuc0PublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTrigger, trigger_uuid="TUC0", repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestBuildTriggerTuc0DevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTrigger, trigger_uuid="TUC0", repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestBuildTriggerTuc0BuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTrigger, trigger_uuid="TUC0", repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestWebhookTmavPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(Webhook, public_id="TMAV", repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestWebhookTmavDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(Webhook, public_id="TMAV", repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestWebhookTmavBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(Webhook, public_id="TMAV", repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryTokenWfo9PublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryToken, code="WFO9", repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'role': u'read'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'read'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'read'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'read'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryTokenWfo9DevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryToken, code="WFO9", repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'role': u'read'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'read'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'read'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'read'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryTokenWfo9BuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryToken, code="WFO9", repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'role': u'read'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'role': u'read'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'role': u'read'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'role': u'read'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryImageC5nsPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryImage, image_id="C5NS", repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryImageC5nsDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryImage, image_id="C5NS", repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryImageC5nsBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryImage, image_id="C5NS", repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryTag4rpuPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTag, tag="4RPU", repository="public/publicrepo") + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryTag4rpuDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTag, tag="4RPU", repository="devtable/shared") + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryTag4rpuBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTag, tag="4RPU", repository="buynlarge/orgrepo") + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestPermissionPrototypeListBuynlarge(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(PermissionPrototypeList, orgname="buynlarge") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'role': u'read', u'delegate': {u'kind': u'user', u'name': 'F0UT'}}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'role': u'read', u'delegate': {u'kind': u'user', u'name': 'F0UT'}}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'role': u'read', u'delegate': {u'kind': u'user', u'name': 'F0UT'}}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'role': u'read', u'delegate': {u'kind': u'user', u'name': 'F0UT'}}) + + +class TestOrgnaizationInvoiceListBuynlarge(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(OrgnaizationInvoiceList, orgname="buynlarge") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestOrgPrivateRepositoriesBuynlarge(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(OrgPrivateRepositories, orgname="buynlarge") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestOrgnaizationMemberListBuynlarge(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(OrgnaizationMemberList, orgname="buynlarge") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestOrgRobotListBuynlarge(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(OrgRobotList, orgname="buynlarge") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestOrganizationCardBuynlarge(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(OrganizationCard, orgname="buynlarge") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'token': '7WAU'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'token': '7WAU'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'token': '7WAU'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'token': '7WAU'}) + + +class TestOrganizationPlanBuynlarge(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(OrganizationPlan, orgname="buynlarge") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'plan': 'AFBR'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'plan': 'AFBR'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'plan': 'AFBR'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'plan': 'AFBR'}) + + +class TestOrgLogsBuynlarge(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(OrgLogs, orgname="buynlarge") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryVisibilityPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryVisibility, repository="public/publicrepo") + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {u'visibility': u'public'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'visibility': u'public'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'visibility': u'public'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'visibility': u'public'}) + + +class TestRepositoryVisibilityDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryVisibility, repository="devtable/shared") + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {u'visibility': u'public'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'visibility': u'public'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'visibility': u'public'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'visibility': u'public'}) + + +class TestRepositoryVisibilityBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryVisibility, repository="buynlarge/orgrepo") + + def test_post_anonymous(self): + self._run_test('POST', 403, None, {u'visibility': u'public'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'visibility': u'public'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'visibility': u'public'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'visibility': u'public'}) + + +class TestBuildTriggerListPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTriggerList, repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestBuildTriggerListDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTriggerList, repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestBuildTriggerListBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(BuildTriggerList, repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestWebhookListPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(WebhookList, repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {}) + + +class TestWebhookListDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(WebhookList, repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {}) + + +class TestWebhookListBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(WebhookList, repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {}) + + +class TestRepositoryTokenListPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTokenList, repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'friendlyName': '9PHL'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'friendlyName': '9PHL'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'friendlyName': '9PHL'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'friendlyName': '9PHL'}) + + +class TestRepositoryTokenListDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTokenList, repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'friendlyName': '9PHL'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'friendlyName': '9PHL'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'friendlyName': '9PHL'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'friendlyName': '9PHL'}) + + +class TestRepositoryTokenListBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryTokenList, repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'friendlyName': '9PHL'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'friendlyName': '9PHL'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'friendlyName': '9PHL'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'friendlyName': '9PHL'}) + + +class TestRepositoryBuildListPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryBuildList, repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'file_id': 'N8X4'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'file_id': 'N8X4'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'file_id': 'N8X4'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'file_id': 'N8X4'}) + + +class TestRepositoryBuildListDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryBuildList, repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'file_id': 'N8X4'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'file_id': 'N8X4'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'file_id': 'N8X4'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'file_id': 'N8X4'}) + + +class TestRepositoryBuildListBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryBuildList, repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'file_id': 'N8X4'}) + + def test_post_freshuser(self): + self._run_test('POST', 403, 'freshuser', {u'file_id': 'N8X4'}) + + def test_post_reader(self): + self._run_test('POST', 403, 'reader', {u'file_id': 'N8X4'}) + + def test_post_devtable(self): + self._run_test('POST', 201, 'devtable', {u'file_id': 'N8X4'}) + + +class TestRepositoryImageListPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryImageList, repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryImageListDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryImageList, repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryImageListBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryImageList, repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryLogsPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryLogs, repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryLogsDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryLogs, repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestRepositoryLogsBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(RepositoryLogs, repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) + + +class TestUserRobot1q88(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(UserRobot, robot_shortname="1Q88") + + def test_put_anonymous(self): + self._run_test('PUT', 403, None, None) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', None) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', None) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', None) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestOrganizationBuynlarge(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(Organization, orgname="buynlarge") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {}) + + +class TestRepositoryPublicPublicrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(Repository, repository="public/publicrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'description': 'IEUG'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'description': 'IEUG'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'description': 'IEUG'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'description': 'IEUG'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryDevtableShared(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(Repository, repository="devtable/shared") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'description': 'IEUG'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'description': 'IEUG'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'description': 'IEUG'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'description': 'IEUG'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestRepositoryBuynlargeOrgrepo(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(Repository, repository="buynlarge/orgrepo") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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', 403, None, {u'description': 'IEUG'}) + + def test_put_freshuser(self): + self._run_test('PUT', 403, 'freshuser', {u'description': 'IEUG'}) + + def test_put_reader(self): + self._run_test('PUT', 403, 'reader', {u'description': 'IEUG'}) + + def test_put_devtable(self): + self._run_test('PUT', 200, 'devtable', {u'description': 'IEUG'}) + + def test_delete_anonymous(self): + self._run_test('DELETE', 403, 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', 400, 'devtable', None) + + +class TestEntitySearchKqhn(ApiTestCase): + def setUp(self): + ApiTestCase.setUp(self) + self._set_url(EntitySearch, prefix="KQHN") + + def test_get_anonymous(self): + self._run_test('GET', 403, 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) -if __name__ == '__main__': - unittest.main()