* Fixed: [statement: require-instance should be true if not present according to rfc7950 Sec 9.9.3](https://github.com/clicon/clixon/issues/302)

This commit is contained in:
Olof hagsand 2022-02-17 10:09:23 +01:00
parent 12695c5d87
commit 1324c914dc
5 changed files with 22 additions and 13 deletions

View file

@ -46,6 +46,9 @@ Expected: March 2022
Users may have to change how they access the system
* YANG leafref `require-instance` default changed to `true`
* This makes leafref validation stricter
* See [statement: require-instance should be true if not present according to rfc7950 Sec 9.9.3](https://github.com/clicon/clixon/issues/302)
* `configure --with-wwwdir=<dir>` is removed
* Command field of clixon-lib:process-control RPC reply used CDATA encoding but now uses regular XML encoding
@ -59,9 +62,8 @@ Users may have to change how they access the system
### Corrected Bugs
* Fixed: [statement: require-instance should be true if not present according to rfc7950 Sec 9.9.3](https://github.com/clicon/clixon/issues/302)
* See also API changes
* Fixed: input RPC validation of choice (non-case)
* Fixed: More than one unknown/extension in combination with augment of extension resulted in extension being skipped.

View file

@ -134,7 +134,7 @@ validate_leafref(cxobj *xt,
char *path_arg;
yang_stmt *ymod;
cg_var *cv;
int require_instance = 0;
int require_instance = 1;
/* require instance */
if ((yreqi = yang_find(ytype, Y_REQUIRE_INSTANCE, NULL)) != NULL){

View file

@ -1,5 +1,6 @@
#!/usr/bin/env bash
# transitive leafref->leafref leafref->identityref completion
#
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
@ -67,31 +68,33 @@ module example-leafref{
}
/* first level leafref */
container leafrefs {
description "Relative path";
description "Leafref relative path, no require-instance";
list leafref{
key name;
leaf name {
type leafref{
path "../../../table/parameter/name";
require-instance false;
}
}
}
}
/* first level leafref absolute */
container leafrefstop {
description "Same but absolute path";
container leafrefsabs {
description "Leafref absolute path, no require-instance";
list leafref{
key name;
leaf name {
type leafref{
path "/table/parameter/name";
require-instance false;
}
}
}
}
/* first level leafref require-instance */
container leafrefsreqi {
description "Same but absolute path";
container leafrefsreqinst {
description "Leafref absolute path, require-instance true";
list leafref{
key name;
leaf name {
@ -105,6 +108,7 @@ module example-leafref{
/* first level identityrefs */
container identityrefs {
list identityref{
description "Identityref base";
key name;
leaf name {
type identityref{
@ -120,6 +124,7 @@ module example-leafref{
leaf name {
type leafref{
path "../../../leafrefs/leafref/name";
require-instance false;
}
}
}
@ -131,6 +136,7 @@ module example-leafref{
leaf name {
type leafref{
path "../../../identityrefs/identityref/name";
require-instance false;
}
}
}
@ -175,10 +181,10 @@ new "expand leafref 1st level"
expectpart "$(echo "set leafrefs leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93"
new "expand leafref top"
expectpart "$(echo "set leafrefstop leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93"
expectpart "$(echo "set leafrefsabs leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93"
new "expand leafref require-instance"
expectpart "$(echo "set leafrefsreqi leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93"
expectpart "$(echo "set leafrefsreqinst leafref ?" | $clixon_cli -f $cfg 2> /dev/null)" 0 "91" "92" "93"
# First level id/leaf refs
new "set identityref des"
@ -217,7 +223,7 @@ expectpart "$($clixon_cli -1 -f $cfg -l o commit)" 0 "^$"
# require-instance
new "set leafref require-instance 99 (non-existent)"
expectpart "$($clixon_cli -1 -f $cfg set leafrefsreqi leafref 99)" 0 "^"$
expectpart "$($clixon_cli -1 -f $cfg set leafrefsreqinst leafref 99)" 0 "^"$
new "cli validate expect failure"
expectpart "$($clixon_cli -1 -f $cfg -l o validate)" 255 "Leafref validation failed: No leaf 99 matching path"

View file

@ -63,7 +63,6 @@ module leafref{
leaf ref{
type leafref {
path "/ex:sender-config/ex:name";
require-instance true;
}
}
}
@ -90,6 +89,7 @@ module leafref{
leaf ref{
type leafref {
path "/ex:sender-config/ex:name";
require-instance false;
}
}
}

View file

@ -79,6 +79,7 @@ cat <<EOF > $dir/startup_db
</config>
</fdb>
<config>
<name>default</name>
<type>oc-ni-types:DEFAULT_INSTANCE</type>
<enabled>true</enabled>
<router-id>1.2.3.4</router-id>