File: test_token.py

package info (click to toggle)
python-hvac 2.3.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,800 kB
  • sloc: python: 29,360; makefile: 42; sh: 14
file content (48 lines) | stat: -rw-r--r-- 1,709 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import pytest

from hvac.api.auth_methods.token import Token


@pytest.fixture
def token_auth(mock_adapter):
    return Token(mock_adapter)


class TestToken:
    @pytest.mark.parametrize("allowed_policies", ["allowed_policies", None])
    @pytest.mark.parametrize("disallowed_policies", ["disallowed_policies", None])
    @pytest.mark.parametrize("orphan", ["orphan", None])
    @pytest.mark.parametrize("renewable", ["renewable", None])
    @pytest.mark.parametrize("path_suffix", ["path_suffix", None])
    @pytest.mark.parametrize("allowed_entity_aliases", ["allowed_entity_aliases", None])
    @pytest.mark.parametrize("token_period", ["token_period", None])
    @pytest.mark.parametrize("token_explicit_max_ttl", ["token_explicit_max_ttl", None])
    def test_create_or_update_role_optional_parameters(
        self,
        token_auth,
        allowed_policies,
        disallowed_policies,
        orphan,
        renewable,
        path_suffix,
        allowed_entity_aliases,
        token_period,
        token_explicit_max_ttl,
    ):
        params = {
            "allowed_policies": allowed_policies,
            "disallowed_policies": disallowed_policies,
            "orphan": orphan,
            "renewable": renewable,
            "path_suffix": path_suffix,
            "allowed_entity_aliases": allowed_entity_aliases,
            "token_period": token_period,
            "token_explicit_max_ttl": token_explicit_max_ttl,
        }
        expected = params.copy()

        _, rkwargs = token_auth.create_or_update_role("role_name", **params)

        assert "json" in rkwargs
        for key, value in expected.items():
            assert value is None or rkwargs["json"][key] == value