CGI-Application-Plugin-CAPTCHA

 view release on metacpan or  search on metacpan

t/02-create.t  view on Meta::CPAN

{
    # Create our mech object
    my $mech = Test::WWW::Mechanize->new( cookie_jar => {} );

    # Force the base app to render some output (something it should NOT normally do!).
    # Capture the result.
    $mech->get_ok('http://localhost:' . PORT . '/', "Got CAPTCHA successfully");

    # Get the cookie we should have been fed
    my $jar = $mech->cookie_jar;
    isa_ok($jar, "HTTP::Cookies");

    # Make sure we got a cryptographic hash in a cookie
    my $cookie = $jar->as_string;
    my ($hash) = $cookie =~ /hash=(.*?);/;
    isnt($hash, "", "Received cryptographic hash in cookie");

    # Make sure our header is type 'image/png'
    #like($hash, qr/^image\/png$/i, "Valid image/png header type for content");

    # Make sure we have content

t/03-verify.t  view on Meta::CPAN

{
    # Create our mech object
    my $mech = Test::WWW::Mechanize->new( cookie_jar => {} );

    # Force the base app to render some output (something it should NOT normally do!).
    # Capture the result.
    $mech->get_ok('http://localhost:' . PORT . '/', "Got CAPTCHA successfully");

    # Get the cookie we should have been fed
    my $jar = $mech->cookie_jar;
    isa_ok($jar, "HTTP::Cookies");

    # Make sure we got a cryptographic hash in a cookie
    my $cookie = $jar->as_string;
    my ($hash) = $cookie =~ /hash=(.*?);/;
    isnt($hash, "", "Received cryptographic hash in cookie");

    # Make sure our cookie contains the CAPTCHA value ABC123
    my $secret = 'vbCrfzMCi45TD7Uz4C6fjWvX6us';
    my $check  = Digest::SHA1::sha1_base64(join("\0", $secret, 'ABC123'));
    #my $salt = substr($hash, 0, 2);



( run in 0.746 second using v1.01-cache-2.11-cpan-e9199f4ba4c )