def CreateReply(self, msg=None,**attributes): reply = AuthPacket2(AccessAccept, self.id, self.secret, self.authenticator, dict=self.dict, **attributes) if msg: reply.set_reply_msg(tools.EncodeString(msg)) reply.source_user = self.get_user_name() return reply
def set_filter_id(self, vendor, filterid): if not filterid: return try: if not vendor_cfg.has_key(int(vendor)): return if vendor_cfg[int(vendor)]['filter_id']: self.AddAttribute(11, tools.EncodeString(filterid)) except Exception, e: radiuslog.error("set_filter_id error,%s" % (str(e)))
def set_special_str(self, vendor, name, value): if not value: return try: if not vendor_cfg.has_key(int(vendor)): return key = vendor_cfg[int(vendor)][name] if key: self.AddAttribute(key, tools.EncodeString(value)) except Exception, e: radiuslog.error("set_special error,vendor=%s,name=%s,value=%s;err=%s"\ %(vendor,name,value,str(e)))
def testStringEncoding(self): self.assertRaises(ValueError, tools.EncodeString, 'x' * 254) self.assertEqual(tools.EncodeString('1234567890'), six.b('1234567890'))