eschutho commented on code in PR #29687: URL: https://github.com/apache/superset/pull/29687#discussion_r1697772249
########## tests/integration_tests/security/api_tests.py: ########## @@ -135,3 +136,125 @@ def test_post_guest_token_bad_resources(self): ) self.assert400(response) + + +class TestSecurityRolesApi(SupersetTestCase): + uri = "api/v1/security/roles/" # noqa: F541 + + @with_config({"FAB_ADD_SECURITY_API": True}) + def test_get_security_roles_admin(self): + """ + Security API: Admin should be able to create roles + """ + self.login(ADMIN_USERNAME) + response = self.client.get(self.uri) + self.assert200(response) + + @with_config({"FAB_ADD_SECURITY_API": True}) + def test_get_security_roles_gamma(self): + """ + Security API: Admin should be able to create roles + """ + self.login(GAMMA_USERNAME) + response = self.client.get(self.uri) + self.assert403(response) + + @with_config({"FAB_ADD_SECURITY_API": True}) + def test_post_security_roles_gamma(self): + """ + Security API: Gamma shouldnt be able to create roles + """ + self.login(GAMMA_USERNAME) + response = self.client.post( + self.uri, + data=json.dumps({"name": "new_role"}), + content_type="application/json", + ) + self.assert403(response) + + @with_config({"FAB_ADD_SECURITY_API": True}) + def test_put_security_roles_gamma(self): + """ + Security API: <TODO> + """ + self.login(GAMMA_USERNAME) + response = self.client.put( + f"{self.uri}1", + data=json.dumps({"name": "new_role"}), + content_type="application/json", + ) + self.assert403(response) + + @with_config({"FAB_ADD_SECURITY_API": True}) + def test_delete_security_roles_gamma(self): + """ + Security API: <TODO> + """ + self.login(GAMMA_USERNAME) + response = self.client.delete( + f"{self.uri}1", + data=json.dumps({"name": "new_role"}), + content_type="application/json", + ) + self.assert403(response) + + +class TestSecurityPermissionsApi(SupersetTestCase): + uri = "api/v1/security/permission/" # noqa: F541 + + @with_config({"FAB_ADD_SECURITY_API": True}) + def test_get_security_roles_admin(self): + """ + Security API: Admin should be able to create roles + """ + self.login(ADMIN_USERNAME) + response = self.client.get(self.uri) + self.assert200(response) + + @with_config({"FAB_ADD_SECURITY_API": True}) + def test_get_security_roles_gamma(self): + """ + Security API: Admin should be able to create roles + """ + self.login(GAMMA_USERNAME) + response = self.client.get(self.uri) + self.assert200(response) + + @with_config({"FAB_ADD_SECURITY_API": True}) + def test_post_security_roles_gamma(self): + """ + Security API: Gamma shouldnt be able to create roles + """ + self.login(GAMMA_USERNAME) + response = self.client.post( + self.uri, + data=json.dumps({"name": "new_role"}), + content_type="application/json", + ) + self.assert403(response) + + # @with_config({"FAB_ADD_SECURITY_API": True}) + # def test_put_security_roles_gamma(self): + # """ + # Security API: <TODO> + # """ + # self.login(GAMMA_USERNAME) + # response = self.client.put( + # f"{self.uri}1", + # data=json.dumps({"name": "new_role"}), + # content_type="application/json", + # ) + # self.assert403(response) + + # @with_config({"FAB_ADD_SECURITY_API": True}) + # def test_delete_security_roles_gamma(self): + # """ + # Security API: <TODO> + # """ + # self.login(GAMMA_USERNAME) + # response = self.client.delete( + # f"{self.uri}1", + # data=json.dumps({"name": "new_role"}), + # content_type="application/json", + # ) + # self.assert403(response) Review Comment: Yey for all the new tests! What should we do with these last two? -- 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