It should be possible to write testing routines for the CAS module, much like the testing routines in the openid module in core.

I'm setting priority to minor since there are more pressing issues at the moment (like getting a D7 version shipped).

CommentFileSizeAuthor
#7 1011848-D6-port-of-tests.patch6.81 KBbfroehle

Comments

bfroehle’s picture

Issue tags: +CAS Wishlist

Tagging as "CAS Wishlist", so that we don't forgot our long-term plans.

bfroehle’s picture

Status: Active » Postponed

This is much harder than I anticipated since, since phpCAS expects the CAS server https. This prevents (easily) creating a mock CAS server using a test_cas.module which I originally had planned on doing.

Marking as postponed, blocking on https://issues.jasig.org/browse/PHPCAS-97

bfroehle’s picture

Status: Postponed » Active

Apparently it's not impossible:

You can always override the urls with the setter functions. For example:

setServerLoginURL()
setServerProxyValidateURL()
setServerSAMLValidateURL()
setServerServiceValidateURL()

The normal autodetection assumes that you have https working for the cas server since with the default config you can't run it on http without some modifications (cookie marked only for secure connections). It prevents people from setting up unsafe SSO servers.
For testing purposes please check out the testing framework Adam has already written for phpcas 1.2.0. I can be used to do "fake" authentications for internal testing without any cas server being present. This might be something usefull for you.

(from [PHPCAS-97] Allow for http CAS servers

This might suggest the addition of a hook which allows the phpCAS object to be directly altered before authentication --- i.e. a hook_cas_phpcas_alter() or similar.

bfroehle’s picture

Priority: Minor » Normal

Created a development branch: http://drupalcode.org/project/cas.git/shortlog/refs/heads/1011848-test-r...

Basic test routines for using the User API are already present. (The goal here would be to catch issues like #1087136: CAS User name does not save in D6, however the test routines are strictly for D7 at this point and I don't anticipate backporting them to D6.)

bfroehle’s picture

Category: feature » bug
Status: Active » Fixed
Issue tags: -CAS Wishlist

I've committed the current progress to 7.x-1.x, see http://drupalcode.org/project/cas.git/commit/d760e61

Issue #1011848 - Add Testing Routines.

CAS SimpleTest Requirements:
- Libraries API module.
- phpCAS installed in a location compatible with Libraries
API, like sites/all/libraries/CAS.

Tests can derive themselves from CasTestHelper which provides
routines to easily create Drupal accounts with CAS usernames
and login CAS users.

Some test routines are provided which:
- Verify basic hook_user_{insert,delete,update,load}
functionality.
- Creating users in the administration interface.
- User behavior, including auto-registration and user
editing.
- Login redirection.
- Logout redirection.

More test routines could be added, including:
- Editing users in the admin interface.
- CAS protected URLs.

Please note some tests are failing, particularly in the "Login Redirection" test case. This means either the test is inappropriate or the code is not properly handling the test case.

Most of these failures relate to the handling of '' vs variable_get('site_frontpage', 'node') as the default front page. CAS currently uses the latter option which redirects to 'node', but I think for the sake of pretty URLs it'd be better to redirect to '' which would truly give you the front page. Both have the same page content.

Another failures relate to logging in using the user login block which redirects you to the front page instead of keeping you at the page you started from.

bfroehle’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
Status: Fixed » Patch (to be ported)

I'm going to work on backporting the tests to 6.x-3.x now. I assume it should be relatively straightforward, but I've never worked with SimpleTest in D6 yet.

bfroehle’s picture

Category: bug » task
Status: Patch (to be ported) » Fixed
StatusFileSize
new6.81 KB

Ported to D6 and committed in http://drupalcode.org/project/cas.git/commit/0bad1c35

The differences to the original D7 commit are attached here.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit d760e61 on 7.x-1.x, 8.x-1.x by bfroehle:
    Issue #1011848 - Add Testing Routines.
    
    CAS SimpleTest Requirements:
    -...