Ejemplo n.º 1
0
    def test_failure(self, mocker):
        get_mock = mocker.patch.object(utils, "get")
        get_mock.side_effect = errors.Error("Bad error")
        set_module_args(name="sample-secrets-provider")

        with pytest.raises(AnsibleFailJson):
            secrets_provider_info.main()
Ejemplo n.º 2
0
    def test_missing_single_secrets_provider(self, mocker):
        get_mock = mocker.patch.object(utils, "get")
        get_mock.return_value = None
        set_module_args(name="sample-secrets-provider")

        with pytest.raises(AnsibleExitJson) as context:
            secrets_provider_info.main()

        assert context.value.args[0]["objects"] == []
Ejemplo n.º 3
0
    def test_get_single_secrets_provider(self, mocker):
        get_mock = mocker.patch.object(utils, "get")
        get_mock.return_value = dict(spec=4)
        set_module_args(name="sample-secrets-provider")

        with pytest.raises(AnsibleExitJson) as context:
            secrets_provider_info.main()

        _client, path = get_mock.call_args[0]
        assert path == "/api/enterprise/secrets/v1/providers/sample-secrets-provider"
        assert context.value.args[0]["objects"] == [4]
Ejemplo n.º 4
0
    def test_get_all_secrets_providers(self, mocker):
        get_mock = mocker.patch.object(utils, "get")
        get_mock.return_value = [dict(spec=1), dict(spec=2)]
        set_module_args()

        with pytest.raises(AnsibleExitJson) as context:
            secrets_provider_info.main()

        _client, path = get_mock.call_args[0]
        assert path == "/api/enterprise/secrets/v1/providers"
        assert context.value.args[0]["objects"] == [1, 2]