'POST https://httpbin.org/post'

def test_post_json(self):

    with self.app.test_client() as c:
        req_json = {'x': 233, 'domain1': self.C.my_host_name, 'domain2': self.C.external_domains[0], 'url1': 'https://eu.httpbin.org/', 'url2': self.url('/post'), 'url3': ('https://%s/extdomains/eu.httpbin.org/1xxx?a=235' % self.C.my_host_name), 'url4': ('//%s/extdomains/eu.httpbin.org/2xxx?a=236' % self.C.my_host_name), 'url5': ('http://%s/extdomains/eu.httpbin.org/3xxx?a=237' % self.C.my_host_name), 'url6': ('http://%s/extdomains/httpbin.org/4xxx.png?a=238' % self.C.my_host_name), 'chinese': '\xe5\x90\xb1\xe5\x90\xb1\xe6\x88\x91\xe7\x88\xb1\xe4\xbd\xa0~    :)'}
        for u in range(1, 7):
            req_json[('url%dq' % u)] = quote_plus(req_json[('url%d' % u)])
            req_json[('url%de' % u)] = slash_esc(req_json[('url%d' % u)])
            req_json[('url%deq' % u)] = quote_plus(req_json[('url%de' % u)])
        self.rv = c.post(self.url('/post'), environ_base=env(), content_type='application/json', data=json.dumps(req_json), headers=headers(others={'Accept': 'application/json'}))
        parse_values = attributes(self.zmirror.parse)
        remote_resp = self.zmirror.parse.remote_response
        remote_resp_json = json.loads(remote_resp.text)
        zmirror_req = remote_resp.request
        self.assertEqual('application/json', self.zmirror.parse.client_header['content-type'], msg=self.dump())
        req_body = json.loads(zmirror_req.body.decode(encoding='utf-8'))
        self.assertEqual('\xe5\x90\xb1\xe5\x90\xb1\xe6\x88\x91\xe7\x88\xb1\xe4\xbd\xa0~    :)', req_body['chinese'], msg=self.dump())
        self.assertEqual(self.C.target_domain, req_body['domain1'], msg=self.dump())
        self.assertEqual(self.C.external_domains[0], req_body['domain2'], msg=self.dump())
        self.assertEqual('https://eu.httpbin.org/', req_body['url1'], msg=self.dump())
        self.assertEqual('https://httpbin.org/post', req_body['url2'], msg=self.dump())
        self.assertEqual('https://eu.httpbin.org/1xxx?a=235', req_body['url3'], msg=self.dump())
        self.assertEqual('//eu.httpbin.org/2xxx?a=236', req_body['url4'], msg=self.dump())
        self.assertEqual('https://eu.httpbin.org/3xxx?a=237', req_body['url5'], msg=self.dump())
        self.assertEqual('https://httpbin.org/4xxx.png?a=238', req_body['url6'], msg=self.dump())
        j = remote_resp_json['json']
        self.assertEqual('\xe5\x90\xb1\xe5\x90\xb1\xe6\x88\x91\xe7\x88\xb1\xe4\xbd\xa0~    :)', j['chinese'], msg=self.dump())
        self.assertEqual(self.C.target_domain, j['domain1'], msg=self.dump())
        self.assertEqual(self.C.external_domains[0], j['domain2'], msg=self.dump())
        self.assertEqual('https://eu.httpbin.org/', j['url1'], msg=self.dump())
        self.assertEqual('https://httpbin.org/post', j['url2'], msg=self.dump())
        self.assertEqual('https://eu.httpbin.org/1xxx?a=235', j['url3'], msg=self.dump())
        self.assertEqual('//eu.httpbin.org/2xxx?a=236', j['url4'], msg=self.dump())
        self.assertEqual('https://eu.httpbin.org/3xxx?a=237', j['url5'], msg=self.dump())
        self.assertEqual('https://httpbin.org/4xxx.png?a=238', j['url6'], msg=self.dump())
        r = load_rv_json(self.rv)
        r_json = r['json']
        self.assertEqual('application/json', r['headers']['Content-Type'], msg=self.dump())
        self.assertEqual(self.C.my_host_name, r['headers']['Host'], msg=self.dump())
        self.assertEqual(233, r_json['x'], msg=self.dump())
        self.assertEqual('\xe5\x90\xb1\xe5\x90\xb1\xe6\x88\x91\xe7\x88\xb1\xe4\xbd\xa0~    :)', r_json['chinese'], msg=self.dump())
        self.assertEqual(self.C.my_host_name, r_json['domain1'], msg=self.dump())
        self.assertEqual(((self.C.my_host_name + '/extdomains/') + self.C.external_domains[0]), r_json['domain2'], msg=self.dump())
        self.zmirror.dump_zmirror_snapshot()
        answers = [None, self.url('/extdomains/eu.httpbin.org/'), self.url('/post'), self.url('/extdomains/eu.httpbin.org/1xxx?a=235'), '//{}/extdomains/eu.httpbin.org/2xxx?a=236'.format(self.C.my_host_name), self.url('/extdomains/eu.httpbin.org/3xxx?a=237'), self.url('/4xxx.png?a=238')]
        for i in range(1, 7):
            self.assertEqual(answers[i], r_json['url{}'.format(i)], msg=self.dump())
            self.assertEqual(slash_esc(answers[i]), r_json['url{}e'.format(i)], msg=self.dump())
            self.assertEqual(quote_plus(answers[i]), r_json['url{}q'.format(i)], msg=self.dump())
            self.assertEqual(quote_plus(slash_esc(answers[i])), r_json['url{}eq'.format(i)], msg=self.dump())
