Exemple #1
0
    def f_users(self):
        self.u1 = models.User(username=u"user1",
                              proven=False,
                              admin=True,
                              mail="*****@*****.**")

        self.u2 = models.User(username=u"user2",
                              proven=False,
                              mail="*****@*****.**")

        self.u3 = models.User(username=u"user3",
                              proven=False,
                              mail="*****@*****.**")

        self.basic_user_list = [self.u1, self.u2, self.u3]

        self.db.session.add_all(self.basic_user_list)
Exemple #2
0
def create_user_wrapper(username, email, timezone=None):
    expiration_date_token = datetime.date.today() + \
        datetime.timedelta(
            days=flask.current_app.config["API_TOKEN_EXPIRATION"])

    copr64 = base64.b64encode("copr") + "##"
    user = models.User(
        username=username,
        mail=email,
        timezone=timezone,
        api_login=copr64 +
        helpers.generate_api_token(app.config["API_TOKEN_LENGTH"] -
                                   len(copr64)),
        api_token=helpers.generate_api_token(app.config["API_TOKEN_LENGTH"]),
        api_token_expiration=expiration_date_token)
    return user
Exemple #3
0
    def f_copr_more_permissions(self, f_copr_permissions):
        self.u4 = models.User(
            username=u"user4",
            proven=False,
            mail="*****@*****.**",
            api_token='u4xxx',
            api_login='******',
            api_token_expiration=datetime.date.today() + datetime.timedelta(days=1000))

        # only a builder
        self.cp4 = models.CoprPermission(
            copr=self.c3,
            user=self.u4,
            copr_builder=helpers.PermissionEnum("approved"),
            copr_admin=helpers.PermissionEnum("nothing"))

        self.db.session.add_all([self.cp1, self.cp2, self.cp3])
Exemple #4
0
    def run(self, name, mail, **kwargs):
        user = models.User(username=name, mail=mail)

        if kwargs["admin"]:
            user.admin = True
        if kwargs["no_admin"]:
            user.admin = False
        if kwargs["proven"]:
            user.proven = True
        if kwargs["no_proven"]:
            user.proven = False
        #
        # if kwargs["api_token"]:
        #     user.api_token = kwargs["api_token"]
        #     user.api_token_expiration = datetime.date(2030, 1, 1)
        # if kwargs["api_login"]:
        #     user.api_token = kwargs["api_login"]
        #

        db.session.add(create_user_wrapper(user, mail))
        db.session.commit()