• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python security.merge_perm函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中superset.security.merge_perm函数的典型用法代码示例。如果您正苦于以下问题:Python merge_perm函数的具体用法?Python merge_perm怎么用?Python merge_perm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了merge_perm函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_filter_druid_datasource

    def test_filter_druid_datasource(self):
        CLUSTER_NAME = 'new_druid'
        cluster = self.get_or_create(
            DruidCluster,
            {'cluster_name': CLUSTER_NAME},
            db.session)
        db.session.merge(cluster)

        gamma_ds = self.get_or_create(
            DruidDatasource, {'datasource_name': 'datasource_for_gamma'},
            db.session)
        gamma_ds.cluster = cluster
        db.session.merge(gamma_ds)

        no_gamma_ds = self.get_or_create(
            DruidDatasource, {'datasource_name': 'datasource_not_for_gamma'},
            db.session)
        no_gamma_ds.cluster = cluster
        db.session.merge(no_gamma_ds)
        db.session.commit()

        security.merge_perm(sm, 'datasource_access', gamma_ds.perm)
        security.merge_perm(sm, 'datasource_access', no_gamma_ds.perm)

        perm = sm.find_permission_view_menu(
            'datasource_access', gamma_ds.get_perm())
        sm.add_permission_role(sm.find_role('Gamma'), perm)
        sm.get_session.commit()

        self.login(username='gamma')
        url = '/druiddatasourcemodelview/list/'
        resp = self.get_resp(url)
        self.assertIn('datasource_for_gamma', resp)
        self.assertNotIn('datasource_not_for_gamma', resp)
开发者ID:johnsonc,项目名称:caravel,代码行数:34,代码来源:druid_tests.py


示例2: test_clean_requests_after_db_grant

    def test_clean_requests_after_db_grant(self):
        session = db.session

        # Case 3. Two access requests from gamma and gamma2
        # Gamma gets database access, gamma2 access request granted
        # Check if request by gamma has been deleted

        gamma_user = sm.find_user(username='gamma')
        access_request1 = create_access_request(
            session, 'table', 'long_lat', TEST_ROLE_1, 'gamma')
        create_access_request(
            session, 'table', 'long_lat', TEST_ROLE_2, 'gamma2')
        ds_1_id = access_request1.datasource_id
        # gamma gets granted database access
        database = session.query(models.Database).first()

        security.merge_perm(
            sm, 'database_access', database.perm)
        ds_perm_view = sm.find_permission_view_menu(
            'database_access', database.perm)
        sm.add_permission_role(
            sm.find_role(DB_ACCESS_ROLE), ds_perm_view)
        gamma_user.roles.append(sm.find_role(DB_ACCESS_ROLE))
        session.commit()
        access_requests = self.get_access_requests('gamma', 'table', ds_1_id)
        self.assertTrue(access_requests)
        # gamma2 request gets fulfilled
        self.client.get(EXTEND_ROLE_REQUEST.format(
            'table', ds_1_id, 'gamma2', TEST_ROLE_2))
        access_requests = self.get_access_requests('gamma', 'table', ds_1_id)

        self.assertFalse(access_requests)
        gamma_user = sm.find_user(username='gamma')
        gamma_user.roles.remove(sm.find_role(DB_ACCESS_ROLE))
        session.commit()
开发者ID:johnsonc,项目名称:caravel,代码行数:35,代码来源:access_tests.py


示例3: post_add

    def post_add(self, table, flash_message=True):
        table.fetch_metadata()
        security.merge_perm(sm, 'datasource_access', table.get_perm())
        if table.schema:
            security.merge_perm(sm, 'schema_access', table.schema_perm)

        if flash_message:
            flash(_(
                'The table was created. '
                'As part of this two phase configuration '
                'process, you should now click the edit button by '
                'the new table to configure it.'), 'info')
开发者ID:alanmcruickshank,项目名称:caravel,代码行数:12,代码来源:views.py


示例4: test_clean_requests_after_schema_grant

    def test_clean_requests_after_schema_grant(self):
        session = db.session

        # Case 4. Two access requests from gamma and gamma2
        # Gamma gets schema access, gamma2 access request granted
        # Check if request by gamma has been deleted

        gamma_user = sm.find_user(username='gamma')
        access_request1 = create_access_request(
            session, 'table', 'wb_health_population', TEST_ROLE_1, 'gamma')
        access_request2 = create_access_request(
            session, 'table', 'wb_health_population', TEST_ROLE_2, 'gamma2')
        ds_1_id = access_request1.datasource_id
        ds = session.query(SqlaTable).filter_by(
            table_name='wb_health_population').first()


        ds.schema = 'temp_schema'
        security.merge_perm(
            sm, 'schema_access', ds.schema_perm)
        schema_perm_view = sm.find_permission_view_menu(
            'schema_access', ds.schema_perm)
        sm.add_permission_role(
            sm.find_role(SCHEMA_ACCESS_ROLE) , schema_perm_view)
        gamma_user.roles.append(sm.find_role(SCHEMA_ACCESS_ROLE))
        session.commit()
        # gamma2 request gets fulfilled
        self.client.get(EXTEND_ROLE_REQUEST.format(
            'table', ds_1_id, 'gamma2', TEST_ROLE_2))
        access_requests = self.get_access_requests('gamma', 'table', ds_1_id)
        self.assertFalse(access_requests)
        gamma_user = sm.find_user(username='gamma')
        gamma_user.roles.remove(sm.find_role(SCHEMA_ACCESS_ROLE))

        ds = session.query(SqlaTable).filter_by(
            table_name='wb_health_population').first()
        ds.schema = None

        session.commit()
开发者ID:avsolatorio,项目名称:caravel,代码行数:39,代码来源:access_tests.py


示例5: post_update

 def post_update(self, metric):
     if metric.is_restricted:
         security.merge_perm(sm, 'metric_access', metric.get_perm())
开发者ID:alanmcruickshank,项目名称:caravel,代码行数:3,代码来源:views.py


示例6: __init__

    def __init__(self, *args, **kwargs):
        if (
                        self.requires_examples and
                        not os.environ.get('SOLO_TEST') and
                        not os.environ.get('examples_loaded')
        ):
            logging.info("Loading examples")
            cli.load_examples(load_test_data=True)
            logging.info("Done loading examples")
            sync_role_definitions()
            os.environ['examples_loaded'] = '1'
        else:
            sync_role_definitions()
        super(SupersetTestCase, self).__init__(*args, **kwargs)
        self.client = app.test_client()
        self.maxDiff = None

        gamma_sqllab_role = sm.add_role("gamma_sqllab")
        for perm in sm.find_role('Gamma').permissions:
            sm.add_permission_role(gamma_sqllab_role, perm)
        db_perm = self.get_main_database(sm.get_session).perm
        security.merge_perm(sm, 'database_access', db_perm)
        db_pvm = sm.find_permission_view_menu(
            view_menu_name=db_perm, permission_name='database_access')
        gamma_sqllab_role.permissions.append(db_pvm)
        for perm in sm.find_role('sql_lab').permissions:
            sm.add_permission_role(gamma_sqllab_role, perm)

        admin = appbuilder.sm.find_user('admin')
        if not admin:
            appbuilder.sm.add_user(
                'admin', 'admin', ' user', '[email protected]',
                appbuilder.sm.find_role('Admin'),
                password='general')

        gamma = appbuilder.sm.find_user('gamma')
        if not gamma:
            appbuilder.sm.add_user(
                'gamma', 'gamma', 'user', '[email protected]',
                appbuilder.sm.find_role('Gamma'),
                password='general')

        gamma2 = appbuilder.sm.find_user('gamma2')
        if not gamma2:
            appbuilder.sm.add_user(
                'gamma2', 'gamma2', 'user', '[email protected]',
                appbuilder.sm.find_role('Gamma'),
                password='general')

        gamma_sqllab_user = appbuilder.sm.find_user('gamma_sqllab')
        if not gamma_sqllab_user:
            appbuilder.sm.add_user(
                'gamma_sqllab', 'gamma_sqllab', 'user', '[email protected]',
                gamma_sqllab_role, password='general')

        alpha = appbuilder.sm.find_user('alpha')
        if not alpha:
            appbuilder.sm.add_user(
                'alpha', 'alpha', 'user', '[email protected]',
                appbuilder.sm.find_role('Alpha'),
                password='general')
        sm.get_session.commit()
        # create druid cluster and druid datasources
        session = db.session
        cluster = (
            session.query(DruidCluster)
            .filter_by(cluster_name="druid_test")
            .first()
        )
        if not cluster:
            cluster = DruidCluster(cluster_name="druid_test")
            session.add(cluster)
            session.commit()

            druid_datasource1 = DruidDatasource(
                datasource_name='druid_ds_1',
                cluster_name='druid_test'
            )
            session.add(druid_datasource1)
            druid_datasource2 = DruidDatasource(
                datasource_name='druid_ds_2',
                cluster_name='druid_test'
            )
            session.add(druid_datasource2)
            session.commit()
开发者ID:avsolatorio,项目名称:caravel,代码行数:85,代码来源:base_tests.py


示例7: pre_add

 def pre_add(self, cluster):
     security.merge_perm(sm, 'database_access', cluster.perm)
开发者ID:alanmcruickshank,项目名称:caravel,代码行数:2,代码来源:views.py


示例8: __init__

    def __init__(self, *args, **kwargs):
        if self.requires_examples and not os.environ.get("SOLO_TEST") and not os.environ.get("examples_loaded"):
            logging.info("Loading examples")
            cli.load_examples(load_test_data=True)
            logging.info("Done loading examples")
            sync_role_definitions()
            os.environ["examples_loaded"] = "1"
        else:
            sync_role_definitions()
        super(SupersetTestCase, self).__init__(*args, **kwargs)
        self.client = app.test_client()
        self.maxDiff = None

        gamma_sqllab_role = sm.add_role("gamma_sqllab")
        for perm in sm.find_role("Gamma").permissions:
            sm.add_permission_role(gamma_sqllab_role, perm)
        db_perm = self.get_main_database(sm.get_session).perm
        security.merge_perm(sm, "database_access", db_perm)
        db_pvm = sm.find_permission_view_menu(view_menu_name=db_perm, permission_name="database_access")
        gamma_sqllab_role.permissions.append(db_pvm)
        for perm in sm.find_role("sql_lab").permissions:
            sm.add_permission_role(gamma_sqllab_role, perm)

        admin = appbuilder.sm.find_user("admin")
        if not admin:
            appbuilder.sm.add_user(
                "admin", "admin", " user", "[email protected]", appbuilder.sm.find_role("Admin"), password="general"
            )

        gamma = appbuilder.sm.find_user("gamma")
        if not gamma:
            appbuilder.sm.add_user(
                "gamma", "gamma", "user", "[email protected]", appbuilder.sm.find_role("Gamma"), password="general"
            )

        gamma_sqllab_user = appbuilder.sm.find_user("gamma_sqllab")
        if not gamma_sqllab_user:
            appbuilder.sm.add_user(
                "gamma_sqllab", "gamma_sqllab", "user", "[email protected]", gamma_sqllab_role, password="general"
            )

        alpha = appbuilder.sm.find_user("alpha")
        if not alpha:
            appbuilder.sm.add_user(
                "alpha", "alpha", "user", "[email protected]", appbuilder.sm.find_role("Alpha"), password="general"
            )
        sm.get_session.commit()

        # create druid cluster and druid datasources
        session = db.session
        cluster = session.query(models.DruidCluster).filter_by(cluster_name="druid_test").first()
        if not cluster:
            cluster = models.DruidCluster(cluster_name="druid_test")
            session.add(cluster)
            session.commit()

            druid_datasource1 = models.DruidDatasource(datasource_name="druid_ds_1", cluster_name="druid_test")
            session.add(druid_datasource1)
            druid_datasource2 = models.DruidDatasource(datasource_name="druid_ds_2", cluster_name="druid_test")
            session.add(druid_datasource2)
            session.commit()
开发者ID:airbnb,项目名称:caravel,代码行数:61,代码来源:base_tests.py


示例9: __init__

 def __init__(self, *args, **kwargs):
     super(SqlLabTests, self).__init__(*args, **kwargs)
     gamma_sqllab = appbuilder.sm.find_role('gamma_sqllab')
     security.merge_perm(sm, 'database_access', self.get_main_database(db.session).perm)
开发者ID:aaronyangzju,项目名称:caravel,代码行数:4,代码来源:sqllab_tests.py



注:本文中的superset.security.merge_perm函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python security_manager.find_role函数代码示例发布时间:2022-05-27
下一篇:
Python db_engine_specs.HiveEngineSpec类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap