In my auto action I have something like:
$c->{ USERNAME } =
$c->engine->env->{ HTTP_COOKIE } ;#Authenticated via apache 2.4
mod_auth_form
$c->{ USERRIGHTS } = $c->model( 'method returning a ref
to a list of the rights for $c->{ USERNAME }');
In a controller I
would like to test
There is code that checks user-rights, if it fails
it redirects to an error page.
I would like to write a sequence of
tests that checks the controller for users with different rights where
some users are expected to get a redirect and others might see different
responses. I'm still trying to work out controller testing so I don't
have functional code to explain but if you pardon the following for not
being quite workable code.
my $user1 = 'restricted' ; my $user2 =
'privileged' ; my $user3 = 'hardworker' ;
$test_object->{ username =
$user1 } ;
redirects_ok( $test_object->('/pageimtesting'), 'restricted
user got sent elsewhere' ) ;
$test_object->{ username = $user2 }
;
content_contains( $test_object->('/pageimtesting'), 'exalted one',
'grovelled for privileged user' ) ;
$test_object->{ username = $user3
} ;
content_contains( $test_object->('/pageimtesting'), 'well do
something', 'told worker to do something.' ) ;
FROM: John Napiorkowski
[mailto:[email protected]]
SENT: Sunday, April 15, 2012 3:35 PM
TO: The
elegant MVC web framework
SUBJECT: Re: [Catalyst] Application Testing,
Mocking Apache Headers/Environment
John,
Could you give us a bit more
information? For example do you have a test case you are trying to
write, but can't? I'll a little confused as to what you are trying to do
and maybe seeing more code would help.
Oh, and Just FYI the newer
versions of Catalyst move the env access from engine to request, and if
you are planning of making heavy use of that I'd consider upgrading, so
that you won't have compatibility issues later.
John
-------------------------
FROM: John Karr <[email protected]
[1]>
TO: 'The elegant MVC web framework' <[email protected]
[2]>
SENT: Thursday, April 12, 2012 3:39 PM
SUBJECT: [Catalyst]
Application Testing, Mocking Apache Headers/Environment
I am trying to
test an application that is deployed behind a proxy and which
is
dependent on obtaining information from the request
through
$c->engine->env this information includes the logged in user and
client ip
address. I've been using the config file to provide override
values,
however, this is not helpful for testing multiple
values.
_______________________________________________
List:
[email protected] [3]
Listinfo:
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
[4]
Searchable archive:
http://www.mail-archive.com/[email protected]/ [5]
Dev site:
http://dev.catalyst.perl.org/ [6]
Links:
------
[1]
mailto:[email protected]
[2] mailto:[email protected]
[3]
mailto:[email protected]
[4]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
[5]
http://www.mail-archive.com/[email protected]/
[6]
http://dev.catalyst.perl.org/
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/