Fix test setup
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2016-08-24 Niibe Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
|
* test/features/steps.py (ini): Use GLC (the global context),
|
||||||
|
instead of FTC (the feature context), so that token only is
|
||||||
|
opened once.
|
||||||
|
|
||||||
2016-08-03 Niibe Yutaka <gniibe@fsij.org>
|
2016-08-03 Niibe Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
* tool/hub_ctrl.py: Port to Python 3.
|
* tool/hub_ctrl.py: Port to Python 3.
|
||||||
|
|||||||
@@ -11,19 +11,19 @@ from array import array
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
def ini(sc):
|
def ini(sc):
|
||||||
if not ftc.token:
|
if not glc.token:
|
||||||
ftc.token = gnuk.get_gnuk_device()
|
glc.token = gnuk.get_gnuk_device()
|
||||||
ftc.token.cmd_select_openpgp()
|
glc.token.cmd_select_openpgp()
|
||||||
|
|
||||||
@Given("cmd_verify with (.*) and \"(.*)\"")
|
@Given("cmd_verify with (.*) and \"(.*)\"")
|
||||||
def cmd_verify(who_str,pass_str):
|
def cmd_verify(who_str,pass_str):
|
||||||
who = int(who_str)
|
who = int(who_str)
|
||||||
scc.result = ftc.token.cmd_verify(who, pass_str)
|
scc.result = glc.token.cmd_verify(who, pass_str)
|
||||||
|
|
||||||
@Given("cmd_change_reference_data with (.*) and \"(.*)\"")
|
@Given("cmd_change_reference_data with (.*) and \"(.*)\"")
|
||||||
def cmd_change_reference_data(who_str,pass_str):
|
def cmd_change_reference_data(who_str,pass_str):
|
||||||
who = int(who_str)
|
who = int(who_str)
|
||||||
scc.result = ftc.token.cmd_change_reference_data(who, pass_str)
|
scc.result = glc.token.cmd_change_reference_data(who, pass_str)
|
||||||
|
|
||||||
@Given("cmd_put_data with (.*) and (\".*\")")
|
@Given("cmd_put_data with (.*) and (\".*\")")
|
||||||
def cmd_put_data(tag_str,content_str_repr):
|
def cmd_put_data(tag_str,content_str_repr):
|
||||||
@@ -31,12 +31,12 @@ def cmd_put_data(tag_str,content_str_repr):
|
|||||||
tag = int(tag_str, 16)
|
tag = int(tag_str, 16)
|
||||||
tagh = tag >> 8
|
tagh = tag >> 8
|
||||||
tagl = tag & 0xff
|
tagl = tag & 0xff
|
||||||
scc.result = ftc.token.cmd_put_data(tagh, tagl, content_str)
|
scc.result = glc.token.cmd_put_data(tagh, tagl, content_str)
|
||||||
|
|
||||||
@Given("cmd_reset_retry_counter with (.*) and \"(.*)\"")
|
@Given("cmd_reset_retry_counter with (.*) and \"(.*)\"")
|
||||||
def cmd_reset_retry_counter(how_str, data):
|
def cmd_reset_retry_counter(how_str, data):
|
||||||
how = int(how_str)
|
how = int(how_str)
|
||||||
scc.result = ftc.token.cmd_reset_retry_counter(how, data)
|
scc.result = glc.token.cmd_reset_retry_counter(how, data)
|
||||||
|
|
||||||
@Given("a RSA key pair (.*)")
|
@Given("a RSA key pair (.*)")
|
||||||
def set_rsa_key(keyno_str):
|
def set_rsa_key(keyno_str):
|
||||||
@@ -46,7 +46,7 @@ def set_rsa_key(keyno_str):
|
|||||||
def import_key(openpgp_keyno_str):
|
def import_key(openpgp_keyno_str):
|
||||||
openpgp_keyno = int(openpgp_keyno_str)
|
openpgp_keyno = int(openpgp_keyno_str)
|
||||||
t = rsa_keys.build_privkey_template(openpgp_keyno, scc.keyno)
|
t = rsa_keys.build_privkey_template(openpgp_keyno, scc.keyno)
|
||||||
scc.result = ftc.token.cmd_put_data_odd(0x3f, 0xff, t)
|
scc.result = glc.token.cmd_put_data_odd(0x3f, 0xff, t)
|
||||||
|
|
||||||
@Given("a fingerprint of OPENPGP.(.*) key")
|
@Given("a fingerprint of OPENPGP.(.*) key")
|
||||||
def get_key_fpr(openpgp_keyno_str):
|
def get_key_fpr(openpgp_keyno_str):
|
||||||
@@ -63,7 +63,7 @@ def cmd_put_data_with_result(tag_str):
|
|||||||
tag = int(tag_str, 16)
|
tag = int(tag_str, 16)
|
||||||
tagh = tag >> 8
|
tagh = tag >> 8
|
||||||
tagl = tag & 0xff
|
tagl = tag & 0xff
|
||||||
scc.result = ftc.token.cmd_put_data(tagh, tagl, scc.result)
|
scc.result = glc.token.cmd_put_data(tagh, tagl, scc.result)
|
||||||
|
|
||||||
@Given("a message (\".*\")")
|
@Given("a message (\".*\")")
|
||||||
def set_msg(content_str_repr):
|
def set_msg(content_str_repr):
|
||||||
@@ -73,7 +73,7 @@ def set_msg(content_str_repr):
|
|||||||
@Given("a public key from token for OPENPGP.(.*)")
|
@Given("a public key from token for OPENPGP.(.*)")
|
||||||
def get_public_key(openpgp_keyno_str):
|
def get_public_key(openpgp_keyno_str):
|
||||||
openpgp_keyno = int(openpgp_keyno_str)
|
openpgp_keyno = int(openpgp_keyno_str)
|
||||||
scc.pubkey_info = ftc.token.cmd_get_public_key(openpgp_keyno)
|
scc.pubkey_info = glc.token.cmd_get_public_key(openpgp_keyno)
|
||||||
|
|
||||||
@Given("verify signature")
|
@Given("verify signature")
|
||||||
def verify_signature():
|
def verify_signature():
|
||||||
@@ -81,11 +81,11 @@ def verify_signature():
|
|||||||
|
|
||||||
@Given("let a token compute digital signature")
|
@Given("let a token compute digital signature")
|
||||||
def compute_signature():
|
def compute_signature():
|
||||||
scc.sig = int(hexlify(ftc.token.cmd_pso(0x9e, 0x9a, scc.digestinfo)),16)
|
scc.sig = int(hexlify(glc.token.cmd_pso(0x9e, 0x9a, scc.digestinfo)),16)
|
||||||
|
|
||||||
@Given("let a token authenticate")
|
@Given("let a token authenticate")
|
||||||
def internal_authenticate():
|
def internal_authenticate():
|
||||||
scc.sig = int(hexlify(ftc.token.cmd_internal_authenticate(scc.digestinfo)),16)
|
scc.sig = int(hexlify(glc.token.cmd_internal_authenticate(scc.digestinfo)),16)
|
||||||
|
|
||||||
@Given("compute digital signature on host with RSA key pair (.*)")
|
@Given("compute digital signature on host with RSA key pair (.*)")
|
||||||
def compute_signature_on_host(keyno_str):
|
def compute_signature_on_host(keyno_str):
|
||||||
@@ -107,29 +107,29 @@ def encrypt_on_host_public_key():
|
|||||||
|
|
||||||
@Given("let a token decrypt encrypted data")
|
@Given("let a token decrypt encrypted data")
|
||||||
def decrypt():
|
def decrypt():
|
||||||
scc.result = ftc.token.cmd_pso_longdata(0x80, 0x86, scc.ciphertext).tostring()
|
scc.result = glc.token.cmd_pso_longdata(0x80, 0x86, scc.ciphertext).tostring()
|
||||||
|
|
||||||
@Given("USB version string of the token")
|
@Given("USB version string of the token")
|
||||||
def usb_version_string():
|
def usb_version_string():
|
||||||
scc.result = ftc.token.get_string(3)
|
scc.result = glc.token.get_string(3)
|
||||||
|
|
||||||
@When("requesting (.+): ([0-9a-fA-F]+)")
|
@When("requesting (.+): ([0-9a-fA-F]+)")
|
||||||
def get_data(name, tag_str):
|
def get_data(name, tag_str):
|
||||||
tag = int(tag_str, 16)
|
tag = int(tag_str, 16)
|
||||||
tagh = tag >> 8
|
tagh = tag >> 8
|
||||||
tagl = tag & 0xff
|
tagl = tag & 0xff
|
||||||
scc.result = ftc.token.cmd_get_data(tagh, tagl)
|
scc.result = glc.token.cmd_get_data(tagh, tagl)
|
||||||
|
|
||||||
@When("removing a key OPENPGP.(.*)")
|
@When("removing a key OPENPGP.(.*)")
|
||||||
def remove_key(openpgp_keyno_str):
|
def remove_key(openpgp_keyno_str):
|
||||||
openpgp_keyno = int(openpgp_keyno_str)
|
openpgp_keyno = int(openpgp_keyno_str)
|
||||||
t = rsa_keys.build_privkey_template_for_remove(openpgp_keyno)
|
t = rsa_keys.build_privkey_template_for_remove(openpgp_keyno)
|
||||||
scc.result = ftc.token.cmd_put_data_odd(0x3f, 0xff, t)
|
scc.result = glc.token.cmd_put_data_odd(0x3f, 0xff, t)
|
||||||
|
|
||||||
@When("generating a key of OPENPGP.(.*)")
|
@When("generating a key of OPENPGP.(.*)")
|
||||||
def generate_key(openpgp_keyno_str):
|
def generate_key(openpgp_keyno_str):
|
||||||
openpgp_keyno = int(openpgp_keyno_str)
|
openpgp_keyno = int(openpgp_keyno_str)
|
||||||
pubkey_info = ftc.token.cmd_genkey(openpgp_keyno)
|
pubkey_info = glc.token.cmd_genkey(openpgp_keyno)
|
||||||
scc.data = rsa_keys.calc_fpr(pubkey_info[0].tostring(), pubkey_info[1].tostring())
|
scc.data = rsa_keys.calc_fpr(pubkey_info[0].tostring(), pubkey_info[1].tostring())
|
||||||
|
|
||||||
@When("put the first data to (.*)")
|
@When("put the first data to (.*)")
|
||||||
@@ -137,14 +137,14 @@ def cmd_put_data_first_with_result(tag_str):
|
|||||||
tag = int(tag_str, 16)
|
tag = int(tag_str, 16)
|
||||||
tagh = tag >> 8
|
tagh = tag >> 8
|
||||||
tagl = tag & 0xff
|
tagl = tag & 0xff
|
||||||
scc.result = ftc.token.cmd_put_data(tagh, tagl, scc.data[0])
|
scc.result = glc.token.cmd_put_data(tagh, tagl, scc.data[0])
|
||||||
|
|
||||||
@When("put the second data to (.*)")
|
@When("put the second data to (.*)")
|
||||||
def cmd_put_data_second_with_result(tag_str):
|
def cmd_put_data_second_with_result(tag_str):
|
||||||
tag = int(tag_str, 16)
|
tag = int(tag_str, 16)
|
||||||
tagh = tag >> 8
|
tagh = tag >> 8
|
||||||
tagl = tag & 0xff
|
tagl = tag & 0xff
|
||||||
result = ftc.token.cmd_put_data(tagh, tagl, scc.data[1])
|
result = glc.token.cmd_put_data(tagh, tagl, scc.data[1])
|
||||||
scc.result = (scc.result and result)
|
scc.result = (scc.result and result)
|
||||||
|
|
||||||
@Then("you should get: (.*)")
|
@Then("you should get: (.*)")
|
||||||
|
|||||||
Reference in New Issue
Block a user