Asserts that a TokenAuthenticationError is returned when the token authenticates, but is not authorized.
(clear_funcs)
| 719 | |
| 720 | @pytest.mark.slow_test |
| 721 | def 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 |