Fixed: input RPC validation of choice (non-case)

This commit is contained in:
Olof hagsand 2022-02-03 15:14:09 +01:00
parent bdc09851f0
commit b5ecd6d5fa
3 changed files with 58 additions and 2 deletions

View file

@ -43,6 +43,8 @@ Users may have to change how they access the system
* Command field of clixon-lib:process-control RPC reply used CDATA encoding but now uses regular XML encoding
### Corrected Bugs
* 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.
## 5.5.0

View file

@ -538,7 +538,7 @@ check_choice(cxobj *xt,
continue;
break;
case Y_CHOICE:
if (yp != ytcase) /* Not same choice (not relevant) */
if (yp != ytchoice) /* Not same choice (not relevant) */
continue;
break;
default:
@ -549,7 +549,6 @@ check_choice(cxobj *xt,
goto done;
goto fail;
} /* while */
ok:
retval = 1;
done:

View file

@ -105,6 +105,29 @@ module clixon-example{
type string;
}
}
choice par1 {
leaf a1{
type string;
}
leaf b1{
type string;
}
}
choice par2 {
case nr1 {
leaf a21{
type string;
}
leaf a22{
type string;
}
}
case nr2 {
leaf b2{
type string;
}
}
}
}
output {
leaf x {
@ -134,6 +157,29 @@ module clixon-example{
type string;
}
}
choice par1 {
leaf a1{
type string;
}
leaf b1{
type string;
}
}
choice par2 {
case nr1 {
leaf a21{
type string;
}
leaf a22{
type string;
}
}
case nr2 {
leaf b2{
type string;
}
}
}
}
}
}
@ -305,6 +351,15 @@ LIST='<u1 xmlns="urn:example:clixon"><uk>bar</uk><val>1</val></u1><u1 xmlns="urn
new "netconf example rpc input list with non-unique keys (should fail)"
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><example xmlns=\"urn:example:clixon\"><x>mandatory</x>$LIST</example></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>operation-failed</error-tag><error-app-tag>data-not-unique</error-app-tag><error-severity>error</error-severity><error-info><non-unique><uk>bar</uk></non-unique></error-info></rpc-error></rpc-reply>]]>]]>$"
new "netconf choice ok"
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><example xmlns=\"urn:example:clixon\"><x>42</x><a1>x</a1><a21>x</a21><a22>x</a22></example></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><x xmlns=\"urn:example:clixon\">42</x><y xmlns=\"urn:example:clixon\">42</y><a1 xmlns=\"urn:example:clixon\">x</a1><a21 xmlns=\"urn:example:clixon\">x</a21><a22 xmlns=\"urn:example:clixon\">x</a22></rpc-reply>]]>]]>$"
new "netconf choice not-case expect fail"
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><example xmlns=\"urn:example:clixon\"><x>42</x><a1>x</a1><b1>x</b1></example></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>b1</bad-element></error-info><error-severity>error</error-severity><error-message>Element in choice statement already exists</error-message></rpc-error></rpc-reply>]]>]]>$"
new "netconf choice case expect fail"
expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO<rpc $DEFAULTNS><example xmlns=\"urn:example:clixon\"><x>42</x><a21>x</a21><b2>x</b2></example></rpc>]]>]]>" "^<rpc-reply $DEFAULTNS><rpc-error><error-type>application</error-type><error-tag>bad-element</error-tag><error-info><bad-element>b2</bad-element></error-info><error-severity>error</error-severity><error-message>Element in choice statement already exists</error-message></rpc-error></rpc-reply>]]>]]>$"
if [ $RC -ne 0 ]; then
new "Kill restconf daemon"
stop_restconf