Skip to content

Commit

Permalink
Use correct namespace when outputing LinkObj XML. Fix #202.
Browse files Browse the repository at this point in the history
  • Loading branch information
gtback committed Jun 25, 2015
1 parent 231029d commit 81e633f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cybox/bindings/link_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ def export(self, lwrite, level, namespace_='LinkObj:', name_='LinkObjectType', n
else:
eol_ = ''
showIndent(lwrite, level, pretty_print)
lwrite('<%s%s%s' % ('LinkObj:', name_, namespacedef_ and ' ' + namespacedef_ or '', ))
lwrite('<%s%s%s' % (namespace_, name_, namespacedef_ and ' ' + namespacedef_ or '', ))
already_processed = set()
self.exportAttributes(lwrite, level, already_processed, 'LinkObj:', name_='LinkObjectType')
if self.hasContent_():
lwrite('>%s' % (eol_, ))
self.exportChildren(lwrite, level + 1, 'LinkObj:', name_, pretty_print=pretty_print)
showIndent(lwrite, level, pretty_print)
lwrite('</%s%s>%s' % ('LinkObj:', name_, eol_))
lwrite('</%s%s>%s' % (namespace_, name_, eol_))
else:
lwrite('/>%s' % (eol_, ))
def exportAttributes(self, lwrite, level, already_processed, namespace_='LinkObj:', name_='LinkObjectType'):
Expand Down
11 changes: 11 additions & 0 deletions cybox/test/objects/link_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from mixbox.vendor.six import u

from cybox.core import Observables
from cybox.objects.link_object import Link
from cybox.objects.uri_object import URI
from cybox.test.objects import ObjectTestCase
Expand All @@ -21,5 +22,15 @@ class TestLink(ObjectTestCase, unittest.TestCase):
'xsi:type': object_type,
}

# https://github.com/CybOXProject/python-cybox/issues/202
def test_correct_namespace_output(self):
link = Link()
link.value = u("https://www.example.com")

xml = Observables(link).to_xml()
self.assertTrue(b"cybox:Properties" in xml)
self.assertTrue(b"LinkObj:Properties" not in xml)


if __name__ == "__main__":
unittest.main()

0 comments on commit 81e633f

Please sign in to comment.