'threaded auth - CURVE'

@skip_pypy
def test_curve_user_id(self):

    self.auth.allow('127.0.0.1')
    certs = self.load_certs(self.secret_keys_dir)
    (server_public, server_secret, client_public, client_secret) = certs
    self.auth.configure_curve(domain='*', location=self.public_keys_dir)
    server = self.socket(zmq.PULL)
    server.curve_publickey = server_public
    server.curve_secretkey = server_secret
    server.curve_server = True
    client = self.socket(zmq.PUSH)
    client.curve_publickey = client_public
    client.curve_secretkey = client_secret
    client.curve_serverkey = server_public
    assert self.can_connect(client, server)
    client.send('test')
    msg = self.recv(server, copy=False)
    assert (msg.bytes == 'test')
    try:
        user_id = msg.get('User-Id')
    except zmq.ZMQVersionError:
        pass
    else:
        assert (user_id == u(client_public))
    self.auth.curve_user_id = (lambda client_key: u'custom')
    client2 = self.socket(zmq.PUSH)
    client2.curve_publickey = client_public
    client2.curve_secretkey = client_secret
    client2.curve_serverkey = server_public
    assert self.can_connect(client2, server)
    client2.send('test2')
    msg = self.recv(server, copy=False)
    assert (msg.bytes == 'test2')
    try:
        user_id = msg.get('User-Id')
    except zmq.ZMQVersionError:
        pass
    else:
        assert (user_id == u'custom')
