Exemple #1
0
    def test_get_redacted_args_invocation(self, args, kwargs):
        class Service(object):
            name = "service"

            @rpc(sensitive_variables="a")
            def method(self, a, b=None):
                pass

        expected = {'a': REDACTED, 'b': 'B'}

        container = ServiceContainer(Service, {})
        entrypoint = get_extension(container, Rpc)

        redacted = get_redacted_args(entrypoint, *args, **kwargs)
        assert redacted == expected
Exemple #2
0
    def test_get_redacted_args_invocation(self, args, kwargs, rabbit_config):

        class Service(object):
            name = "service"

            @rpc(sensitive_arguments="a")
            def method(self, a, b=None):
                pass  # pragma: no cover

        expected = {'a': REDACTED, 'b': 'B'}

        container = ServiceContainer(Service, rabbit_config)
        entrypoint = get_extension(container, Rpc)

        redacted = get_redacted_args(entrypoint, *args, **kwargs)
        assert redacted == expected
Exemple #3
0
    def test_get_redacted_args_invocation(self, args, kwargs, rabbit_config):

        class Service(object):
            name = "service"

            @rpc(sensitive_arguments="a")
            def method(self, a, b=None):
                pass  # pragma: no cover

        expected = {'a': REDACTED, 'b': 'B'}

        container = ServiceContainer(Service, rabbit_config)
        entrypoint = get_extension(container, Rpc)

        redacted = get_redacted_args(entrypoint, *args, **kwargs)
        assert redacted == expected
Exemple #4
0
    def test_get_redacted_args_invocation(self, args, kwargs):

        class Service(object):
            name = "service"

            @rpc(sensitive_variables="a")
            def method(self, a, b=None):
                pass

        expected = {'a': REDACTED, 'b': 'B'}

        container = ServiceContainer(Service, {})
        entrypoint = get_extension(container, Rpc)

        redacted = get_redacted_args(entrypoint, *args, **kwargs)
        assert redacted == expected
Exemple #5
0
    def test_get_redacted_args(self, sensitive_variables, expected):
        class Service(object):
            name = "service"

            @rpc(sensitive_variables=sensitive_variables)
            def method(self, a, b):
                pass

        args = ("A", "B")
        kwargs = {}

        container = ServiceContainer(Service, {})
        entrypoint = get_extension(container, Rpc)

        redacted = get_redacted_args(entrypoint, *args, **kwargs)
        assert redacted == expected
Exemple #6
0
    def test_get_redacted_args(self, sensitive_variables, expected):

        class Service(object):
            name = "service"

            @rpc(sensitive_variables=sensitive_variables)
            def method(self, a, b):
                pass

        args = ("A", "B")
        kwargs = {}

        container = ServiceContainer(Service, {})
        entrypoint = get_extension(container, Rpc)

        redacted = get_redacted_args(entrypoint, *args, **kwargs)
        assert redacted == expected
Exemple #7
0
    def test_get_redacted_args_partial(self, sensitive_variables, expected):
        class Service(object):
            name = "service"

            @rpc(sensitive_variables=sensitive_variables)
            def method(self, a, b):
                pass

        complex_arg = {'foo': [1, 2, 3], 'bar': "BAR"}

        args = ("A", complex_arg)
        kwargs = {}

        container = ServiceContainer(Service, {})
        entrypoint = get_extension(container, Rpc)

        redacted = get_redacted_args(entrypoint, *args, **kwargs)
        assert redacted == expected
Exemple #8
0
    def test_get_redacted_args(
        self, sensitive_arguments, expected, rabbit_config
    ):

        class Service(object):
            name = "service"

            @rpc(sensitive_arguments=sensitive_arguments)
            def method(self, a, b):
                pass  # pragma: no cover

        args = ("A", "B")
        kwargs = {}

        container = ServiceContainer(Service, rabbit_config)
        entrypoint = get_extension(container, Rpc)

        redacted = get_redacted_args(entrypoint, *args, **kwargs)
        assert redacted == expected
Exemple #9
0
    def test_get_redacted_args(
        self, sensitive_arguments, expected, rabbit_config
    ):

        class Service(object):
            name = "service"

            @rpc(sensitive_arguments=sensitive_arguments)
            def method(self, a, b):
                pass  # pragma: no cover

        args = ("A", "B")
        kwargs = {}

        container = ServiceContainer(Service, rabbit_config)
        entrypoint = get_extension(container, Rpc)

        redacted = get_redacted_args(entrypoint, *args, **kwargs)
        assert redacted == expected
Exemple #10
0
    def get_call_args(self, worker_ctx):
        """ Return serialisable call arguments
        """

        entrypoint = worker_ctx.entrypoint

        if getattr(entrypoint, 'sensitive_variables', None):
            call_args = get_redacted_args(entrypoint, *worker_ctx.args,
                                          **worker_ctx.kwargs)
            redacted = True
        else:
            method = getattr(entrypoint.container.service_cls,
                             entrypoint.method_name)
            call_args = inspect.getcallargs(method, None, *worker_ctx.args,
                                            **worker_ctx.kwargs)
            del call_args['self']
            redacted = False

        return call_args, redacted
Exemple #11
0
    def test_get_redacted_args_partial(self, sensitive_variables, expected):

        class Service(object):
            name = "service"

            @rpc(sensitive_variables=sensitive_variables)
            def method(self, a, b):
                pass

        complex_arg = {
            'foo': [1, 2, 3],
            'bar': "BAR"
        }

        args = ("A", complex_arg)
        kwargs = {}

        container = ServiceContainer(Service, {})
        entrypoint = get_extension(container, Rpc)

        redacted = get_redacted_args(entrypoint, *args, **kwargs)
        assert redacted == expected
Exemple #12
0
    def test_get_redacted_args_partial(
        self, sensitive_arguments, expected, rabbit_config
    ):

        class Service(object):
            name = "service"

            @rpc(sensitive_arguments=sensitive_arguments)
            def method(self, a, b):
                pass  # pragma: no cover

        complex_arg = {
            'foo': [1, 2, 3],
            'bar': "BAR"
        }

        args = ("A", complex_arg)
        kwargs = {}

        container = ServiceContainer(Service, rabbit_config)
        entrypoint = get_extension(container, Rpc)

        redacted = get_redacted_args(entrypoint, *args, **kwargs)
        assert redacted == expected
Exemple #13
0
    def test_get_redacted_args_partial(
        self, sensitive_arguments, expected, rabbit_config
    ):

        class Service(object):
            name = "service"

            @rpc(sensitive_arguments=sensitive_arguments)
            def method(self, a, b):
                pass  # pragma: no cover

        complex_arg = {
            'foo': [1, 2, 3],
            'bar': "BAR"
        }

        args = ("A", complex_arg)
        kwargs = {}

        container = ServiceContainer(Service, rabbit_config)
        entrypoint = get_extension(container, Rpc)

        redacted = get_redacted_args(entrypoint, *args, **kwargs)
        assert redacted == expected
Exemple #14
0
            def worker_setup(self, worker_ctx):
                entrypoint = worker_ctx.entrypoint
                args = worker_ctx.args
                kwargs = worker_ctx.kwargs

                redacted.update(get_redacted_args(entrypoint, *args, **kwargs))
    def worker_setup(self, worker_ctx):
        entrypoint = worker_ctx.entrypoint
        args = worker_ctx.args
        kwargs = worker_ctx.kwargs

        redacted.update(get_redacted_args(entrypoint, *args, **kwargs))