Skip to content

Commit

Permalink
Resolved issue CiscoDevNet#1056
Browse files Browse the repository at this point in the history
  • Loading branch information
ygorelik committed Mar 28, 2022
1 parent 8ba1520 commit 30884cf
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#### Resolved GitHub issues
* Fixed Python 3.5 code compatibility issue for Ubuntu:xenial
* install_ydk.sh tries to create a new venv ([#1034](https://github.com/CiscoDevNet/ydk-gen/issues/1034))
* getting YCodecError when leaf value has string 'sftp://' ([#1056](https://github.com/CiscoDevNet/ydk-gen/issues/1056))
* vrf route-target leaf stitching(bool) fails as invalid ([#1059](https://github.com/CiscoDevNet/ydk-gen/issues/1059))

### Resolved non-GitHub issues
Expand Down
1 change: 1 addition & 0 deletions sdk/cpp/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Added support for MacOS Big Sur

#### Resolved GitHub issues
* getting YCodecError when leaf value has string 'sftp://' ([#1056](https://github.com/CiscoDevNet/ydk-gen/issues/1056))
* vrf route-target leaf stitching(bool) fails as invalid ([#1059](https://github.com/CiscoDevNet/ydk-gen/issues/1059))

#### Resolved non-GitHub issues
Expand Down
9 changes: 7 additions & 2 deletions sdk/cpp/core/src/path/data_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,13 @@ ydk::path::DataNodeImpl::create_datanode(const std::string& path, const std::str
populate_new_schemas_from_path(path);

// Do not populate new schemas from URL value
if ( !(v.length() > strlen("http://") && v.substr(0, strlen("http://")) == "http://") &&
!(v.length() > strlen("https://") && v.substr(0, strlen("https://")) == "https://") )
// const char * cv = v.c_str();
// if ( !(strncmp(cv, "http://", strlen("http://")) &&
// strncmp(cv, "https://", strlen("https://")) &&
// strncmp(cv, "ftp://", strlen("ftp://")) &&
// strncmp(cv+1, "ftp://", strlen("ftp://")) ) )
auto url_pos = v.find("://");
if ( url_pos == std::string::npos || url_pos > 5 )
{
populate_new_schemas_from_path(v);
}
Expand Down
32 changes: 32 additions & 0 deletions sdk/cpp/core/tests/test_codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,35 @@ TEST_CASE( "decode_rpc_with_attribute" )
</interfaces>)";
REQUIRE(reply_xml == rpc_reply_extracted);
}

TEST_CASE("test_url_path_value") {
std::string searchdir{TEST_HOME};
mock::MockSession sp{searchdir, test_openconfig, EncodingFormat::XML};
auto & schema = sp.get_root_schema();
ydk::path::Codec codec{};

auto & runner = schema.create_datanode("ydktest-sanity:runner", "");
runner.create_datanode("no-key-list[1]/test",
"sftp://[email protected]:/auto/cafy-ott/cafy_log/cafy3/22-1/cafy3-run-1213418/67/7_5_2_13I_NCS5500");
runner.create_datanode("no-key-list[2]/test", "tftp://10.105.227.199/ops/exec");

auto xml = codec.encode(runner, ydk::EncodingFormat::XML, true);
auto expected = R"(<runner xmlns="http://cisco.com/ns/yang/ydktest-sanity">
<no-key-list>
<test>sftp://[email protected]:/auto/cafy-ott/cafy_log/cafy3/22-1/cafy3-run-1213418/67/7_5_2_13I_NCS5500</test>
</no-key-list>
<no-key-list>
<test>tftp://10.105.227.199/ops/exec</test>
</no-key-list>
</runner>
)";
REQUIRE(xml== expected);

auto dn = codec.decode(schema, xml, ydk::EncodingFormat::XML);
REQUIRE(dn != nullptr);
auto real_dn = dn->get_children()[0];
REQUIRE(real_dn != nullptr);

auto xml_rt = codec.encode(*real_dn, ydk::EncodingFormat::XML, true);
REQUIRE(xml == xml_rt);
}

0 comments on commit 30884cf

Please sign in to comment.