#!/usr/bin/env bash # Test for RFC6022 YANG Module for NETCONF Monitoring # Tests the location scheme by using the clixon http-data feature (only restconf=native) # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi APPNAME=example # Does not work with fcgi if [ "${WITH_RESTCONF}" = "fcgi" ]; then echo "...skipped: Must run with --with-restconf=native" rm -rf $dir if [ "$s" = $0 ]; then exit 0; else return 0; fi fi cfg=$dir/conf_yang.xml fyang=$dir/clixon-example@2022-01-01.yang # Proper test setup datapath=/data wdir=$dir/www RESTCONFIG=$(restconf_config none false $RCPROTO $enable) cat < $cfg $cfg clixon-restconf:allow-auth-none clixon-restconf:http-data ${YANG_INSTALLDIR} $fyang false /usr/local/lib/$APPNAME/clispec /usr/local/lib/$APPNAME/cli $APPNAME /usr/local/var/$APPNAME/$APPNAME.sock /usr/local/lib/$APPNAME/backend /usr/local/var/$APPNAME/$APPNAME.pidfile $dir $datapath $wdir true $RCPROTO://localhost/www $RESTCONFIG EOF cat < $dir/clixon-example@2022-01-01.yang module clixon-example{ yang-version 1.1; namespace "urn:example:clixon"; prefix ex; revision 2022-01-01; } EOF # Same via HTTP cat < $dir/www/data/clixon-example@2022-01-01.yang module clixon-example{ yang-version 1.1; namespace "urn:example:clixon"; prefix ex; revision 2022-01-01; } 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_backend -s init -f $cfg fi new "wait backend" wait_backend if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre new "start restconf daemon" start_restconf -f $cfg fi new "wait restconf" wait_restconf $RCPROTO new "Retrieving Schema List via Operation" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "" "clixon-example2022-01-01yangurn:example:clixonNETCONF$RCPROTO://localhost/www/clixon-example@2022-01-01.yang.*" # 4.2. Retrieving Schema Instances # From 2b. bar, version 2008-06-1 in YANG format, via get-schema new "Get clixon-example schema via http location" expectpart "$(curl $CURLOPTS -X GET -H 'Accept: text/html' $RCPROTO://localhost/www/clixon-example@2022-01-01.yang)" 0 "HTTP/$HVER 404" if [ $RC -ne 0 ]; then new "Kill restconf daemon" stop_restconf fi 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 new "endtest" endtest