Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,6 @@ def get_authorized_dag_ids(
return {dag.dag_id for dag in session.execute(select(DagModel.dag_id))}
if resource.startswith(permissions.RESOURCE_DAG_PREFIX):
resources.add(resource[len(permissions.RESOURCE_DAG_PREFIX) :])
else:
resources.add(resource)
return set(session.scalars(select(DagModel.dag_id).where(DagModel.dag_id.in_(resources))))

@cached_property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,14 +706,14 @@ def test_filter_authorized_menu_items(
(
"GET",
[(ACTION_CAN_READ, RESOURCE_DAG)],
{"test_dag1", "test_dag2"},
{"test_dag1", "test_dag2", "Connections"},
),
# Scenario 2
# With global edit permissions on Dags
(
"PUT",
[(ACTION_CAN_EDIT, RESOURCE_DAG)],
{"test_dag1", "test_dag2"},
{"test_dag1", "test_dag2", "Connections"},
),
# Scenario 3
# With DAG-specific permissions
Expand Down Expand Up @@ -750,6 +750,13 @@ def test_filter_authorized_menu_items(
[(ACTION_CAN_EDIT, "DAG:test_dag1"), (ACTION_CAN_EDIT, "DAG:test_dag2")],
{"test_dag1", "test_dag2"},
),
# Scenario 9
# With non-DAG related permissions
(
"GET",
[(ACTION_CAN_READ, "DAG:test_dag1"), (ACTION_CAN_READ, RESOURCE_CONNECTION)],
{"test_dag1"},
),
],
)
def test_get_authorized_dag_ids(
Expand All @@ -759,6 +766,8 @@ def test_get_authorized_dag_ids(
EmptyOperator(task_id="task1")
with dag_maker("test_dag2"):
EmptyOperator(task_id="task1")
with dag_maker("Connections"):
EmptyOperator(task_id="task1")

auth_manager_with_appbuilder.security_manager.sync_perm_for_dag("test_dag1")
auth_manager_with_appbuilder.security_manager.sync_perm_for_dag("test_dag2")
Expand Down
Loading