Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CKAN registering only plugin's first blueprint #7108

Merged
merged 8 commits into from
Oct 5, 2022

Conversation

pdelboca
Copy link
Member

Proposed fixes:

This PR fixes an error in the logic that makes CKAN to register only the first Blueprint defined in an extension.

It also refactors some of the CSRF logic to internal method for better readability and maintenance.

@pdelboca
Copy link
Member Author

@smotornyuk what do you think is the best way to test that all blueprints returned by get_blueprint() gets registered?

I'm thinking on adding a test to test_middleware.py by refactoring a little bit the MockRoutingPlugin class to register two blueprints. What are your thoughts on how to test this scenarios?

@pdelboca pdelboca marked this pull request as ready for review September 28, 2022 13:15
@smotornyuk
Copy link
Member

How about testing inside the existing iblueprint plugin? If you update this example, people who are checking these examples will also know about the ability to register multiple blueprints at once.

As for testing, stubbing register_extension_blueprint or Flask's Blueprint.register_blueprint would be the most reliable option, but honestly, I don't like such low-level tests. What do you think about registering a blueprint with the route /x and another one with the route /y and just making a couple of requests to these endpoints? In this way, no matter how the code changes(even if we migrate from flask to something else in the future), this test will remain the same.

@pdelboca
Copy link
Member Author

@smotornyuk I have implemented the tests and updated the ExampleIBlueprintPlugin.

let me know your thoughs!

@smotornyuk smotornyuk merged commit 0766930 into ckan:master Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants