Parcourir la source

add test for pk version of the commands...

One missing thing is the ability to generate public keys from
private keys for running the code standalone..
main
John-Mark Gurney il y a 1 an
Parent
révision
fad1e9fe22
1 fichiers modifiés avec 29 ajouts et 10 suppressions
  1. +29
    -10
      lora.py

+ 29
- 10
lora.py Voir le fichier

@@ -1576,19 +1576,36 @@ class TestLORAmain(unittest.TestCase):
init_key = X25519.gen()
resp_key = X25519.gen()

f = {}
for i in [ 'init', 'resp' ]:
key = locals()['%s_key' % i]

for j in [ 'pub', 'priv' ]:
data = getattr(key, 'get%s' % j)().hex()
file = self.basetempdir / ('%s_%s.key' % (i, j))
f['%s_%s_key_file' % (i, j)] = file

with file.open('w') as fp:
fp.write(data)

keys.append(('pk', (
[ '-k', f['init_priv_key_file'],
'-p', f['resp_pub_key_file'] ],
[ '-k', f['resp_priv_key_file'],
'-p', f['init_pub_key_file'] ]
)))
for name, (initargs, respargs) in keys:
with self.subTest(name=name):
# XXX - macosx specific library path var
with self.subTest(name=name), patch.dict(os.environ,
dict(DYLD_LIBRARY_PATH=self.origcwd)):
self.run_program_keyargs(initargs, respargs)

def run_program_keyargs(self, initargs, respargs):
try:
# XXX - macosx specific library path var
with patch.dict(os.environ,
dict(DYLD_LIBRARY_PATH=self.origcwd)):
resp = subprocess.Popen([ 'python', __file__,
'-r', 'dummy:TestAttr.dummy_func' ] +
respargs, stdin=DEVNULL, stderr=PIPE,
stdout=PIPE)
resp = subprocess.Popen([ 'python', __file__,
'-r', 'dummy:TestAttr.dummy_func' ] +
respargs, stdin=DEVNULL, stderr=PIPE,
stdout=PIPE)

init = subprocess.Popen([ 'python', __file__ ] +
initargs + [ 'ping' ], stdin=DEVNULL, stderr=PIPE,
@@ -1608,10 +1625,12 @@ class TestLORAmain(unittest.TestCase):
self.assertEqual(errout, b'')

finally:
init.terminate()
init.kill()
_, errout = init.communicate()
#print(repr(errout))
#sys.stdout.flush()
self.assertEqual(errout, b'')

resp.terminate()
resp.kill()
_, errout = resp.communicate()
self.assertEqual(errout, b'')

Chargement…
Annuler
Enregistrer