Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path API does not validate leafref properly #1001

Open
111pontes opened this issue Jun 18, 2020 · 0 comments
Open

Path API does not validate leafref properly #1001

111pontes opened this issue Jun 18, 2020 · 0 comments
Labels

Comments

@111pontes
Copy link
Collaborator

The schema path /oc-if:interfaces/interface/name is a leafref pointing to /oc-if:interfaces/interface/config/name. Validation should raise an exception if the values do not match in a payload. In the following example, the former has a value of Loopback0 and the latter has a value of Loopback1. Validation testing should cover this scenario.

Script

#!/usr/bin/env python3

from ydk.path import Repository, Capability, Codec
from ydk.types import EncodingFormat

payload = '''
<interfaces xmlns="http://openconfig.net/yang/interfaces">
  <interface>
    <name>Loopback0</name>
    <config>
      <name>Loopback1</name>
      <description>Lo0 interface description</description>
      <mtu>1500</mtu>
    </config>
  </interface>
</interfaces>
'''

repo = Repository('/home/host/.ydk/router')
caps = [Capability('openconfig-interfaces', '')]
root_schema = repo.create_root_schema(caps)

codec = Codec()

data_node = codec.decode(root_schema, payload, EncodingFormat.XML)

print(codec.encode(data_node, EncodingFormat.JSON, True))

Output:

user@host$ ./test.py 
{
  "openconfig-interfaces:interfaces": {
    "interface": [
      {
        "name": "Loopback0",
        "config": {
          "name": "Loopback1",
          "description": "Lo0 interface description",
          "mtu": 1500
        }
      }
    ]
  }
}

Segmentation fault
user@host$ 

System:

Ubuntu Bionic running:

user@host$ pip list | grep "ydk "
ydk                      0.8.4
user@host$ 
@111pontes 111pontes added the bug label Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant