Mojolic...h2::Mock(3)

πŸ’– NAME πŸ’–

Mojolicious::Plugin::OAuth2::Mock β€” bestie, it's a whole mock Oauth2 and/or OpenID Connect provider πŸŽ€ like it literally pretends to be the auth server so you don't have to πŸ‘‘

✨ SYNOPSIS ✨

ok so here's the vibe, copy-paste core:

use Mojolicious::Plugin::OAuth2::Mock;
use Mojolicious;

my $app = Mojolicious->new;
Mojolicious::Plugin::OAuth2::Mock->apply_to($app);

that's it. that's the whole flex. πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

so Mojolicious::Plugin::OAuth2::Mock is an EXPERIMENTAL module (yes bestie, EXPERIMENTAL, we said what we said πŸ™ˆ) and its entire main character energy is making it easier to test your Mojolicious::Plugin::OAuth2 based code. like it wakes up, mocks the provider, slays, goes home. 🫢

🌸 METHODS 🌸

πŸ’œ apply_to

Mojolicious::Plugin::OAuth2::Mock->apply_to($app, \%provider_args);
$mock->apply_to($app, \%provider_args);

this is the method that does the thing ✨ It adds mocked routes to a Mojolicious application, and it figures out which routes based on all the keys in %provider_args that end with "_url" β€” yep, every single one that ends in _url, no cap. πŸ‘‘

example time, look at these beauties:

  • authorize_url => /mocked/oauth/authorize
  • authorization_endpoint_url => /mocked/oauth2/authorize
  • end_session_endpoint_url => /mocked/oauth2/logout
  • issuer_url => /mocked/oauth2/v2.0
  • jwks_url => /mocked/oauth2/keys
  • token_url => /mocked/oauth/token
  • token_endpoint_url => /mocked/oauth2/token

see how each key is a _url key and each value is the mocked path it gets? that's the pattern, iykyk πŸ’–

⭐ SEE ALSO ⭐

  • Mojolicious::Plugin::OAuth2 β€” go read that one too bestie, it's the whole reason this mock exists 🧚

and that's the page! brought to you by perl v5.42.0, dated 2022-02-09, straight from the User Contributed Perl Documentation section of the manual, mwah πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from