-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dev/core#2752 Use acl, not blanket permissions on FinancialAccount, FinancialType, EntityFinancialAccount #21181
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -1142,6 +1142,9 @@ public static function getEntityActionPermissions() { | |||||||
$permissions['product'] = $permissions['contribution']; | ||||||||
|
||||||||
$permissions['financial_item'] = $permissions['contribution']; | ||||||||
$permissions['financial_type']['get'] = $permissions['contribution']['get']; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initial test runs suggest that maybe we want the permissions of contribution.get OR 'Administer CiviCRM' (or 'Administer CiviCRM Data' which is implicit in Administer CiviCRM)
I just added error handling - but not 100% sure if that is enough forgiveness |
||||||||
$permissions['entity_financial_account']['get'] = $permissions['contribution']['get']; | ||||||||
$permissions['financial_account']['get'] = $permissions['contribution']['get']; | ||||||||
|
||||||||
// Payment permissions | ||||||||
$permissions['payment'] = [ | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Civi\Financialacls; | ||
|
||
use Civi\Api4\EntityFinancialAccount; | ||
|
||
// I fought the Autoloader and the autoloader won. | ||
require_once 'BaseTestClass.php'; | ||
|
||
/** | ||
* @group headless | ||
*/ | ||
class EntityFinancialAccountTest extends BaseTestClass { | ||
|
||
/** | ||
* Test only accounts with permitted income types can be retrieved. | ||
* | ||
* @throws \API_Exception | ||
*/ | ||
public function testGetEntityFinancialAccount(): void { | ||
$this->setupLoggedInUserWithLimitedFinancialTypeAccess(); | ||
$entityFinancialAccounts = EntityFinancialAccount::get(FALSE)->execute(); | ||
$this->assertCount(23, $entityFinancialAccounts); | ||
$restrictedAccounts = EntityFinancialAccount::get()->execute(); | ||
$this->assertCount(9, $restrictedAccounts); | ||
foreach ($restrictedAccounts as $restrictedAccount) { | ||
if ($restrictedAccount['entity_table'] === 'civicrm_financial_type') { | ||
$this->assertEquals(1, $restrictedAccount['entity_id']); | ||
} | ||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Civi\Financialacls; | ||
|
||
use Civi\Api4\FinancialAccount; | ||
|
||
// I fought the Autoloader and the autoloader won. | ||
require_once 'BaseTestClass.php'; | ||
|
||
/** | ||
* @group headless | ||
*/ | ||
class FinancialAccountTest extends BaseTestClass { | ||
|
||
/** | ||
* Test only accounts with permitted income types can be retrieved. | ||
* | ||
* @throws \API_Exception | ||
*/ | ||
public function testGetFinancialAccount(): void { | ||
$this->setupLoggedInUserWithLimitedFinancialTypeAccess(); | ||
$financialAccounts = FinancialAccount::get(FALSE)->execute(); | ||
$this->assertCount(14, $financialAccounts); | ||
$restrictedAccounts = FinancialAccount::get()->execute(); | ||
$this->assertCount(1, $restrictedAccounts); | ||
$this->assertEquals('Donation', $restrictedAccounts[0]['name']); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note I updated the v3 api to always set
$props['check_permissions']
- the ?? will default to true if NULL but not if set to false