Change in pysim[master]: pySim-shell: match SW in apdu command
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/28169 ) Change subject: pySim-shell: match SW in apdu command ...................................................................... pySim-shell: match SW in apdu command The apdu command has no option to match the resulting SW. Lets add a new option for this. Change-Id: Ic5a52d7cf533c51d111850eb6d8147011a48ae6c --- M pySim-shell.py 1 file changed, 5 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/69/28169/1 diff --git a/pySim-shell.py b/pySim-shell.py index d1ed506..083594c 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -40,7 +40,7 @@ from pySim.commands import SimCardCommands from pySim.transport import init_reader, ApduTracer, argparse_add_reader_args from pySim.cards import card_detect, SimCard -from pySim.utils import h2b, swap_nibbles, rpad, b2h, h2s, JsonEncoder, bertlv_parse_one +from pySim.utils import h2b, swap_nibbles, rpad, b2h, h2s, JsonEncoder, bertlv_parse_one, sw_match from pySim.utils import dec_st, sanitize_pin_adm, tabulate_str_list, is_hex, boxed_heading_str from pySim.card_handler import CardHandler, CardHandlerAuto @@ -246,6 +246,7 @@ apdu_cmd_parser = argparse.ArgumentParser() apdu_cmd_parser.add_argument('APDU', type=str, help='APDU as hex string') + apdu_cmd_parser.add_argument('--expect_sw', help='expect a specified status word', type=str, default=None) @cmd2.with_argparser(apdu_cmd_parser) def do_apdu(self, opts): @@ -258,6 +259,9 @@ self.poutput("SW: %s, RESP: %s" % (sw, data)) else: self.poutput("SW: %s" % sw) + if opts.expect_sw: + if not sw_match(sw, opts.expect_sw): + raise SwMatchError(sw, opts.expect_sw) class InterceptStderr(list): def __init__(self): -- To view, visit https://gerrit.osmocom.org/c/pysim/+/28169 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Ic5a52d7cf533c51d111850eb6d8147011a48ae6c Gerrit-Change-Number: 28169 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier@sysmocom.de> Gerrit-MessageType: newchange
participants (1)
-
dexter