mik-laj commented on a change in pull request #15295:
URL: https://github.com/apache/airflow/pull/15295#discussion_r611214862



##########
File path: tests/api_connexion/test_security.py
##########
@@ -0,0 +1,48 @@
+# 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.
+
+import pytest
+
+from airflow.security import permissions
+from tests.test_utils.api_connexion_utils import create_user, delete_user
+
+
[email protected](scope="module")
+def configured_app(minimal_app_for_api):
+    app = minimal_app_for_api
+    create_user(
+        app,  # type:ignore
+        username="test",
+        role_name="Test",
+        permissions=[(permissions.ACTION_CAN_READ, 
permissions.RESOURCE_CONFIG)],  # type: ignore
+    )
+
+    yield minimal_app_for_api
+
+    delete_user(app, username="test")  # type: ignore
+
+
+class TestSession:
+    @pytest.fixture(autouse=True)
+    def setup_attrs(self, configured_app) -> None:
+        self.app = configured_app
+        self.client = self.app.test_client()  # type:ignore
+
+    def test_session_not_created_on_api_request(self):
+        self.client.get("api/v1/dags", environ_overrides={'REMOTE_USER': 
"test"})
+        cookie = next((cookie for cookie in self.client.cookie_jar if 
cookie.name == "session"), None)
+        assert cookie is None

Review comment:
       ```suggestion
           assert all(cookie for cookie in self.client.cookie_jar if 
cookie.name != "session")
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to