MCPcopy Index your code
hub / github.com/saltstack/salt / test_runner_token_authorization_error

Function test_runner_token_authorization_error

tests/pytests/unit/test_master.py:577–599  ·  view source on GitHub ↗

Asserts that a TokenAuthenticationError is returned when the token authenticates, but is not authorized.

(clear_funcs)

Source from the content-addressed store, hash-verified

575
576@pytest.mark.slow_test
577def test_runner_token_authorization_error(clear_funcs):
578 """
579 Asserts that a TokenAuthenticationError is returned when the token authenticates, but is
580 not authorized.
581 """
582 token = "asdfasdfasdfasdf"
583 clear_load = {"token": token, "fun": "test.arg"}
584 mock_token = {"token": token, "eauth": "foo", "name": "test"}
585 mock_ret = {
586 "error": {
587 "name": "TokenAuthenticationError",
588 "message": (
589 'Authentication failure of type "token" occurred for user test.'
590 ),
591 }
592 }
593
594 with patch(
595 "salt.auth.LoadAuth.authenticate_token", MagicMock(return_value=mock_token)
596 ), patch("salt.auth.LoadAuth.get_auth_list", MagicMock(return_value=[])):
597 ret = clear_funcs.runner(clear_load)
598
599 assert ret == mock_ret
600
601
602@pytest.mark.slow_test

Callers

nothing calls this directly

Calls 2

patchFunction · 0.50
runnerMethod · 0.45

Tested by

no test coverage detected