undef state path bypass

This commit is contained in:
Olof hagsand 2020-05-04 13:35:04 +02:00
parent 592c513b83
commit 3ab1f50a19
3 changed files with 109 additions and 5 deletions

View file

@ -249,7 +249,7 @@ clixon_plugin_statedata_all(clicon_handle h,
clicon_log_xml(LOG_DEBUG, x, "%s STATE:", __FUNCTION__);
#endif
#ifdef USE_STATE_PATH_KLUDGE
/* This kludge skips all yang binding and validation of paths begining with a
/* This kludge skips all yang binding and validation of paths beginning with a
* specific prefix
* Note that there are many problems with this kludge.
*/
@ -294,7 +294,11 @@ clixon_plugin_statedata_all(clicon_handle h,
goto done;
}
/*! Create and initialize transaction */
/*! Create and initialize a validate/commit transaction
* @retval td New alloced transaction,
* @retval NULL Error
* @see transaction_free which deallocates the returned handle
*/
transaction_data_t *
transaction_new(void)
{
@ -310,7 +314,10 @@ transaction_new(void)
return td;
}
/*! Free transaction structure */
/*! Free transaction structure
*
* @param[in] td Transaction data will be deallocated after the call
*/
int
transaction_free(transaction_data_t *td)
{
@ -330,6 +337,13 @@ transaction_free(transaction_data_t *td)
return 0;
}
/*! Call single plugin transaction_begin() before a validate/commit.
* @param[in] cp Plugin handle
* @param[in] h Clixon handle
* @param[in] td Transaction data
* @retval 0 OK
* @retval -1 Error
*/
int
plugin_transaction_begin_one(clixon_plugin *cp,
clicon_handle h,
@ -375,6 +389,13 @@ plugin_transaction_begin_all(clicon_handle h,
return retval;
}
/*! Call single plugin transaction_validate() in a validate/commit transaction
* @param[in] cp Plugin handle
* @param[in] h Clixon handle
* @param[in] td Transaction data
* @retval 0 OK
* @retval -1 Error
*/
int
plugin_transaction_validate_one(clixon_plugin *cp,
clicon_handle h,
@ -418,6 +439,14 @@ plugin_transaction_validate_all(clicon_handle h,
return retval;
}
/*! Call single plugin transaction_complete() in a validate/commit transaction
* complete is called after validate (before commit)
* @param[in] cp Plugin handle
* @param[in] h Clixon handle
* @param[in] td Transaction data
* @retval 0 OK
* @retval -1 Error
*/
int
plugin_transaction_complete_one(clixon_plugin *cp,
clicon_handle h,
@ -493,6 +522,14 @@ plugin_transaction_revert_all(clicon_handle h,
return retval; /* ignore errors */
}
/*! Call single plugin transaction_commit() in a commit transaction
* @param[in] cp Plugin handle
* @param[in] h Clixon handle
* @param[in] td Transaction data
* @retval 0 OK
* @retval -1 Error
*/
int
plugin_transaction_commit_one(clixon_plugin *cp,
clicon_handle h,
@ -544,6 +581,14 @@ plugin_transaction_commit_all(clicon_handle h,
return retval;
}
/*! Call single plugin transaction_commit_done() in a commit transaction
* @param[in] cp Plugin handle
* @param[in] h Clixon handle
* @param[in] td Transaction data
* @retval 0 OK
* @retval -1 Error
*/
int
plugin_transaction_commit_done_one(clixon_plugin *cp,
clicon_handle h,
@ -588,6 +633,13 @@ plugin_transaction_commit_done_all(clicon_handle h,
return retval;
}
/*! Call single plugin transaction_end() in a commit/validate transaction
* @param[in] cp Plugin handle
* @param[in] h Clixon handle
* @param[in] td Transaction data
* @retval 0 OK
* @retval -1 Error
*/
int
plugin_transaction_end_one(clixon_plugin *cp,
clicon_handle h,

View file

@ -102,7 +102,8 @@
#define STATE_ORDERED_BY_SYSTEM
/*! Restart specific backend plugins
* Experimental code for now, needs some testing
* Note, depending on plugin callbacks, there may be other dependencies which may make this
* difficult in the general case.
*/
#undef RESTART_PLUGIN_RPC
@ -132,5 +133,5 @@
* This is a temporary option which will go away in future releases, therefore
* marked as obsolete.";
*/
#define USE_STATE_PATH_KLUDGE
#undef USE_STATE_PATH_KLUDGE

51
test/test_xml_validate.sh Executable file
View file

@ -0,0 +1,51 @@
#!/usr/bin/env bash
# Test for XML validations, Mainly Yang encoding
# Mainly negative checks, ie input correct but invalid XML and expect to get
# error message back.
# Triggered by the fact that clixon accepted duplicate containers.
# Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
: ${clixon_util_xml:="clixon_util_xml -D $DBG"}
fyang=$dir/example.yang
cat <<EOF > $fyang
module example {
yang-version 1.1;
namespace "urn:example:example";
prefix ex;
revision 2019-01-13;
container a{
container b{
leaf c {
type string;
}
}
}
}
EOF
new "xml unknown yang, fail"
echo "$clixon_util_xml -uy $fyang -vo"
expecteof "$clixon_util_xml -uy $fyang -vo" 0 '<a xmlns="urn:example:example"><xxx/></a>' 2> /dev/null
new "xml double containers no validation, ok"
expecteof "$clixon_util_xml -y $fyang -o" 0 '<a xmlns="urn:example:example"><b><c>x</c></b><b><c>y</c></b></a>' '^<a xmlns="urn:example:example"><b><c>x</c></b><b><c>y</c></b></a>$'
new "xml double containers validation, fail"
expecteof "$clixon_util_xml -y $fyang -vo" 255 '<a xmlns="urn:example:example"><b><c>x</c></b><b><c>y</c></b></a>' 2> /dev/null
#'xml validation error: protocol operation-failed'
new "xml double leafs no validation, ok"
expecteof "$clixon_util_xml -y $fyang -o" 0 '<a xmlns="urn:example:example"><b><c>x</c><c>y</c></b></a>' '<a xmlns="urn:example:example"><b><c>x</c><c>y</c></b></a>'
new "xml double leafs validation, fail"
expecteof "$clixon_util_xml -y $fyang -vo" 255 '<a xmlns="urn:example:example"><b><c>x</c><c>y</c></b></a>' 2> /dev/null
#'xml validation error: protocol operation-failed'
rm -rf $dir
# unset conditional parameters
unset clixon_util_xml