def update_user(private_id, public_id, domain, password, ifc, plaintext=False): callback = Callback() if password: homestead.put_password(private_id, domain, password, callback, plaintext=plaintext) response = callback.wait()[0] if isinstance(response, HTTPError): _log.error( "Failed to update password for private ID %s - HTTP status code %d", private_id, response.code) return False if ifc: homestead.put_filter_criteria(public_id, ifc, callback) response = callback.wait()[0] if isinstance(response, HTTPError): _log.error("Failed to update public ID %s - HTTP status code %d", public_id, response.code) return False return True
def put_default_ifc(): print "Adding default IFC for %s" % sip_uri stats["Missing IFCs re-created"] += 1 global pending_requests pending_requests+=1 homestead.put_filter_criteria(sip_uri, ifcs.generate_ifcs(settings.SIP_DIGEST_REALM), logging_handler)
def put_default_ifc(): print "Adding default IFC for %s" % sip_uri stats["Missing IFCs re-created"] += 1 global pending_requests pending_requests+=1 homestead.put_filter_criteria(sip_uri, ifcs.generate_ifcs(utils.sip_uri_to_domain(sip_uri)), logging_handler)
def put_default_ifc(): print "Adding default IFC for %s" % sip_uri stats["Missing IFCs re-created"] += 1 global pending_requests pending_requests += 1 homestead.put_filter_criteria( sip_uri, ifcs.generate_ifcs(utils.sip_uri_to_domain(sip_uri)), logging_handler)
def test_put_ifcs(self, settings, AsyncHTTPClient): self.standard_setup(settings, AsyncHTTPClient) callback = Mock() homestead.put_filter_criteria(PUBLIC_URI, '<xml />', callback) self.mock_httpclient.fetch.assert_called_once_with(IFC_URL, callback, method="PUT", body='<xml />', follow_redirects=False)
def test_put_ifcs(self, settings, AsyncHTTPClient): self.standard_setup(settings, AsyncHTTPClient) callback = Mock() homestead.put_filter_criteria(PUBLIC_URI, '<xml />', callback) self.mock_httpclient.fetch.assert_called_once_with(IFC_URL, callback, method="PUT", body='<xml />', headers={'Content-Type': 'application/json'})
def test_put_ifcs(self, settings, AsyncHTTPClient): self.standard_setup(settings, AsyncHTTPClient) callback = Mock() homestead.put_filter_criteria(PUBLIC_URI, '<xml />', callback) self.mock_httpclient.fetch.assert_called_once_with( IFC_URL, ANY, method="PUT", body='<xml />', follow_redirects=False, allow_ipv6=True)
def get_ifc_callback(response, sip_uri=sip_uri): """ Handle response to initial GET, only PUT new data if there wasn't anything there. """ global num_responses, num_requests print "%s Get ifc response %s" % (sip_uri, response.code) if response.code == 404: print "%s ifc needs to be repopulated" % (sip_uri,) homestead.put_filter_criteria(sip_uri, ifcs.generate_ifcs(utils.sip_uri_to_domain(sip_uri)), put_ifc_callback) else: inc_resp_count()
def update_user(private_id, public_id, domain, password, ifc, plaintext=False): callback = Callback() if password: homestead.put_password(private_id, domain, password, callback, plaintext=plaintext) response = callback.wait()[0] if isinstance(response, HTTPError): _log.error("Failed to update password for private ID %s - HTTP status code %d", private_id, response.code) return False if ifc: homestead.put_filter_criteria(public_id, ifc, callback) response = callback.wait()[0] if isinstance(response, HTTPError): _log.error("Failed to update public ID %s - HTTP status code %d", public_id, response.code) return False return True