- Added Restconf-style xml/json message bodies everywhere
- Added api_return_err0() and changed many calls to that instead of api_return_err - Added netconf_operation_not_supported_xml()
This commit is contained in:
parent
c50f9f8056
commit
ad08200931
17 changed files with 496 additions and 660 deletions
|
|
@ -172,7 +172,7 @@ if [ $BE -ne 0 ]; then
|
|||
start_backend -s init -f $cfg -- -sS $fstate -v /table/parameter[name="4242"]
|
||||
fi
|
||||
|
||||
new "waiting"
|
||||
new "wait backend"
|
||||
wait_backend
|
||||
|
||||
if [ $RC -ne 0 ]; then
|
||||
|
|
@ -181,16 +181,15 @@ if [ $RC -ne 0 ]; then
|
|||
|
||||
new "start restconf daemon"
|
||||
start_restconf -f $cfg
|
||||
|
||||
new "waiting"
|
||||
wait_restconf
|
||||
fi
|
||||
|
||||
new "wait restconf"
|
||||
wait_restconf
|
||||
|
||||
new "restconf POST initial tree"
|
||||
expectpart "$(curl $CURLOPTS -X POST -H 'Content-Type: application/yang-data+xml' -d "$XML" $RCPROTO://localhost/restconf/data)" 0 'HTTP/1.1 201 Created'
|
||||
|
||||
new "restconf GET initial datastore"
|
||||
#echo "curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPROTO://localhost/restconf/data/example:a=0"
|
||||
expectpart "$(curl $CURLOPTS -X GET -H 'Accept: application/yang-data+xml' $RCPROTO://localhost/restconf/data/example:a=0)" 0 'HTTP/1.1 200 OK' "$XML"
|
||||
|
||||
# XXX cannot get this to work for all combinations of nc/netcat fcgi/native
|
||||
|
|
@ -233,7 +232,18 @@ Accept: application/yang-data+xml
|
|||
|
||||
EOF
|
||||
)" 0 "HTTP/1.1 405" "Not Allowed" # nginx uses "method not allowed" evhtp "not allowed"
|
||||
fi # Cannot get to work
|
||||
|
||||
# XXX error from evhtp parsing, should pick up error code
|
||||
new "restconf GET wrong http version raw"
|
||||
expectpart "$(${netcat} 127.0.0.1 80 <<EOF
|
||||
GET /restconf/data/example:a=0 HTTP/a.1
|
||||
Host: localhost
|
||||
Accept: application/yang-data+xml
|
||||
|
||||
EOF
|
||||
)" 0 "HTTP/1.1 400 Bad Request" # native: '<error-tag>malformed-message</error-tag><error-message>The requested URL or a header is in some way badly formed</error-message>'
|
||||
|
||||
fi # netcat Cannot get to work on all platforms
|
||||
|
||||
new "restconf XYZ not found"
|
||||
expectpart "$(curl $CURLOPTS -X XYS -H 'Accept: application/yang-data+xml' $RCPROTO://localhost/restconf/data/example:a=0)" 0 'HTTP/1.1 404 Not Found'
|
||||
|
|
@ -241,7 +251,7 @@ expectpart "$(curl $CURLOPTS -X XYS -H 'Accept: application/yang-data+xml' $RCPR
|
|||
# XXX dont work w fcgi
|
||||
if [ "${WITH_RESTCONF}" = "native" ]; then
|
||||
new "restconf HEAD not allowed"
|
||||
expectpart "$(curl $CURLOPTS -X HEAD -H 'Accept: application/yang-data+xml' $RCPROTO://localhost/restconf)" 0 "HTTP/1.1 405" "Not Allowed"
|
||||
expectpart "$(curl $CURLOPTS -X HEAD -H 'Accept: application/yang-data+xml' $RCPROTO://localhost/restconf)" 0 "HTTP/1.1 405" "Not Allowed" "Allow: GET"
|
||||
fi
|
||||
|
||||
new "restconf GET non-qualified list"
|
||||
|
|
|
|||
|
|
@ -114,6 +114,9 @@ expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:c
|
|||
new "restconf GET interface subtree"
|
||||
expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example:cont1/interface=local0)" 0 "HTTP/1.1 200 OK" '{"example:interface":\[{"name":"local0","type":"regular"}\]}'
|
||||
|
||||
new "restconf PUT interface without media"
|
||||
expectpart "$(curl $CURLOPTS -X PUT $RCPROTO://localhost/restconf/data/example:cont1/interface=local0 -d '{"example:interface":{"name":"local0","type":"foo"}}')" 0 "HTTP/1.1 415 Unsupported Media Type"
|
||||
|
||||
new "restconf GET interface subtree xml"
|
||||
ret=$(curl $CURLOPTS -H "Accept: application/yang-data+xml" -X GET $RCPROTO://localhost/restconf/data/example:cont1/interface=local0)
|
||||
expect='<interface xmlns="urn:example:clixon"><name>local0</name><type>regular</type></interface>'
|
||||
|
|
|
|||
|
|
@ -266,6 +266,9 @@ EOF
|
|||
new "admin set x 42"
|
||||
expectpart "$(curl $CURLOPTS --key $certdir/andy.key --cert $certdir/andy.crt -X PUT -H "Content-Type: application/yang-data+json" -d '{"example:x":42}' $RCPROTO://localhost/restconf/data/example:x)" 0 "HTTP/1.1 204 No Content"
|
||||
|
||||
new "admin set x 42 without media"
|
||||
expectpart "$(curl $CURLOPTS --key $certdir/andy.key --cert $certdir/andy.crt -X PUT -d '{"example:x":42}' $RCPROTO://localhost/restconf/data/example:x)" 0 "HTTP/1.1 415 Unsupported Media Type" '{"ietf-restconf:errors":{"error":{"error-type":"protocol","error-tag":"operation-not-supported","error-severity":"error","error-message":"Unsupported Media Type"}}}'
|
||||
|
||||
new "admin get x 42"
|
||||
expectpart "$(curl $CURLOPTS --key $certdir/andy.key --cert $certdir/andy.crt -X GET $RCPROTO://localhost/restconf/data/example:x)" 0 "HTTP/1.1 200 OK" '{"example:x":42}'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue