Skip to content
Browse files

testbroker

  • Loading branch information...
1 parent 204de2e commit b47098c63e2ee0f6be50e539300079d5beabef59 @rep committed
Showing with 44 additions and 0 deletions.
  1. +44 −0 broker/testbroker.py
View
44 broker/testbroker.py
@@ -0,0 +1,44 @@
+import sys
+from feedbroker import *
+
+
+FeedConnOrig = FeedConn
+FeedBrokerOrig = FeedBroker
+
+
+class FeedBroker(FeedBrokerOrig):
+ def initdb(self):
+ pass
+
+
+class FeedConn(FeedConnOrig):
+ def auth(self, ident, hash):
+ self.checkauth([{'identifier': str(ident), 'secret': 'secretsecret'},], hash)
+
+ def checkauth(self, r, hash):
+ if len(r) > 0:
+ akobj = r[0]
+ akhash = hashlib.sha1('{0}{1}'.format(self.rand, akobj['secret'])).digest()
+ self.idents.add(akobj['identifier'])
+ logging.info('Auth success by {0}.'.format(akobj['identifier']))
+ else:
+ self.error('authfail.')
+
+ self.io_in(b'')
+
+ def may_publish(self, chan):
+ return True
+
+ def may_subscribe(self, chan):
+ return True
+
+
+def main():
+ fb = FeedBroker()
+
+ loop()
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
+

0 comments on commit b47098c

Please sign in to comment.
Something went wrong with that request. Please try again.