From f145b9d2a67eb0b2a21c976810ad556da93b3e54 Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Thu, 26 Apr 2012 14:10:12 +0200 Subject: [PATCH] add some config checks for neos --- tests/test_args_to_config.c | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tests/test_args_to_config.c b/tests/test_args_to_config.c index fa06513..58fbea1 100644 --- a/tests/test_args_to_config.c +++ b/tests/test_args_to_config.c @@ -510,6 +510,60 @@ int _test_swap_with_update(void) assert(rc == 0); } +int _test_ndef_for_neo(void) +{ + YKP_CONFIG *cfg = ykp_alloc(); + YK_STATUS *st = _test_init_st(2, 1, 7); + + char *argv[] = { + "unittest", "-nhttps://my.yubico.com/neo/", + NULL + }; + int argc = 2; + + int rc = _test_config(cfg, st, argc, argv); + assert(rc == 1); + struct config_st *ycfg = (struct config_st *) ykp_core_config(cfg); + assert(((struct ykp_config_t*)cfg)->command == SLOT_NDEF); + + ykp_free_config(cfg); + free(st); +} + +int _test_ndef_with_non_neo(void) +{ + YKP_CONFIG *cfg = ykp_alloc(); + YK_STATUS *st = _test_init_st(2, 2, 4); + + char *argv[] = { + "unittest", "-nhttps://my.yubico.com/neo/", + NULL + }; + int argc = 2; + + int rc = _test_config(cfg, st, argc, argv); + assert(rc == 0); + + ykp_free_config(cfg); + free(st); +} + +int _test_slot_two_with_neo(void) +{ + YKP_CONFIG *cfg = ykp_alloc(); + YK_STATUS *st = _test_init_st(2, 1, 7); + + char *argv[] = { + "unittest", "-2", NULL + }; + int argc = 2; + + int rc = _test_config(cfg, st, argc, argv); + assert(rc == 0); + ykp_free_config(cfg); + free(st); +} + int main (int argc, char **argv) { _test_config_slot1(); @@ -530,6 +584,9 @@ int main (int argc, char **argv) _test_swap_with_slot(); _test_slot_with_update(); _test_swap_with_update(); + _test_ndef_for_neo(); + _test_ndef_with_non_neo(); + _test_slot_two_with_neo(); return 0; } -- 2.39.5