tests for new establish_key wormhole hook
defered should behave similarly to the `verify` hook
This commit is contained in:
parent
cd40fc7a03
commit
33fa6f6ede
|
@ -522,6 +522,32 @@ class Basic(unittest.TestCase):
|
||||||
self.assertEqual(len(pieces), 3) # nameplate plus two words
|
self.assertEqual(len(pieces), 3) # nameplate plus two words
|
||||||
self.assert_(re.search(r'^\d+-\w+-\w+$', code), code)
|
self.assert_(re.search(r'^\d+-\w+-\w+$', code), code)
|
||||||
|
|
||||||
|
def _test_establish_key_hook(self, established):
|
||||||
|
|
||||||
|
timing = DebugTiming()
|
||||||
|
w = wormhole._Wormhole(APPID, "relay_url", reactor, None, timing)
|
||||||
|
|
||||||
|
if established is True:
|
||||||
|
w._key = b"key"
|
||||||
|
elif established is False:
|
||||||
|
w._key = None
|
||||||
|
else:
|
||||||
|
w._key = b"key"
|
||||||
|
w._error = WelcomeError()
|
||||||
|
|
||||||
|
d = w.establish_key()
|
||||||
|
|
||||||
|
if w._key is not None and established is True:
|
||||||
|
self.successResultOf(d)
|
||||||
|
elif established is False:
|
||||||
|
self.assertNot(d.called)
|
||||||
|
else:
|
||||||
|
self.failureResultOf(d)
|
||||||
|
|
||||||
|
def test_establish_key_hook(self):
|
||||||
|
for established in (True, False, "error"):
|
||||||
|
self._test_establish_key_hook(established)
|
||||||
|
|
||||||
# make sure verify() can be called both before and after the verifier is
|
# make sure verify() can be called both before and after the verifier is
|
||||||
# computed
|
# computed
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user