From 087003e4737287062a4dfa7b8c00c333977f4dfb Mon Sep 17 00:00:00 2001 From: Craig Rueda Date: Tue, 1 Mar 2022 09:47:13 -0800 Subject: [PATCH] fix(packages): Fixing users packages (#18973) * Fixing users packages * Linting me() fn * Fixing tests / moving packages * Fixing imports (cherry picked from commit 5fc7adb55b364c2f0f72a7b37f73590038936bf4) --- superset/initialization/__init__.py | 2 +- superset/views/users/__init__.py | 17 +++++++++++++++++ superset/{ => views}/users/api.py | 2 +- superset/{ => views}/users/schemas.py | 0 tests/integration_tests/security_tests.py | 2 +- tests/integration_tests/users/__init__.py | 17 +++++++++++++++++ 6 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 superset/views/users/__init__.py rename superset/{ => views}/users/api.py (98%) rename superset/{ => views}/users/schemas.py (100%) create mode 100644 tests/integration_tests/users/__init__.py diff --git a/superset/initialization/__init__.py b/superset/initialization/__init__.py index 8c0e0a3b4447..59e204d6d65e 100644 --- a/superset/initialization/__init__.py +++ b/superset/initialization/__init__.py @@ -50,7 +50,6 @@ ) 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 @@ -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 diff --git a/superset/views/users/__init__.py b/superset/views/users/__init__.py new file mode 100644 index 000000000000..fd9417fe5c1e --- /dev/null +++ b/superset/views/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/superset/users/api.py b/superset/views/users/api.py similarity index 98% rename from superset/users/api.py rename to superset/views/users/api.py index 7d52056a8f07..524a382b0679 100644 --- a/superset/users/api.py +++ b/superset/views/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: 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 b311612fcd2b..2ebced8069a3 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"], diff --git a/tests/integration_tests/users/__init__.py b/tests/integration_tests/users/__init__.py new file mode 100644 index 000000000000..fd9417fe5c1e --- /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.