def configured_app(minimal_app_for_api): app = minimal_app_for_api create_user( app, # type: ignore username="******", role_name="Test", permissions=[ (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG), (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_RUN), (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE), (permissions.ACTION_CAN_READ, permissions.RESOURCE_XCOM), ], ) create_user( app, # type: ignore username="******", role_name="TestGranularDag", permissions=[ (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_RUN), (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE), (permissions.ACTION_CAN_READ, permissions.RESOURCE_XCOM), ], ) app.appbuilder.sm.sync_perm_for_dag( # type: ignore # pylint: disable=no-member "test-dag-id-1", access_control={'TestGranularDag': [permissions.ACTION_CAN_EDIT, permissions.ACTION_CAN_READ]}, ) create_user(app, username="******", role_name="TestNoPermissions") # type: ignore yield app delete_user(app, username="******") # type: ignore delete_user(app, username="******") # type: ignore
def configured_app(minimal_app_for_api): app = minimal_app_for_api create_user( app, # type: ignore username="******", role_name="Test", permissions=[ (permissions.ACTION_CAN_LIST, permissions.RESOURCE_ROLE_MODEL_VIEW), (permissions.ACTION_CAN_ADD, permissions.RESOURCE_ROLE_MODEL_VIEW), (permissions.ACTION_CAN_SHOW, permissions.RESOURCE_ROLE_MODEL_VIEW), (permissions.ACTION_CAN_LIST, permissions.RESOURCE_PERMISSION_MODEL_VIEW), (permissions.ACTION_CAN_DELETE, permissions.RESOURCE_ROLE_MODEL_VIEW), (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_ROLE_MODEL_VIEW), ], ) create_user(app, username="******", role_name="TestNoPermissions") # type: ignore yield app delete_user(app, username="******") # type: ignore delete_user(app, username="******") # type: ignore
def configured_app(minimal_app_for_api): app = minimal_app_for_api create_user( app, # type:ignore username="******", role_name="Test", permissions=[(permissions.ACTION_CAN_READ, permissions.RESOURCE_CONFIG) ], # type: ignore ) yield minimal_app_for_api delete_user(app, username="******") # type: ignore
def configured_app(minimal_app_for_api): app = minimal_app_for_api create_user( app, # type: ignore username="******", role_name="Test", permissions=[(permissions.ACTION_CAN_READ, permissions.RESOURCE_PROVIDER)], ) create_user(app, username="******", role_name="TestNoPermissions") # type: ignore yield app delete_user(app, username="******") # type: ignore delete_user(app, username="******") # type: ignore
def configured_app(minimal_app_for_api): app = minimal_app_for_api create_user( app, # type:ignore username="******", role_name="Test", permissions=[(permissions.ACTION_CAN_READ, permissions.RESOURCE_CONFIG)], # type: ignore ) create_user(app, username="******", role_name="TestNoPermissions") # type: ignore with conf_vars({('webserver', 'expose_config'): 'True'}): yield minimal_app_for_api delete_user(app, username="******") # type: ignore delete_user(app, username="******") # type: ignore
def configured_app(minimal_app_for_api): app = minimal_app_for_api create_user( app, # type: ignore username="******", role_name="Test", permissions=[ (permissions.ACTION_CAN_LIST, permissions.RESOURCE_USER_DB_MODELVIEW), (permissions.ACTION_CAN_SHOW, permissions.RESOURCE_USER_DB_MODELVIEW), ], ) create_user(app, username="******", role_name="TestNoPermissions") # type: ignore yield app delete_user(app, username="******") # type: ignore delete_user(app, username="******") # type: ignore
def configured_app(minimal_app_for_api): app = minimal_app_for_api create_user( app, # type: ignore username="******", role_name="Test", permissions=[ (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG), (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_RUN), (permissions.ACTION_CAN_READ, permissions.RESOURCE_TASK_INSTANCE), (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_TASK_INSTANCE), ], ) create_user(app, username="******", role_name="TestNoPermissions") # type: ignore yield app delete_user(app, username="******") # type: ignore
def configured_app(minimal_app_for_api): app = minimal_app_for_api create_user( app, # type: ignore username="******", role_name="Test", permissions=[ (permissions.ACTION_CAN_CREATE, permissions.RESOURCE_VARIABLE), (permissions.ACTION_CAN_READ, permissions.RESOURCE_VARIABLE), (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_VARIABLE), (permissions.ACTION_CAN_DELETE, permissions.RESOURCE_VARIABLE), ], ) create_user(app, username="******", role_name="TestNoPermissions") # type: ignore yield app delete_user(app, username="******") # type: ignore delete_user(app, username="******") # type: ignore
def configured_app(minimal_app_for_api): app = minimal_app_for_api create_user( app, # type: ignore username="******", role_name="Test", permissions=[ (permissions.ACTION_CAN_CREATE, permissions.RESOURCE_DAG), (permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG), (permissions.ACTION_CAN_EDIT, permissions.RESOURCE_DAG), (permissions.ACTION_CAN_DELETE, permissions.RESOURCE_DAG), ], ) create_user(app, username="******", role_name="TestNoPermissions") # type: ignore create_user(app, username="******", role_name="TestGranularDag") # type: ignore app.appbuilder.sm.sync_perm_for_dag( # type: ignore # pylint: disable=no-member "TEST_DAG_1", access_control={'TestGranularDag': [permissions.ACTION_CAN_EDIT, permissions.ACTION_CAN_READ]}, ) app.appbuilder.sm.sync_perm_for_dag( # type: ignore # pylint: disable=no-member "TEST_DAG_1", access_control={'TestGranularDag': [permissions.ACTION_CAN_EDIT, permissions.ACTION_CAN_READ]}, ) with DAG( DAG_ID, start_date=datetime(2020, 6, 15), doc_md="details", params={"foo": 1}, tags=['example'], ) as dag: DummyOperator(task_id=TASK_ID) with DAG(DAG2_ID, start_date=datetime(2020, 6, 15)) as dag2: # no doc_md DummyOperator(task_id=TASK_ID) with DAG(DAG3_ID) as dag3: # DAG start_date set to None DummyOperator(task_id=TASK_ID, start_date=datetime(2019, 6, 12)) dag_bag = DagBag(os.devnull, include_examples=False) dag_bag.dags = {dag.dag_id: dag, dag2.dag_id: dag2, dag3.dag_id: dag3} app.dag_bag = dag_bag yield app delete_user(app, username="******") # type: ignore delete_user(app, username="******") # type: ignore delete_user(app, username="******") # type: ignore
def tearDownClass(cls) -> None: delete_user(cls.app, username="******") # type: ignore
def tearDownClass(cls) -> None: delete_user(cls.app, username="******") # type: ignore delete_user(cls.app, username="******") # type: ignore delete_user(cls.app, username="******") # type: ignore
def tearDownClass(cls) -> None: delete_user(cls.app, username="******") # type: ignore cls.app = app.create_app(testing=True) # type:ignore
def teardown_class(cls) -> None: delete_user(cls.app, username="******") # type: ignore delete_user(cls.app, username="******") # type: ignore
def tearDownClass(cls) -> None: delete_user(cls.app, username="******") delete_user(cls.app, username="******")