-
Notifications
You must be signed in to change notification settings - Fork 192
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
Experimental way of testing HubController api endpoint call #9704
base: issv3
Are you sure you want to change the base?
Conversation
👋 Hello! Thanks for contributing to our project. If you are unsure the failing tests are related to your code, you can check the "reference jobs". These are jobs that run on a scheduled time with code from master. If they fail for the same reason as your build, it means the tests or the infrastructure are broken. If they do not fail, but yours do, it means it is related to your code. Reference tests: KNOWN ISSUES Sometimes the build can fail when pulling new jar files from download.opensuse.org . This is a known limitation. Given this happens rarely, when it does, all you need to do is rerun the test. Sorry for the inconvenience. For more tips on troubleshooting, see the troubleshooting guide. Happy hacking! |
Suggested tests to cover this Pull Request |
@CDellaGiusta This looks good. I would implement this in a new class called |
simulateHubControllerApi has all the dependencies to HubFactory and HubController If we decide to go for a separate ControllerTestUtils class, then we can keep these two methods in the same place. Let's see what the others think |
//maybe this method could be moved to SparkTestUtils? | ||
private Object simulateApiEndpointCall(String apiEndpoint, HttpMethod httpMethod, String authBearerToken) | ||
throws Exception { | ||
Optional<RouteMatch> routeMatch = spark.Spark.routes() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be a option to use the route find method, which would be able to handle wildcard?
In the URL you could use the expected URL to be used (like: /systems/1000001/bla
) which would math the route pattern like /systems/:ID/bla
.
You can see an example in here: https://github.com/rjmateus/uyuni/blob/uyuni_hack_authorization_check/java/code/src/com/redhat/rhn/frontend/servlets/AccessFilter.java#L116-L118
What does this PR change?
EXPERIMENTAL!
The aim is to test a HubController API call without actually setting up a remote server and using tools like postman.
The idea is that unit tests can be done to test the behaviour and the returned values, while a single manual test can be done from the external (e.g. postman) to check that the API endpoint is really visible.
In this test I tried to test the /hub/managerinfo API endpoint, and of course I will use the testing environment to build and test the APIs that are still missing.
Although I guess I will be expanding the way things are tested, I'd like somebody else to have a look at it to see if I'm on the right track before proceeding further on this road. All comments and suggestions are extremely welcome.
GUI diff
Documentation
Test coverage
Links
Changelogs
Re-run a test