annotate sat_pubsub/test/test_gateway.py @ 350:4d4575911060

sql (PostgreSQL): schema update: - added version check on top of update files, SQL will not be applied if the version is not the one expected - new db schema version (3) - added "presence" access_model in nodes - added "schema" column in nodes - converted items data to xml, this will allow the use of all XML functions PostgreSQL now needs to have been compiled with --with-libxml .
author Goffi <goffi@goffi.org>
date Fri, 08 Sep 2017 08:02:04 +0200
parents 5d7c3787672e
children 9fbb31ce495b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
1 #!/usr/bin/python
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
2 #-*- coding: utf-8 -*-
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
3
312
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
4 # Copyright (c) 2003-2011 Ralph Meijer
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
5 # Copyright (c) 2012-2016 Jérôme Poisson
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
6
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
7
312
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
8 # This program is free software: you can redistribute it and/or modify
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
9 # it under the terms of the GNU Affero General Public License as published by
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
10 # the Free Software Foundation, either version 3 of the License, or
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
11 # (at your option) any later version.
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
12
312
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
13 # This program is distributed in the hope that it will be useful,
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
16 # GNU Affero General Public License for more details.
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
17
312
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
18 # You should have received a copy of the GNU Affero General Public License
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
20 # --
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
21
312
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
22 # This program is based on Idavoll (http://idavoll.ik.nu/),
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
23 # originaly written by Ralph Meijer (http://ralphm.net/blog/)
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
24 # It is sublicensed under AGPL v3 (or any later version) as allowed by the original
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
25 # license.
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
26
312
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
27 # --
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
28
312
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
29 # Here is a copy of the original license:
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
30
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
31 # Copyright (c) 2003-2011 Ralph Meijer
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
32
312
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
33 # Permission is hereby granted, free of charge, to any person obtaining
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
34 # a copy of this software and associated documentation files (the
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
35 # "Software"), to deal in the Software without restriction, including
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
36 # without limitation the rights to use, copy, modify, merge, publish,
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
37 # distribute, sublicense, and/or sell copies of the Software, and to
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
38 # permit persons to whom the Software is furnished to do so, subject to
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
39 # the following conditions:
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
40
312
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
41 # The above copyright notice and this permission notice shall be
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
42 # included in all copies or substantial portions of the Software.
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
43
312
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
44 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
45 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
46 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
47 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
48 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
49 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
5d7c3787672e fixed copyright put in docstring instead of comments
Goffi <goffi@goffi.org>
parents: 311
diff changeset
50 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
233
564ae55219e1 sublicensed under AGPL V3
Goffi <goffi@goffi.org>
parents: 232
diff changeset
51
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
52
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
53 """
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
54 Tests for L{idavoll.gateway}.
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
55
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
56 Note that some tests are functional tests that require a running idavoll
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
57 service.
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
58 """
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
59
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
60 from StringIO import StringIO
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
61
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
62 import simplejson
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
63
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
64 from twisted.internet import defer
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
65 from twisted.trial import unittest
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
66 from twisted.web import error, http, http_headers, server
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
67 from twisted.web.test import requesthelper
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
68 from twisted.words.xish import domish
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
69 from twisted.words.protocols.jabber.jid import JID
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
70
234
51af2ed8bd50 replaced idavoll imports by sat_pubsub imports
Goffi <goffi@goffi.org>
parents: 233
diff changeset
71 from sat_pubsub import gateway
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
72 from sat_pubsub.backend import BackendService
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
73 from sat_pubsub.memory_storage import Storage
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
74
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
75 AGENT = "Idavoll Test Script"
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
76 NS_ATOM = "http://www.w3.org/2005/Atom"
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
77
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
78 TEST_ENTRY = domish.Element((NS_ATOM, 'entry'))
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
79 TEST_ENTRY.addElement("id",
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
80 content="urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a")
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
81 TEST_ENTRY.addElement("title", content="Atom-Powered Robots Run Amok")
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
82 TEST_ENTRY.addElement("author").addElement("name", content="John Doe")
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
83 TEST_ENTRY.addElement("content", content="Some text.")
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
84
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
85 baseURI = "http://localhost:8086/"
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
86 component = "pubsub"
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
87 componentJID = JID(component)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
88 ownerJID = JID('owner@example.org')
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
89
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
90 def _render(resource, request):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
91 result = resource.render(request)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
92 if isinstance(result, str):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
93 request.write(result)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
94 request.finish()
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
95 return defer.succeed(None)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
96 elif result is server.NOT_DONE_YET:
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
97 if request.finished:
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
98 return defer.succeed(None)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
99 else:
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
100 return request.notifyFinish()
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
101 else:
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
102 raise ValueError("Unexpected return value: %r" % (result,))
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
103
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
104
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
105 class DummyRequest(requesthelper.DummyRequest):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
106
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
107 def __init__(self, *args, **kwargs):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
108 requesthelper.DummyRequest.__init__(self, *args, **kwargs)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
109 self.requestHeaders = http_headers.Headers()
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
110
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
111
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
112
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
113 class GetServiceAndNodeTest(unittest.TestCase):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
114 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
115 Tests for {gateway.getServiceAndNode}.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
116 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
117
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
118 def test_basic(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
119 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
120 getServiceAndNode parses an XMPP URI with node parameter.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
121 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
122 uri = b'xmpp:pubsub.example.org?;node=test'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
123 service, nodeIdentifier = gateway.getServiceAndNode(uri)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
124 self.assertEqual(JID(u'pubsub.example.org'), service)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
125 self.assertEqual(u'test', nodeIdentifier)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
126
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
127
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
128 def test_schemeEmpty(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
129 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
130 If the URI scheme is empty, an exception is raised.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
131 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
132 uri = b'pubsub.example.org'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
133 self.assertRaises(gateway.XMPPURIParseError,
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
134 gateway.getServiceAndNode, uri)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
135
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
136
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
137 def test_schemeNotXMPP(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
138 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
139 If the URI scheme is not 'xmpp', an exception is raised.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
140 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
141 uri = b'mailto:test@example.org'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
142 self.assertRaises(gateway.XMPPURIParseError,
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
143 gateway.getServiceAndNode, uri)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
144
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
145
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
146 def test_authorityPresent(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
147 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
148 If the URI has an authority component, an exception is raised.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
149 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
150 uri = b'xmpp://pubsub.example.org/'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
151 self.assertRaises(gateway.XMPPURIParseError,
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
152 gateway.getServiceAndNode, uri)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
153
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
154
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
155 def test_queryEmpty(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
156 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
157 If there is no query component, the nodeIdentifier is empty.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
158 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
159 uri = b'xmpp:pubsub.example.org'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
160 service, nodeIdentifier = gateway.getServiceAndNode(uri)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
161
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
162 self.assertEqual(JID(u'pubsub.example.org'), service)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
163 self.assertEqual(u'', nodeIdentifier)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
164
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
165
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
166 def test_jidInvalid(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
167 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
168 If the JID from the path component is invalid, an exception is raised.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
169 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
170 uri = b'xmpp:@@pubsub.example.org?;node=test'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
171 self.assertRaises(gateway.XMPPURIParseError,
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
172 gateway.getServiceAndNode, uri)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
173
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
174
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
175 def test_pathEmpty(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
176 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
177 If there is no path component, an exception is raised.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
178 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
179 uri = b'xmpp:?node=test'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
180 self.assertRaises(gateway.XMPPURIParseError,
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
181 gateway.getServiceAndNode, uri)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
182
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
183
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
184 def test_nodeAbsent(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
185 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
186 If the node parameter is missing, the nodeIdentifier is empty.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
187 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
188 uri = b'xmpp:pubsub.example.org?'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
189 service, nodeIdentifier = gateway.getServiceAndNode(uri)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
190
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
191 self.assertEqual(JID(u'pubsub.example.org'), service)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
192 self.assertEqual(u'', nodeIdentifier)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
193
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
194
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
195
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
196 class GetXMPPURITest(unittest.TestCase):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
197 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
198 Tests for L{gateway.getXMPPURITest}.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
199 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
200
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
201 def test_basic(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
202 uri = gateway.getXMPPURI(JID(u'pubsub.example.org'), u'test')
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
203 self.assertEqual('xmpp:pubsub.example.org?;node=test', uri)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
204
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
205
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
206 class CreateResourceTest(unittest.TestCase):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
207 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
208 Tests for L{gateway.CreateResource}.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
209 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
210
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
211 def setUp(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
212 self.backend = BackendService(Storage())
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
213 self.resource = gateway.CreateResource(self.backend, componentJID,
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
214 ownerJID)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
215
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
216
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
217 def test_get(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
218 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
219 The method GET is not supported.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
220 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
221 request = DummyRequest([b''])
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
222 self.assertRaises(error.UnsupportedMethod,
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
223 _render, self.resource, request)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
224
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
225
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
226 def test_post(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
227 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
228 Upon a POST, a new node is created and the URI returned.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
229 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
230 request = DummyRequest([b''])
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
231 request.method = 'POST'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
232
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
233 def gotNodes(nodeIdentifiers, uri):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
234 service, nodeIdentifier = gateway.getServiceAndNode(uri)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
235 self.assertIn(nodeIdentifier, nodeIdentifiers)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
236
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
237 def rendered(result):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
238 self.assertEqual('application/json',
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
239 request.outgoingHeaders['content-type'])
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
240 payload = simplejson.loads(b''.join(request.written))
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
241 self.assertIn('uri', payload)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
242 d = self.backend.getNodes()
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
243 d.addCallback(gotNodes, payload['uri'])
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
244 return d
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
245
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
246 d = _render(self.resource, request)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
247 d.addCallback(rendered)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
248 return d
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
249
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
250
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
251
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
252 class DeleteResourceTest(unittest.TestCase):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
253 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
254 Tests for L{gateway.DeleteResource}.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
255 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
256
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
257 def setUp(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
258 self.backend = BackendService(Storage())
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
259 self.resource = gateway.DeleteResource(self.backend, componentJID,
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
260 ownerJID)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
261
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
262
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
263 def test_get(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
264 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
265 The method GET is not supported.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
266 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
267 request = DummyRequest([b''])
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
268 self.assertRaises(error.UnsupportedMethod,
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
269 _render, self.resource, request)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
270
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
271
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
272 def test_post(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
273 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
274 Upon a POST, a new node is created and the URI returned.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
275 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
276 request = DummyRequest([b''])
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
277 request.method = b'POST'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
278
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
279 def rendered(result):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
280 self.assertEqual(http.NO_CONTENT, request.responseCode)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
281
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
282 def nodeCreated(nodeIdentifier):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
283 uri = gateway.getXMPPURI(componentJID, nodeIdentifier)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
284 request.args[b'uri'] = [uri]
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
285 request.content = StringIO(b'')
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
286
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
287 return _render(self.resource, request)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
288
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
289 d = self.backend.createNode(u'test', ownerJID)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
290 d.addCallback(nodeCreated)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
291 d.addCallback(rendered)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
292 return d
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
293
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
294
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
295 def test_postWithRedirect(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
296 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
297 Upon a POST, a new node is created and the URI returned.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
298 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
299 request = DummyRequest([b''])
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
300 request.method = b'POST'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
301 otherNodeURI = b'xmpp:pubsub.example.org?node=other'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
302
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
303 def rendered(result):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
304 self.assertEqual(http.NO_CONTENT, request.responseCode)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
305 self.assertEqual(1, len(deletes))
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
306 nodeIdentifier, owner, redirectURI = deletes[-1]
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
307 self.assertEqual(otherNodeURI, redirectURI)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
308
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
309 def nodeCreated(nodeIdentifier):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
310 uri = gateway.getXMPPURI(componentJID, nodeIdentifier)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
311 request.args[b'uri'] = [uri]
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
312 payload = {b'redirect_uri': otherNodeURI}
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
313 body = simplejson.dumps(payload)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
314 request.content = StringIO(body)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
315 return _render(self.resource, request)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
316
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
317 def deleteNode(nodeIdentifier, owner, redirectURI):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
318 deletes.append((nodeIdentifier, owner, redirectURI))
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
319 return defer.succeed(nodeIdentifier)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
320
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
321 deletes = []
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
322 self.patch(self.backend, 'deleteNode', deleteNode)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
323 d = self.backend.createNode(u'test', ownerJID)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
324 d.addCallback(nodeCreated)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
325 d.addCallback(rendered)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
326 return d
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
327
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
328
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
329 def test_postUnknownNode(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
330 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
331 If the node to be deleted is unknown, 404 Not Found is returned.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
332 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
333 request = DummyRequest([b''])
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
334 request.method = b'POST'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
335
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
336 def rendered(result):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
337 self.assertEqual(http.NOT_FOUND, request.responseCode)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
338
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
339 uri = gateway.getXMPPURI(componentJID, u'unknown')
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
340 request.args[b'uri'] = [uri]
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
341 request.content = StringIO(b'')
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
342
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
343 d = _render(self.resource, request)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
344 d.addCallback(rendered)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
345 return d
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
346
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
347
274
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
348 def test_postMalformedXMPPURI(self):
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
349 """
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
350 If the XMPP URI is malformed, Bad Request is returned.
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
351 """
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
352 request = DummyRequest([b''])
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
353 request.method = b'POST'
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
354
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
355 def rendered(result):
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
356 self.assertEqual(http.BAD_REQUEST, request.responseCode)
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
357
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
358 uri = 'xmpp:@@@@'
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
359 request.args[b'uri'] = [uri]
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
360 request.content = StringIO(b'')
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
361
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
362 d = _render(self.resource, request)
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
363 d.addCallback(rendered)
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
364 return d
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
365
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
366
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
367 def test_postURIMissing(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
368 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
369 If no URI is passed, 400 Bad Request is returned.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
370 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
371 request = DummyRequest([b''])
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
372 request.method = b'POST'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
373
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
374 def rendered(result):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
375 self.assertEqual(http.BAD_REQUEST, request.responseCode)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
376
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
377 request.content = StringIO(b'')
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
378
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
379 d = _render(self.resource, request)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
380 d.addCallback(rendered)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
381 return d
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
382
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
383
274
6641ea7990ee Fix checking for malformed XMPP URI in DeleteResource.
Ralph Meijer <ralphm@ik.nu>
parents: 273
diff changeset
384
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
385 class CallbackResourceTest(unittest.TestCase):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
386 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
387 Tests for L{gateway.CallbackResource}.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
388 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
389
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
390 def setUp(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
391 self.callbackEvents = []
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
392 self.resource = gateway.CallbackResource(self._callback)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
393
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
394
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
395 def _callback(self, payload, headers):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
396 self.callbackEvents.append((payload, headers))
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
397
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
398
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
399 def test_get(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
400 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
401 The method GET is not supported.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
402 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
403 request = DummyRequest([b''])
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
404 self.assertRaises(error.UnsupportedMethod,
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
405 _render, self.resource, request)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
406
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
407
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
408 def test_post(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
409 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
410 The body posted is passed to the callback.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
411 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
412 request = DummyRequest([b''])
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
413 request.method = 'POST'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
414 request.content = StringIO(b'<root><child/></root>')
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
415
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
416 def rendered(result):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
417 self.assertEqual(1, len(self.callbackEvents))
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
418 payload, headers = self.callbackEvents[-1]
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
419 self.assertEqual('root', payload.name)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
420
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
421 self.assertEqual(http.NO_CONTENT, request.responseCode)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
422 self.assertFalse(b''.join(request.written))
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
423
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
424 d = _render(self.resource, request)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
425 d.addCallback(rendered)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
426 return d
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
427
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
428
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
429 def test_postEvent(self):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
430 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
431 If the Event header is set, the payload is empty and the header passed.
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
432 """
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
433 request = DummyRequest([b''])
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
434 request.method = 'POST'
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
435 request.requestHeaders.addRawHeader(b'Event', b'DELETE')
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
436 request.content = StringIO(b'')
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
437
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
438 def rendered(result):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
439 self.assertEqual(1, len(self.callbackEvents))
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
440 payload, headers = self.callbackEvents[-1]
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
441 self.assertIdentical(None, payload)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
442 self.assertEqual(['DELETE'], headers.getRawHeaders(b'Event'))
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
443 self.assertFalse(b''.join(request.written))
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
444
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
445 d = _render(self.resource, request)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
446 d.addCallback(rendered)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
447 return d
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
448
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
449
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
450
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
451 class GatewayTest(unittest.TestCase):
187
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
452 timeout = 2
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
453
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
454 def setUp(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
455 self.client = gateway.GatewayClient(baseURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
456 self.client.startService()
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
457 self.addCleanup(self.client.stopService)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
458
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
459 def trapConnectionRefused(failure):
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
460 from twisted.internet.error import ConnectionRefusedError
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
461 failure.trap(ConnectionRefusedError)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
462 raise unittest.SkipTest("Gateway to test against is not available")
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
463
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
464 def trapNotFound(failure):
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
465 from twisted.web.error import Error
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
466 failure.trap(Error)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
467
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
468 d = self.client.ping()
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
469 d.addErrback(trapConnectionRefused)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
470 d.addErrback(trapNotFound)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
471 return d
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
472
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
473
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
474 def tearDown(self):
204
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
475 return self.client.stopService()
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
476
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
477
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
478 def test_create(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
479
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
480 def cb(response):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
481 self.assertIn('uri', response)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
482
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
483 d = self.client.create()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
484 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
485 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
486
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
487 def test_publish(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
488
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
489 def cb(response):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
490 self.assertIn('uri', response)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
491
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
492 d = self.client.publish(TEST_ENTRY)
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
493 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
494 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
495
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
496 def test_publishExistingNode(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
497
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
498 def cb2(response, xmppURI):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
499 self.assertEquals(xmppURI, response['uri'])
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
500
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
501 def cb1(response):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
502 xmppURI = response['uri']
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
503 d = self.client.publish(TEST_ENTRY, xmppURI)
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
504 d.addCallback(cb2, xmppURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
505 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
506
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
507 d = self.client.create()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
508 d.addCallback(cb1)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
509 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
510
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
511 def test_publishNonExisting(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
512 def cb(err):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
513 self.assertEqual('404', err.status)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
514
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
515 d = self.client.publish(TEST_ENTRY, 'xmpp:%s?node=test' % component)
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
516 self.assertFailure(d, error.Error)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
517 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
518 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
519
209
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
520 def test_delete(self):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
521 def cb(response):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
522 xmppURI = response['uri']
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
523 d = self.client.delete(xmppURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
524 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
525
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
526 d = self.client.create()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
527 d.addCallback(cb)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
528 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
529
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
530 def test_deleteWithRedirect(self):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
531 def cb(response):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
532 xmppURI = response['uri']
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
533 redirectURI = 'xmpp:%s?node=test' % component
209
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
534 d = self.client.delete(xmppURI, redirectURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
535 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
536
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
537 d = self.client.create()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
538 d.addCallback(cb)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
539 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
540
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
541 def test_deleteNotification(self):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
542 def onNotification(data, headers):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
543 try:
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
544 self.assertTrue(headers.hasHeader('Event'))
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
545 self.assertEquals(['DELETED'], headers.getRawHeaders('Event'))
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
546 self.assertFalse(headers.hasHeader('Link'))
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
547 except:
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
548 self.client.deferred.errback()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
549 else:
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
550 self.client.deferred.callback(None)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
551
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
552 def cb(response):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
553 xmppURI = response['uri']
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
554 d = self.client.subscribe(xmppURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
555 d.addCallback(lambda _: xmppURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
556 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
557
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
558 def cb2(xmppURI):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
559 d = self.client.delete(xmppURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
560 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
561
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
562 self.client.callback = onNotification
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
563 self.client.deferred = defer.Deferred()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
564 d = self.client.create()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
565 d.addCallback(cb)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
566 d.addCallback(cb2)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
567 return defer.gatherResults([d, self.client.deferred])
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
568
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
569 def test_deleteNotificationWithRedirect(self):
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
570 redirectURI = 'xmpp:%s?node=test' % component
209
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
571
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
572 def onNotification(data, headers):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
573 try:
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
574 self.assertTrue(headers.hasHeader('Event'))
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
575 self.assertEquals(['DELETED'], headers.getRawHeaders('Event'))
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
576 self.assertEquals(['<%s>; rel=alternate' % redirectURI],
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
577 headers.getRawHeaders('Link'))
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
578 except:
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
579 self.client.deferred.errback()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
580 else:
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
581 self.client.deferred.callback(None)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
582
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
583 def cb(response):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
584 xmppURI = response['uri']
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
585 d = self.client.subscribe(xmppURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
586 d.addCallback(lambda _: xmppURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
587 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
588
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
589 def cb2(xmppURI):
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
590 d = self.client.delete(xmppURI, redirectURI)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
591 return d
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
592
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
593 self.client.callback = onNotification
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
594 self.client.deferred = defer.Deferred()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
595 d = self.client.create()
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
596 d.addCallback(cb)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
597 d.addCallback(cb2)
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
598 return defer.gatherResults([d, self.client.deferred])
7f3ffb7a1a9e Add support for node deletion with redirect.
Ralph Meijer <ralphm@ik.nu>
parents: 206
diff changeset
599
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
600 def test_list(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
601 d = self.client.listNodes()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
602 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
603
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
604 def test_subscribe(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
605 def cb(response):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
606 xmppURI = response['uri']
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
607 d = self.client.subscribe(xmppURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
608 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
609
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
610 d = self.client.create()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
611 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
612 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
613
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
614 def test_subscribeGetNotification(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
615
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
616 def onNotification(data, headers):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
617 self.client.deferred.callback(None)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
618
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
619 def cb(response):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
620 xmppURI = response['uri']
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
621 d = self.client.subscribe(xmppURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
622 d.addCallback(lambda _: xmppURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
623 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
624
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
625 def cb2(xmppURI):
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
626 d = self.client.publish(TEST_ENTRY, xmppURI)
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
627 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
628
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
629
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
630 self.client.callback = onNotification
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
631 self.client.deferred = defer.Deferred()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
632 d = self.client.create()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
633 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
634 d.addCallback(cb2)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
635 return defer.gatherResults([d, self.client.deferred])
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
636
204
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
637
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
638 def test_subscribeTwiceGetNotification(self):
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
639
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
640 def onNotification1(data, headers):
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
641 d = client1.stopService()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
642 d.chainDeferred(client1.deferred)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
643
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
644 def onNotification2(data, headers):
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
645 d = client2.stopService()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
646 d.chainDeferred(client2.deferred)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
647
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
648 def cb(response):
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
649 xmppURI = response['uri']
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
650 d = client1.subscribe(xmppURI)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
651 d.addCallback(lambda _: xmppURI)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
652 return d
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
653
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
654 def cb2(xmppURI):
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
655 d = client2.subscribe(xmppURI)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
656 d.addCallback(lambda _: xmppURI)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
657 return d
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
658
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
659 def cb3(xmppURI):
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
660 d = self.client.publish(TEST_ENTRY, xmppURI)
204
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
661 return d
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
662
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
663
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
664 client1 = gateway.GatewayClient(baseURI, callbackPort=8088)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
665 client1.startService()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
666 client1.callback = onNotification1
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
667 client1.deferred = defer.Deferred()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
668 client2 = gateway.GatewayClient(baseURI, callbackPort=8089)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
669 client2.startService()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
670 client2.callback = onNotification2
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
671 client2.deferred = defer.Deferred()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
672
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
673 d = self.client.create()
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
674 d.addCallback(cb)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
675 d.addCallback(cb2)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
676 d.addCallback(cb3)
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
677 dl = defer.gatherResults([d, client1.deferred, client2.deferred])
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
678 return dl
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
679
b4bf0a5ce50d Implement storage facilities for the HTTP gateway.
Ralph Meijer <ralphm@ik.nu>
parents: 198
diff changeset
680
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
681 def test_subscribeGetDelayedNotification(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
682
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
683 def onNotification(data, headers):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
684 self.client.deferred.callback(None)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
685
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
686 def cb(response):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
687 xmppURI = response['uri']
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
688 self.assertNot(self.client.deferred.called)
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
689 d = self.client.publish(TEST_ENTRY, xmppURI)
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
690 d.addCallback(lambda _: xmppURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
691 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
692
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
693 def cb2(xmppURI):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
694 d = self.client.subscribe(xmppURI)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
695 return d
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
696
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
697
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
698 self.client.callback = onNotification
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
699 self.client.deferred = defer.Deferred()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
700 d = self.client.create()
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
701 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
702 d.addCallback(cb2)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
703 return defer.gatherResults([d, self.client.deferred])
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
704
187
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
705 def test_subscribeGetDelayedNotification2(self):
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
706 """
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
707 Test that subscribing as second results in a notification being sent.
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
708 """
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
709
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
710 def onNotification1(data, headers):
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
711 client1.deferred.callback(None)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
712 client1.stopService()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
713
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
714 def onNotification2(data, headers):
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
715 client2.deferred.callback(None)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
716 client2.stopService()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
717
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
718 def cb(response):
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
719 xmppURI = response['uri']
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
720 self.assertNot(client1.deferred.called)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
721 self.assertNot(client2.deferred.called)
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
722 d = self.client.publish(TEST_ENTRY, xmppURI)
187
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
723 d.addCallback(lambda _: xmppURI)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
724 return d
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
725
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
726 def cb2(xmppURI):
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
727 d = client1.subscribe(xmppURI)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
728 d.addCallback(lambda _: xmppURI)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
729 return d
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
730
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
731 def cb3(xmppURI):
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
732 d = client2.subscribe(xmppURI)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
733 return d
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
734
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
735 client1 = gateway.GatewayClient(baseURI, callbackPort=8088)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
736 client1.startService()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
737 client1.callback = onNotification1
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
738 client1.deferred = defer.Deferred()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
739 client2 = gateway.GatewayClient(baseURI, callbackPort=8089)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
740 client2.startService()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
741 client2.callback = onNotification2
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
742 client2.deferred = defer.Deferred()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
743
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
744
187
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
745 d = self.client.create()
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
746 d.addCallback(cb)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
747 d.addCallback(cb2)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
748 d.addCallback(cb3)
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
749 dl = defer.gatherResults([d, client1.deferred, client2.deferred])
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
750 return dl
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
751
69cdd8c6a431 Make sure second subscribers through HTTP also get a notification of the
Ralph Meijer <ralphm@ik.nu>
parents: 186
diff changeset
752
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
753 def test_subscribeNonExisting(self):
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
754 def cb(err):
191
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
755 self.assertEqual('403', err.status)
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
756
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
757 d = self.client.subscribe('xmpp:%s?node=test' % component)
183
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
758 self.assertFailure(d, error.Error)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
759 d.addCallback(cb)
c21b986cff30 Implement HTTP client to gateway and implement functional tests with it.
Ralph Meijer <ralphm@ik.nu>
parents:
diff changeset
760 return d
185
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
761
186
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
762
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
763 def test_subscribeRootGetNotification(self):
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
764
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
765 def clean(rootNode):
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
766 return self.client.unsubscribe(rootNode)
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
767
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
768 def onNotification(data, headers):
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
769 self.client.deferred.callback(None)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
770
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
771 def cb(response):
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
772 xmppURI = response['uri']
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
773 jid, nodeIdentifier = gateway.getServiceAndNode(xmppURI)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
774 rootNode = gateway.getXMPPURI(jid, '')
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
775
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
776 d = self.client.subscribe(rootNode)
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
777 d.addCallback(lambda _: self.addCleanup(clean, rootNode))
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
778 d.addCallback(lambda _: xmppURI)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
779 return d
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
780
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
781 def cb2(xmppURI):
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
782 return self.client.publish(TEST_ENTRY, xmppURI)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
783
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
784
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
785 self.client.callback = onNotification
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
786 self.client.deferred = defer.Deferred()
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
787 d = self.client.create()
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
788 d.addCallback(cb)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
789 d.addCallback(cb2)
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
790 return defer.gatherResults([d, self.client.deferred])
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
791
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
792
191
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
793 def test_unsubscribeNonExisting(self):
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
794 def cb(err):
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
795 self.assertEqual('403', err.status)
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
796
273
6ba0d6def7f5 Use twisted.web instead of web2, initial tests.
Ralph Meijer <ralphm@ik.nu>
parents: 255
diff changeset
797 d = self.client.unsubscribe('xmpp:%s?node=test' % component)
191
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
798 self.assertFailure(d, error.Error)
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
799 d.addCallback(cb)
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
800 return d
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
801
48245777acea Return proper HTTP status codes on failed un-/subscription.
Ralph Meijer <ralphm@ik.nu>
parents: 187
diff changeset
802
185
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
803 def test_items(self):
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
804 def cb(response):
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
805 xmppURI = response['uri']
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
806 d = self.client.items(xmppURI)
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
807 return d
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
808
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
809 d = self.client.publish(TEST_ENTRY)
186
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
810 d.addCallback(cb)
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
811 return d
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
812
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
813
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
814 def test_itemsMaxItems(self):
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
815 def cb(response):
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
816 xmppURI = response['uri']
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
817 d = self.client.items(xmppURI, 2)
365fd3e4daf8 Add maxItems support.
Ralph Meijer <ralphm@ik.nu>
parents: 185
diff changeset
818 return d
185
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
819
206
274a45d2a5ab Implement root collection that includes all leaf nodes.
Ralph Meijer <ralphm@ik.nu>
parents: 204
diff changeset
820 d = self.client.publish(TEST_ENTRY)
185
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
821 d.addCallback(cb)
9038908dc2f5 Add gateway support for retrieving items from a node. Reorder gateway module.
Ralph Meijer <ralphm@ik.nu>
parents: 183
diff changeset
822 return d