forked from ralphm/wokkel
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow publish-subscribe client requests to come from a specific JID.
Author: ralphm. Fixes #46. --HG-- extra : convert_revision : svn%3Ab33ecbfc-034c-dc11-8662-000475d9059e/trunk%40170
- Loading branch information
Showing
2 changed files
with
115 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -255,6 +255,22 @@ def cb(nodeIdentifier): | |
return d | ||
|
||
|
||
def test_createNodeWithSender(self): | ||
""" | ||
Test sending create request from a specific JID. | ||
""" | ||
|
||
d = self.protocol.createNode(JID('pubsub.example.org'), 'test', | ||
sender=JID('[email protected]')) | ||
|
||
iq = self.stub.output[-1] | ||
self.assertEquals('[email protected]', iq['from']) | ||
|
||
response = toResponse(iq, 'result') | ||
self.stub.send(response) | ||
return d | ||
|
||
|
||
def test_deleteNode(self): | ||
""" | ||
Test sending delete request. | ||
|
@@ -278,6 +294,22 @@ def test_deleteNode(self): | |
return d | ||
|
||
|
||
def test_deleteNodeWithSender(self): | ||
""" | ||
Test sending delete request. | ||
""" | ||
|
||
d = self.protocol.deleteNode(JID('pubsub.example.org'), 'test', | ||
sender=JID('[email protected]')) | ||
|
||
iq = self.stub.output[-1] | ||
self.assertEquals('[email protected]', iq['from']) | ||
|
||
response = toResponse(iq, 'result') | ||
self.stub.send(response) | ||
return d | ||
|
||
|
||
def test_publish(self): | ||
""" | ||
Test sending publish request. | ||
|
@@ -329,6 +361,23 @@ def test_publishNoItems(self): | |
return d | ||
|
||
|
||
def test_publishWithSender(self): | ||
""" | ||
Test sending publish request from a specific JID. | ||
""" | ||
|
||
item = pubsub.Item() | ||
d = self.protocol.publish(JID('pubsub.example.org'), 'test', [item], | ||
JID('[email protected]')) | ||
|
||
iq = self.stub.output[-1] | ||
self.assertEquals('[email protected]', iq['from']) | ||
|
||
response = toResponse(iq, 'result') | ||
self.stub.send(response) | ||
return d | ||
|
||
|
||
def test_subscribe(self): | ||
""" | ||
Test sending subscription request. | ||
|
@@ -398,6 +447,27 @@ def test_subscribeUnconfigured(self): | |
return d | ||
|
||
|
||
def test_subscribeWithSender(self): | ||
""" | ||
Test sending subscription request from a specific JID. | ||
""" | ||
d = self.protocol.subscribe(JID('pubsub.example.org'), 'test', | ||
JID('[email protected]'), | ||
sender=JID('[email protected]')) | ||
|
||
iq = self.stub.output[-1] | ||
self.assertEquals('[email protected]', iq['from']) | ||
|
||
response = toResponse(iq, 'result') | ||
pubsub = response.addElement((NS_PUBSUB, 'pubsub')) | ||
subscription = pubsub.addElement('subscription') | ||
subscription['node'] = 'test' | ||
subscription['jid'] = '[email protected]' | ||
subscription['subscription'] = 'subscribed' | ||
self.stub.send(response) | ||
return d | ||
|
||
|
||
def test_unsubscribe(self): | ||
""" | ||
Test sending unsubscription request. | ||
|
@@ -421,6 +491,20 @@ def test_unsubscribe(self): | |
return d | ||
|
||
|
||
def test_unsubscribeWithSender(self): | ||
""" | ||
Test sending unsubscription request from a specific JID. | ||
""" | ||
d = self.protocol.unsubscribe(JID('pubsub.example.org'), 'test', | ||
JID('[email protected]'), | ||
sender=JID('[email protected]')) | ||
|
||
iq = self.stub.output[-1] | ||
self.assertEquals('[email protected]', iq['from']) | ||
self.stub.send(toResponse(iq, 'result')) | ||
return d | ||
|
||
|
||
def test_items(self): | ||
""" | ||
Test sending items request. | ||
|
@@ -487,6 +571,25 @@ def cb(items): | |
return d | ||
|
||
|
||
def test_itemsWithSender(self): | ||
""" | ||
Test sending items request from a specific JID. | ||
""" | ||
|
||
d = self.protocol.items(JID('pubsub.example.org'), 'test', | ||
sender=JID('[email protected]')) | ||
|
||
iq = self.stub.output[-1] | ||
self.assertEquals('[email protected]', iq['from']) | ||
|
||
response = toResponse(iq, 'result') | ||
items = response.addElement((NS_PUBSUB, 'pubsub')).addElement('items') | ||
items['node'] = 'test' | ||
|
||
self.stub.send(response) | ||
return d | ||
|
||
|
||
|
||
class PubSubRequestTest(unittest.TestCase): | ||
|
||
|