reorder clixon-restconf.yang and some test fixes

This commit is contained in:
Olof Hagsand 2021-02-14 14:48:52 +00:00
parent dcc19d3edf
commit d1e5599572
4 changed files with 50 additions and 33 deletions

View file

@ -566,6 +566,8 @@ restconf_authentication_cb(clicon_handle h,
done: done:
clicon_debug(1, "%s retval:%d authenticated:%d user:%s", clicon_debug(1, "%s retval:%d authenticated:%d user:%s",
__FUNCTION__, retval, authenticated, clicon_username_get(h)); __FUNCTION__, retval, authenticated, clicon_username_get(h));
if (username)
free(username);
if (xret) if (xret)
xml_free(xret); xml_free(xret);
return retval; return retval;

View file

@ -254,10 +254,13 @@ example_basic_auth(clicon_handle h,
goto fail; goto fail;
/* authenticated */ /* authenticated */
*userp = user; *userp = user;
user=NULL; /* to avoid free below */
*authp = 1; *authp = 1;
retval = 0; retval = 0;
done: /* error */ done: /* error */
clicon_debug(1, "%s retval:%d authp:%d userp:%s", __FUNCTION__, retval, *authp, *userp); clicon_debug(1, "%s retval:%d authp:%d userp:%s", __FUNCTION__, retval, *authp, *userp);
if (user)
free(user);
if (cb) if (cb)
cbuf_free(cb); cbuf_free(cb);
if (xt) if (xt)

View file

@ -150,6 +150,12 @@ expectpart "$(curl -u wilma:bar $CURLOPTS -X PATCH -H 'Content-Type: application
new 'user is authorized' new 'user is authorized'
expectpart "$(curl -u andy:bar $CURLOPTS -X PATCH -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Clash -d '{"example-jukebox:artist":{"name":"Clash","album":{"name":"London Calling"}}}')" 0 "HTTP/1.1 204 No Content" expectpart "$(curl -u andy:bar $CURLOPTS -X PATCH -H 'Content-Type: application/yang-data+json' $RCPROTO://localhost/restconf/data/example-jukebox:jukebox/library/artist=Clash -d '{"example-jukebox:artist":{"name":"Clash","album":{"name":"London Calling"}}}')" 0 "HTTP/1.1 204 No Content"
# Kill old
if [ $RC -ne 0 ]; then
new "Kill restconf daemon"
stop_restconf
fi
# Restart # Restart
cat<<EOF > $startupdb cat<<EOF > $startupdb
<config> <config>
@ -249,10 +255,7 @@ if [ $RC -ne 0 ]; then
stop_restconf stop_restconf
fi fi
if [ $BE -eq 0 ]; then if [ $BE -ne 0 ]; then
exit # BE
fi
new "Kill backend" new "Kill backend"
# Check if premature kill # Check if premature kill
pid=$(pgrep -u root -f clixon_backend) pid=$(pgrep -u root -f clixon_backend)
@ -261,6 +264,7 @@ if [ -z "$pid" ]; then
fi fi
# kill backend # kill backend
stop_backend -f $cfg stop_backend -f $cfg
fi
# Set by restconf_config # Set by restconf_config
unset RESTCONFIG unset RESTCONFIG

View file

@ -105,24 +105,6 @@ module clixon-restconf {
Note client-certificate applies only if ssl-enable is true and socket has ssl"; Note client-certificate applies only if ssl-enable is true and socket has ssl";
default none; default none;
} }
leaf server-cert-path {
type string;
description
"Path to server certificate file.
Note only applies if socket has ssl enabled";
}
leaf server-key-path {
type string;
description
"Path to server key file
Note only applies if socket has ssl enabled";
}
leaf server-ca-cert-path {
type string;
description
"Path to server CA cert file
Note only applies if socket has ssl enabled";
}
leaf debug { leaf debug {
description description
"Set debug level of restconf daemon. "Set debug level of restconf daemon.
@ -148,21 +130,47 @@ module clixon-restconf {
which may be desirable for performance or tests which may be desirable for performance or tests
This replaces the CLICON_RESTCONF_PRETTY option in clixon-config.yang"; This replaces the CLICON_RESTCONF_PRETTY option in clixon-config.yang";
} }
/* From this point only specific options
* First fcgi-specific options
*/
leaf fcgi-socket { leaf fcgi-socket {
if-feature fcgi; if-feature fcgi; /* Set by default by fcgi clixon_restconf daemon */
type string; type string;
default "/www-data/fastcgi_restconf.sock"; default "/www-data/fastcgi_restconf.sock";
description description
"FastCGI unix socket. Should be specified in webserver "Path to FastCGI unix socket. Should be specified in webserver
Eg in nginx: fastcgi_pass unix:/www-data/clicon_restconf.sock Eg in nginx: fastcgi_pass unix:/www-data/clicon_restconf.sock
Only if with-restconf=fcgi, NOT evhtp Only if with-restconf=fcgi, NOT evhtp
This replaces CLICON_RESTCONF_PATH option in clixon-config.yang"; This replaces CLICON_RESTCONF_PATH option in clixon-config.yang";
} }
/* Second, evhtp-specific options */
leaf server-cert-path {
type string;
description
"Path to server certificate file.
Note only applies if socket has ssl enabled";
}
leaf server-key-path {
type string;
description
"Path to server key file
Note only applies if socket has ssl enabled";
}
leaf server-ca-cert-path {
type string;
description
"Path to server CA cert file
Note only applies if socket has ssl enabled";
}
list socket { list socket {
description
"List of server sockets that the restconf daemon listens to";
key "namespace address port"; key "namespace address port";
leaf namespace { leaf namespace {
type string; type string;
description "indicates a namespace for instance. On platforms where namespaces are not suppported, always 'default'"; description
"Network namespace.
On platforms where namespaces are not suppported, always 'default'";
} }
leaf address { leaf address {
type inet:ip-address; type inet:ip-address;
@ -170,7 +178,7 @@ module clixon-restconf {
} }
leaf port { leaf port {
type inet:port-number; type inet:port-number;
description "IP port to bind to"; description "TCP port to bind to";
} }
leaf ssl { leaf ssl {
type boolean; type boolean;