def test_http_metrics_client_post_proxies(post, config_file_factory, rhsm_config_file_factory): config_file = config_file_factory("") rhsm_config_file = rhsm_config_file_factory() metrics_client = MetricsHTTPClient(config_file=config_file.name, rhsm_config_file=rhsm_config_file.name) metrics_client.base_url = "localhost" proxies = {"https": "http://*****:*****@localhost:3128"} metrics_client.proxies = proxies metrics_client.post({}) post.assert_called_once_with(ANY, json=ANY, proxies=proxies)
def test_metrics_post_event_no_proxy(post, config_file_factory, rhsm_config_file_factory): config_file = config_file_factory("") rhsm_config_file = rhsm_config_file_factory() metrics_client = MetricsHTTPClient(config_file=config_file.name, rhsm_config_file=rhsm_config_file.name) event = Mock() metrics_client.post(event) post.assert_called_once_with( "https://cert-api.access.redhat.com:443/redhat_access/r/insights/platform/module-update-router/v1/event", json=event, proxies=None, )
def test_offline_no_post(session_post, config_file_factory, rhsm_config_file_factory): ''' Verify that when the metrics client is set to offline, no POSTs are performed ''' config_file = config_file_factory("") rhsm_config_file = rhsm_config_file_factory() m = MetricsHTTPClient(config_file=config_file.name, rhsm_config_file=rhsm_config_file.name) m.offline = True m.post("test") session_post.assert_not_called()
def test_metrics_post_event_proxy(post, config_file_factory, rhsm_config_file_factory): config_file = config_file_factory("") rhsm_config_file = rhsm_config_file_factory( proxy_hostname="localhost", proxy_port=3128, proxy_user="******", proxy_password="******" ) metrics_client = MetricsHTTPClient(config_file=config_file.name, rhsm_config_file=rhsm_config_file.name) event = Mock() metrics_client.post(event) post.assert_called_once_with( "https://cert-api.access.redhat.com:443/redhat_access/r/insights/platform/module-update-router/v1/event", json=event, proxies={"https": "http://*****:*****@localhost:3128"}, )
def test_metrics_post_event_no_proxy(post, config_file_factory, rhsm_config_file_factory): config_file = config_file_factory("") rhsm_config_file = rhsm_config_file_factory( hostname="satellite.example.com", repo_ca_cert="/path/to/cacert/cert.pem", consumerCertDir="/path/to/sat/certs") metrics_client = MetricsHTTPClient(config_file=config_file.name, rhsm_config_file=rhsm_config_file.name) event = Mock() metrics_client.post(event) post.assert_called_once_with( "https://satellite.example.com:443/redhat_access/r/insights/platform/module-update-router/v1/event", json=event, proxies=None, )