We want to improve automated test coverage for the OAuth extension's critical workflows. Each of the critical flows would likely be its own sub-task, where it would be reviewed and decided (then implemented) which test strategy is needed.
Critical flows
- Developers proposing an OAuth[1/2] consumer (SpecialMWOAuthConsumerRegistration and dependent classes)
- Developers updating an existing OAuth[1/2] consumer (SpecialMWOAuthConsumerRegistration and dependent classes)
- An admin reviewing and approving/declining a proposed consumer (SpecialMWOAuthManageConsumers and dependent classes)
- Users managing approved consumer grants (SpecialMWOAuthManageMyGrants and dependent classes)
- OAuth1 consumer authorization and token exchange (SpecialMWOAuth/authorize and dependent classes)
- OAuth2 authorization and token exchange via SessionProvider (/rest.php/oauth2/authorize, /oauth2/access_token, oauth2/reset_secret and dependent classes)
- Open ID Connect endpoints: Special:MWOAuth/identify (for OAuth 1), oauth2/rest.php/resource/profile (for OAuth 2)
We need to determine which critical flows will be covered by PHPUnit tests and which by E2E testing. PHPUnit is what we already use for PHP/backend side of things, but for E2E testing, we have some options to consider: API testing, Selenium, QUnit, others?
PHPUnit coverage
(source): https://doc.wikimedia.org/cover-extensions/OAuth/src/index.html
Based on the image above, the focus might be Backend, Frontend, Control, and AuthorizationProvider, which together account for most of the classes in the critical flows.
E2E testing
This will mostly cover the action and REST API endpoints (which are multi-requests), such as the authorization and token exchange logic in SpecialMWOAuth. See: https://gitlab.wikimedia.org/tgr/oauth-test-scripts, @Tgr uploaded some useful scripts.
[ ] Decide which framework to use for end-to-end testing. We ended up decided to do everything using PHPUnit.
- Selenium?
- QUnit?
- API testing?
- other?
Related tasks:
- T341759: Create functional tests for core OAuth functionality
- T78314: Add tests against beta to catch OAuth integration issues
We'll likely be using HandlerTestTrait (for REST handlers), ApiTestCase (for action API), and SpecialPageTestBase (for special pages).
Acceptance criteria
- Improved PHPUnit test coverage (X%) for critical workflow. X to be decided and updated.
- E2E tests for critical workflows (PHPUnit)
