Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
BRIC
dokuwiki
Commits
4f56ecbf
Commit
4f56ecbf
authored
14 years ago
by
Adrian Lang
Browse files
Options
Downloads
Patches
Plain Diff
Fix handling of case in auth_isMember; add and fix test cases
parent
5827ba0b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
_test/cases/inc/auth_admincheck.test.php
+75
-3
75 additions, 3 deletions
_test/cases/inc/auth_admincheck.test.php
inc/auth.php
+2
-2
2 additions, 2 deletions
inc/auth.php
with
77 additions
and
5 deletions
_test/cases/inc/auth_admincheck.test.php
+
75
−
3
View file @
4f56ecbf
...
...
@@ -3,17 +3,44 @@
require_once
DOKU_INC
.
'inc/init.php'
;
require_once
DOKU_INC
.
'inc/auth.php'
;
class
auth_admin_test_AuthInSensitive
extends
auth_basic
{
function
isCaseSensitive
(){
return
false
;
}
}
class
auth_admin_test
extends
UnitTestCase
{
private
$oldauth
;
function
setup
()
{
global
$auth
;
$this
->
oldauth
=
$auth
;
parent
::
setup
();
}
function
setSensitive
()
{
global
$auth
;
$auth
=
new
auth_basic
;
}
function
setInSensitive
()
{
global
$auth
;
$auth
=
new
auth_admin_test_AuthInSensitive
;
}
function
teardown
()
{
global
$auth
;
global
$conf
;
global
$AUTH_ACL
;
unset
(
$conf
);
unset
(
$AUTH_ACL
);
$auth
=
$this
->
oldauth
;
parent
::
teardown
();
}
function
test_ismanager
(){
function
test_ismanager_insensitive
(){
$this
->
setInSensitive
();
global
$conf
;
$conf
[
'superuser'
]
=
'john,@admin,@Mötly Görls, Dörte'
;
$conf
[
'manager'
]
=
'john,@managers,doe, @Mötly Böys, Dänny'
;
...
...
@@ -36,7 +63,8 @@ class auth_admin_test extends UnitTestCase {
$this
->
assertEqual
(
auth_ismanager
(
'jill'
,
array
(
'mötly böys'
),
false
),
true
);
}
function
test_isadmin
(){
function
test_isadmin_insensitive
(){
$this
->
setInSensitive
();
global
$conf
;
$conf
[
'superuser'
]
=
'john,@admin,doe,@roots'
;
...
...
@@ -54,6 +82,50 @@ class auth_admin_test extends UnitTestCase {
$this
->
assertEqual
(
auth_ismanager
(
'doe'
,
array
(
'admin'
),
true
),
true
);
}
function
test_ismanager_sensitive
(){
$this
->
setSensitive
();
global
$conf
;
$conf
[
'superuser'
]
=
'john,@admin,@Mötly Görls, Dörte'
;
$conf
[
'manager'
]
=
'john,@managers,doe, @Mötly Böys, Dänny'
;
// anonymous user
$this
->
assertEqual
(
auth_ismanager
(
'jill'
,
null
,
false
),
false
);
// admin or manager users
$this
->
assertEqual
(
auth_ismanager
(
'john'
,
null
,
false
),
true
);
$this
->
assertEqual
(
auth_ismanager
(
'doe'
,
null
,
false
),
true
);
$this
->
assertEqual
(
auth_ismanager
(
'dörte'
,
null
,
false
),
false
);
$this
->
assertEqual
(
auth_ismanager
(
'dänny'
,
null
,
false
),
false
);
// admin or manager groups
$this
->
assertEqual
(
auth_ismanager
(
'jill'
,
array
(
'admin'
),
false
),
true
);
$this
->
assertEqual
(
auth_ismanager
(
'jill'
,
array
(
'managers'
),
false
),
true
);
$this
->
assertEqual
(
auth_ismanager
(
'jill'
,
array
(
'mötly görls'
),
false
),
false
);
$this
->
assertEqual
(
auth_ismanager
(
'jill'
,
array
(
'mötly böys'
),
false
),
false
);
}
function
test_isadmin_sensitive
(){
$this
->
setSensitive
();
global
$conf
;
$conf
[
'superuser'
]
=
'john,@admin,doe,@roots'
;
// anonymous user
$this
->
assertEqual
(
auth_ismanager
(
'jill'
,
null
,
true
),
false
);
// admin user
$this
->
assertEqual
(
auth_ismanager
(
'john'
,
null
,
true
),
true
);
$this
->
assertEqual
(
auth_ismanager
(
'Doe'
,
null
,
true
),
false
);
// admin groups
$this
->
assertEqual
(
auth_ismanager
(
'jill'
,
array
(
'admin'
),
true
),
true
);
$this
->
assertEqual
(
auth_ismanager
(
'jill'
,
array
(
'roots'
),
true
),
true
);
$this
->
assertEqual
(
auth_ismanager
(
'john'
,
array
(
'admin'
),
true
),
true
);
$this
->
assertEqual
(
auth_ismanager
(
'doe'
,
array
(
'admin'
),
true
),
true
);
$this
->
assertEqual
(
auth_ismanager
(
'Doe'
,
array
(
'admin'
),
true
),
true
);
}
}
//Setup VIM: ex: et ts=4 :
This diff is collapsed.
Click to expand it.
inc/auth.php
+
2
−
2
View file @
4f56ecbf
...
...
@@ -415,7 +415,7 @@ function auth_isMember($memberlist,$user,array $groups){
if
(
!
$auth
)
return
false
;
// clean user and groups
if
(
$auth
->
isCaseSensitive
()){
if
(
!
$auth
->
isCaseSensitive
()){
$user
=
utf8_strtolower
(
$user
);
$groups
=
array_map
(
'utf8_strtolower'
,
$groups
);
}
...
...
@@ -430,7 +430,7 @@ function auth_isMember($memberlist,$user,array $groups){
// compare cleaned values
foreach
(
$members
as
$member
){
if
(
$auth
->
isCaseSensitive
())
$member
=
utf8_strtolower
(
$member
);
if
(
!
$auth
->
isCaseSensitive
())
$member
=
utf8_strtolower
(
$member
);
if
(
$member
[
0
]
==
'@'
){
$member
=
$auth
->
cleanGroup
(
substr
(
$member
,
1
));
if
(
in_array
(
$member
,
$groups
))
return
true
;
...
...
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