Graham Ollis > PlugAuth-Lite-0.07 > Test::PlugAuth

Download:
PlugAuth-Lite-0.07.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.07   Source  

NAME ^

Test::PlugAuth - minimum PlugAuth server to test Clustericious apps against

VERSION ^

version 0.07

SYNOPSIS ^

assuming you have a Clustericious app MyApp with authentication/authorization directives that you need to test:

 use Test::Clustericious::Config;
 use Test::Clustericious;
 use Test::PlugAuth;
 
 my $auth = Test::PlugAuth->new(auth => {
   my($user,$pass) = @_;
   return $user eq 'gooduser' && $pass eq 'goodpass';
 });
 
 create_config_ok 'MyApp', { plug_auth => { url => $auth->url } };
 
 $t = Test::Clustericious->new('MyApp');
 $auth->apply_to_client_app($t->app);
 
 my $port = $t->ua->app_url->port;
 
 $t->get_ok("http://baduser:badpass\@localhost:$port/private")
   ->status_is(401);
 $t->get_ok("http://gooduser:goodpass\@localhost:$port/private")
   ->status_is(200);

DESCRIPTION ^

Provides a way to test a Clustericious application with a fake PlugAuth server with reduced boilerplate

CONSTRUCTOR ^

Test::PlugAuth->new( $config )

Creates a new instance of Test::PlugAuth. The $config is passed directly into PlugAuth::Lite. See Mojolicious::Plugin::PlugAuthLite for details.

ATTRIBUTES ^

ua

The Mojo::UserAgent used to connect to the PlugAuth (lite) server.

app

The PlugAuth::Lite instance of the PlugAuth server.

url

The (fake) url used to connect to the PlugAuth server with. You MUST connect to through the Mojo::UserAgent above.

METHODS ^

$test_auth->apply_to_client_app( $client_app )

Given a Clustericious application $client_app, this method will rewire our Mojo::UserAgent for authentication requests to PlugAuth.

AUTHOR ^

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2013 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: