site-kit-wp
site-kit-wp copied to clipboard
Extract a new REST controller from core `Authentication`
Feature Description
Similar to the work we did in #5732, this issue is about extracting the REST related behavior into a new controller.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- All rest routes registered and related helper methods and defined by the core
Authenticationclass should be extracted to a newGoogle\Site_Kit\Core\Authentication\REST_Authentication_Controllerclass- An accompanying test case should be created for it, similar to others that exercises the REST endpoints it registers and all REST-related tests should move from
AuthenticationTestto the controller's test case - Test coverage should be added for any untested endpoints
- The controller should be registered within
Authentication::register
- An accompanying test case should be created for it, similar to others that exercises the REST endpoints it registers and all REST-related tests should move from
- No change in behavior should be made/observable here
Implementation Brief
- [ ] Add
Google\Site_Kit\Core\Authentication\REST_Authentication_Controllerclass- In
constructmethod pass theAuthenticationinstance, and set it as a class property so all the needed methods can be accessed easily. - Add
registermethod, and movegooglesitekit_apifetch_preload_pathsandgooglesitekit_rest_routesfilters fromAuthenticationclass here - Move
get_rest_routesmethod fromAuthenticationclass, and use it's instance from class property to access the needed methods there
- In
- [ ] Update
includes/Core/Authentication/Authentication.php- In
construct, instantiateREST_Authentication_Controllerclass, passing$this, and invokeREST_Authentication_Controller::registermethod in theAuthentication::register
- In
Test Coverage
- Add
REST_Authentication_ControllerTest.php- Add tests for
googlesitekit_rest_routesandgooglesitekit_apifetch_preload_paths - Move over the
test_disconnect - Add test coverage for
connectionandauthenticationendpoints, confirming the data returned, andget-token, you can save it usingOAuth_Client::OPTION_ACCESS_TOKEN
- Add tests for
QA Brief
- Set up Site Kit on a new site
- Set up all modules and uninstall all modules
No errors should occur during authentication.
Changelog entry
- N/A
IB ✔️
QA Update ✅
- Tested on dev envrironment.
- Done smoke testing.
- Verified all modules setup successfully.
- Verified all modules disconnected successfully.
- No console errors or dashboard errors found.
@10upsimon I left a comment on the PR but there is a little bit of follow-up to do here. This is good to go for now, but let's open another issue to address the rest. Let me know if you have any questions, thanks!