diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d028621..161bb162 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,6 +72,9 @@ Users may have to change how they access the system ### Corrected Bugs +* Fixed: Netconf diff callback did not work with choice and same value replace + * Eg if YANG is `choice c { leaf x; leaf y }` and XML changed from `42` to `42` the datastrore changed, but was not detected by diff algorithms and provided to validate callbacks. + * Thanks: Alexander Skorichenko, Netgate * Fixed: [Autocli does not offer completions for leafref to identityref #254](https://github.com/clicon/clixon/issues/254) * This is a part of YANG Leafref feature update * Fixed: [clixon_netconf errors on client XML Declaration with valid encoding spec](https://github.com/clicon/clixon/issues/250) diff --git a/lib/src/clixon_xml_map.c b/lib/src/clixon_xml_map.c index 9a57ef99..36f485eb 100644 --- a/lib/src/clixon_xml_map.c +++ b/lib/src/clixon_xml_map.c @@ -608,7 +608,10 @@ xml_diff1(cxobj *x0, b2 = xml_body(x1c); if (b1 == NULL && b2 == NULL) ; - else if (b1 == NULL || b2 == NULL || strcmp(b1, b2) != 0){ + else if (b1 == NULL || b2 == NULL + || strcmp(b1, b2) != 0 + || strcmp(xml_name(x0c), xml_name(x1c)) != 0 /* Ex: choice { a:bool; b:bool } */ + ){ if (cxvec_append(x0c, changed_x0, changedlen) < 0) goto done; (*changedlen)--; /* append two vectors */ diff --git a/test/test_transaction.sh b/test/test_transaction.sh index 41759948..1147bf9c 100755 --- a/test/test_transaction.sh +++ b/test/test_transaction.sh @@ -57,6 +57,14 @@ module trans{ type int32; } } + choice csame { + leaf first { + type boolean; + } + leaf second { + type boolean; + } + } } } EOF @@ -305,6 +313,38 @@ for op in begin validate complete commit commit_done end; do let line++ done +# Variant check that only b,c + +new "8. Set first choice" +expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOtrue]]>]]>" "^]]>]]>$" + +new "netconf commit same" +expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" + +new "Set second choice" +expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLOtrue]]>]]>" "^]]>]]>$" + +# choice chanmge with same value did not show up in log +new "netconf commit second" +expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +let nr++ +let nr++ + +let line+=12 +# check complete +for op in begin validate complete commit commit_done; do + checklog "$nr main_$op change: truetrue" $line + let line++ + checklog "$nr nacm_$op change: truetrue" $line + let line++ +done + +# End is special because change does not have old element +checklog "$nr main_end change: true" $line +let line++ +# This check does not work if MOVE_TRANS_END is set +checklog "$nr nacm_end change: true" $line +let line++ if [ $BE -ne 0 ]; then new "Kill backend" # Check if premature kill