コード例 #1
0
 def setUp(self, create_all=True):
     if create_all:
         db.create_all()
     access_init_command(0)
     register_deployed_dags_command_test(verbose=0)
     user_data = dict(
         username="******",
         email="*****@*****.**",
         pwd="Testpassword1!",
     )
     self.set_client(self.get_server_url())
     response = self.login_or_signup(user_data)
     self.client.token = response["token"]
     self.url = None
     self.model = None
     self.items_to_check = []
     register_dag_permissions_command(
         open_deployment=current_app.config["OPEN_DEPLOYMENT"], verbose=0)
コード例 #2
0
ファイル: test_users.py プロジェクト: baobabsoluciones/corn
    def setUp(self):
        db.create_all()
        access_init_command(0)
        register_deployed_dags_command_test(verbose=0)

        self.url = USER_URL
        self.model = UserModel

        self.admin = dict(username="******",
                          email="*****@*****.**",
                          password="******")

        response = self.client.post(
            SIGNUP_URL,
            data=json.dumps(self.admin),
            follow_redirects=True,
            headers={"Content-Type": "application/json"},
        )

        self.admin["id"] = response.json["id"]

        user_role = UserRoleModel({
            "user_id": self.admin["id"],
            "role_id": ADMIN_ROLE
        })
        user_role.save()
        db.session.commit()

        self.login_keys = ["username", "password"]

        self.viewer = dict(username="******",
                           email="*****@*****.**",
                           password="******")

        response = self.client.post(
            SIGNUP_URL,
            data=json.dumps(self.viewer),
            follow_redirects=True,
            headers={"Content-Type": "application/json"},
        )

        self.viewer["id"] = response.json["id"]
        register_dag_permissions_command(verbose=0)
コード例 #3
0
    def setUp(self):
        log.root.setLevel(current_app.config["LOG_LEVEL"])
        db.create_all()
        access_init_command(0)
        register_deployed_dags_command_test(verbose=0)
        data = {
            "username": "******",
            "email": "*****@*****.**",
            "password": "******",
        }

        self.client.post(
            SIGNUP_URL,
            data=json.dumps(data),
            follow_redirects=True,
            headers={"Content-Type": "application/json"},
        )

        register_dag_permissions_command(
            open_deployment=int(current_app.config["OPEN_DEPLOYMENT"]), verbose=0
        )

        data.pop("email")

        self.token = self.client.post(
            LOGIN_URL,
            data=json.dumps(data),
            follow_redirects=True,
            headers={"Content-Type": "application/json"},
        ).json["token"]

        self.user = Auth.return_user_from_token(self.token)
        self.url = None
        self.model = None
        self.copied_items = set()
        self.items_to_check = []
        self.roles_with_access = []
コード例 #4
0
        logrotate = subprocess.run(
            f"cat > /etc/logrotate.d/cornflow <<EOF\n {conf} \nEOF",
            shell=True)
        out_logrotate = logrotate.stdout
        print(out_logrotate)

    except error:
        print(error)

# make initdb, access control and/or migrations
app = create_app(ENV, CORNFLOW_DB_CONN)
with app.app_context():
    migrate = Migrate(app=app, db=db)
    upgrade()
    access_init_command(0)
    # create user if auth type is db or oid
    if AUTH == 1 or AUTH == 0:
        # create cornflow admin user
        create_user_with_role(
            CORNFLOW_ADMIN_USER,
            CORNFLOW_ADMIN_EMAIL,
            CORNFLOW_ADMIN_PWD,
            "admin",
            ADMIN_ROLE,
            verbose=1,
        )
        # create cornflow service user
        create_user_with_role(
            CORNFLOW_SERVICE_USER,
            CORNFLOW_SERVICE_EMAIL,
コード例 #5
0
ファイル: test_users.py プロジェクト: baobabsoluciones/corn
    def setUp(self):
        db.create_all()
        access_init_command(0)
        register_deployed_dags_command_test(verbose=0)

        self.url = USER_URL
        self.model = UserModel

        self.viewer = dict(username="******",
                           email="*****@*****.**",
                           password="******")

        self.planner = dict(
            username="******",
            email="*****@*****.**",
            password="******",
            first_name="first_planner",
            last_name="last_planner",
        )

        self.planner_2 = dict(username="******",
                              email="*****@*****.**",
                              password="******")

        self.admin = dict(username="******",
                          email="*****@*****.**",
                          password="******")

        self.admin_2 = dict(
            username="******",
            email="*****@*****.**",
            password="******",
        )

        self.service_user = dict(
            username="******",
            email="*****@*****.**",
            password="******",
        )

        self.login_keys = ["username", "password"]
        self.items_to_check = ["email", "username", "id"]
        self.modifiable_items = [
            "email",
            "username",
            "password",
            "first_name",
            "last_name",
        ]

        self.payloads = [
            self.viewer,
            self.planner,
            self.planner_2,
            self.admin,
            self.admin_2,
            self.service_user,
        ]

        for u_data in self.payloads:

            response = self.client.post(
                SIGNUP_URL,
                data=json.dumps(u_data),
                follow_redirects=True,
                headers={"Content-Type": "application/json"},
            )

            u_data["id"] = response.json["id"]

            if "viewer" in u_data["email"]:
                user_role = UserRoleModel({
                    "user_id": u_data["id"],
                    "role_id": VIEWER_ROLE
                })
                user_role.save()

                UserRoleModel.query.filter_by(user_id=u_data["id"],
                                              role_id=PLANNER_ROLE).delete()
                db.session.commit()

            if "admin" in u_data["email"]:
                user_role = UserRoleModel({
                    "user_id": u_data["id"],
                    "role_id": ADMIN_ROLE
                })
                user_role.save()

            if "service_user" in u_data["email"]:
                user_role = UserRoleModel({
                    "user_id": u_data["id"],
                    "role_id": SERVICE_ROLE
                })
                user_role.save()

        db.session.commit()
        register_dag_permissions_command(verbose=0)