#!/usr/bin/env bash # Restconf RFC8072 yang patch # XXX enable YANG_PACTH in include/clixon_custom.h to run this test # Use nacm module in example/main/example_restconf.c hardcoded to # andy:bar and wilma:bar # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi echo "...skipped: YANG_PATCH NYI" if [ "$s" = $0 ]; then exit 0; else return 0; fi APPNAME=example cfg=$dir/conf.xml startupdb=$dir/startup_db fjukebox=$dir/example-jukebox.yang # Define default restconfig config: RESTCONFIG RESTCONFIG=$(restconf_config user false) cat < $cfg $cfg /usr/local/share/clixon $IETFRFC $dir /usr/local/var/$APPNAME/$APPNAME.sock ietf-netconf:startup /usr/local/lib/$APPNAME/restconf $dir/restconf.pidfile $dir internal true $RESTCONFIG EOF NACM0=" true deny deny permit admin andy limited wilma admin admin permit-all * * permit Allow the 'admin' group complete access to all operations and data. limited limited limit-jukebox jukebox-example read create delete deny " cat< $startupdb <${DATASTORE_TOP}> $NACM0 EOF # An extra testmodule that includes nacm cat < $dir/example-system.yang module example-system { namespace "http://example.com/ns/example-system"; prefix "ex"; import ietf-netconf-acm { prefix nacm; } container system { leaf enable-jukebox-streaming { type boolean; } leaf extraleaf { type string; } } } EOF # Common Jukebox spec (fjukebox must be set) . ./jukebox.sh new "test params: -s startup -f $cfg" if [ $BE -ne 0 ]; then new "kill old backend" sudo clixon_backend -zf $cfg if [ $? -ne 0 ]; then err fi sudo pkill -f clixon_backend # to be sure new "start backend -s startup -f $cfg" start_backend -s startup -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 # RFC 8072 A.1.1 REQ=' add-songs-patch edit1 create /song=Bridge%20Burning Bridge Burning /media/bridge_burning.mp3 MP3 288 edit2 create /song=Rope Rope /media/rope.mp3 MP3 259 edit3 create /song=Dear%20Rosemary Dear Rosemary /media/dear_rosemary.mp3 MP3 269 ' new "RFC 8072 A.1.1 Add resources: Error." expectpart "$(curl -u andy:bar $CURLOPTS -X PATCH -H 'Content-Type: application/yang-patch+xml' -H 'Accept: application/yang-data+xml' $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Foo%20Fighters/album=Wasting%20Light -d "$REQ")" 0 "HTTP/$HVER 409" 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 # Set by restconf_config unset RESTCONFIG rm -rf $dir new "endtest" endtest