Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Testing OpenID Logins + more

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


frioux at gmail

Aug 31, 2009, 8:43 PM

Post #1 of 6 (1389 views)
Permalink
Testing OpenID Logins + more

Hey guys,

I'd really like to start testing my controllers, and I wished I'd started
sooner, but oh well. The biggest barrier at this point is the login
system. It uses OpenID for auth, which is where the hard stuff comes from.
I *have* looked at the tests for the OpenID module for catalyst auth, and
although I'll surely end up using something like that, it's pretty
intimidating. Does anyone have any existing basic tests for OpenID stuff,
to test their server, as opposed to the OpenID module, that they might be
willing to share? I'd really appreciate it. In the meantime I'll be trying
to look more at Ashley's stuff.

Thanks!

--
fREW Schmidt
http://blog.afoolishmanifesto.com


bobtfish at bobtfish

Sep 2, 2009, 10:48 AM

Post #2 of 6 (1265 views)
Permalink
Re: Testing OpenID Logins + more [In reply to]

On 1 Sep 2009, at 04:43, fREW Schmidt wrote:
> I'd really like to start testing my controllers, and I wished I'd
> started sooner, but oh well. The biggest barrier at this point is
> the login system. It uses OpenID for auth, which is where the hard
> stuff comes from.
<snip>

Why bother with the complexity when testing if it isn't the OpenID
stuff your testing specifically.

I'd arrange for the relevant tests to supply a custom config file (I
do this by mangling MYAPP_CONFIG env variable in the tests, although
I'm sure there are more elegant solutions)..

You can then change the authentication config to use different auth
modules (for example authenticating a hard-coded list of test users
with known roles) for the purposes of testing your controllers.

You still want to do _some_ testing of login / logout etc, but there
is no point in jumping through hoops for _all_ of your controller
testing.

Hope this helps.

Cheers
t0m


_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


frioux at gmail

Sep 2, 2009, 2:45 PM

Post #3 of 6 (1269 views)
Permalink
Re: Testing OpenID Logins + more [In reply to]

On Wed, Sep 2, 2009 at 12:48 PM, Tomas Doran <bobtfish [at] bobtfish> wrote:

>
> On 1 Sep 2009, at 04:43, fREW Schmidt wrote:
>
>> I'd really like to start testing my controllers, and I wished I'd started
>> sooner, but oh well. The biggest barrier at this point is the login system.
>> It uses OpenID for auth, which is where the hard stuff comes from.
>>
> <snip>
>
> Why bother with the complexity when testing if it isn't the OpenID stuff
> your testing specifically.
>
> I'd arrange for the relevant tests to supply a custom config file (I do
> this by mangling MYAPP_CONFIG env variable in the tests, although I'm sure
> there are more elegant solutions)..
>

Awesome! This is one of the main things I wanted. I'll let you know how it
works out.


> You can then change the authentication config to use different auth modules
> (for example authenticating a hard-coded list of test users with known
> roles) for the purposes of testing your controllers.
>
> You still want to do _some_ testing of login / logout etc, but there is no
> point in jumping through hoops for _all_ of your controller testing.
>

Yeah, especially since it would mean my controller tests would have to load
of TWO catatlyst servers every time, which is just silly.


--
fREW Schmidt
http://blog.afoolishmanifesto.com


apv at sedition

Sep 2, 2009, 5:31 PM

Post #4 of 6 (1258 views)
Permalink
Re: Testing OpenID Logins + more [In reply to]

On Aug 31, 2009, at 8:43 PM, fREW Schmidt wrote:
> I'd really like to start testing my controllers, and I wished I'd
> started sooner, but oh well. The biggest barrier at this point is
> the login system. It uses OpenID for auth, which is where the hard
> stuff comes from. I *have* looked at the tests for the OpenID
> module for catalyst auth, and although I'll surely end up using
> something like that, it's pretty intimidating. Does anyone have
> any existing basic tests for OpenID stuff, to test their server, as
> opposed to the OpenID module, that they might be willing to share?
> I'd really appreciate it. In the meantime I'll be trying to look
> more at Ashley's stuff.


Hey there. The test applications (there are two in the t/ dir) are
also in slight disarray. Which is to say, they used to be one test
application but due to forking issues (it had to talk to itself to
provide:consume) I split them where splitting means make exact copies
of the first and renamed each: Provider and Consumer respectively.
Each has been tweaked slightly, and the config of one probably
contains erroneous artifacts from bug fixing, compounding the
difficulty of comprehending them. I'm somewhat proud to say the
current dev version is passing its tests (so far on all test
reports). If you wait awhile I may clean them up, generalize, and Pod
them. Tuits are always the issue. I'm going to do one more dev
release turning on all the "live" tests for everyone (it's an ENV
triggered test now) and if that passes in the wild I'll do a 0.15
which I hope will have some cleanup in the test code for the curious
but... I have considered doing the Provider app as a standalone
release so it could be used in testing. If anyone thinks that's
worthwhile, send a name you'd think sensible
(CatalystX::Test::OpenID::Provider?) and feature wishlist. Again,
it's a tuit issue and I'd way behind on plenty.

I think t0m had the right idea though. Don't test it, or don't unit
test it. Running live or in a staging server, I'd use a known OpenID
account to do a Selenium/WWW::Mech style test.

-Ashley


_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


apv at sedition

Sep 2, 2009, 5:46 PM

Post #5 of 6 (1259 views)
Permalink
Re: Testing OpenID Logins + more [In reply to]

On Sep 2, 2009, at 10:48 AM, Tomas Doran wrote:
> On 1 Sep 2009, at 04:43, fREW Schmidt wrote:
>> I'd really like to start testing my controllers, and I wished I'd
>> started sooner, but oh well. The biggest barrier at this point is
>> the login system. It uses OpenID for auth, which is where the
>> hard stuff comes from.
> <snip>
>
> Why bother with the complexity when testing if it isn't the OpenID
> stuff your testing specifically.
>
> I'd arrange for the relevant tests to supply a custom config file
> (I do this by mangling MYAPP_CONFIG env variable in the tests,
> although I'm sure there are more elegant solutions)..

This is what I've adopted. I have "permanent" config in myapp.yml and
then whatever site customization in myapp_local.yml and then a
configuration file specifically for testing (substituting DB config
normally) myapp_test.yml

And then a test like:

BEGIN {
$ENV{MYAPP_CONFIG_LOCAL_SUFFIX} = "test";
}
use strict;
use warnings;
use Test::More "no_plan";
use Test::WWW::Mechanize::Catalyst;
# etc...

That will pick up the right config and override your core stuff where
needed/desired. I don't know if this is a widespread practice but
I've been doing it for a long time now and really like it.

-Ashley


_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


frioux at gmail

Sep 3, 2009, 12:38 PM

Post #6 of 6 (1241 views)
Permalink
Re: Testing OpenID Logins + more [In reply to]

<snip>

> That will pick up the right config and override your core stuff where
> needed/desired. I don't know if this is a widespread practice but I've been
> doing it for a long time now and really like it.
>
> -Ashley


Great! This should work nicely. Thanks again folks. Hopefully I'll have
working tests soon.

Ashley: I'll let you know if I make a cleaner provider, otherwise I'll
eventually steal your generalized/cleaned up version.


--
fREW Schmidt
http://blog.afoolishmanifesto.com

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.