Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cas
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
cas
Commits
d3289f26
Commit
d3289f26
authored
13 years ago
by
Bradley M. Froehle
Browse files
Options
Downloads
Patches
Plain Diff
Automatically download phpCAS in SimpleTest routine.
parent
c03144bd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.txt
+11
-0
11 additions, 0 deletions
README.txt
cas.test
+66
-2
66 additions, 2 deletions
cas.test
with
77 additions
and
2 deletions
README.txt
+
11
−
0
View file @
d3289f26
...
...
@@ -57,3 +57,14 @@ API Changes Since 6.x-2.x
=========================
The hooks hook_auth_name() and hook_auth_filter() were combined and renamed
to hook_cas_user_alter(). See cas.api.php.
Testing
=======
The CAS module comes with built-in test routines. To enable testing on a
development site, enable the 'Testing' module. Then navigate to Admin >
Configuration > Development > Testing. The CAS test routines are available
under "Central Authentication Service".
Note, the CAS test routines will automatically download phpCAS from the JASIG
website, to ensure a version compatible with the test routines, and so that
the tests may run successfully on qa.drupal.org.
This diff is collapsed.
Click to expand it.
cas.test
+
66
−
2
View file @
d3289f26
...
...
@@ -8,11 +8,75 @@
class
CasTestHelper
extends
DrupalWebTestCase
{
protected
$admin_user
;
function
setUp
()
{
parent
::
setUp
(
array
(
'cas'
,
'cas_test'
,
'libraries'
));
/**
* Helper class for CAS tests.
*
* Creates an administrative user and downloads phpCAS.
*/
function
setUp
(
$modules
=
array
())
{
$modules
=
array_merge
(
array
(
'cas'
,
'cas_test'
),
$modules
);
parent
::
setUp
(
$modules
);
// Create admin user.
$this
->
admin_user
=
$this
->
drupalCreateUser
(
array
(
'administer users'
,
'administer cas'
));
// Find the most URL of the most recent phpCAS version.
$url
=
variable_get
(
'cas_phpcas_download_url'
,
'http://downloads.jasig.org/cas-clients/php/'
);
$result
=
drupal_http_request
(
$url
);
// Extract all available phpCAS versions.
preg_match_all
(
'/<a href="(\d.+)\/">/'
,
$result
->
data
,
$matches
);
$versions
=
$matches
[
1
];
// The following versions contain bugs rendering them incompatible with the
// cas_test module.
$bad_versions
=
array
(
'1.2.0RC1'
,
'1.2.0RC2'
,
'1.2.0'
,
'1.2.1RC1'
,
'1.2.1'
,
);
$versions
=
array_diff
(
$versions
,
$bad_versions
);
// Sort versions in ascending order, and select the most recent one.
uasort
(
$versions
,
'version_compare'
);
$version
=
end
(
$versions
);
$this
->
assertTrue
(
$version
,
t
(
'Found phpCAS version @version at @url.'
,
array
(
'@version'
=>
$version
,
'@url'
=>
$url
)));
// Build the filename and URL or the phpCAS tarball.
$filename
=
'CAS-'
.
$version
.
'.tgz'
;
$url
=
rtrim
(
$url
,
'/'
)
.
'/'
.
$version
.
'/'
.
$filename
;
// Download phpCAS tarball to a simpletest cache directory. If we put the
// file in the public, private, or temporary directory we would need to
// re-download it every test case.
$cache_directory
=
$this
->
originalFileDirectory
.
'/simpletest/cas'
;
$local
=
$cache_directory
.
'/'
.
$filename
;
if
(
!
file_exists
(
$cache_directory
))
{
mkdir
(
$cache_directory
);
}
if
(
!
file_exists
(
$local
))
{
$local
=
system_retrieve_file
(
$url
,
$local
,
FALSE
,
FILE_EXISTS_REPLACE
);
$this
->
assertTrue
(
$local
,
t
(
'Downloaded @url to @local.'
,
array
(
'@url'
=>
$url
,
'@local'
=>
$local
)));
}
else
{
$this
->
pass
(
t
(
'Found @local.'
,
array
(
'@url'
=>
$url
,
'@local'
=>
$local
)));
}
// Extract the files.
$archiver
=
archiver_get_archiver
(
$local
);
$files
=
$archiver
->
listContents
();
// We extract to the private directory, for security.
$extract_dir
=
'private://cas'
;
$cas_library_dir
=
$extract_dir
.
'/'
.
strtok
(
$files
[
1
],
'/\\'
);
$archiver
->
extract
(
$extract_dir
);
$this
->
pass
(
t
(
'Extracted @local to @extract_dir.'
,
array
(
'@local'
=>
$local
,
'@extract_dir'
=>
$extract_dir
)));
// Set the CAS library directory.
$this
->
assertTrue
(
file_exists
(
$cas_library_dir
.
'/CAS.php'
),
t
(
'CAS.php found in @cas_library_dir.'
,
array
(
'@cas_library_dir'
=>
$cas_library_dir
)));
variable_set
(
'cas_library_dir'
,
$cas_library_dir
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment