Esempio n. 1
0
 def test_CONNECT_encdec_keepalive(self):
     request = CONNECT()
     response = CONNECT()
     request.version     = v31
     request.clientId    = "client-foo"
     request.keepalive   = 12
     request.willTopic   = None
     request.willMessage = None
     request.willQoS     = None
     request.willRetain  = None
     request.username    = None
     request.password    = None
     request.cleanStart  = True
     response.decode(request.encode())
     self.assertEqual(request.encoded[0],  response.encoded[0])
     self.assertEqual(request.version,     response.version)
     self.assertEqual(request.clientId,    response.clientId)
     self.assertEqual(request.keepalive,   response.keepalive)
     self.assertEqual(request.willTopic,   response.willTopic)
     self.assertEqual(request.willMessage, response.willMessage)
     self.assertEqual(request.willQoS,     response.willQoS)
     self.assertEqual(request.willRetain,  response.willRetain)
     self.assertEqual(request.username,    response.username)
     self.assertEqual(request.password,    response.password)
     self.assertEqual(request.cleanStart,  response.cleanStart)
     self.assertEqual(request.version,     response.version)
Esempio n. 2
0
 def test_CONNECT_encdec_willTopic(self):
     request = CONNECT()
     response = CONNECT()
     request.clientId = "client-foo"
     request.keepalive = 1
     request.willTopic = "foo-topic"
     request.willMessage = ""
     request.willQoS = 1
     request.willRetain = False
     request.username = None
     request.password = None
     request.cleanStart = True
     request.version = v31
     response.decode(request.encode())
     self.assertEqual(request.encoded[0], response.encoded[0])
     self.assertEqual(request.version, response.version)
     self.assertEqual(request.clientId, response.clientId)
     self.assertEqual(request.keepalive, response.keepalive)
     self.assertEqual(request.willTopic, response.willTopic)
     self.assertEqual(request.willMessage, response.willMessage)
     self.assertEqual(request.willQoS, response.willQoS)
     self.assertEqual(request.willRetain, response.willRetain)
     self.assertEqual(request.username, response.username)
     self.assertEqual(request.password, response.password)
     self.assertEqual(request.cleanStart, response.cleanStart)
Esempio n. 3
0
 def test_CONNECT_encdec_userpass(self):
     request = CONNECT()
     response = CONNECT()
     request.clientId    = "client-foo"
     request.keepalive   = 12000
     request.willTopic   = "foo-topic"
     request.willMessage = ""
     request.willQoS     = 0
     request.willRetain  = False
     request.username    = "******"
     request.password    = "******"
     request.cleanStart  = True
     request.version     = v31
     response.decode(request.encode())
     self.assertEqual(request.encoded[0],  response.encoded[0])
     self.assertEqual(request.version,     response.version)
     self.assertEqual(request.clientId,    response.clientId)
     self.assertEqual(request.keepalive,   response.keepalive)
     self.assertEqual(request.willTopic,   response.willTopic)
     self.assertEqual(request.willMessage, response.willMessage)
     self.assertEqual(request.willQoS,     response.willQoS)
     self.assertEqual(request.willRetain,  response.willRetain)
     self.assertEqual(request.username,    response.username)
     self.assertEqual(request.password,    response.password.decode(encoding='ascii', errors='ignore'))
     self.assertEqual(request.cleanStart,  response.cleanStart)
Esempio n. 4
0
 def test_CONNECT_encdec_userpass(self):
     request = CONNECT()
     response = CONNECT()
     request.clientId = "client-foo"
     request.keepalive = 12000
     request.willTopic = "foo-topic"
     request.willMessage = ""
     request.willQoS = 0
     request.willRetain = False
     request.username = "******"
     request.password = "******"
     request.cleanStart = True
     request.version = v31
     response.decode(request.encode())
     self.assertEqual(request.encoded[0], response.encoded[0])
     self.assertEqual(request.version, response.version)
     self.assertEqual(request.clientId, response.clientId)
     self.assertEqual(request.keepalive, response.keepalive)
     self.assertEqual(request.willTopic, response.willTopic)
     self.assertEqual(request.willMessage, response.willMessage)
     self.assertEqual(request.willQoS, response.willQoS)
     self.assertEqual(request.willRetain, response.willRetain)
     self.assertEqual(request.username, response.username)
     self.assertEqual(
         request.password,
         response.password.decode(encoding='ascii', errors='ignore'))
     self.assertEqual(request.cleanStart, response.cleanStart)