def test_gs_config_bad(self): auth_testing.mock_is_admin(self, True) with self.call_should_fail(400): self.call_api('gs_config', { 'cas_gs_path': 'bucket/gs_path', 'cas_gs_temp': '/bucket/gs_temp/' })
def test_has_role_admin(self): auth_testing.mock_is_admin(self, False) self.assertFalse( acl.has_role('package', 'OWNER', auth_testing.DEFAULT_MOCKED_IDENTITY)) auth_testing.mock_is_admin(self, True) self.assertTrue( acl.has_role('package', 'OWNER', auth_testing.DEFAULT_MOCKED_IDENTITY))
def setUp(self): super(FrontendHandlersTest, self).setUp() self.mock(replication, 'trigger_replication', lambda *_args, **_kws: None) self.app = webtest.TestApp( handlers_frontend.create_application(debug=True), extra_environ={'REMOTE_ADDR': '127.0.0.1'}) auth_testing.mock_is_admin(self, True) auth_testing.mock_get_current_identity(self)
def setUp(self): super(CASServiceApiTest, self).setUp() auth_testing.mock_get_current_identity(self) auth_testing.mock_is_admin(self) self.cas_service = common.MockedCASService() def mocked_get_cas_service(): return self.cas_service self.mock(impl, 'get_cas_service', mocked_get_cas_service)
def test_gs_config_ok(self): auth_testing.mock_is_admin(self, True) self.call_api('gs_config', GS_CONFIG) conf = config.GlobalConfig.fetch() # Strips '/'. self.assertEqual(conf.cas_gs_path, '/bucket/gs_path') self.assertEqual(conf.cas_gs_temp, '/bucket/gs_temp') # Second call with same data doesn't change version. version = conf.key.id() self.call_api('gs_config', GS_CONFIG) self.assertEqual(config.GlobalConfig.fetch().key.id(), version)
def test_service_account(self): auth_testing.mock_is_admin(self, True) self.call_api('service_account', SERVICE_ACCOUNT_INFO) conf = config.GlobalConfig.fetch() self.assertEqual(conf.service_account_email, '*****@*****.**') self.assertEqual(conf.service_account_pkey, 'private_key') self.assertEqual(conf.service_account_pkey_id, 'private_key_id') # Second call with same data doesn't change version. version = conf.key.id() self.call_api('service_account', SERVICE_ACCOUNT_INFO) self.assertEqual(config.GlobalConfig.fetch().key.id(), version)
def test_instance_admin(self): auth_testing.mock_is_admin(self, True) self.assertFalse(acl.is_ip_whitelisted_machine()) self.assertTrue(acl.can_access()) self.assertTrue(acl.can_view_config()) self.assertTrue(acl.can_edit_config()) self.assertTrue(acl.can_create_bot()) self.assertTrue(acl.can_edit_bot()) self.assertTrue(acl.can_delete_bot()) self.assertTrue(acl.can_view_bot()) self.assertTrue(acl.can_create_task()) self.assertTrue(acl.can_schedule_high_priority_tasks()) self.assertTrue(acl.can_edit_task(self._task_owned)) self.assertTrue(acl.can_edit_task(self._task_other)) self.assertTrue(acl.can_edit_all_tasks()) self.assertTrue(acl.can_view_task(self._task_owned)) self.assertTrue(acl.can_view_task(self._task_other)) self.assertTrue(acl.can_view_all_tasks())
def setUp(self): super(ImporterTest, self).setUp() auth_testing.mock_is_admin(self, True) auth_testing.mock_get_current_identity(self)
def test_require_auth(self): auth_testing.mock_is_admin(self, False) with self.call_should_fail(403): self.call_api('service_account', SERVICE_ACCOUNT_INFO) with self.call_should_fail(403): self.call_api('gs_config', GS_CONFIG)
def setUp(self): super(PackageRepositoryApiTest, self).setUp() auth_testing.mock_get_current_identity(self) auth_testing.mock_is_admin(self) self.repo_service = MockedRepoService() self.mock(impl, 'get_repo_service', lambda: self.repo_service)
def mock_admin(self): auth_testing.mock_is_admin(self, True) auth_testing.mock_get_current_identity(self)
def setUp(self): super(PackageRepositoryApiTest, self).setUp() auth_testing.mock_get_current_identity(self) auth_testing.mock_is_admin(self) self.repo_service = MockedRepoService() self.mock(impl, "get_repo_service", lambda: self.repo_service)