Permalink
Browse files

add tests for whitelist and a small bug fix on matches, also add supp…

…ort for *
  • Loading branch information...
1 parent f829dca commit 82c4c4d89b23cc0c35f5d9a7cfc5b8fccbc6a6c0 Christopher tofu Zorn committed Apr 27, 2010
Showing with 90 additions and 3 deletions.
  1. +23 −0 CHANGELOG.txt
  2. +7 −2 punjab/httpb.py
  3. +60 −1 tests/xep124.py
View
@@ -0,0 +1,23 @@
+Fix stream:error namespace bug (Garret Heaton <powdahound@gmail.com>)
+
+Add whitelist command line option. (Garret Heaton <powdahound@gmail.com>)
+
+Add ability for wildcard subdomains (Garret Heaton <powdahound@gmail.com>)
+
+== Mon Feb 8, 2010 ==
+
+Abstract out the different XEPs in order to split 124 for BOSH and 206 for XMPP Over
+BOSH. Allows for other protocols over BOSH. (commit 41fddc8)
+
+Flash Crossdomain support (commit ee8aae1)
+
+W3C CORS Support (commit 41ff4c3)
+
+Default Resource url http-bind (commit 8020ba1)
+
+Prevent Domains using a white list (commit 08ca878)
+
+Added Twisted-names to dependency list (commit 6b65977)
+
+Make ssl errors better.
+
View
@@ -586,12 +586,17 @@ def startSession(self, body, xmpp_elements):
# entries beginning with periods will allow subdomains.
#
# e.g.: A 'to' of 'foo.example.com' would not match 'example.com' but
- # would match '.example.com'
+ # would match '.example.com' or '*example.com' or '*.example.com'
if self.white_list:
valid_host = False
for domain in self.white_list:
if body['to'] == domain or \
- domain[0] == '.' and body['to'].endswith(domain):
+ (domain[0] == '*' and domain[1] == '.' and\
+ body['to'].endswith(domain[2:])) or \
+ (domain[0] == '*' and \
+ body['to'].endswith(domain[1:])) or \
+ (domain[0] == '.' and \
+ body['to'].endswith(domain[1:])):
valid_host = True
break
if not valid_host:
View
@@ -36,7 +36,8 @@ def setUp(self):
os.mkdir("./html") # create directory in _trial_temp
self.root = static.File("./html") # make _trial_temp/html the root html directory
self.rid = random.randint(0,10000000)
- self.b = resource.IResource(HttpbService(1))
+ self.hbs = HttpbService(1)
+ self.b = resource.IResource(self.hbs)
self.root.putChild('xmpp-bosh', self.b)
self.site = server.Site(self.root)
@@ -137,6 +138,64 @@ def _error(e):
return d
+ def testWhiteList(self):
+ """
+ Basic tests for whitelisting domains.
+ """
+
+ def _testSessionCreate(res):
+ self.failUnless(res[0].name=='body', 'Wrong element')
+ self.failUnless(res[0].hasAttribute('sid'), 'Not session id')
+
+ def _error(e):
+ # This fails on DNS
+ log.err(e)
+
+ self.hbs.white_list = ['.localhost']
+ BOSH_XML = """<body content='text/xml; charset=utf-8'
+ hold='1'
+ rid='1573741820'
+ to='localhost'
+ secure='true'
+ ver='1.6'
+ wait='60'
+ ack='1'
+ xml:lang='en'
+ xmlns='http://jabber.org/protocol/httpbind'/>
+ """
+
+ d = self.proxy.connect(BOSH_XML).addCallback(_testSessionCreate)
+ d.addErrback(_error)
+ return d
+
+ def testWhiteListError(self):
+ """
+ Basic tests for whitelisting domains.
+ """
+
+ def _testSessionCreate(res):
+ self.fail("Session should not be created")
+
+ def _error(e):
+ return True
+
+ self.hbs.white_list = ['test']
+ BOSH_XML = """<body content='text/xml; charset=utf-8'
+ hold='1'
+ rid='1573741820'
+ to='localhost'
+ secure='true'
+ ver='1.6'
+ wait='60'
+ ack='1'
+ xml:lang='en'
+ xmlns='http://jabber.org/protocol/httpbind'/>
+ """
+
+ d = self.proxy.connect(BOSH_XML).addCallback(_testSessionCreate)
+ d.addErrback(_error)
+ return d
+
def testSessionTimeout(self):
"""Test if we timeout correctly
"""

0 comments on commit 82c4c4d

Please sign in to comment.