MCPcopy Index your code
hub / github.com/bugy/script-server / ExecutionServiceAuthorizationTest

Class ExecutionServiceAuthorizationTest

src/tests/execution_service_test.py:307–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305
306
307class ExecutionServiceAuthorizationTest(unittest.TestCase):
308 owner_user = User('user_x', {audit_utils.AUTH_USERNAME: 'some_name'})
309
310 @parameterized.expand([
311 (owner_user.user_id, None),
312 ('another_user', AccessProhibitedException),
313 ('admin_user', AccessProhibitedException),
314 ('history_user', AccessProhibitedException)
315 ])
316 def test_get_active_executor(self, user_id, expected_exception):
317 self._assert_throws_exception(expected_exception,
318 self.executor_service.get_active_executor,
319 self.execution_id,
320 User(user_id, {}))
321
322 @parameterized.expand([
323 (owner_user.user_id, None),
324 ('another_user', AccessProhibitedException),
325 ('admin_user', AccessProhibitedException),
326 ('history_user', AccessProhibitedException)
327 ])
328 def test_stop_script(self, user_id, expected_exception):
329 self._assert_throws_exception(expected_exception,
330 self.executor_service.stop_script,
331 self.execution_id,
332 User(user_id, {}),
333 has_results=False)
334
335 @parameterized.expand([
336 (owner_user.user_id, None),
337 ('another_user', AccessProhibitedException),
338 ('admin_user', AccessProhibitedException),
339 ('history_user', AccessProhibitedException)
340 ])
341 def test_kill_script(self, user_id, expected_exception):
342 self._assert_throws_exception(expected_exception,
343 self.executor_service.kill_script,
344 self.execution_id,
345 User(user_id, {}),
346 has_results=False)
347
348 @parameterized.expand([
349 (owner_user.user_id, None),
350 ('another_user', AccessProhibitedException),
351 ('admin_user', None),
352 ('history_user', None)
353 ])
354 def test_is_running(self, user_id, expected_exception):
355 self._assert_throws_exception(expected_exception,
356 self.executor_service.is_running,
357 self.execution_id,
358 User(user_id, {}))
359
360 @parameterized.expand([
361 (owner_user.user_id, None),
362 ('another_user', AccessProhibitedException),
363 ('admin_user', AccessProhibitedException),
364 ('history_user', AccessProhibitedException)

Callers

nothing calls this directly

Calls 1

UserClass · 0.90

Tested by

no test coverage detected