Esempio n. 1
0
def _delete_number(db_sess, sip_uri, private_id, delete_digest, on_success, on_failure, force_delete):
    """
       Deletes all information associated with a private/public identity
       pair, optionally deleting the digest associated with the private identity
    """

    def on_upstream_deletion(*args):
        _log.info("Deletion from Homestead and Homer was OK - returning number to pool")
        numbers.remove_owner(db_sess, sip_uri)
        db_sess.commit()
        on_success(args)

    # Concurrently, delete data from Homestead and Homer
    request_group = HTTPCallbackGroup(on_upstream_deletion, on_failure)

    if force_delete:
        request_group = HTTPCallbackGroup(on_success, on_failure)
        _log.info("Returning number to pool before attempting deletion from Homestead and Homer")
        numbers.remove_owner(db_sess, sip_uri)
        db_sess.commit()

    if delete_digest:
        # Deleting the private ID will delete its associated IRS (and
        # therefore any subsidiary public IDs and their service profiles)
        homestead.delete_private_id(private_id, request_group.callback())
    else:
        homestead.delete_public_id(sip_uri, request_group.callback())
    xdm.delete_simservs(sip_uri, request_group.callback())
Esempio n. 2
0
def _delete_number(db_sess, sip_uri, private_id, delete_digest, on_success,
                   on_failure, force_delete):
    """
       Deletes all information associated with a private/public identity
       pair, optionally deleting the digest associated with the private identity
    """
    def on_upstream_deletion(*args):
        _log.info(
            "Deletion from Homestead and Homer was OK - returning number to pool"
        )
        numbers.remove_owner(db_sess, sip_uri)
        db_sess.commit()
        on_success(args)

    # Concurrently, delete data from Homestead and Homer
    request_group = HTTPCallbackGroup(on_upstream_deletion, on_failure)

    if force_delete:  # pragma: no cover
        request_group = HTTPCallbackGroup(on_success, on_failure)
        _log.info(
            "Returning number to pool before attempting deletion from Homestead and Homer"
        )
        numbers.remove_owner(db_sess, sip_uri)
        db_sess.commit()

    if delete_digest:
        # Deleting the private ID will delete its associated IRS (and
        # therefore any subsidiary public IDs and their service profiles)
        homestead.delete_private_id(private_id, request_group.callback())
    else:
        homestead.delete_public_id(sip_uri, request_group.callback())
    xdm.delete_simservs(sip_uri, request_group.callback())
Esempio n. 3
0
 def test_delete_public_id_mainline(self, settings, AsyncHTTPClient):
     self.standard_setup(settings, AsyncHTTPClient)
     callback = Mock()
     homestead.delete_public_id(PUBLIC_URI, callback)
     self.mock_httpclient.fetch.assert_called_once_with(
       'http://homestead/irs/irs-uuid/service_profiles/sp-uuid/public_ids/sip%3Apub%40foo.bar',
         callback,
         method='DELETE',
         follow_redirects=False)
Esempio n. 4
0
 def test_delete_public_id_mainline(self, settings, AsyncHTTPClient):
     self.standard_setup(settings, AsyncHTTPClient)
     callback = Mock()
     homestead.delete_public_id(PUBLIC_URI, callback)
     # The public ID itself is deleted synchronously - we don't
     # have infrastructure to test that yet
     self.mock_httpclient.fetch.assert_called_once_with(
       'http://homestead/irs/irs-uuid/service_profiles/sp-uuid',
         callback,
         method='DELETE',
         follow_redirects=False,
         allow_ipv6=True)
Esempio n. 5
0
 def test_delete_public_id_mainline(self, settings, AsyncHTTPClient):
     self.standard_setup(settings, AsyncHTTPClient)
     callback = Mock()
     homestead.delete_public_id(PUBLIC_URI, callback)
     # The public ID itself is deleted synchronously - we don't
     # have infrastructure to test that yet
     self.mock_httpclient.fetch.assert_called_once_with(
         'http://homestead/irs/irs-uuid/service_profiles/sp-uuid',
         ANY,
         method='DELETE',
         follow_redirects=False,
         allow_ipv6=True)
Esempio n. 6
0
def _delete_number(db_sess, sip_uri, private_id, delete_digest, on_success, on_failure):
    """
       Deletes all information associated with a private/public identity
       pair, optionally deleting the digest associated with the private identity
    """
    numbers.remove_owner(db_sess, sip_uri)
    db_sess.commit()

    # Concurrently, delete data from Homestead and Homer
    request_group = HTTPCallbackGroup(on_success, on_failure)
    if delete_digest:
        homestead.delete_private_id(private_id, request_group.callback())
    homestead.delete_public_id(sip_uri, request_group.callback())
    xdm.delete_simservs(sip_uri, request_group.callback())
Esempio n. 7
0
def delete_user(private_id, public_id, force=False):
    success = True
    callback = Callback()

    homestead.delete_public_id(public_id, callback)
    response = callback.wait()[0]
    if isinstance(response, HTTPError):
        _log.error("Failed to delete public ID %s - HTTP status code %d", private_id, response.code)
        success = False
        if not force:
            return success

    homestead.delete_private_id(private_id, callback)
    response = callback.wait()[0]
    if isinstance(response, HTTPError):
        _log.error("Failed to delete private ID %s - HTTP status code %d", private_id, response.code)
        success = False

    return success
Esempio n. 8
0
def delete_user(private_id, public_id, force=False):
    success = True
    callback = Callback()

    homestead.delete_public_id(public_id, callback)
    response = callback.wait()[0]
    if isinstance(response, HTTPError):
        _log.error("Failed to delete public ID %s - HTTP status code %d", private_id, response.code)
        success = False
        if not force:
            return success

    homestead.delete_private_id(private_id, callback)
    response = callback.wait()[0]
    if isinstance(response, HTTPError):
        _log.error("Failed to delete private ID %s - HTTP status code %d", private_id, response.code)
        success = False

    return success