From e0325c7fb26777b1e1fa665a5fb56d99810b42ad Mon Sep 17 00:00:00 2001 From: Craig Date: Mon, 28 Feb 2022 19:37:45 -0800 Subject: [PATCH 1/4] Fixing users packages --- superset/users/__init__.py | 17 +++++++++++++++++ tests/integration_tests/users/__init__.py | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 superset/users/__init__.py create mode 100644 tests/integration_tests/users/__init__.py diff --git a/superset/users/__init__.py b/superset/users/__init__.py new file mode 100644 index 0000000000000..fd9417fe5c1e9 --- /dev/null +++ b/superset/users/__init__.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# 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. diff --git a/tests/integration_tests/users/__init__.py b/tests/integration_tests/users/__init__.py new file mode 100644 index 0000000000000..fd9417fe5c1e9 --- /dev/null +++ b/tests/integration_tests/users/__init__.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# 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 ea7e2424164df7761b9b83e44e172cc30f5778c6 Mon Sep 17 00:00:00 2001 From: Craig Date: Mon, 28 Feb 2022 20:13:19 -0800 Subject: [PATCH 2/4] Linting me() fn --- superset/users/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset/users/api.py b/superset/users/api.py index 7d52056a8f070..524a382b0679d 100644 --- a/superset/users/api.py +++ b/superset/users/api.py @@ -31,7 +31,7 @@ class CurrentUserRestApi(BaseApi): @expose("/", methods=["GET"]) @safe - def me(self) -> Response: + def get_me(self) -> Response: """Get the user object corresponding to the agent making the request --- get: From 23813bfdd73281f939700c336029d178f282b18b Mon Sep 17 00:00:00 2001 From: Craig Date: Tue, 1 Mar 2022 08:43:42 -0800 Subject: [PATCH 3/4] Fixing tests / moving packages --- superset/initialization/__init__.py | 2 +- superset/{ => views}/users/__init__.py | 0 superset/{ => views}/users/api.py | 0 superset/{ => views}/users/schemas.py | 0 tests/integration_tests/security_tests.py | 2 +- 5 files changed, 2 insertions(+), 2 deletions(-) rename superset/{ => views}/users/__init__.py (100%) rename superset/{ => views}/users/api.py (100%) rename superset/{ => views}/users/schemas.py (100%) diff --git a/superset/initialization/__init__.py b/superset/initialization/__init__.py index 8c0e0a3b44478..f196fd9f75b2b 100644 --- a/superset/initialization/__init__.py +++ b/superset/initialization/__init__.py @@ -50,9 +50,9 @@ ) from superset.security import SupersetSecurityManager from superset.typing import FlaskResponse -from superset.users.api import CurrentUserRestApi from superset.utils.core import pessimistic_connection_handling from superset.utils.log import DBEventLogger, get_event_logger_from_cfg_value +from superset.views.users.api import CurrentUserRestApi if TYPE_CHECKING: from superset.app import SupersetApp diff --git a/superset/users/__init__.py b/superset/views/users/__init__.py similarity index 100% rename from superset/users/__init__.py rename to superset/views/users/__init__.py diff --git a/superset/users/api.py b/superset/views/users/api.py similarity index 100% rename from superset/users/api.py rename to superset/views/users/api.py diff --git a/superset/users/schemas.py b/superset/views/users/schemas.py similarity index 100% rename from superset/users/schemas.py rename to superset/views/users/schemas.py diff --git a/tests/integration_tests/security_tests.py b/tests/integration_tests/security_tests.py index b311612fcd2b4..2ebced8069a3d 100644 --- a/tests/integration_tests/security_tests.py +++ b/tests/integration_tests/security_tests.py @@ -905,7 +905,7 @@ def test_views_are_secured(self): ["LocaleView", "index"], ["AuthDBView", "login"], ["AuthDBView", "logout"], - ["CurrentUserRestApi", "me"], + ["CurrentUserRestApi", "get_me"], ["Dashboard", "embedded"], ["R", "index"], ["Superset", "log"], From d5a2f984a57924c8e1999c04bb87fe88330dabe6 Mon Sep 17 00:00:00 2001 From: Craig Date: Tue, 1 Mar 2022 09:08:12 -0800 Subject: [PATCH 4/4] Fixing imports --- superset/initialization/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset/initialization/__init__.py b/superset/initialization/__init__.py index f196fd9f75b2b..59e204d6d65e8 100644 --- a/superset/initialization/__init__.py +++ b/superset/initialization/__init__.py @@ -52,7 +52,6 @@ from superset.typing import FlaskResponse from superset.utils.core import pessimistic_connection_handling from superset.utils.log import DBEventLogger, get_event_logger_from_cfg_value -from superset.views.users.api import CurrentUserRestApi if TYPE_CHECKING: from superset.app import SupersetApp @@ -195,6 +194,7 @@ def init_views(self) -> None: TabStateView, ) from superset.views.tags import TagView + from superset.views.users.api import CurrentUserRestApi # # Setup API views