Since 6.1 RESTCONF PUTs have added clixon-lib namespace for attributes.

These empty namespaces are removed.
This commit is contained in:
Olof hagsand 2023-03-27 12:57:24 +02:00
parent da2edceb7e
commit 2c104daee2
4 changed files with 21 additions and 4 deletions

View file

@ -653,6 +653,7 @@ text_modify(clicon_handle h,
if (strcmp(restype, "enumeration") == 0 || if (strcmp(restype, "enumeration") == 0 ||
strcmp(restype, "bits") == 0) strcmp(restype, "bits") == 0)
x1bstr = clixon_trim2(x1bstr, " \t\n"); x1bstr = clixon_trim2(x1bstr, " \t\n");
#if 0 /* Passes regression test without, keep for some time until other test requires it */
/* If origin body has namespace definitions, copy them. The reason is that /* If origin body has namespace definitions, copy them. The reason is that
* some bodies rely on namespace prefixes, such as NACM path, but there is * some bodies rely on namespace prefixes, such as NACM path, but there is
* no way we can know this here. * no way we can know this here.
@ -663,6 +664,7 @@ text_modify(clicon_handle h,
*/ */
if (assign_namespace_body(x1, x0) < 0) if (assign_namespace_body(x1, x0) < 0)
goto done; goto done;
#endif
} }
/* XXX here x1bstr is checked for null, while adding an empty string above */ /* XXX here x1bstr is checked for null, while adding an empty string above */
if ((x0b = xml_body_get(x0)) == NULL && x1bstr && strlen(x1bstr)){ if ((x0b = xml_body_get(x0)) == NULL && x1bstr && strlen(x1bstr)){

View file

@ -1006,6 +1006,7 @@ assign_namespace_element(cxobj *x0, /* source */
* *
* @param[in] x0 Source XML * @param[in] x0 Source XML
* @param[in] x1 Destination XML * @param[in] x1 Destination XML
* @note "standard" namespaces, including clixon internal namespaces are removed
*/ */
int int
assign_namespace_body(cxobj *x0, /* source */ assign_namespace_body(cxobj *x0, /* source */
@ -1031,9 +1032,13 @@ assign_namespace_body(cxobj *x0, /* source */
else else
prefix1 = name; prefix1 = name;
/* prefix1 contains actual prefix or NULL, prefix0 can be xmlns */ /* prefix1 contains actual prefix or NULL, prefix0 can be xmlns */
if (strcmp(namespace, NETCONF_BASE_NAMESPACE) ==0 || if (strcmp(namespace, NETCONF_BASE_NAMESPACE) == 0 ||
strcmp(namespace, YANG_XML_NAMESPACE) ==0) strcmp(namespace, YANG_XML_NAMESPACE) == 0 ||
strcmp(namespace, CLIXON_CONF_NS) == 0 ||
strcmp(namespace, CLIXON_LIB_NS) == 0
)
continue; continue;
continue; // XXX
/* Detect if prefix:namespace is declared already? */ /* Detect if prefix:namespace is declared already? */
if (xml2ns(x1, prefix1, &namespace1) == 1) if (xml2ns(x1, prefix1, &namespace1) == 1)
continue; continue;

View file

@ -56,7 +56,7 @@ module clixon-example{
base if:interface-type; base if:interface-type;
} }
/* Generic config data */ /* Generic config data */
container table{ container table{
list parameter{ list parameter{
key name; key name;
leaf name{ leaf name{
@ -256,6 +256,16 @@ expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<xx:rpc xmlns:xx
new "netconf discard-changes" new "netconf discard-changes"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><discard-changes/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><discard-changes/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
# These are clixon-lib attributes used by RESTCONF
new "netonf edit-config with extra attributes on leaf"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><edit-config><target><candidate/></target><default-operation>none</default-operation><config><table xmlns=\"urn:example:clixon\"><parameter><name>x</name><value nc:operation=\"replace\" xmlns:cl=\"http://clicon.org/lib\">99</value></parameter></table></config></edit-config></rpc>" "<rpc-reply $DEFAULTNS xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><ok/></rpc-reply>"
new "netconf get-config"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"42\"><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data><table xmlns=\"urn:example:clixon\"><parameter><name>x</name><value>99</value></parameter></table></data></rpc-reply>"
new "netconf discard-changes"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><discard-changes/></rpc>" "" "<rpc-reply $DEFAULTNS><ok/></rpc-reply>"
new "netconf get empty config2" new "netconf get empty config2"
expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data/></rpc-reply>" expecteof_netconf "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO" "<rpc $DEFAULTNS><get-config><source><candidate/></source></get-config></rpc>" "" "<rpc-reply $DEFAULTNS><data/></rpc-reply>"

View file

@ -245,7 +245,7 @@ new 'B.3.5. "point" Parameter leaf-list 4 before 3'
expectpart "$(curl $CURLOPTS -X POST -H 'Content-Type: application/yang-data+json' -d '{"example-jukebox:extra":"4"}' $RCPROTO://localhost/restconf/data?insert=before\&point=%2Fexample-jukebox%3Aextra%3D3 )" 0 "HTTP/$HVER 201" "Location: $RCPROTO://localhost/restconf/data/example-jukebox:extra=4" expectpart "$(curl $CURLOPTS -X POST -H 'Content-Type: application/yang-data+json' -d '{"example-jukebox:extra":"4"}' $RCPROTO://localhost/restconf/data?insert=before\&point=%2Fexample-jukebox%3Aextra%3D3 )" 0 "HTTP/$HVER 201" "Location: $RCPROTO://localhost/restconf/data/example-jukebox:extra=4"
new 'B.3.5. "insert/point" leaf-list check order (2,4,3,1)' new 'B.3.5. "insert/point" leaf-list check order (2,4,3,1)'
expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example-jukebox:extra -H 'Accept: application/yang-data+xml')" 0 "HTTP/$HVER 200" '<extra xmlns="http://example.com/ns/example-jukebox">2</extra><extra xmlns="http://example.com/ns/example-jukebox" xmlns:jbox="http://example.com/ns/example-jukebox">4</extra><extra xmlns="http://example.com/ns/example-jukebox">3</extra><extra xmlns="http://example.com/ns/example-jukebox">1</extra>' expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/example-jukebox:extra -H 'Accept: application/yang-data+xml')" 0 "HTTP/$HVER 200" '<extra xmlns="http://example.com/ns/example-jukebox">2</extra><extra xmlns="http://example.com/ns/example-jukebox">4</extra><extra xmlns="http://example.com/ns/example-jukebox">3</extra><extra xmlns="http://example.com/ns/example-jukebox">1</extra>'
#new "B.2.2. Detect Datastore Resource Entity-Tag Change" # XXX done except entity-changed #new "B.2.2. Detect Datastore Resource Entity-Tag Change" # XXX done except entity-changed
#new 'B.3.3. "fields" Parameter' #new 'B.3.3. "fields" Parameter'