'test PLAIN authentication'

def test_plain(self):

    server = self.socket(zmq.DEALER)
    server.identity = 'IDENT'
    client = self.socket(zmq.DEALER)
    self.assertEqual(client.plain_username, '')
    self.assertEqual(client.plain_password, '')
    client.plain_username = USER
    client.plain_password = PASS
    self.assertEqual(client.getsockopt(zmq.PLAIN_USERNAME), USER)
    self.assertEqual(client.getsockopt(zmq.PLAIN_PASSWORD), PASS)
    self.assertEqual(client.plain_server, 0)
    self.assertEqual(server.plain_server, 0)
    server.plain_server = True
    self.assertEqual(server.mechanism, zmq.PLAIN)
    self.assertEqual(client.mechanism, zmq.PLAIN)
    assert (not client.plain_server)
    assert server.plain_server
    self.start_zap()
    iface = 'tcp://127.0.0.1'
    port = server.bind_to_random_port(iface)
    client.connect(('%s:%i' % (iface, port)))
    self.bounce(server, client)
    self.stop_zap()
