Mercurial > hg
comparison tests/test-wireproto-clientreactor.py @ 40024:86b22a4cfab1
wireprotov2: client support for advertising redirect targets
With the server now able to emit a redirect target descriptor, we can
start to teach the client to recognize it.
This commit implements support for filtering the advertised
redirect targets against supported features and for advertising
compatible redirect targets as part of command requests. It also
adds the minimal boilerplate required to fail when a content
redirect is seen.
The server doesn't yet do anything with the advertised redirect
targets. And the client can't yet follow redirects if it did. But
at least we're putting bytes on the wire.
Differential Revision: https://phab.mercurial-scm.org/D4776
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 26 Sep 2018 15:02:19 -0700 |
parents | deff7cf7eefd |
children | 57782791b7e9 |
comparison
equal
deleted
inserted
replaced
40023:10cf8b116dd8 | 40024:86b22a4cfab1 |
---|---|
137 action, meta = sendframe( | 137 action, meta = sendframe( |
138 reactor, | 138 reactor, |
139 ffs(b'%d 0 0 command-response eos bar' % request.requestid)) | 139 ffs(b'%d 0 0 command-response eos bar' % request.requestid)) |
140 self.assertEqual(action, b'responsedata') | 140 self.assertEqual(action, b'responsedata') |
141 | 141 |
142 class RedirectTests(unittest.TestCase): | |
143 def testredirect(self): | |
144 reactor = framing.clientreactor(buffersends=False) | |
145 | |
146 redirect = { | |
147 b'targets': [b'a', b'b'], | |
148 b'hashes': [b'sha256'], | |
149 } | |
150 | |
151 request, action, meta = reactor.callcommand( | |
152 b'foo', {}, redirect=redirect) | |
153 | |
154 self.assertEqual(action, b'sendframes') | |
155 | |
156 frames = list(meta[b'framegen']) | |
157 self.assertEqual(len(frames), 1) | |
158 | |
159 self.assertEqual(frames[0], | |
160 ffs(b'1 1 stream-begin command-request new ' | |
161 b"cbor:{b'name': b'foo', " | |
162 b"b'redirect': {b'targets': [b'a', b'b'], " | |
163 b"b'hashes': [b'sha256']}}")) | |
164 | |
142 if __name__ == '__main__': | 165 if __name__ == '__main__': |
143 import silenttestrunner | 166 import silenttestrunner |
144 silenttestrunner.main(__name__) | 167 silenttestrunner.main(__name__) |