From 49a205d422fc55fff1c9ea251b183a7a8071c14b Mon Sep 17 00:00:00 2001 From: Michal Vasko Date: Fri, 1 Dec 2023 08:46:57 +0100 Subject: [PATCH] errors UPDATE out-of-bounds type value error --- src/err_netconf.c | 2 +- tests/modules/errors.yang | 2 +- tests/test_error.c | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/err_netconf.c b/src/err_netconf.c index ce8cb938..29dde473 100644 --- a/src/err_netconf.c +++ b/src/err_netconf.c @@ -271,7 +271,7 @@ np_err_sr2nc_edit(sr_session_ctx_t *ev_sess, const sr_session_ctx_t *err_sess) /* data-missing */ sr_session_set_netconf_error(ev_sess, "protocol", "data-missing", NULL, NULL, err->message, 0); } else if (!strncmp(err->message, "Invalid type", 12) || !strncmp(err->message, "Unsatisfied range", 17) || - !strncmp(err->message, "Unsatisfied pattern", 19)) { + !strncmp(err->message, "Unsatisfied pattern", 19) || strstr(err->message, "min/max bounds")) { /* create error message */ str = strndup(err->message, (strchr(err->message, '.') + 1) - err->message); diff --git a/tests/modules/errors.yang b/tests/modules/errors.yang index 4a53e2ae..545cd28f 100644 --- a/tests/modules/errors.yang +++ b/tests/modules/errors.yang @@ -83,7 +83,7 @@ module errors { } leaf num { - type uint32 { + type uint16 { range "10..100"; } } diff --git a/tests/test_error.c b/tests/test_error.c index 14e8d665..1106e807 100644 --- a/tests/test_error.c +++ b/tests/test_error.c @@ -387,7 +387,7 @@ test_bad_element(void **state) " application\n" " bad-element\n" " error\n" - " Invalid type uint32 value \"string\".\n" + " Invalid type uint16 value \"string\".\n" " \n" " /errors:num\n" " \n" @@ -410,6 +410,22 @@ test_bad_element(void **state) "\n"); FREE_TEST_VARS(st); + /* out of type range */ + data = "100000"; + SEND_EDIT_RPC(st, data); + ASSERT_ERROR_REPLY(st); + assert_string_equal(st->str, + "\n" + " application\n" + " bad-element\n" + " error\n" + " Value \"100000\" is out of type uint16 min/max bounds.\n" + " \n" + " /errors:num\n" + " \n" + "\n"); + FREE_TEST_VARS(st); + /* unsatisfied pattern */ data = "bb"; SEND_EDIT_RPC(st, data);