Skip to content
Snippets Groups Projects
Commit e5e8e16e authored by Claudiu Cristea's avatar Claudiu Cristea
Browse files

ISAICP-9052: Switch should hide also OSS Solutions.

parent 51d22212
No related branches found
No related tags found
1 merge request!186Release/v1.112.1
......@@ -3,11 +3,19 @@
Feature: Test EU OSS Catalogue killswitch
Scenario: Switch ON/OFF
Given oss_solution content:
| title | oss_development_status | oss_source | oss_categories | oss_short_description | status |
| The Opensource Panacea | development | developers_italia | content-management | The cure | published |
When I go to "/eu-oss-catalogue"
Then the response status code should be 200
But I should not see "Sign in to continue"
And I go to "/eu-oss-catalogue/solutions"
Then the response status code should be 200
But I should not see "Sign in to continue"
And I go to the content page of the type "oss_solution" with the title "The Opensource Panacea"
Then the response status code should be 200
But I should not see "Sign in to continue"
Given I am logged in as an "authenticated"
When I go to "/eu-oss-catalogue"
......@@ -16,6 +24,8 @@ Feature: Test EU OSS Catalogue killswitch
Then the response status code should be 200
And I go to "/eu-oss-catalogue/solutions"
Then the response status code should be 200
And I go to the content page of the type "oss_solution" with the title "The Opensource Panacea"
Then the response status code should be 200
Given I am logged in as a "developer"
When I go to "/eu-oss-catalogue"
......@@ -28,6 +38,8 @@ Feature: Test EU OSS Catalogue killswitch
Then the response status code should be 200
And I go to "/admin/content/eu-oss-catalogue/log"
Then the response status code should be 200
And I go to the content page of the type "oss_solution" with the title "The Opensource Panacea"
Then the response status code should be 200
Given I visit "/dashboard"
When I press "Disable EU OSS Catalogue"
......@@ -38,6 +50,8 @@ Feature: Test EU OSS Catalogue killswitch
Then I should see the heading "Sign in to continue"
And I go to "/eu-oss-catalogue/solutions"
Then I should see the heading "Sign in to continue"
And I go to the content page of the type "oss_solution" with the title "The Opensource Panacea"
Then I should see the heading "Sign in to continue"
Given I am logged in as an "authenticated"
When I go to "/eu-oss-catalogue"
......@@ -46,6 +60,8 @@ Feature: Test EU OSS Catalogue killswitch
Then the response status code should be 403
And I go to "/eu-oss-catalogue/solutions"
Then the response status code should be 403
And I go to the content page of the type "oss_solution" with the title "The Opensource Panacea"
Then the response status code should be 403
Given I am logged in as a "developer"
When I go to "/eu-oss-catalogue"
......@@ -58,33 +74,44 @@ Feature: Test EU OSS Catalogue killswitch
Then the response status code should be 403
And I go to "/admin/content/eu-oss-catalogue/log"
Then the response status code should be 403
# Developer is and amin role, they can still see the node.
And I go to the content page of the type "oss_solution" with the title "The Opensource Panacea"
Then the response status code should be 200
Given I visit "/dashboard"
When I press "Enable EU OSS Catalogue"
Then I should see the success message "EU OSS Catalogue has been enabled"
Given I am an anonymous user
When I go to "/eu-oss-catalogue"
Then the response status code should be 200
And I go to "/eu-oss-catalogue/solutions"
Then the response status code should be 200
And I go to "/admin/content/eu-oss-catalogue"
Then the response status code should be 200
And I go to "/admin/content/eu-oss-catalogue/oss-solutions"
Then the response status code should be 200
And I go to "/admin/content/eu-oss-catalogue/log"
Then the response status code should be 200
And I go to the content page of the type "oss_solution" with the title "The Opensource Panacea"
Then the response status code should be 200
Given I am logged in as an "authenticated"
Given I am an anonymous user
When I go to "/eu-oss-catalogue"
And I check "I agree to the Legal notice document"
And I press "Submit"
Then the response status code should be 200
But I should not see "Sign in to continue"
And I go to "/eu-oss-catalogue/solutions"
Then the response status code should be 200
But I should not see "Sign in to continue"
And I go to the content page of the type "oss_solution" with the title "The Opensource Panacea"
Then the response status code should be 200
But I should not see "Sign in to continue"
Given I am logged in as a "developer"
Given I am logged in as an "authenticated"
When I go to "/eu-oss-catalogue"
And I check "I agree to the Legal notice document"
And I press "Submit"
Then the response status code should be 200
And I go to "/eu-oss-catalogue/solutions"
Then the response status code should be 200
And I go to "/admin/content/eu-oss-catalogue"
Then the response status code should be 200
And I go to "/admin/content/eu-oss-catalogue/oss-solutions"
Then the response status code should be 200
And I go to "/admin/content/eu-oss-catalogue/log"
And I go to the content page of the type "oss_solution" with the title "The Opensource Panacea"
Then the response status code should be 200
......@@ -9,15 +9,17 @@
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Access\AccessResultInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\block\BlockInterface;
use Drupal\collection\Entity\CollectionInterface;
use Drupal\custom_page\Entity\CustomPageInterface;
use Drupal\eu_oss_catalogue\Entity\OssSolutionInterface;
use Drupal\joinup_group\Entity\GroupInterface;
use Drupal\joinup_oss_catalogue\Entity\JoinupOssSolution;
use Drupal\joinup_oss_catalogue\OssCatalogueCollectionInterface;
use Drupal\node\NodeInterface;
use Drupal\rdf_entity\RdfInterface;
/**
* Implements hook_views_plugins_argument_alter().
......@@ -198,13 +200,23 @@ function joinup_oss_catalogue_is_enabled(): bool {
}
/**
* Implements hook_ENTITY_TYPE_access().
* Implements hook_entity_access().
*
* @todo Remove this function in ISAICP-9053.
*/
function joinup_oss_catalogue_rdf_entity_access(RdfInterface $entity, $operation, AccountInterface $account): AccessResultInterface {
if ($entity->id() === OssCatalogueCollectionInterface::COLLECTION_ENTITY_ID) {
return AccessResult::forbiddenIf(!joinup_oss_catalogue_is_enabled())->addCacheableDependency($entity);
function joinup_oss_catalogue_entity_access(EntityInterface $entity): AccessResultInterface {
if (
// The entity is the EU OSS Catalogue collection...
($entity instanceof CollectionInterface && $entity->id() === OssCatalogueCollectionInterface::COLLECTION_ENTITY_ID) ||
// ...or the EU OSS Catalogue collection landing page...
($entity instanceof CustomPageInterface && $entity->uuid() === OssCatalogueCollectionInterface::LANDING_PAGE) ||
// ...or an OSS Solution.
($entity instanceof OssSolutionInterface)
) {
return AccessResult::forbiddenIf(
!joinup_oss_catalogue_is_enabled(),
'EU OSS Catalogue is disabled',
)->addCacheableDependency($entity);
}
return AccessResult::neutral();
}
......
......@@ -8,9 +8,7 @@
use Drupal\Core\Access\AccessResultInterface;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\collection\Entity\CollectionInterface;
use Drupal\eu_oss_catalogue\EuOssCatalogueInterface;
use Drupal\joinup_oss_catalogue\OssCatalogueCollectionInterface;
use Symfony\Component\Routing\Route;
/**
......@@ -35,15 +33,6 @@ public function access(Route $route, RouteMatchInterface $routeMatch): AccessRes
if ($requirement !== 'TRUE') {
throw new \Exception("The _eu_oss_catalogue_check_enabled route requirement when present can only have 'TRUE' as value but '$requirement' was given.");
}
if ($routeMatch->getRouteName() === 'entity.rdf_entity.canonical') {
$rdf_entity = $routeMatch->getParameter('rdf_entity');
if (!$rdf_entity instanceof CollectionInterface || $rdf_entity->id() !== OssCatalogueCollectionInterface::COLLECTION_ENTITY_ID) {
// Any page except the EU OSS Catalogue landing page is allowed.
return AccessResult::allowed();
}
}
return joinup_oss_catalogue_is_enabled() ? AccessResult::allowed() : AccessResult::forbidden('EU OSS Catalogue functionality is disabled');
}
......
......@@ -34,7 +34,6 @@ public function alterRoutes(RouteCollection $collection): void {
'view.eu_oss_catalogue_admin.page',
'view.eu_oss_catalogue_log.page',
'view.search_oss_catalogue.search',
'entity.rdf_entity.canonical',
];
foreach ($routeNames as $routeName) {
if ($route = $collection->get($routeName)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment