Fixed: The module clixon-rfc5277 was always enabled, but should only be enabled when CLICON_STREAM_DISCOVERY_RFC5277 is enabled.

This commit is contained in:
Olof hagsand 2020-06-14 18:01:31 +02:00
parent e898dda016
commit cea5746597
4 changed files with 94 additions and 90 deletions

View file

@ -60,6 +60,10 @@ Expected: July 2020
* Added new function `clicon_xml2str()` to complement xml_print and others that returns a malloced string. * Added new function `clicon_xml2str()` to complement xml_print and others that returns a malloced string.
* Added new function `xml_child_index_each()` to iterate over the children of an XML node according to the order defined by an explicit index variable. This is a complement to `xml_child_each()` which iterates using the default order. * Added new function `xml_child_index_each()` to iterate over the children of an XML node according to the order defined by an explicit index variable. This is a complement to `xml_child_each()` which iterates using the default order.
### Corrected Bugs
* Fixed: The module `clixon-rfc5277` was always enabled, but should only be enabled when `CLICON_STREAM_DISCOVERY_RFC5277` is enabled.
## 4.5.0 ## 4.5.0
12 May 2020 12 May 2020

View file

@ -65,166 +65,166 @@
#include "restconf_fcgi_lib.h" #include "restconf_fcgi_lib.h"
/*! HTTP error 400 /*! HTTP error 400
* @param[in] r Fastcgi request handle * @param[in] req Fastcgi request handle
*/ */
int int
restconf_badrequest(clicon_handle h, restconf_badrequest(clicon_handle h,
FCGX_Request *r) FCGX_Request *req)
{ {
char *path; char *path;
path = clixon_restconf_param_get(h, "REQUEST_URI"); path = clixon_restconf_param_get(h, "REQUEST_URI");
FCGX_SetExitStatus(400, r->out); FCGX_SetExitStatus(400, req->out);
FCGX_FPrintF(r->out, "Status: 400 Bad Request\r\n"); /* 400 bad request */ FCGX_FPrintF(req->out, "Status: 400 Bad Request\r\n"); /* 400 bad request */
FCGX_FPrintF(r->out, "Content-Type: text/html\r\n\r\n"); FCGX_FPrintF(req->out, "Content-Type: text/html\r\n\r\n");
FCGX_FPrintF(r->out, "<h1>Clixon Bad request/h1>\n"); FCGX_FPrintF(req->out, "<h1>Clixon Bad request/h1>\n");
FCGX_FPrintF(r->out, "The requested URL %s or data is in some way badly formed.\n", FCGX_FPrintF(req->out, "The requested URL %s or data is in some way badly formed.\n",
path); path);
return 0; return 0;
} }
/*! HTTP error 401 /*! HTTP error 401
* @param[in] r Fastcgi request handle * @param[in] req Fastcgi request handle
*/ */
int int
restconf_unauthorized(clicon_handle h, restconf_unauthorized(clicon_handle h,
FCGX_Request *r) FCGX_Request *req)
{ {
char *path; char *path;
path = clixon_restconf_param_get(h, "REQUEST_URI"); path = clixon_restconf_param_get(h, "REQUEST_URI");
FCGX_SetExitStatus(401, r->out); FCGX_SetExitStatus(401, req->out);
FCGX_FPrintF(r->out, "Status: 401 Unauthorized\r\n"); /* 401 unauthorized */ FCGX_FPrintF(req->out, "Status: 401 Unauthorized\r\n"); /* 401 unauthorized */
FCGX_FPrintF(r->out, "Content-Type: text/html\r\n\r\n"); FCGX_FPrintF(req->out, "Content-Type: text/html\r\n\r\n");
FCGX_FPrintF(r->out, "<error-tag>access-denied</error-tag>\n"); FCGX_FPrintF(req->out, "<error-tag>access-denied</error-tag>\n");
FCGX_FPrintF(r->out, "The requested URL %s was unauthorized.\n", path); FCGX_FPrintF(req->out, "The requested URL %s was unauthorized.\n", path);
return 0; return 0;
} }
/*! HTTP error 403 /*! HTTP error 403
* @param[in] r Fastcgi request handle * @param[in] req Fastcgi request handle
*/ */
int int
restconf_forbidden(clicon_handle h, restconf_forbidden(clicon_handle h,
FCGX_Request *r) FCGX_Request *req)
{ {
char *path; char *path;
path = clixon_restconf_param_get(h, "REQUEST_URI"); path = clixon_restconf_param_get(h, "REQUEST_URI");
FCGX_SetExitStatus(403, r->out); FCGX_SetExitStatus(403, req->out);
FCGX_FPrintF(r->out, "Status: 403 Forbidden\r\n"); /* 403 forbidden */ FCGX_FPrintF(req->out, "Status: 403 Forbidden\r\n"); /* 403 forbidden */
FCGX_FPrintF(r->out, "Content-Type: text/html\r\n\r\n"); FCGX_FPrintF(req->out, "Content-Type: text/html\r\n\r\n");
FCGX_FPrintF(r->out, "<h1>Forbidden</h1>\n"); FCGX_FPrintF(req->out, "<h1>Forbidden</h1>\n");
FCGX_FPrintF(r->out, "The requested URL %s was forbidden.\n", path); FCGX_FPrintF(req->out, "The requested URL %s was forbidden.\n", path);
return 0; return 0;
} }
/*! HTTP error 404 /*! HTTP error 404
* @param[in] r Fastcgi request handle * @param[in] req Fastcgi request handle
*/ */
int int
restconf_notfound(clicon_handle h, restconf_notfound(clicon_handle h,
FCGX_Request *r) FCGX_Request *req)
{ {
char *path; char *path;
path = clixon_restconf_param_get(h, "REQUEST_URI"); path = clixon_restconf_param_get(h, "REQUEST_URI");
FCGX_SetExitStatus(404, r->out); FCGX_SetExitStatus(404, req->out);
FCGX_FPrintF(r->out, "Status: 404 Not Found\r\n"); /* 404 not found */ FCGX_FPrintF(req->out, "Status: 404 Not Found\r\n"); /* 404 not found */
FCGX_FPrintF(r->out, "Content-Type: text/html\r\n\r\n"); FCGX_FPrintF(req->out, "Content-Type: text/html\r\n\r\n");
FCGX_FPrintF(r->out, "<h1>Not Found</h1>\n"); FCGX_FPrintF(req->out, "<h1>Not Found</h1>\n");
FCGX_FPrintF(r->out, "Not Found\n"); FCGX_FPrintF(req->out, "Not Found\n");
FCGX_FPrintF(r->out, "The requested URL %s was not found on this server.\n", FCGX_FPrintF(req->out, "The requested URL %s was not found on this server.\n",
path); path);
return 0; return 0;
} }
/*! HTTP error 406 Not acceptable /*! HTTP error 406 Not acceptable
* @param[in] r Fastcgi request handle * @param[in] req Fastcgi request handle
*/ */
int int
restconf_notacceptable(clicon_handle h, restconf_notacceptable(clicon_handle h,
FCGX_Request *r) FCGX_Request *req)
{ {
char *path; char *path;
path = clixon_restconf_param_get(h, "REQUEST_URI"); path = clixon_restconf_param_get(h, "REQUEST_URI");
FCGX_SetExitStatus(406, r->out); FCGX_SetExitStatus(406, req->out);
FCGX_FPrintF(r->out, "Status: 406 Not Acceptable\r\n"); /* 406 not acceptible */ FCGX_FPrintF(req->out, "Status: 406 Not Acceptable\r\n"); /* 406 not acceptible */
FCGX_FPrintF(r->out, "Content-Type: text/html\r\n\r\n"); FCGX_FPrintF(req->out, "Content-Type: text/html\r\n\r\n");
FCGX_FPrintF(r->out, "<h1>Not Acceptable</h1>\n"); FCGX_FPrintF(req->out, "<h1>Not Acceptable</h1>\n");
FCGX_FPrintF(r->out, "Not Acceptable\n"); FCGX_FPrintF(req->out, "Not Acceptable\n");
FCGX_FPrintF(r->out, "The target resource does not have a current representation that would be acceptable to the user agent.\n", FCGX_FPrintF(req->out, "The target resource does not have a current representation that would be acceptable to the user agent.\n",
path); path);
return 0; return 0;
} }
/*! HTTP error 409 /*! HTTP error 409
* @param[in] r Fastcgi request handle * @param[in] req Fastcgi request handle
*/ */
int int
restconf_conflict(FCGX_Request *r) restconf_conflict(FCGX_Request *req)
{ {
FCGX_SetExitStatus(409, r->out); FCGX_SetExitStatus(409, req->out);
FCGX_FPrintF(r->out, "Status: 409 Conflict\r\n"); /* 409 Conflict */ FCGX_FPrintF(req->out, "Status: 409 Conflict\r\n"); /* 409 Conflict */
FCGX_FPrintF(r->out, "Content-Type: text/html\r\n\r\n"); FCGX_FPrintF(req->out, "Content-Type: text/html\r\n\r\n");
FCGX_FPrintF(r->out, "<h1>Data resource already exists</h1>\n"); FCGX_FPrintF(req->out, "<h1>Data resource already exists</h1>\n");
return 0; return 0;
} }
/*! HTTP error 409 /*! HTTP error 409
* @param[in] r Fastcgi request handle * @param[in] req Fastcgi request handle
*/ */
int int
restconf_unsupported_media(FCGX_Request *r) restconf_unsupported_media(FCGX_Request *req)
{ {
FCGX_SetExitStatus(415, r->out); FCGX_SetExitStatus(415, req->out);
FCGX_FPrintF(r->out, "Status: 415 Unsupported Media Type\r\n"); FCGX_FPrintF(req->out, "Status: 415 Unsupported Media Type\r\n");
FCGX_FPrintF(r->out, "Content-Type: text/html\r\n\r\n"); FCGX_FPrintF(req->out, "Content-Type: text/html\r\n\r\n");
FCGX_FPrintF(r->out, "<h1>Unsupported Media Type</h1>\n"); FCGX_FPrintF(req->out, "<h1>Unsupported Media Type</h1>\n");
return 0; return 0;
} }
/*! HTTP error 500 /*! HTTP error 500
* @param[in] r Fastcgi request handle * @param[in] req Fastcgi request handle
*/ */
int int
restconf_internal_server_error(clicon_handle h, restconf_internal_server_error(clicon_handle h,
FCGX_Request *r) FCGX_Request *req)
{ {
char *path; char *path;
clicon_debug(1, "%s", __FUNCTION__); clicon_debug(1, "%s", __FUNCTION__);
path = clixon_restconf_param_get(h, "REQUEST_URI"); path = clixon_restconf_param_get(h, "REQUEST_URI");
FCGX_FPrintF(r->out, "Status: 500 Internal Server Error\r\n"); /* 500 internal server error */ FCGX_FPrintF(req->out, "Status: 500 Internal Server Error\r\n"); /* 500 internal server error */
FCGX_FPrintF(r->out, "Content-Type: text/html\r\n\r\n"); FCGX_FPrintF(req->out, "Content-Type: text/html\r\n\r\n");
FCGX_FPrintF(r->out, "<h1>Internal server error when accessing %s</h1>\n", path); FCGX_FPrintF(req->out, "<h1>Internal server error when accessing %s</h1>\n", path);
return 0; return 0;
} }
/*! HTTP error 501 /*! HTTP error 501
* @param[in] r Fastcgi request handle * @param[in] req Fastcgi request handle
*/ */
int int
restconf_notimplemented(FCGX_Request *r) restconf_notimplemented(FCGX_Request *req)
{ {
clicon_debug(1, "%s", __FUNCTION__); clicon_debug(1, "%s", __FUNCTION__);
FCGX_FPrintF(r->out, "Status: 501 Not Implemented\r\n"); FCGX_FPrintF(req->out, "Status: 501 Not Implemented\r\n");
FCGX_FPrintF(r->out, "Content-Type: text/html\r\n\r\n"); FCGX_FPrintF(req->out, "Content-Type: text/html\r\n\r\n");
FCGX_FPrintF(r->out, "<h1>Not Implemented/h1>\n"); FCGX_FPrintF(req->out, "<h1>Not Implemented/h1>\n");
return 0; return 0;
} }
/*! Print all FCGI headers /*! Print all FCGI headers
* @param[in] r Fastcgi request handle * @param[in] req Fastcgi request handle
* @see https://nginx.org/en/docs/http/ngx_http_core_module.html#var_https * @see https://nginx.org/en/docs/http/ngx_http_core_module.html#var_https
*/ */
int int
restconf_test(FCGX_Request *r, restconf_test(FCGX_Request *req,
int dbg) int dbg)
{ {
char **environ = r->envp; char **environ = req->envp;
int i; int i;
clicon_debug(1, "All environment vars:"); clicon_debug(1, "All environment vars:");
@ -303,24 +303,24 @@ clixon_restconf_params_clear(clicon_handle h,
} }
/*! /*!
* @param[in] r Fastcgi request handle * @param[in] req Fastcgi request handle
*/ */
cbuf * cbuf *
readdata(FCGX_Request *r) readdata(FCGX_Request *req)
{ {
int c; int c;
cbuf *cb; cbuf *cb;
if ((cb = cbuf_new()) == NULL) if ((cb = cbuf_new()) == NULL)
return NULL; return NULL;
while ((c = FCGX_GetChar(r->in)) != -1) while ((c = FCGX_GetChar(req->in)) != -1)
cprintf(cb, "%c", c); cprintf(cb, "%c", c);
return cb; return cb;
} }
/*! Return restconf error on get/head request /*! Return restconf error on get/head request
* @param[in] h Clixon handle * @param[in] h Clixon handle
* @param[in] r Fastcgi request handle * @param[in] req Fastcgi request handle
* @param[in] xerr XML error message from backend * @param[in] xerr XML error message from backend
* @param[in] pretty Set to 1 for pretty-printed xml/json output * @param[in] pretty Set to 1 for pretty-printed xml/json output
* @param[in] media Output media * @param[in] media Output media
@ -329,7 +329,7 @@ readdata(FCGX_Request *r)
*/ */
int int
api_return_err(clicon_handle h, api_return_err(clicon_handle h,
FCGX_Request *r, FCGX_Request *req,
cxobj *xerr, cxobj *xerr,
int pretty, int pretty,
restconf_media media, restconf_media media,
@ -381,23 +381,23 @@ api_return_err(clicon_handle h,
} }
if ((reason_phrase = restconf_code2reason(code)) == NULL) if ((reason_phrase = restconf_code2reason(code)) == NULL)
reason_phrase=""; reason_phrase="";
FCGX_SetExitStatus(code, r->out); /* Created */ FCGX_SetExitStatus(code, req->out); /* Created */
FCGX_FPrintF(r->out, "Status: %d %s\r\n", code, reason_phrase); FCGX_FPrintF(req->out, "Status: %d %s\r\n", code, reason_phrase);
FCGX_FPrintF(r->out, "Content-Type: %s\r\n\r\n", restconf_media_int2str(media)); FCGX_FPrintF(req->out, "Content-Type: %s\r\n\r\n", restconf_media_int2str(media));
switch (media){ switch (media){
case YANG_DATA_XML: case YANG_DATA_XML:
if (clicon_xml2cbuf(cb, xerr, 2, pretty, -1) < 0) if (clicon_xml2cbuf(cb, xerr, 2, pretty, -1) < 0)
goto done; goto done;
clicon_debug(1, "%s code:%d err:%s", __FUNCTION__, code, cbuf_get(cb)); clicon_debug(1, "%s code:%d err:%s", __FUNCTION__, code, cbuf_get(cb));
if (pretty){ if (pretty){
FCGX_FPrintF(r->out, " <errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">\n", cbuf_get(cb)); FCGX_FPrintF(req->out, " <errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">\n", cbuf_get(cb));
FCGX_FPrintF(r->out, "%s", cbuf_get(cb)); FCGX_FPrintF(req->out, "%s", cbuf_get(cb));
FCGX_FPrintF(r->out, " </errors>\r\n"); FCGX_FPrintF(req->out, " </errors>\r\n");
} }
else { else {
FCGX_FPrintF(r->out, "<errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">", cbuf_get(cb)); FCGX_FPrintF(req->out, "<errors xmlns=\"urn:ietf:params:xml:ns:yang:ietf-restconf\">", cbuf_get(cb));
FCGX_FPrintF(r->out, "%s", cbuf_get(cb)); FCGX_FPrintF(req->out, "%s", cbuf_get(cb));
FCGX_FPrintF(r->out, "</errors>\r\n"); FCGX_FPrintF(req->out, "</errors>\r\n");
} }
break; break;
case YANG_DATA_JSON: case YANG_DATA_JSON:
@ -405,16 +405,16 @@ api_return_err(clicon_handle h,
goto done; goto done;
clicon_debug(1, "%s code:%d err:%s", __FUNCTION__, code, cbuf_get(cb)); clicon_debug(1, "%s code:%d err:%s", __FUNCTION__, code, cbuf_get(cb));
if (pretty){ if (pretty){
FCGX_FPrintF(r->out, "{\n"); FCGX_FPrintF(req->out, "{\n");
FCGX_FPrintF(r->out, " \"ietf-restconf:errors\" : %s\n", FCGX_FPrintF(req->out, " \"ietf-restconf:errors\" : %s\n",
cbuf_get(cb)); cbuf_get(cb));
FCGX_FPrintF(r->out, "}\r\n"); FCGX_FPrintF(req->out, "}\r\n");
} }
else{ else{
FCGX_FPrintF(r->out, "{"); FCGX_FPrintF(req->out, "{");
FCGX_FPrintF(r->out, "\"ietf-restconf:errors\":"); FCGX_FPrintF(req->out, "\"ietf-restconf:errors\":");
FCGX_FPrintF(r->out, "%s", cbuf_get(cb)); FCGX_FPrintF(req->out, "%s", cbuf_get(cb));
FCGX_FPrintF(r->out, "}\r\n"); FCGX_FPrintF(req->out, "}\r\n");
} }
break; break;
default: default:
@ -434,14 +434,14 @@ api_return_err(clicon_handle h,
} }
/*! Print location header from FCGI environment /*! Print location header from FCGI environment
* @param[in] r Fastcgi request handle * @param[in] req Fastcgi request handle
* @param[in] xobj If set (eg POST) add to api-path * @param[in] xobj If set (eg POST) add to api-path
* $https on if connection operates in SSL mode, or an empty string otherwise * $https on if connection operates in SSL mode, or an empty string otherwise
* @note ports are ignored * @note ports are ignored
*/ */
int int
http_location(clicon_handle h, http_location(clicon_handle h,
FCGX_Request *r, FCGX_Request *req,
cxobj *xobj) cxobj *xobj)
{ {
int retval = -1; int retval = -1;
@ -460,14 +460,14 @@ http_location(clicon_handle h,
} }
if (xml2api_path_1(xobj, cb) < 0) if (xml2api_path_1(xobj, cb) < 0)
goto done; goto done;
FCGX_FPrintF(r->out, "Location: http%s://%s%s%s\r\n", FCGX_FPrintF(req->out, "Location: http%s://%s%s%s\r\n",
https?"s":"", https?"s":"",
host, host,
request_uri, request_uri,
cbuf_get(cb)); cbuf_get(cb));
} }
else else
FCGX_FPrintF(r->out, "Location: http%s://%s%s\r\n", FCGX_FPrintF(req->out, "Location: http%s://%s%s\r\n",
https?"s":"", https?"s":"",
host, host,
request_uri); request_uri);

View file

@ -73,11 +73,11 @@ expectpart "$(curl -si -X GET -H 'Accept: application/yang-data+xml' $RCPROTO://
# Should be alphabetically ordered # Should be alphabetically ordered
new "restconf get restconf/operations. RFC8040 3.3.2 (json)" new "restconf get restconf/operations. RFC8040 3.3.2 (json)"
expectpart "$(curl -si -X GET $RCPROTO://localhost/restconf/operations)" 0 'HTTP/1.1 200 OK' '{"operations":{"clixon-example:client-rpc":\[null\],"clixon-example:empty":\[null\],"clixon-example:optional":\[null\],"clixon-example:example":\[null\],"clixon-lib:debug":\[null\],"clixon-lib:ping":\[null\],"clixon-lib:stats":\[null\],"clixon-lib:restart-plugin":\[null\],"ietf-netconf:get-config":\[null\],"ietf-netconf:edit-config":\[null\],"ietf-netconf:copy-config":\[null\],"ietf-netconf:delete-config":\[null\],"ietf-netconf:lock":\[null\],"ietf-netconf:unlock":\[null\],"ietf-netconf:get":\[null\],"ietf-netconf:close-session":\[null\],"ietf-netconf:kill-session":\[null\],"ietf-netconf:commit":\[null\],"ietf-netconf:discard-changes":\[null\],"ietf-netconf:validate":\[null\],"clixon-rfc5277:create-subscription":\[null\]}}' expectpart "$(curl -si -X GET $RCPROTO://localhost/restconf/operations)" 0 'HTTP/1.1 200 OK' '{"operations":{"clixon-example:client-rpc":\[null\],"clixon-example:empty":\[null\],"clixon-example:optional":\[null\],"clixon-example:example":\[null\],"clixon-lib:debug":\[null\],"clixon-lib:ping":\[null\],"clixon-lib:stats":\[null\],"clixon-lib:restart-plugin":\[null\],"ietf-netconf:get-config":\[null\],"ietf-netconf:edit-config":\[null\],"ietf-netconf:copy-config":\[null\],"ietf-netconf:delete-config":\[null\],"ietf-netconf:lock":\[null\],"ietf-netconf:unlock":\[null\],"ietf-netconf:get":\[null\],"ietf-netconf:close-session":\[null\],"ietf-netconf:kill-session":\[null\],"ietf-netconf:commit":\[null\],"ietf-netconf:discard-changes":\[null\],"ietf-netconf:validate":\[null\]}}'
new "restconf get restconf/operations. RFC8040 3.3.2 (xml)" new "restconf get restconf/operations. RFC8040 3.3.2 (xml)"
ret=$(curl -s -X GET -H "Accept: application/yang-data+xml" $RCPROTO://localhost/restconf/operations) ret=$(curl -s -X GET -H "Accept: application/yang-data+xml" $RCPROTO://localhost/restconf/operations)
expect='<operations><client-rpc xmlns="urn:example:clixon"/><empty xmlns="urn:example:clixon"/><optional xmlns="urn:example:clixon"/><example xmlns="urn:example:clixon"/><debug xmlns="http://clicon.org/lib"/><ping xmlns="http://clicon.org/lib"/><stats xmlns="http://clicon.org/lib"/><restart-plugin xmlns="http://clicon.org/lib"/><get-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><copy-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><delete-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><lock xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><unlock xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><get xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><close-session xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><kill-session xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><commit xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><discard-changes xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><validate xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><create-subscription xmlns="urn:ietf:params:xml:ns:netmod:notification"/></operations>' expect='<operations><client-rpc xmlns="urn:example:clixon"/><empty xmlns="urn:example:clixon"/><optional xmlns="urn:example:clixon"/><example xmlns="urn:example:clixon"/><debug xmlns="http://clicon.org/lib"/><ping xmlns="http://clicon.org/lib"/><stats xmlns="http://clicon.org/lib"/><restart-plugin xmlns="http://clicon.org/lib"/><get-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><copy-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><delete-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><lock xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><unlock xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><get xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><close-session xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><kill-session xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><commit xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><discard-changes xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/><validate xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/></operations>'
match=`echo $ret | grep --null -Eo "$expect"` match=`echo $ret | grep --null -Eo "$expect"`
if [ -z "$match" ]; then if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"

View file

@ -101,7 +101,7 @@ expectpart "$(curl -si -X GET -H 'Accept: application/yang-data+xml' $RCPROTO://
# This just catches the header and the jukebox module, the RFC has foo and bar which # This just catches the header and the jukebox module, the RFC has foo and bar which
# seems wrong to recreate # seems wrong to recreate
new "B.1.2. Retrieve the Server Module Information" new "B.1.2. Retrieve the Server Module Information"
expectpart "$(curl -si -X GET -H 'Accept: application/yang-data+json' $RCPROTO://localhost/restconf/data/ietf-yang-library:modules-state)" 0 "HTTP/1.1 200 OK" 'Cache-Control: no-cache' "Content-Type: application/yang-data+json" '{"ietf-yang-library:modules-state":{"module-set-id":"0","module":\[{"name":"clixon-lib","revision":"2020-04-23","namespace":"http://clicon.org/lib","conformance-type":"implement"},{"name":"clixon-rfc5277","revision":"2008-07-01","namespace":"urn:ietf:params:xml:ns:netmod:notification","conformance-type":"implement"},{"name":"example-events","revision":"","namespace":"urn:example:events","conformance-type":"implement"},{"name":"example-jukebox","revision":"2016-08-15","namespace":"http://example.com/ns/example-jukebox","conformance-type":"implement"},{"name":"example-system","revision":"","namespace":"http://example.com/ns/example-system","conformance-type":"implement"},{"name":"ietf-inet-types","revision":"2013-07-15","namespace":"urn:ietf:params:xml:ns:yang:ietf-inet-types","conformance-type":"implement"},' expectpart "$(curl -si -X GET -H 'Accept: application/yang-data+json' $RCPROTO://localhost/restconf/data/ietf-yang-library:modules-state)" 0 "HTTP/1.1 200 OK" 'Cache-Control: no-cache' "Content-Type: application/yang-data+json" '{"ietf-yang-library:modules-state":{"module-set-id":"0","module":\[{"name":"clixon-lib","revision":"2020-04-23","namespace":"http://clicon.org/lib","conformance-type":"implement"},{"name":"example-events","revision":"","namespace":"urn:example:events","conformance-type":"implement"},{"name":"example-jukebox","revision":"2016-08-15","namespace":"http://example.com/ns/example-jukebox","conformance-type":"implement"},{"name":"example-system","revision":"","namespace":"http://example.com/ns/example-system","conformance-type":"implement"},{"name":"ietf-inet-types","revision":"2013-07-15","namespace":"urn:ietf:params:xml:ns:yang:ietf-inet-types","conformance-type":"implement"},'
new "B.1.3. Retrieve the Server Capability Information" new "B.1.3. Retrieve the Server Capability Information"
expectpart "$(curl -si -X GET -H 'Accept: application/yang-data+xml' $RCPROTO://localhost/restconf/data/ietf-restconf-monitoring:restconf-state/capabilities)" 0 "HTTP/1.1 200 OK" "Content-Type: application/yang-data+xml" 'Cache-Control: no-cache' '<capabilities xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring"><capability>urn:ietf:params:restconf:capability:defaults:1.0?basic-mode=explicit</capability><capability>urn:ietf:params:restconf:capability:depth</capability> expectpart "$(curl -si -X GET -H 'Accept: application/yang-data+xml' $RCPROTO://localhost/restconf/data/ietf-restconf-monitoring:restconf-state/capabilities)" 0 "HTTP/1.1 200 OK" "Content-Type: application/yang-data+xml" 'Cache-Control: no-cache' '<capabilities xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf-monitoring"><capability>urn:ietf:params:restconf:capability:defaults:1.0?basic-mode=explicit</capability><capability>urn:ietf:params:restconf:capability:depth</capability>