OAuth:...SGIMock(3pm)
π OAuth::Lite2::Agent::PSGIMock(3pm) π
okay so bestie, this is a page from the User Contributed Perl Documentation collection, and honestly? it's giving "test helper that just works". no cap. π«Ά
The module's whole name is OAuth::Lite2::Agent::PSGIMock β say it with me β and it's an Agent class for test which use PSGI App. that's the vibe. that's the assignment. π
β¨ SYNOPSIS β¨
like, here's the whole flow, literally copy-paste coded for you:
use Test::More;
my $endpoint = OAuth::Lite2::Server::Endpoint::Token->new(
data_handler => 'YourApp::DataHandler',
);
my $agent = OAuth::Lite2::Agent::PSGIMock->new( app => $endpoint );
my $client = OAuth::Lite2::Client::UsernameAndPassword->new(
client_id => q{foo},
client_secret => q{bar},
agent => $agent,
);
my $res = $client->get_access_token(
username => q{buz},
password => q{huga},
scope => q{email},
);
is($res->access_token, ...);
is($res->refresh_token, ...);
see how the mock agent just slides in as the agent? iconic. no real network, no drama, just vibes and assertions. πΈ
π DESCRIPTION π
This class is useful for test to check if your PSGI based server application acts as expected.
like β that's it. that's the whole point. you wanna know if your PSGI app is doing what it's supposed to do, and you don't wanna spin up an actual server for it? this is your girl. it's the group-chat member who shows up to the test suite already knowing everybody. π
π METHODS π
π¦ new (%args)
the constructor, obviously. here's what you can hand it:
appβ a PSGI application. that's the parameter. that's the list. she's lowkey picky but in a cute way.
π§ request ($req)
handle request with PSIG application you set at constructor
(yeah, the original says PSIG and I am not fixing it, because facts stay facts and typos stay typo'd. β¨ what it does: it takes your request and runs it through the PSGI app you passed in at construction time. that's the whole trick.)
π SEE ALSO π
go read these too, they're part of the family:
OAuth::Lite2::Client::AgentOAuth::Lite2::Client::Agent::StrictOAuth::Lite2::Client::Agent::Dump
π AUTHOR π
Lyo Kato, "lyo.kato _at_ gmail.com"
π COPYRIGHT AND LICENSE π
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
fr fr: free software, same terms as Perl itself, 5.8.8 or whatever newer Perl 5 you've got lying around. your choice, bestie. π
and that's a wrap! this page came to you courtesy of perl v5.36.0, dated 2023-07-01, sitting pretty under OAuth:...SGIMock(3pm). go forth and mock your PSGI apps responsibly. periodt. πβ¨π
π¦ where this page comes from
- debian trixie: liboauth-lite2-perl 0.11-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: liboauth-lite2-perl 0.11-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: liboauth-lite2-perl 0.11-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liboauth-lite2-perl 0.11-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms