Skip to content

Cover authorization flows and encryption with tests - #42

Merged
robertlemke merged 2 commits into
mainfrom
task/test-seams-and-coverage
Sep 14, 2026
Merged

robertlemke merged 2 commits into
mainfrom
task/test-seams-and-coverage

Conversation

@robertlemke

Copy link
Copy Markdown
Member

The OAuth client creates the HTTP client of its OAuth provider in the new protected method createHttpClient(), so that subclasses can configure it and tests can replace it. Nothing else changes in the behaviour of the package.

With this, the tests cover starting and finishing an authorization, the client credentials grant, removing authorizations, their metadata, and the encryption service. Guzzle's mock handler stands in for the OAuth server. The test fixtures are loaded through autoload-dev.

This is the first of several pull requests for version 5.0, which build on each other.

OAuthClient now creates the HTTP client of its OAuth provider in the
protected method createHttpClient(). Subclasses can override it, for
example to set timeouts or a proxy, and tests can replace it.

Previously, league/oauth2-client created the client internally, so the
requests of the authorization code and client credentials flows could
not be observed in tests.
The tests now cover starting and finishing an authorization, the client
credentials grant, removing authorizations, their metadata, and the
encryption service. They use Guzzle's mock handler in place of the
OAuth server and an in-memory stand-in for the entity manager.

The test fixtures are loaded through autoload-dev instead of
require_once, and a test named after SHA-1 now says that it checks a
SHA-512 hash.
@robertlemke
robertlemke merged commit 27b0c12 into main Sep 14, 2026
6 checks passed
@robertlemke
robertlemke deleted the task/test-seams-and-coverage branch September 14, 2026 11:07
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.

1 participant