Fixed a cornercase of RFC 7950 Sec 7.9, a choice witout case with sub-containers

This commit is contained in:
Olof hagsand 2022-05-16 13:12:59 +02:00
parent 5bd64712c7
commit 3a336838f7
3 changed files with 52 additions and 7 deletions

View file

@ -106,6 +106,25 @@ module system{
}
}
}
/* Choice shorthand with sub-container */
container choice-subcontainer {
presence true;
choice name {
container udp {
leaf udp1{
type string;
}
leaf udp2{
type string;
}
}
container tcp {
leaf tcp1{
type string;
}
}
}
}
}
}
EOF
@ -335,6 +354,29 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS>
new "netconf validate ok"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "netconf discard-changes"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><discard-changes/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
# Merge in choice-subcontainer
new "netconf choice sub-container 1st leaf"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><system xmlns=\"urn:example:config\" nc:operation=\"replace\" xmlns:nc=\"$BASENS\">
<choice-subcontainer><udp><udp1>42</udp1></udp></choice-subcontainer>
</system></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "netconf choice sub-container 2nd leaf (dont remove 1st)"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><edit-config><target><candidate/></target><config><system xmlns=\"urn:example:config\" xmlns:nc=\"$BASENS\">
<choice-subcontainer><udp><udp2 nc:operation=\"replace\">99</udp2></udp></choice-subcontainer>
</system></config></edit-config></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "netconf get both items"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "<rpc-reply $DEFAULTNS><data><system xmlns=\"urn:example:config\"><choice-subcontainer><udp><udp1>42</udp1><udp2>99</udp2></udp></choice-subcontainer></system></data></rpc-reply>" ""
new "netconf validate ok"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><validate><source><candidate/></source></validate></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "netconf discard-changes"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><discard-changes/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
if [ $RC -ne 0 ]; then
new "Kill restconf daemon"
stop_restconf