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
1f6e92fa
Commit
1f6e92fa
authored
11 years ago
by
Christopher Smith
Browse files
Options
Downloads
Patches
Plain Diff
unittests for auth_loadACL
parent
21c3090a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
_test/tests/inc/auth_loadacl.test.php
+121
-0
121 additions, 0 deletions
_test/tests/inc/auth_loadacl.test.php
with
121 additions
and
0 deletions
_test/tests/inc/auth_loadacl.test.php
0 → 100644
+
121
−
0
View file @
1f6e92fa
<?php
/**
* auth_loadACL carries out the user & group substitutions
*
*/
class
auth_loadacl_test
extends
DokuWikiTest
{
function
setUp
()
{
global
$USERINFO
;
parent
::
setUp
();
$_SERVER
[
'REMOTE_USER'
]
=
'testuser'
;
$USERINFO
[
'grps'
]
=
array
(
'foo'
,
'bar'
);
}
function
tearDown
()
{
parent
::
tearDown
();
}
function
auth_loadACL_testwrapper
(
$acls
)
{
global
$config_cascade
;
$acl_file
=
$config_cascade
[
'acl'
][
'default'
];
$config_cascade
[
'acl'
][
'default'
]
.
=
'.test'
;
file_put_contents
(
$config_cascade
[
'acl'
][
'default'
],
$acls
);
$result
=
auth_loadACL
();
unlink
(
$config_cascade
[
'acl'
][
'default'
]);
$config_cascade
[
'acl'
][
'default'
]
=
$acl_file
;
return
$result
;
}
function
test_simple
()
{
$acls
=
<<<ACL
* @ALL 2
ACL;
$expect
=
array
(
"*
\t
@ALL 2"
);
$this
->
assertEquals
(
$expect
,
$this
->
auth_loadACL_testwrapper
(
$acls
));
}
function
test_user_substitution
()
{
$acls
=
<<<ACL
%USER% %USER% 2
ACL;
$expect
=
array
(
"testuser
\t
testuser 2"
,
);
$this
->
assertEquals
(
$expect
,
$this
->
auth_loadACL_testwrapper
(
$acls
));
}
function
test_group_substitution
()
{
$acls
=
<<<ACL
%GROUP% %GROUP% 2
ACL;
$expect
=
array
(
"foo
\t
@foo 2"
,
"bar
\t
@bar 2"
,
);
$this
->
assertEquals
(
$expect
,
$this
->
auth_loadACL_testwrapper
(
$acls
));
}
function
test_both_substitution
()
{
$acls
=
<<<ACL
%GROUP%:%USER% %USER% 2
%GROUP%:%USER% %GROUP% 2
ACL;
$expect
=
array
(
"foo:testuser
\t
testuser 2"
,
"bar:testuser
\t
testuser 2"
,
"foo:testuser
\t
@foo 2"
,
"bar:testuser
\t
@bar 2"
,
);
$this
->
assertEquals
(
$expect
,
$this
->
auth_loadACL_testwrapper
(
$acls
));
}
// put it all together - read the standard acl provided with the test suite
function
test_standardtestacls
(){
$expect
=
array
(
"*
\t
@ALL 8"
,
"private:*
\t
@ALL 0"
,
"users:*
\t
@ALL 1"
,
"users:testuser:*
\t
testuser 16"
,
"groups:*
\t
@ALL 1"
,
"groups:foo:*
\t
@foo 16"
,
"groups:bar:*
\t
@bar 16"
,
);
$this
->
assertEquals
(
$expect
,
auth_loadACL
());
}
// FS#2867, '\s' in php regular expressions may match non-space characters utf8 strings
// this is due to locale setting on the server, which may match bytes '\xA0' and '\x85'
// these two bytes are present in valid multi-byte UTF-8 characters.
// this test will use one, 'ठ' (DEVANAGARI LETTER TTHA, e0 a4 a0). There are many others.
function
test_FS2867
()
{
global
$USERINFO
;
setlocale
(
LC_ALL
,
"English_United States.1252"
);
// should only succeed on windows systems
setlocale
(
LC_ALL
,
"en_US.UTF-8"
);
// should succeed on other systems
$_SERVER
[
'REMOTE_USER'
]
=
'utfठ8'
;
$USERINFO
[
'grps'
]
=
array
(
'utfठ16'
,
'utfठa'
);
$acls
=
<<<ACL
%GROUP%:%USER% %USER% 2
%GROUP%:* %GROUP% 4
devangariठttha @ALL 2
ACL;
$expect
=
array
(
"utfठ16:utfठ8
\t
utfठ8 2"
,
"utfठa:utfठ8
\t
utfठ8 2"
,
"utfठ16:*
\t
@utfठ16 4"
,
"utfठa:*
\t
@utfठa 4"
,
"devangariठttha
\t
@ALL 2"
,
);
$this
->
assertEquals
(
$expect
,
$this
->
auth_loadACL_testwrapper
(
$acls
));
}
}
//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