Problem/Motivation

#3160148: Add access permission check to "View JSON" operation link
#3160149: Fix "View API Documentation" link in entity operations

Steps to reproduce

Given that a "Site Admin" was logged in to the site
When navigating to "/admin/content"
And clicked on the "Operations" options for a content
And API resource type was activated for the content type
Then should see "View JSON"
And should see "View API Docs"
And not to show up for other user roles.

View API Docs entity operation

Proposed resolution

Grant "Site Admin" user role the following permissions:

  - "access view api docs entity operation"
  - "access view json entity operation"

Remaining tasks

  • ✅ File an issue about this project
  • ✅ Change permissions for "Site Admin" user role to access JSON:API and API Docs
  • ✅ Testing to ensure no regression
  • ✅ Automated unit/functional testing coverage
    Varbase CircleCI Build Passing
  • ✅ Developer Documentation support on feature change/addition
  • ➖ User Guide Documentation support on feature change/addition
  • ✅ Code review from 1 Varbase core team member
  • ✅ Full testing and approval
  • ✅ Credit contributors
  • ✅ Review with the product owner
  • ✅ Release varbase-9.0.2

User interface changes

Only View JSON

View JSON with View API Docs
View API Docs entity operation

API changes

  • N/A

Data model changes

  • N/A

New Gherkin scenarios for the JSON:API

@javascript @check @local @development @staging @production
  Scenario: Check that Site Admin users can access "View JSON" and "View API Docs" entity operations
    Given I am a logged in user with the "test_site_admin" user
     When I go to "/admin/content"
      And I wait
     Then I should see "Content"
      And I should see the "View JSON" operation for the "Homepage" content
      And I should see the "View API Docs" operation for the "Homepage" content
      And I should see the "Edit" operation for the "Homepage" content
      And I should see the "Layout" operation for the "Homepage" content
      And I should see the "View JSON" operation for the "Blog" content
      And I should see the "View API Docs" operation for the "Blog" content

     When I go to "/admin/content/media"
      And I wait
     Then I should see "Media"
      And I should see the "View JSON" operation for the "Media entity test" media
      And I should see the "View API Docs" operation for the "Media entity test" media
      And I should see the "Edit" operation for the "Media entity test" media

     When I go to "/admin/structure/taxonomy/manage/tags/overview"
      And I wait
     Then I should see "Tags"
      And I should see "space"
      And I should not see the "View JSON" operation for the "space" term
      And I should not see the "View API Docs" operation for the "space" term

     When I go to "/admin/structure/entityqueue"
      And I wait
     Then I should see "Entityqueues"
      And I should not see the "View JSON" operation for the "Media Hero Slider" entity
      And I should not see the "View API Docs" operation for the "Media Hero Slider" entity
      But I should not see the "Edit items" operation for the "Media Hero Slider" entity
      

  @javascript @check @local @development @staging @production
  Scenario: Check that Content Admin users can not access "View JSON" and "View API Docs" entity operations
    Given I am a logged in user with the "test_content_admin" user
     When I go to "/admin/content"
      And I wait
     Then I should see "Content"
      And I should not see the "View JSON" operation for the "Homepage" content
      And I should not see the "View API Docs" operation for the "Homepage" content
      But I should see the "Edit" operation for the "Homepage" content
      And I should see the "Layout" operation for the "Homepage" content

     When I go to "/admin/content/media"
      And I wait
     Then I should see "Media"
      And I should not see the "View JSON" operation for the "Media entity test" media
      And I should not see the "View API Docs" operation for the "Media entity test" media
      But I should see the "Edit" operation for the "Media entity test" media

     When I go to "/admin/structure/taxonomy/manage/tags/overview"
      And I wait
     Then I should see "Tags"
      And I should see "space"
      And I should not see the "View JSON" operation for the "space" term
      And I should not see the "View API Docs" operation for the "space" term

     When I go to "/admin/structure/entityqueue"
      And I wait
     Then I should see "Entityqueues"
      And I should not see the "View JSON" operation for the "Media Hero Slider" entity
      And I should not see the "View API Docs" operation for the "Media Hero Slider" entity
      But I should not see the "Edit items" operation for the "Media Hero Slider" entity


  @javascript @check @local @development @staging @production
  Scenario: Check that Editor users can access "View JSON" and "View API Docs" entity operations
    Given I am a logged in user with the "test_editor" user
     When I go to "/admin/content"
      And I wait
     Then I should see "Content"
      And I should not see the "View JSON" operation for the "Homepage" content
      And I should not see the "View API Docs" operation for the "Homepage" content
      But I should see the "Edit" operation for the "Homepage" content
      And I should see the "Layout" operation for the "Homepage" content

     When I go to "/admin/content/media"
      And I wait
     Then I should see "Media"
      And I should not see the "View JSON" operation for the "Media entity test" media
      And I should not see the "View API Docs" operation for the "Media entity test" media
      But I should see the "Edit" operation for the "Media entity test" media

     When I go to "/admin/structure/taxonomy/manage/tags/overview"
      And I wait
     Then I should see "Tags"
      And I should see "space"
      And I should not see the "View JSON" operation for the "space" term
      And I should not see the "View API Docs" operation for the "space" term

Using 2 new distinction steps

  /**
   * Check if an entity has a specific operation link.
   *
   * Varbase Context #varbase.
   *
   * Example 1: Then I should see the "Edit" operation for the "Homepage" entity
   * Example 2: Then I should see "Layout" operation for the "Homepage"
   * Example 3: Then see "Edit" operation for "Homepage"
   * Example 4: Then should see "Delete" operation for the "Blog" entity
   * Example 5: Then I should see "Clone" operation for the "Homepage" entity
   *
   * @Then /^(?:|I )(?:|should )see (?:|the )"([^"]*)" operation for the "([^"]*)" (?:|entity|content|media|file|term|user)$/
   */
  /**
   * Check if an entity not having a specific operation link.
   *
   * Varbase Context #varbase.
   *
   * Example 1: Then I should not see the "View API" operation for the "Homepage" entity
   * Example 2: Then I should not see "View API Docs" operation for the "Homepage"
   * Example 3: Then not see "Delete" operation for "Homepage"
   * Example 4: Then should not see "Delete" operation for the "Blog" entity
   * Example 5: Then I should not see "Clone" operation for the "Homepage" entity
   *
   * @Then /^(?:|I )(?:|should )not see (?:|the )"([^"]*)" operation for the "([^"]*)" (?:|entity|content|media|file|term|user)$/
   */

Comments

RajabNatshah created an issue. See original summary.

rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Title: Add a new permission (and grant it to Site Admin by default) for the "View JSON" operation link on entities » Add a new permission to Site Admin to access "View JSON" and "View API Docs" entity operations
Issue summary: View changes
rajab natshah’s picture

Title: Add a new permission to Site Admin to access "View JSON" and "View API Docs" entity operations » Add new permissions to Site Admin user role to access "View JSON" and "View API Docs" entity operations
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes

  • RajabNatshah committed 4e11d06 on 9.0.x
    Issue #3243594: Add new permissions to Site Admin user role to access "...
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Assigned: rajab natshah » mohammed j. razem
Issue summary: View changes
Status: Active » Needs review
Issue tags: +varbase-9.0.2
rajab natshah’s picture

Assigned: mohammed j. razem » Unassigned
Issue summary: View changes
rajab natshah’s picture

Status: Needs review » Fixed
rajab natshah’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

rajab natshah’s picture

Issue summary: View changes