예제 #1
0
 /**
  * @magentoDbIsolation enabled
  */
 public function testGetAllowedResources()
 {
     $userIdentifierA = $this->_createUserIdentifier(UserIdentifier::USER_TYPE_INTEGRATION);
     $resourcesA = array('Magento_Adminhtml::dashboard', 'Magento_Cms::page');
     $this->_service->grantPermissions($userIdentifierA, $resourcesA);
     $userIdentifierB = $this->_createUserIdentifier(UserIdentifier::USER_TYPE_INTEGRATION);
     $resourcesB = array('Magento_Cms::block', 'Magento_Sales::cancel');
     $this->_service->grantPermissions($userIdentifierB, $resourcesB);
     /** Preconditions check */
     $this->_ensurePermissionsAreGranted($userIdentifierA, $resourcesA);
     $this->_ensurePermissionsAreGranted($userIdentifierB, $resourcesB);
     $this->assertEquals($resourcesA, $this->_service->getAllowedResources($userIdentifierA), "The list of resources allowed to the user is invalid.");
     $this->assertEquals($resourcesB, $this->_service->getAllowedResources($userIdentifierB), "The list of resources allowed to the user is invalid.");
 }
예제 #2
0
 /**
  * Process integration resource permissions after the integration is created
  *
  * @param \Magento\Integration\Model\Resource\Setup $subject
  * @param string[] $integrationNames Name of integrations passed as array from the invocation chain
  *
  * @return string[]
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterInitIntegrationProcessing(\Magento\Integration\Model\Resource\Setup $subject, $integrationNames)
 {
     if (empty($integrationNames)) {
         return array();
     }
     /** @var array $integrations */
     $integrations = $this->_integrationConfig->getIntegrations();
     foreach ($integrationNames as $name) {
         if (isset($integrations[$name])) {
             $integration = $this->_integrationService->findByName($name);
             if ($integration->getId()) {
                 $userIdentifier = $this->_userIdentifierFactory->create(UserIdentifier::USER_TYPE_INTEGRATION, $integration->getId());
                 $this->_authzService->grantPermissions($userIdentifier, $integrations[$name]['resources']);
             }
         }
     }
     return $integrationNames;
 }