Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
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
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
447922c2
Commit
447922c2
authored
13 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
More phpunit tests
parent
036e578e
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
htdocs/core/lib/security.lib.php
+3
-7
3 additions, 7 deletions
htdocs/core/lib/security.lib.php
test/phpunit/SecurityTest.php
+19
-3
19 additions, 3 deletions
test/phpunit/SecurityTest.php
with
22 additions
and
10 deletions
htdocs/core/lib/security.lib.php
+
3
−
7
View file @
447922c2
...
...
@@ -85,7 +85,7 @@ function dol_hash($chain,$type=0)
* If GETPOST('action') defined, we also check write and delete permission.
*
* @param User $user User to check
* @param string $features Features to check (in most cases, it's module name)
* @param string $features Features to check (in most cases, it's module name
. Examples: 'societe', 'contact', 'produit|service', ...
)
* @param int $objectid Object ID if we want to check permission on a particular record (optionnal)
* @param string $dbtablename Table name where object is stored. Not used if objectid is null (optionnal)
* @param string $feature2 Feature to check, second level of permission (optionnal)
...
...
@@ -94,7 +94,7 @@ function dol_hash($chain,$type=0)
* @param Canvas $objcanvas Object canvas
* @return int Always 1, die process if not allowed
*/
function
restrictedArea
(
$user
,
$features
=
'societe'
,
$objectid
=
0
,
$dbtablename
=
''
,
$feature2
=
''
,
$dbt_keyfield
=
'fk_soc'
,
$dbt_select
=
'rowid'
,
$objcanvas
=
null
)
function
restrictedArea
(
$user
,
$features
,
$objectid
=
0
,
$dbtablename
=
''
,
$feature2
=
''
,
$dbt_keyfield
=
'fk_soc'
,
$dbt_select
=
'rowid'
,
$objcanvas
=
null
)
{
global
$db
,
$conf
;
...
...
@@ -163,11 +163,7 @@ function restrictedArea($user, $features='societe', $objectid=0, $dbtablename=''
}
}
if
(
!
$readok
)
{
//print "Read access is down";
accessforbidden
();
}
if
(
!
$readok
)
accessforbidden
();
//print "Read access is ok";
// Check write permission from module
...
...
This diff is collapsed.
Click to expand it.
test/phpunit/SecurityTest.php
+
19
−
3
View file @
447922c2
...
...
@@ -41,6 +41,14 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't nee
if
(
!
defined
(
'NOREQUIREAJAX'
))
define
(
'NOREQUIREAJAX'
,
'1'
);
if
(
!
defined
(
"NOLOGIN"
))
define
(
"NOLOGIN"
,
'1'
);
// If this page is public (can be called outside logged session)
if
(
empty
(
$user
->
id
))
{
print
"Load permissions for admin user nb 1
\n
"
;
$user
->
fetch
(
1
);
$user
->
getrights
();
}
$conf
->
global
->
MAIN_DISABLE_ALL_MAILS
=
1
;
/**
* Class for PHPUnit tests
...
...
@@ -226,15 +234,23 @@ class SecurityTest extends PHPUnit_Framework_TestCase
}
/**
* test
GetRandomPassword
* test
RestrictedArea
*
* @return
number
* @return
void
*/
public
function
testRestrictedArea
()
{
global
$conf
,
$user
,
$langs
,
$db
;
$conf
=
$this
->
savconf
;
$user
=
$this
->
savuser
;
$langs
=
$this
->
savlangs
;
$db
=
$this
->
savdb
;
//$dummyuser=new User($db);
//$result=restrictedArea($dummyuser,'societe');
$result
=
restrictedArea
(
$user
,
'societe'
);
$this
->
assertEquals
(
1
,
$result
);
}
}
...
...
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