Ejemplo n.º 1
0
 def setUp(self):
     for item in classes:
         class_ = getattr(models, item)
         class_.createTable(ifNotExists=True)
     new_user = models.UserConfig(uuid=123456,
                                  login="******",
                                  password="******",
                                  authId="auth_id")
     new_user2 = models.UserConfig(uuid=654321,
                                   login="******",
                                   password="******",
                                   authId="auth_id2")
     new_flow = models.Flow(flowId=123)
     new_flow2 = models.Flow(flowId=321)
     models.Message(text="Hello",
                    time=1,
                    userConfig=new_user,
                    flow=new_flow)
     models.Message(text="Privet",
                    time=2,
                    userConfig=new_user,
                    flow=new_flow)
     models.Message(text="Hello2",
                    time=3,
                    userConfig=new_user2,
                    flow=new_flow2)
     self.test = api.ValidJSON.parse_obj(ALL_MESSAGES)
Ejemplo n.º 2
0
 def setUp(self):
     for item in classes:
         class_ = getattr(models, item)
         class_.createTable(ifNotExists=True)
     new_user1 = models.UserConfig(uuid=123456,
                                   login="******",
                                   password="******",
                                   authId="auth_id")
     new_user2 = models.UserConfig(uuid=987654,
                                   login="******",
                                   password="******",
                                   authId="auth_id2")
     new_flow1 = models.Flow(flowId=1,
                             timeCreated=111,
                             flowType='chat',
                             title='title2',
                             info='info2')
     new_flow2 = models.Flow(flowId=2,
                             timeCreated=222,
                             flowType='chat',
                             title='title2',
                             info='info2')
     models.Message(text="Hello1",
                    time=111,
                    userConfig=new_user1,
                    flow=new_flow1)
     models.Message(text="Hello2",
                    time=222,
                    userConfig=new_user2,
                    flow=new_flow2)
     models.Message(text="Hello3",
                    time=333,
                    userConfig=new_user1,
                    flow=new_flow1)
     self.test = api.ValidJSON.parse_obj(GET_UPDATE)
Ejemplo n.º 3
0
 def test_user_already_exists(self):
     models.UserConfig(uuid=123456,
                       login="******",
                       password="******")
     run_method = controller.ProtocolMethods(self.test)
     result = json.loads(run_method.get_response())
     self.assertEqual(result["errors"]["code"], 409)
Ejemplo n.º 4
0
 def setUp(self):
     for item in classes:
         class_ = getattr(models, item)
         class_.createTable(ifNotExists=True)
     models.UserConfig(uuid=123456,
                       login="******",
                       password="******",
                       authId="auth_id")
     logger.remove()
Ejemplo n.º 5
0
 def test_two_element_in_database(self):
     models.UserConfig(uuid=654321,
                       login="******",
                       password="******",
                       salt=b"salt",
                       key=b"key")
     run_method = controller.ProtocolMethods(self.test)
     result = json.loads(run_method.get_response())
     self.assertEqual(result["errors"]["code"], 404)
Ejemplo n.º 6
0
 def setUp(self):
     for item in classes:
         class_ = getattr(models, item)
         class_.createTable(ifNotExists=True)
     models.UserConfig(uuid=123456,
                       login="******",
                       password="******",
                       authId="auth_id")
     self.test = api.ValidJSON.parse_obj(ALL_FLOW)
Ejemplo n.º 7
0
 def setUp(self):
     for item in classes:
         class_ = getattr(models, item)
         class_.createTable(ifNotExists=True)
     models.UserConfig(uuid=123456,
                       login="******",
                       password="******",
                       authId="auth_id")
     models.Flow(flowId=123,
                 timeCreated=111,
                 flowType="chat")
     self.test = api.ValidJSON.parse_obj(SEND_MESSAGE)
Ejemplo n.º 8
0
 def setUp(self):
     for item in classes:
         class_ = getattr(models, item)
         class_.createTable(ifNotExists=True)
     models.UserConfig(uuid=123456,
                       login="******",
                       password="******",
                       username="******",
                       isBot=False,
                       authId="auth_id",
                       email='*****@*****.**',
                       bio='bio')
     self.test = api.ValidJSON.parse_obj(USER_INFO)
Ejemplo n.º 9
0
 def setUp(self):
     gen_hash = lib.Hash("password", 123456,
                         b"salt", b"key")
     self.hash_password = gen_hash.password_hash()
     for item in classes:
         class_ = getattr(models, item)
         class_.createTable(ifNotExists=True)
     models.UserConfig(uuid=123456,
                       login="******",
                       password="******",
                       hashPassword=self.hash_password,
                       salt=b"salt",
                       key=b"key")
     self.test = api.ValidJSON.parse_obj(AUTH)
Ejemplo n.º 10
0
 def setUp(self):
     for item in classes:
         class_ = getattr(models, item)
         class_.createTable(ifNotExists=True)
     new_user = models.UserConfig(uuid=123456,
                                  login="******",
                                  password="******",
                                  authId="auth_id")
     new_flow = models.Flow(flowId=123)
     models.Message(id=1,
                    text="Hello",
                    time=123456,
                    userConfig=new_user,
                    flow=new_flow)
     self.test = api.ValidJSON.parse_obj(EDITED_MESSAGE)
Ejemplo n.º 11
0
    def _register_user(self):
        """The function registers the user who is not in the database.
        Note: This version also authentificate user, that exist in database
        Future version will return error if login exist in database

        """
        # FIXME после замены uuid на UUID из питоньего модуля
        random.seed(urandom(64))
        gen_uuid = random.randrange(10000, 999999999999)
        if self.__check_login(self.request.data.user[0].login):
            self.__catching_error(409)
        else:
            generated = lib.Hash(password=self.request.data.user[0].password,
                                 uuid=gen_uuid)
            models.UserConfig(uuid=gen_uuid,
                              password=self.request.data.user[0].password,
                              hashPassword=generated.password_hash(),
                              login=self.request.data.user[0].login,
                              username=self.request.data.user[0].username,
                              email=self.request.data.user[0].email,
                              key=generated.get_key(),
                              salt=generated.get_salt(),
                              authId=(gen_auth_id := generated.auth_id()))
            user = api.User()