#!/usr/bin/env bash # Yang list unique tests using descendant schema node identifiers # That is, not only direct descendants as the example in RFC7890 7.8.3.1 # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exi{t 0; else return 0; fi APPNAME=example cfg=$dir/conf_yang.xml fyang=$dir/unique.yang cat < $cfg $cfg ${YANG_INSTALLDIR} $fyang /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/run/$APPNAME.sock /usr/local/var/run/$APPNAME.pidfile /usr/local/var/$APPNAME EOF # Example (the list server part) from RFC7950 Sec 7.8.3.1 w changed types cat < $fyang module unique{ yang-version 1.1; namespace "urn:example:clixon"; prefix un; list outer{ key name; leaf name{ type string; } unique c/inner/value; container c{ list inner{ key name; leaf name{ type string; } leaf value{ type string; } } } } } EOF new "test params: -f $cfg" if [ $BE -ne 0 ]; then new "kill old backend" sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err fi new "start backend -s init -f $cfg" # start new backend start_backend -s init -f $cfg fi new "wait backend" wait_backend RPC=$(cat<replace x afoo bbar y afie bfum EOF ) # RFC test two-field cases new "Add valid example" expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "${RPC}" "" "" new "netconf validate ok" expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" new "netconf discard-changes" expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "" "" "" rpc="replacexafoobfooyafiebfum" new "Add invalid example 1" expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "${rpc}" "" "applicationoperation-faileddata-not-uniqueerror/rpc/edit-config/config/outer[name=\"x\"]/c/inner/value" rpc="replacexafoobbaryafiebbar" new "Add invalid example 2" expecteof_netconf "$clixon_netconf -qef $cfg" 0 "$DEFAULTHELLO" "${rpc}" "" "applicationoperation-faileddata-not-uniqueerror/rpc/edit-config/config/outer[name=\"y\"]/c/inner/value" if [ $BE -ne 0 ]; then new "Kill backend" # Check if premature kill pid=$(pgrep -u root -f clixon_backend) if [ -z "$pid" ]; then err "backend already dead" fi # kill backend stop_backend -f $cfg fi rm -rf $dir unset RPC new "endtest" endtest