From daaf3f17df054e6962d2b5da3d50e2c0247e1897 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 17 Nov 2020 14:42:12 +0100 Subject: [PATCH] revert clixon-err on XML restconf backend config --- lib/src/clixon_xml.c | 8 +------- lib/src/clixon_yang_parse_lib.c | 4 ++-- test/restconf_config.sh | 18 ++++++++++++++++++ test/test_api.sh | 3 +++ test/test_augment.sh | 5 ++++- test/test_choice.sh | 7 +++++-- test/test_identity.sh | 9 ++++++--- test/test_restconf.sh | 14 +++++++------- test/test_ssl_certs.sh | 13 ++++--------- test/test_yang_models.sh | 2 ++ 10 files changed, 52 insertions(+), 31 deletions(-) create mode 100644 test/restconf_config.sh diff --git a/lib/src/clixon_xml.c b/lib/src/clixon_xml.c index 3fd9e6f2..18150796 100644 --- a/lib/src/clixon_xml.c +++ b/lib/src/clixon_xml.c @@ -376,7 +376,6 @@ char* xml_name(cxobj *xn) { if (xn == NULL) { - clicon_err(OE_XML, EINVAL, "x is NULL"); return NULL; } return xn->x_name; @@ -570,7 +569,6 @@ cxobj* xml_parent(cxobj *xn) { if (xn == NULL) { - clicon_err(OE_XML, EINVAL, "xn is NULL"); return NULL; } return xn->x_up; @@ -713,7 +711,6 @@ enum cxobj_type xml_type(cxobj *xn) { if (xn == NULL) { - clicon_err(OE_XML, EINVAL, "xn is NULL"); return CX_ERROR; } return xn->x_type; @@ -808,7 +805,6 @@ xml_child_i(cxobj *xn, int i) { if (xn == NULL || i < 0) { - clicon_err(OE_XML, EINVAL, "xn is NULL or invalid child nr"); return NULL; } if (!is_element(xn)) @@ -1221,7 +1217,6 @@ xml_find(cxobj *xp, cxobj *x = NULL; if (xp == NULL || name == NULL) { - clicon_err(OE_XML, EINVAL, "xp or name is NULL"); return NULL; } if (!is_element(xp)) @@ -1838,8 +1833,7 @@ xml_free(cxobj *x) cxobj *xc; if (x == NULL){ - clicon_err(OE_XML, EINVAL, "x is NULL"); - return -1; + return 0; } if (x->x_name) free(x->x_name); diff --git a/lib/src/clixon_yang_parse_lib.c b/lib/src/clixon_yang_parse_lib.c index c9b2f55f..fe2dba69 100644 --- a/lib/src/clixon_yang_parse_lib.c +++ b/lib/src/clixon_yang_parse_lib.c @@ -927,10 +927,10 @@ yang_parse_module(clicon_handle h, goto done; if (nr == 0){ if (revision) - clicon_err(OE_YANG, ENOENT, "No1 yang files found matching \"%s@%s\" in the list of CLICON_YANG_DIRs", + clicon_err(OE_YANG, ENOENT, "No yang files found matching \"%s@%s\" in the list of CLICON_YANG_DIRs", module, revision); else - clicon_err(OE_YANG, ENOENT, "No2 yang files found matching \"%s\" in the list of CLICON_YANG_DIRs", module); + clicon_err(OE_YANG, ENOENT, "No yang files found matching \"%s\" in the list of CLICON_YANG_DIRs", module); goto done; } filename = cbuf_get(fbuf); diff --git a/test/restconf_config.sh b/test/restconf_config.sh new file mode 100644 index 00000000..a0b85c8e --- /dev/null +++ b/test/restconf_config.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# Create restconf backend config with a single socket +# ipv4 no-ssl + +RESTCONFIG=$(cat < + false + password + default
0.0.0.0
80false
+ +EOF +) + +new "netconf edit config" +expecteof "$clixon_netconf -qf $cfg" 0 "$RESTCONFIG]]>]]>" "^]]>]]>$" + +new "netconf commit" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" diff --git a/test/test_api.sh b/test/test_api.sh index d922b866..c407f37b 100755 --- a/test/test_api.sh +++ b/test/test_api.sh @@ -228,6 +228,9 @@ if [ $BE -ne 0 ]; then new "waiting" wait_backend +# Load restconf config +. ./restconf_config.sh + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre diff --git a/test/test_augment.sh b/test/test_augment.sh index 97e1f404..09096472 100755 --- a/test/test_augment.sh +++ b/test/test_augment.sh @@ -167,6 +167,9 @@ fi new "waiting" wait_backend +# Load restconf config +. ./restconf_config.sh + if [ $RC -ne 0 ]; then new "kill old restconf daemon" @@ -189,7 +192,7 @@ expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf verify get with refined ports" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^e1mymod:some-new-iftypetrue808080]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^e1mymod:some-new-iftypetrue808080" new "netconf set identity defined in other" expecteof "$clixon_netconf -qf $cfg" 0 " diff --git a/test/test_choice.sh b/test/test_choice.sh index 9388d33b..4bdf8b7e 100755 --- a/test/test_choice.sh +++ b/test/test_choice.sh @@ -119,6 +119,9 @@ fi new "waiting" wait_backend +# Load restconf config +. ./restconf_config.sh + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre @@ -153,7 +156,7 @@ new "netconf set protocol tcp" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get protocol tcp" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" new "netconf commit protocol tcp" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" @@ -162,7 +165,7 @@ new "netconf changing from TCP to UDP (RFC7950 7.9.6)" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" new "netconf get protocol udp" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^" new "netconf commit protocol udp" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" diff --git a/test/test_identity.sh b/test/test_identity.sh index 0b7857d6..3e44bc39 100755 --- a/test/test_identity.sh +++ b/test/test_identity.sh @@ -154,6 +154,9 @@ fi new "waiting" wait_backend +# Load restconf config +. ./restconf_config.sh + if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre @@ -276,7 +279,7 @@ new "restconf get own identity" expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:crypto)" 0 'HTTP/1.1 200 OK' '{"example:crypto":"aes"}' new "netconf get own identity as set by restconf" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^aes]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^aes" new "restconf delete identity" expectpart "$(curl $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/example:crypto)" 0 "HTTP/1.1 204 No Content" @@ -297,7 +300,7 @@ new "restconf get other identity" expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:crypto)" 0 'HTTP/1.1 200 OK' '{"example:crypto":"example-des:des3"}' new "netconf get other identity" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^des:des3]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^des:des3" new "restconf delete identity" expectpart "$(curl $CURLOPTS -X DELETE $RCPROTO://localhost/restconf/data/example:crypto)" 0 "HTTP/1.1 204 No Content" @@ -313,7 +316,7 @@ new "restconf get other identity (set by netconf)" expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:crypto)" 0 'HTTP/1.1 200 OK' '{"example:crypto":"example-des:des3"}' new "netconf get other identity" -expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^des:des3]]>]]>$" +expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^des:des3" if [ $RC -ne 0 ]; then new "Kill restconf daemon" diff --git a/test/test_restconf.sh b/test/test_restconf.sh index d8edfa67..f0985fc2 100755 --- a/test/test_restconf.sh +++ b/test/test_restconf.sh @@ -72,7 +72,7 @@ state='{"clixon-example:state":{"op":\["41","42","43"\]}' if $IPv6; then # For backend config, create 4 sockets, all combinations IPv4/IPv6 + http/https - RESTCONFCONFIG=$(cat < true password @@ -88,7 +88,7 @@ EOF ) else # For backend config, create 4 sockets, all combinations IPv4/IPv6 + http/https - RESTCONFCONFIG=$(cat < true password @@ -136,7 +136,7 @@ testrun() if [ $config = backend ] ; then # Create a backend config # restconf backend config new "netconf edit config" - expecteof "$clixon_netconf -qf $cfg" 0 "$RESTCONFCONFIG]]>]]>" "^]]>]]>$" + expecteof "$clixon_netconf -qf $cfg" 0 "$RESTCONFIG]]>]]>" "^]]>]]>$" new "netconf commit" expecteof "$clixon_netconf -qf $cfg" 0 "]]>]]>" "^]]>]]>$" @@ -147,11 +147,11 @@ testrun() stop_restconf_pre if [ $config = backend ] ; then # Add -b option - new "start restconf daemon -b" - start_restconf -f $cfg -b + new "start restconf daemon -o CLICON_RESTCONF_CONFIG=true" + start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=true else - new "start restconf daemon" - start_restconf -f $cfg + new "start restconf daemon -o CLICON_RESTCONF_CONFIG=false" + start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=false fi fi new "wait restconf" diff --git a/test/test_ssl_certs.sh b/test/test_ssl_certs.sh index 5dcbc05f..c4de2921 100755 --- a/test/test_ssl_certs.sh +++ b/test/test_ssl_certs.sh @@ -156,13 +156,8 @@ EOF fi # genkeys # Set a clixon-restconf config -if [ ${RCPROTO} = "https" ]; then - ssl=true - port=443 -else - ssl=false - port=80 -fi +ssl=true +port=443 authtype=client-certificate # Run with and without getting config from backend @@ -219,10 +214,10 @@ EOF stop_restconf_pre if $USEBACKEND; then new "start restconf daemon -b -- -s" - start_restconf -f $cfg -b -- -s + start_restconf -f $cfg -o CLICON_RESTCONF_CONFIG=true -- -s else new "start restconf daemon -s -c -- -s" - start_restconf -f $cfg -s -c -- -s + start_restconf -f $cfg -s -c -o CLICON_RESTCONF_CONFIG=false -- -s fi fi diff --git a/test/test_yang_models.sh b/test/test_yang_models.sh index 654c0848..839214ec 100755 --- a/test/test_yang_models.sh +++ b/test/test_yang_models.sh @@ -35,6 +35,7 @@ cat < $cfg $cfg ni-ieee1588-ptp:cmlds + ietf-alarms:alarm-shelving $YANGMODELS/standard/ietf/RFC $YANGMODELS/standard/ieee/draft/802.1/Qcr $YANGMODELS/standard/ieee/draft/802 @@ -85,6 +86,7 @@ new "yangmodel Standard IEEE 802.1: $YANGMODELS/standard/ieee/published/802.3" expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ieee/published/802.3 show version)" 0 "$version." # Standard IETF +# XXX fails on augmenting "action" new "yangmodel Standard IETF: $YANGMODELS/standard/ietf/RFC" expectpart "$($clixon_cli -D $DBG -1f $cfg -o CLICON_YANG_MAIN_DIR=$YANGMODELS/standard/ietf/RFC show version)" 0 "$version."