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
71a161ae
Commit
71a161ae
authored
13 years ago
by
Dominik Eckelmann
Browse files
Options
Downloads
Patches
Plain Diff
transformed auth_aclcheck to phpunit
parent
f02cff8f
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
_testing/README
+0
-1
0 additions, 1 deletion
_testing/README
_testing/unittests/inc/auth_aclcheck.test.php
+244
-0
244 additions, 0 deletions
_testing/unittests/inc/auth_aclcheck.test.php
with
244 additions
and
1 deletion
_testing/README
+
0
−
1
View file @
71a161ae
...
...
@@ -19,7 +19,6 @@ The easiest way to install phpunit is via pear:
==== Bad tests ====
Bad tests are tests that do not run out of the box.
* inc/auth_aclcheck
* inc/DifferenceEngine
* inc/html_hilight (runkit)
* inc/indexer_idx_indexlengths
...
...
This diff is collapsed.
Click to expand it.
_testing/unittests/inc/auth_aclcheck.test.php
0 → 100644
+
244
−
0
View file @
71a161ae
<?php
require_once
DOKU_INC
.
'inc/init.php'
;
require_once
DOKU_INC
.
'inc/auth.php'
;
require_once
DOKU_INC
.
'inc/auth/basic.class.php'
;
class
auth_acl_test
extends
PHPUnit_Framework_TestCase
{
var
$oldConf
;
var
$oldAuthAcl
;
function
setup
()
{
global
$conf
;
global
$AUTH_ACL
;
global
$auth
;
$this
->
oldConf
=
$conf
;
$this
->
oldAuthAcl
=
$AUTH_ACL
;
$auth
=
new
auth_basic
();
}
function
teardown
()
{
global
$conf
;
global
$AUTH_ACL
;
$conf
=
$this
->
oldConf
;
$AUTH_ACL
=
$this
->
oldAuthAcl
;
}
function
test_restricted
(){
global
$conf
;
global
$AUTH_ACL
;
$conf
[
'superuser'
]
=
'john'
;
$conf
[
'useacl'
]
=
1
;
$AUTH_ACL
=
array
(
'* @ALL 0'
,
'* @user 8'
,
);
// anonymous user
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
''
,
array
()),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
''
,
array
()),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
''
,
array
()),
AUTH_NONE
);
// user with no matching group
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jill'
,
array
(
'foo'
)),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'jill'
,
array
(
'foo'
)),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'jill'
,
array
(
'foo'
)),
AUTH_NONE
);
// user with matching group
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jill'
,
array
(
'foo'
,
'user'
)),
AUTH_UPLOAD
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'jill'
,
array
(
'foo'
,
'user'
)),
AUTH_UPLOAD
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'jill'
,
array
(
'foo'
,
'user'
)),
AUTH_UPLOAD
);
// super user
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'john'
,
array
(
'foo'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'john'
,
array
(
'foo'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'john'
,
array
(
'foo'
)),
AUTH_ADMIN
);
}
function
test_restricted_ropage
(){
global
$conf
;
global
$AUTH_ACL
;
$conf
[
'superuser'
]
=
'john'
;
$conf
[
'useacl'
]
=
1
;
$AUTH_ACL
=
array
(
'* @ALL 0'
,
'* @user 8'
,
'namespace:page @user 1'
,
);
// anonymous user
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
''
,
array
()),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
''
,
array
()),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
''
,
array
()),
AUTH_NONE
);
// user with no matching group
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jill'
,
array
(
'foo'
)),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'jill'
,
array
(
'foo'
)),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'jill'
,
array
(
'foo'
)),
AUTH_NONE
);
// user with matching group
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jill'
,
array
(
'foo'
,
'user'
)),
AUTH_UPLOAD
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'jill'
,
array
(
'foo'
,
'user'
)),
AUTH_READ
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'jill'
,
array
(
'foo'
,
'user'
)),
AUTH_UPLOAD
);
// super user
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'john'
,
array
(
'foo'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'john'
,
array
(
'foo'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'john'
,
array
(
'foo'
)),
AUTH_ADMIN
);
}
function
test_aclexample
(){
global
$conf
;
global
$AUTH_ACL
;
$conf
[
'superuser'
]
=
'john'
;
$conf
[
'useacl'
]
=
1
;
$AUTH_ACL
=
array
(
'* @ALL 4'
,
'* bigboss 16'
,
'start @ALL 1'
,
'marketing:* @marketing 8'
,
'devel:* @ALL 0'
,
'devel:* @devel 8'
,
'devel:* bigboss 16'
,
'devel:funstuff bigboss 0'
,
'devel:* @marketing 1'
,
'devel:marketing @marketing 2'
,
);
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
''
,
array
())
,
AUTH_CREATE
);
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'bigboss'
,
array
(
'foo'
))
,
AUTH_DELETE
);
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jill'
,
array
(
'marketing'
))
,
AUTH_CREATE
);
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jane'
,
array
(
'devel'
))
,
AUTH_CREATE
);
$this
->
assertEquals
(
auth_aclcheck
(
'start'
,
''
,
array
())
,
AUTH_READ
);
$this
->
assertEquals
(
auth_aclcheck
(
'start'
,
'bigboss'
,
array
(
'foo'
))
,
AUTH_READ
);
$this
->
assertEquals
(
auth_aclcheck
(
'start'
,
'jill'
,
array
(
'marketing'
))
,
AUTH_READ
);
$this
->
assertEquals
(
auth_aclcheck
(
'start'
,
'jane'
,
array
(
'devel'
))
,
AUTH_READ
);
$this
->
assertEquals
(
auth_aclcheck
(
'marketing:page'
,
''
,
array
())
,
AUTH_CREATE
);
$this
->
assertEquals
(
auth_aclcheck
(
'marketing:page'
,
'bigboss'
,
array
(
'foo'
))
,
AUTH_DELETE
);
$this
->
assertEquals
(
auth_aclcheck
(
'marketing:page'
,
'jill'
,
array
(
'marketing'
))
,
AUTH_UPLOAD
);
$this
->
assertEquals
(
auth_aclcheck
(
'marketing:page'
,
'jane'
,
array
(
'devel'
))
,
AUTH_CREATE
);
$this
->
assertEquals
(
auth_aclcheck
(
'devel:page'
,
''
,
array
())
,
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'devel:page'
,
'bigboss'
,
array
(
'foo'
))
,
AUTH_DELETE
);
$this
->
assertEquals
(
auth_aclcheck
(
'devel:page'
,
'jill'
,
array
(
'marketing'
))
,
AUTH_READ
);
$this
->
assertEquals
(
auth_aclcheck
(
'devel:page'
,
'jane'
,
array
(
'devel'
))
,
AUTH_UPLOAD
);
$this
->
assertEquals
(
auth_aclcheck
(
'devel:funstuff'
,
''
,
array
())
,
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'devel:funstuff'
,
'bigboss'
,
array
(
'foo'
))
,
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'devel:funstuff'
,
'jill'
,
array
(
'marketing'
))
,
AUTH_READ
);
$this
->
assertEquals
(
auth_aclcheck
(
'devel:funstuff'
,
'jane'
,
array
(
'devel'
))
,
AUTH_UPLOAD
);
$this
->
assertEquals
(
auth_aclcheck
(
'devel:marketing'
,
''
,
array
())
,
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'devel:marketing'
,
'bigboss'
,
array
(
'foo'
))
,
AUTH_DELETE
);
$this
->
assertEquals
(
auth_aclcheck
(
'devel:marketing'
,
'jill'
,
array
(
'marketing'
))
,
AUTH_EDIT
);
$this
->
assertEquals
(
auth_aclcheck
(
'devel:marketing'
,
'jane'
,
array
(
'devel'
))
,
AUTH_UPLOAD
);
}
function
test_multiadmin_restricted
(){
global
$conf
;
global
$AUTH_ACL
;
$conf
[
'superuser'
]
=
'john,@admin,doe,@roots'
;
$conf
[
'useacl'
]
=
1
;
$AUTH_ACL
=
array
(
'* @ALL 0'
,
'* @user 8'
,
);
// anonymous user
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
''
,
array
()),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
''
,
array
()),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
''
,
array
()),
AUTH_NONE
);
// user with no matching group
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jill'
,
array
(
'foo'
)),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'jill'
,
array
(
'foo'
)),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'jill'
,
array
(
'foo'
)),
AUTH_NONE
);
// user with matching group
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jill'
,
array
(
'foo'
,
'user'
)),
AUTH_UPLOAD
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'jill'
,
array
(
'foo'
,
'user'
)),
AUTH_UPLOAD
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'jill'
,
array
(
'foo'
,
'user'
)),
AUTH_UPLOAD
);
// super user john
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'john'
,
array
(
'foo'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'john'
,
array
(
'foo'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'john'
,
array
(
'foo'
)),
AUTH_ADMIN
);
// super user doe
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'doe'
,
array
(
'foo'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'doe'
,
array
(
'foo'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'doe'
,
array
(
'foo'
)),
AUTH_ADMIN
);
// user with matching admin group
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jill'
,
array
(
'foo'
,
'admin'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'jill'
,
array
(
'foo'
,
'admin'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'jill'
,
array
(
'foo'
,
'admin'
)),
AUTH_ADMIN
);
// user with matching another admin group
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jill'
,
array
(
'foo'
,
'roots'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'jill'
,
array
(
'foo'
,
'roots'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'jill'
,
array
(
'foo'
,
'roots'
)),
AUTH_ADMIN
);
}
function
test_multiadmin_restricted_ropage
(){
global
$conf
;
global
$AUTH_ACL
;
$conf
[
'superuser'
]
=
'john,@admin,doe,@roots'
;
$conf
[
'useacl'
]
=
1
;
$AUTH_ACL
=
array
(
'* @ALL 0'
,
'* @user 8'
,
'namespace:page @user 1'
,
);
// anonymous user
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
''
,
array
()),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
''
,
array
()),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
''
,
array
()),
AUTH_NONE
);
// user with no matching group
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jill'
,
array
(
'foo'
)),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'jill'
,
array
(
'foo'
)),
AUTH_NONE
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'jill'
,
array
(
'foo'
)),
AUTH_NONE
);
// user with matching group
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jill'
,
array
(
'foo'
,
'user'
)),
AUTH_UPLOAD
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'jill'
,
array
(
'foo'
,
'user'
)),
AUTH_READ
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'jill'
,
array
(
'foo'
,
'user'
)),
AUTH_UPLOAD
);
// super user john
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'john'
,
array
(
'foo'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'john'
,
array
(
'foo'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'john'
,
array
(
'foo'
)),
AUTH_ADMIN
);
// super user doe
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'doe'
,
array
(
'foo'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'doe'
,
array
(
'foo'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'doe'
,
array
(
'foo'
)),
AUTH_ADMIN
);
// user with matching admin group
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jill'
,
array
(
'foo'
,
'admin'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'jill'
,
array
(
'foo'
,
'admin'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'jill'
,
array
(
'foo'
,
'admin'
)),
AUTH_ADMIN
);
// user with matching another admin group
$this
->
assertEquals
(
auth_aclcheck
(
'page'
,
'jill'
,
array
(
'foo'
,
'roots'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:page'
,
'jill'
,
array
(
'foo'
,
'roots'
)),
AUTH_ADMIN
);
$this
->
assertEquals
(
auth_aclcheck
(
'namespace:*'
,
'jill'
,
array
(
'foo'
,
'roots'
)),
AUTH_ADMIN
);
}
}
//Setup VIM: ex: et ts=4 :
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