forked from demisto/content
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtools.py
More file actions
26 lines (21 loc) · 1.17 KB
/
tools.py
File metadata and controls
26 lines (21 loc) · 1.17 KB
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
from functools import wraps
from typing import Callable
from demisto_sdk.commands.test_content.mock_server import MITMProxy
def run_with_proxy_configured(function: Callable) -> Callable:
"""
This is a decorator for the 'instance_testing method`.
This decorator configures the proxy in the server before the instance_testing execution and removes it afterwards.
Args:
function: Should be the instance_testing method.
"""
@wraps(function)
def decorated(build, *args, **kwargs):
build.proxy.configure_proxy_in_demisto(proxy=build.servers[0].internal_ip + ':' + MITMProxy.PROXY_PORT,
username=build.username, password=build.password,
server=f'https://localhost:{build.servers[0].ssh_tunnel_port}')
result = function(build, *args, **kwargs)
build.proxy.configure_proxy_in_demisto(proxy='',
username=build.username, password=build.password,
server=f'https://localhost:{build.servers[0].ssh_tunnel_port}')
return result
return decorated