mayurnewase commented on code in PR #22325:
URL: https://github.com/apache/superset/pull/22325#discussion_r1051422243


##########
tests/integration_tests/security/row_level_security_tests.py:
##########
@@ -304,6 +306,45 @@ def 
test_rls_filter_doesnt_alter_admin_birth_names_query(self):
         assert not self.BASE_FILTER_REGEX.search(sql)
 
 
+class TestRowLevelSecurityWithRelatedFilters(SupersetTestCase):
+    @pytest.mark.usefixtures("load_birth_names_data")
+    @pytest.mark.usefixtures("load_energy_table_data")
+    def test_rls_tables_related_api(self):
+        self.login("Admin")
+
+        params = prison.dumps({"page": 0, "page_size": 100})
+
+        rv = 
self.client.get(f"/api/v1/rowlevelsecurity/related/tables?q={params}")
+        self.assertEqual(rv.status_code, 200)
+        data = json.loads(rv.data.decode("utf-8"))
+        result = data["result"]
+
+        db_tables = db.session.query(SqlaTable).all()
+
+        db_table_names = set([t.table_name for t in db_tables])
+        received_tables = set([table["text"].split(".")[-1] for table in 
result])
+
+        assert data["count"] == len(db_tables)
+        assert len(result) == len(db_tables)
+        assert db_table_names == received_tables
+
+    def test_rls_roles_related_api(self):
+        self.login("Admin")
+        params = prison.dumps({"page": 0, "page_size": 100})
+
+        rv = 
self.client.get(f"/api/v1/rowlevelsecurity/related/roles?q={params}")
+        self.assertEqual(rv.status_code, 200)
+        data = json.loads(rv.data.decode("utf-8"))
+        result = data["result"]
+
+        db_role_names = set([r.name for r in security_manager.get_all_roles()])
+        received_roles = set([role["text"] for role in result])
+
+        assert data["count"] == len(db_role_names)
+        assert len(result) == len(db_role_names)
+        assert db_role_names == received_roles

Review Comment:
   added tests for post, put, bulk delete.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to