MCPcopy
hub / github.com/saltstack/salt / test_wheel_token_authorization_error

Function test_wheel_token_authorization_error

tests/pytests/unit/test_master.py:721–742  ·  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

719
720@pytest.mark.slow_test
721def test_wheel_token_authorization_error(clear_funcs):
722 """
723 Asserts that a TokenAuthenticationError is returned when the token authenticates, but is
724 not authorized.
725 """
726 token = "asdfasdfasdfasdf"
727 clear_load = {"token": token, "fun": "test.arg"}
728 mock_token = {"token": token, "eauth": "foo", "name": "test"}
729 mock_ret = {
730 "error": {
731 "name": "TokenAuthenticationError",
732 "message": (
733 'Authentication failure of type "token" occurred for user test.'
734 ),
735 }
736 }
737
738 with patch(
739 "salt.auth.LoadAuth.authenticate_token", MagicMock(return_value=mock_token)
740 ), patch("salt.auth.LoadAuth.get_auth_list", MagicMock(return_value=[])):
741 ret = clear_funcs.wheel(clear_load)
742 assert ret == mock_ret
743
744
745@pytest.mark.slow_test

Callers

nothing calls this directly

Calls 2

patchFunction · 0.50
wheelMethod · 0.45

Tested by

no test coverage detected