def test_03_bad_response_message(self): """ Test various improperly constructed response messages """ DUMMY_TESTS = { "GET": [ ( RequestMsg("GET", "/GET/test_03_bad_response_message", headers={"Content-Length": "000"}), None, None, ), ] } body_filler = "?" * 1024 * 300 # Q2 # fake server - just to create a sink for the "fakeServer" address so # credit will be granted. rx = AsyncTestReceiver(self.INT_A.listener, source="fakeServer") # no correlation id: client = ThreadedTestClient(DUMMY_TESTS, self.http_fake_port) req = rx.queue.get(timeout=TIMEOUT) resp = Message(body="NO CORRELATION ID " + body_filler) resp.to = req.reply_to ts = AsyncTestSender(address=self.INT_A.listener, target=req.reply_to, message=resp) ts.wait() self.assertEqual(1, ts.rejected) client.wait() self.assertIsNotNone(client.error) # missing application properties client = ThreadedTestClient(DUMMY_TESTS, self.http_fake_port) req = rx.queue.get(timeout=TIMEOUT) resp = Message(body="NO APPLICATION PROPS " + body_filler) resp.to = req.reply_to resp.correlation_id = req.id ts = AsyncTestSender(address=self.INT_A.listener, target=req.reply_to, message=resp) ts.wait() self.assertEqual(1, ts.rejected) client.wait() self.assertIsNotNone(client.error) # no status application property client = ThreadedTestClient(DUMMY_TESTS, self.http_fake_port) req = rx.queue.get(timeout=TIMEOUT) resp = Message(body="MISSING STATUS HEADER " + body_filler) resp.to = req.reply_to resp.correlation_id = req.id resp.properties = {"stuff": "value"} ts = AsyncTestSender(address=self.INT_A.listener, target=req.reply_to, message=resp) ts.wait() self.assertEqual(1, ts.rejected) client.wait() self.assertIsNotNone(client.error) # TODO: fix body parsing (returns NEED_MORE) # # invalid body format # client = ThreadedTestClient(DUMMY_TESTS, # self.http_fake_port) # req = rx.queue.get(timeout=TIMEOUT) # resp = Message(body="INVALID BODY FORMAT " + body_filler) # resp.to = req.reply_to # resp.correlation_id = req.id # resp.properties = {"http:status": 200} # ts = AsyncTestSender(address=self.INT_A.listener, # target=req.reply_to, # message=resp) # ts.wait() # self.assertEqual(1, ts.rejected); # client.wait() # self.assertIsNotNone(client.error) rx.stop() sleep(0.5) # fudge factor allow socket close to complete # verify router is still sane: count, error = http1_ping(self.http_server_port, self.http_listener_port) self.assertIsNone(error) self.assertEqual(1, count)