On 6/16/06, Michael Petnuch <[EMAIL PROTECTED]> wrote:
Hey Cees,
I put up a test script on my website. Since I was using the DBI
driver I created a simple database to show the problem (just in case
its a problem with the DBI driver?). Anyway, included in the files
is a database dump. I am using MySQL 5 and the latest versions of
CGI::App and the Auth and Authz plugins. I put the files here:
http://www.petnuch.com/TEST_FOR_CEES/
Thanks Michael,
That helped a lot. This is definately a bug, and since it is an
annoying one, I have packaged up a new release and sent it up to CPAN.
If you want it early, you can download it from my website here:
http://cees.crtconsulting.ca/perl/modules/CGI-Application-Plugin-Authorization-0.05.tar.gz
P.S. I hope this is what you wanted, because I am not really familiar
with the Perl "test" modules to create an example using one of those.
What you provided was perfect. It saved me a lot of time, and hence I
was able to fix the problem quickly. As for using the perl test
modules, I'll show you very quickly how I altered your script to use
the tests:
# Added this to the top of the Testing.pm file
use Test::More qw(no_plan);
# testing a positive result
ok($self->authorization('is_user')->authorize(1), "User is authorized
to edit article 1");
# testing a negative result
ok( ! $self->authorization('is_user')->authorize(2), "User is not
authorized to edit article 2");
This ends up printing the results to STDOUT instead of collecting them
in $html, but I am not too worried about that, because I ran these
tests from the command line anyway. Doing it this way makes it
immediately obvious when something is wrong, and when you have fixed
it. Here is the failure results:
ok 1 - User is authorized to edit article 1
ok 2 - User is not authorized to edit article 2
ok 3 - User is authorized to edit article 3
ok 4 - User has clearence 1
ok 5 - User does not have clearence 2
not ok 6 - User does not have clearence 3
# Failed test 'User does not have clearence 3'
# in Testing.pm at line 110.
And once I fixed the problem, this is the result:
ok 1 - User is authorized to edit article 1
ok 2 - User is not authorized to edit article 2I get lots of info to
help in debugging.
ok 3 - User is authorized to edit article 3
ok 4 - User has clearence 1
ok 5 - User does not have clearence 2
ok 6 - User does not have clearence 3
So just by using that very simple 'ok' function, I can very quickly
see what is going on.
Thanks again for the bug report...
Cheers,
Cees
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]