From e6be51953cad5f2872ea8effa40cd1060158f058 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 10 Dec 2019 01:17:34 -0800 Subject: [PATCH] Avoid circular dependency between superset config and superset package (#8254) Resolve comments Avoid circular dependency between superset config and superset package Resolve comments --- superset/security/__init__.py | 17 +++++++++++++++++ superset/{security.py => security/manager.py} | 0 tests/security_tests.py | 8 ++++---- 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 superset/security/__init__.py rename superset/{security.py => security/manager.py} (100%) diff --git a/superset/security/__init__.py b/superset/security/__init__.py new file mode 100644 index 000000000..42f1a0c56 --- /dev/null +++ b/superset/security/__init__.py @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from superset.security.manager import SupersetSecurityManager # noqa: F401 diff --git a/superset/security.py b/superset/security/manager.py similarity index 100% rename from superset/security.py rename to superset/security/manager.py diff --git a/tests/security_tests.py b/tests/security_tests.py index f5fbb1c80..abb6c0355 100644 --- a/tests/security_tests.py +++ b/tests/security_tests.py @@ -399,7 +399,7 @@ class RolePermissionTests(SupersetTestCase): # TODO test slice permission - @patch("superset.security.g") + @patch("superset.security.manager.g") def test_schemas_accessible_by_user_admin(self, mock_g): mock_g.user = security_manager.find_user("admin") with self.client.application.test_request_context(): @@ -409,7 +409,7 @@ class RolePermissionTests(SupersetTestCase): ) self.assertEquals(schemas, ["1", "2", "3"]) # no changes - @patch("superset.security.g") + @patch("superset.security.manager.g") def test_schemas_accessible_by_user_schema_access(self, mock_g): # User has schema access to the schema 1 create_schema_perm("[examples].[1]") @@ -423,7 +423,7 @@ class RolePermissionTests(SupersetTestCase): self.assertEquals(schemas, ["1"]) delete_schema_perm("[examples].[1]") - @patch("superset.security.g") + @patch("superset.security.manager.g") def test_schemas_accessible_by_user_datasource_access(self, mock_g): # User has schema access to the datasource temp_schema.wb_health_population in examples DB. mock_g.user = security_manager.find_user("gamma") @@ -434,7 +434,7 @@ class RolePermissionTests(SupersetTestCase): ) self.assertEquals(schemas, ["temp_schema"]) - @patch("superset.security.g") + @patch("superset.security.manager.g") def test_schemas_accessible_by_user_datasource_and_schema_access(self, mock_g): # User has schema access to the datasource temp_schema.wb_health_population in examples DB. create_schema_perm("[examples].[2]")