modified restconf err
This commit is contained in:
parent
22307e0a9e
commit
a547b3f31d
4 changed files with 57 additions and 15 deletions
|
|
@ -11,14 +11,14 @@
|
||||||
|
|
||||||
### API changes on existing features (you may need to change your code)
|
### API changes on existing features (you may need to change your code)
|
||||||
* RESTCONF error reporting
|
* RESTCONF error reporting
|
||||||
* Invalid api-path syntax error changed from 412 operation-failed to 404 invalid-value. For example, change from
|
* Invalid api-path syntax (eg non-matching yang) error changed from 412 operation-failed to 400 unknown-element / invalid-value. For example, change from
|
||||||
```
|
```
|
||||||
HTTP/1.1 412 Precondition Failed
|
HTTP/1.1 412 Precondition Failed
|
||||||
{"ietf-restconf:errors":{"error":{"error-type":"protocol","error-tag":"operation-failed","error-severity":"error","error-message":"No such yang module: badmodule"}}}
|
{"ietf-restconf:errors":{"error":{"error-type":"protocol","error-tag":"operation-failed","error-severity":"error","error-message":"No such yang module: badmodule"}}}
|
||||||
```
|
```
|
||||||
to:
|
to:
|
||||||
```
|
```
|
||||||
HTTP/1.1 404 Not Found
|
HTTP/1.1 400 Bad Request
|
||||||
{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"No such yang module: badmodule"}}}
|
{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"No such yang module: badmodule"}}}
|
||||||
```
|
```
|
||||||
* Typical installation should now add a `clicon` user (as well as group)
|
* Typical installation should now add a `clicon` user (as well as group)
|
||||||
|
|
|
||||||
|
|
@ -332,7 +332,7 @@ netconf_bad_attribute_xml(cxobj **xret,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! Create Netconf unknwon-attribute error XML tree according to RFC 6241 App A
|
/*! Create Netconf unknown-attribute error XML tree according to RFC 6241 App A
|
||||||
*
|
*
|
||||||
* An unexpected attribute is present.
|
* An unexpected attribute is present.
|
||||||
* @param[out] cb CLIgen buf. Error XML is written in this buffer
|
* @param[out] cb CLIgen buf. Error XML is written in this buffer
|
||||||
|
|
|
||||||
|
|
@ -2465,12 +2465,7 @@ api_path2xpath_cvv(cvec *api_path,
|
||||||
else
|
else
|
||||||
y = yang_find_datanode(y, name);
|
y = yang_find_datanode(y, name);
|
||||||
if (y == NULL){
|
if (y == NULL){
|
||||||
if ((cberr = cbuf_new()) == NULL){
|
if (netconf_unknown_element_xml(xerr, "application", name, "Unknown element") < 0)
|
||||||
clicon_err(OE_UNIX, errno, "cbuf_new");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
cprintf(cberr, "Unknown element: '%s'", name);
|
|
||||||
if (netconf_invalid_value_xml(xerr, "application", cbuf_get(cberr)) < 0)
|
|
||||||
goto done;
|
goto done;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
|
||||||
APPNAME=example
|
APPNAME=example
|
||||||
|
|
||||||
cfg=$dir/conf.xml
|
cfg=$dir/conf.xml
|
||||||
fyang=$dir/restconf.yang
|
fyang=$dir/example.yang
|
||||||
|
fyang2=$dir/aug.yang
|
||||||
fxml=$dir/initial.xml
|
fxml=$dir/initial.xml
|
||||||
|
|
||||||
# <CLICON_YANG_MODULE_MAIN>example</CLICON_YANG_MODULE_MAIN>
|
# <CLICON_YANG_MODULE_MAIN>example</CLICON_YANG_MODULE_MAIN>
|
||||||
|
|
@ -27,7 +28,7 @@ cat <<EOF > $cfg
|
||||||
<clixon-config xmlns="http://clicon.org/config">
|
<clixon-config xmlns="http://clicon.org/config">
|
||||||
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
<CLICON_CONFIGFILE>$cfg</CLICON_CONFIGFILE>
|
||||||
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>/usr/local/share/clixon</CLICON_YANG_DIR>
|
||||||
<CLICON_YANG_DIR>$IETFRFC</CLICON_YANG_DIR>
|
<CLICON_YANG_DIR>$dir</CLICON_YANG_DIR>
|
||||||
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
|
||||||
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
<CLICON_RESTCONF_PRETTY>false</CLICON_RESTCONF_PRETTY>
|
||||||
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
<CLICON_SOCK>/usr/local/var/$APPNAME/$APPNAME.sock</CLICON_SOCK>
|
||||||
|
|
@ -36,11 +37,32 @@ cat <<EOF > $cfg
|
||||||
</clixon-config>
|
</clixon-config>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
cat <<EOF > $fyang2
|
||||||
|
module augm{
|
||||||
|
yang-version 1.1;
|
||||||
|
namespace "urn:example:aug";
|
||||||
|
prefix aug;
|
||||||
|
description "Used as a base for augment";
|
||||||
|
container route-state {
|
||||||
|
description
|
||||||
|
"Root container for routing models";
|
||||||
|
config "false";
|
||||||
|
container dynamic {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
cat <<EOF > $fyang
|
cat <<EOF > $fyang
|
||||||
module example{
|
module example{
|
||||||
yang-version 1.1;
|
yang-version 1.1;
|
||||||
namespace "urn:example:clixon";
|
namespace "urn:example:clixon";
|
||||||
prefix ex;
|
prefix ex;
|
||||||
|
import aug {
|
||||||
|
description "Just for augment";
|
||||||
|
prefix "aug";
|
||||||
|
}
|
||||||
|
|
||||||
list a {
|
list a {
|
||||||
key k;
|
key k;
|
||||||
leaf k {
|
leaf k {
|
||||||
|
|
@ -62,6 +84,17 @@ module example{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
augment "/aug:route-config/aug:dynamic" {
|
||||||
|
container ospf {
|
||||||
|
container routers {
|
||||||
|
container auto-cost {
|
||||||
|
leaf reference-bandwidth {
|
||||||
|
type uint32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
@ -101,12 +134,26 @@ new "restconf GET initial datastore"
|
||||||
expecteq "$(curl -s -X GET -H 'Accept: application/yang-data+xml' http://localhost/restconf/data/example:a)" 0 "$XML
|
expecteq "$(curl -s -X GET -H 'Accept: application/yang-data+xml' http://localhost/restconf/data/example:a)" 0 "$XML
|
||||||
"
|
"
|
||||||
|
|
||||||
new "restconf GET non-existent container header"
|
|
||||||
expectfn "curl -s -I -X GET http://localhost/restconf/data/example:a/c" 0 "HTTP/1.1 404 Not Found"
|
|
||||||
|
|
||||||
new "restconf GET non-existent container body"
|
new "restconf GET non-existent container body"
|
||||||
expectfn "curl -s -X GET http://localhost/restconf/data/example:a/c" 0 '{"ietf-restconf:errors":{"error":{"rpc-error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Instance does not exist"}}}}'
|
expectpart "$(curl -si -X GET http://localhost/restconf/data/example:a/c)" 0 'HTTP/1.1 404 Not Found' '{"ietf-restconf:errors":{"error":{"rpc-error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Instance does not exist"}}}}'
|
||||||
|
|
||||||
|
new "restconf GET invalid (no yang) container body"
|
||||||
|
expectpart "$(curl -si -X GET http://localhost/restconf/data/example:a/xxx)" 0 'HTTP/1.1 400 Bad Request' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"unknown-element","error-info":{"bad-element":"xxx"},"error-severity":"error","error-message":"Unknown element"}}}'
|
||||||
|
|
||||||
|
new "restconf GET invalid (no yang) element"
|
||||||
|
expectpart "$(curl -si -X GET http://localhost/restconf/data/example:xxx)" 0 'HTTP/1.1 400 Bad Request' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"unknown-element","error-info":{"bad-element":"xxx"},"error-severity":"error","error-message":"Unknown element"}}}'
|
||||||
|
|
||||||
|
if false; then
|
||||||
|
new "restconf POST non-existent (no yang) element"
|
||||||
|
# should be invalid element
|
||||||
|
expectpart "$(curl -is -X POST -H 'Content-Type: application/yang-data+xml' -d "$XML" http://localhost/restconf/data/example:a=23/xxx)" 0 'HTTP/1.1 400 Bad Request' '{"ietf-restconf:errors":{"error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Unknown element: '
|
||||||
|
|
||||||
|
|
||||||
|
new "restconf GET multi-namespace path"
|
||||||
|
# simplify yang
|
||||||
|
# works for config?
|
||||||
|
expectpart "$(curl -si -X GET http://localhost/restconf/data/augm:route-state/dynamic/ospf/routers/auto-cost/reference-bandwidth)" 0 'HTTP/1.1 404 Not Found' '{"ietf-restconf:errors":{"error":{"rpc-error":{"error-type":"application","error-tag":"invalid-value","error-severity":"error","error-message":"Unknown element: 'xxx'"}}}}'
|
||||||
|
fi
|
||||||
new "Kill restconf daemon"
|
new "Kill restconf daemon"
|
||||||
stop_restconf
|
stop_restconf
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue