Skip to content

Commit 9fd3367

Browse files
committed
Merge pull request #234 from CybOXProject/issue-227
Update WhoisRegistrantInfoType in bindings.
2 parents 4d30309 + 524fe8c commit 9fd3367

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

cybox/bindings/whois_object.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,8 @@ class WhoisRegistrantInfoType(WhoisContactType):
509509

510510
subclass = None
511511
superclass = WhoisContactType
512-
def __init__(self, contact_type=None, Contact_ID=None, Name=None, Email_Address=None, Phone_Number=None, Address=None, Registrant_ID=None):
513-
super(WhoisRegistrantInfoType, self).__init__(contact_type, Contact_ID, Name, Email_Address, Phone_Number, Address, )
512+
def __init__(self, contact_type=None, Contact_ID=None, Name=None, Email_Address=None, Phone_Number=None, Fax_Number=None, Address=None, Organization=None, Registrant_ID=None):
513+
super(WhoisRegistrantInfoType, self).__init__(contact_type, Contact_ID, Name, Email_Address, Phone_Number, Fax_Number, Address, Organization, )
514514
self.Registrant_ID = Registrant_ID
515515
def factory(*args_, **kwargs_):
516516
if WhoisRegistrantInfoType.subclass:

cybox/test/objects/whois_test.py

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import unittest
55
import uuid
66

7+
from cybox.bindings.cybox_common import StringObjectPropertyType
8+
from cybox.bindings.whois_object import (WhoisContactType,
9+
WhoisRegistrantInfoType)
10+
711
from cybox.objects.address_object import Address
812
from cybox.objects.uri_object import URI
913
from cybox.objects.whois_object import (WhoisEntry, WhoisContact,
@@ -84,15 +88,17 @@ class TestContact(EntityTestCase, unittest.TestCase):
8488

8589
_full_dict = {
8690
'contact_type': "ADMIN",
87-
'contact_id': "abc123",
88-
'name': "John Smith",
91+
'contact_id': u"abc123",
92+
'name': u"John Smith",
8993
'email_address': {
90-
'address_value': "john@smith.com",
94+
'address_value': u"john@smith.com",
9195
'category': Address.CAT_EMAIL,
9296
'xsi:type': "AddressObjectType",
9397
},
94-
'phone_number': "(800) 555-1212",
95-
'address': "123 Main St.\nAnytown, CA 01234",
98+
'phone_number': u"(800) 555-1212",
99+
'fax_number': u"(800) 555-1200",
100+
'address': u"123 Main St.\nAnytown, CA 01234",
101+
'organization': u"XYZ Hosting",
96102
}
97103

98104
def test_parse_email_address(self):
@@ -114,6 +120,31 @@ class TestRegistrant(EntityTestCase, unittest.TestCase):
114120
'registrant_id': "reg1234",
115121
}
116122

123+
# https://github.com/CybOXProject/python-cybox/issues/227
124+
def test_issue_227_binding_init(self):
125+
# Fax_Number and Organization were added to the __init__ method of
126+
# WhoisContactType, but not to its subclass (WhoisRegistrantType). Once
127+
# the objects are constructed, they should have equivalent dictionary
128+
# represesntations (as long as the extra fields in the subclass are not
129+
# present).
130+
contact_obj = WhoisContactType(
131+
contact_type="ADMIN",
132+
Contact_ID=StringObjectPropertyType(valueOf_="abc123"),
133+
Fax_Number=StringObjectPropertyType(valueOf_=u"(800) 555-1200"),
134+
Organization=StringObjectPropertyType(valueOf_=u"XYZ Hosting"),
135+
)
136+
contact = WhoisContact.from_obj(contact_obj)
137+
138+
reg_obj = WhoisRegistrantInfoType(
139+
contact_type="ADMIN",
140+
Contact_ID=StringObjectPropertyType(valueOf_="abc123"),
141+
Fax_Number=StringObjectPropertyType(valueOf_=u"(800) 555-1200"),
142+
Organization=StringObjectPropertyType(valueOf_=u"XYZ Hosting"),
143+
)
144+
registrant = WhoisRegistrant.from_obj(reg_obj)
145+
146+
self.assertEqual(contact.to_dict(), registrant.to_dict())
147+
117148

118149
class TestRegistrar(EntityTestCase, unittest.TestCase):
119150
klass = WhoisRegistrar

0 commit comments

Comments
 (0)