Skip to content

WIP: [CFM-861-tests] Add Behat tests for permissions. #1494

Closed
anvmn wants to merge 15 commits into
feature/CFM-861-adjust-permissionsfrom
feature/CFM-861-permission-behat-tests
Closed

WIP: [CFM-861-tests] Add Behat tests for permissions. #1494
anvmn wants to merge 15 commits into
feature/CFM-861-adjust-permissionsfrom
feature/CFM-861-permission-behat-tests

Conversation

@anvmn
Copy link
Copy Markdown
Contributor

@anvmn anvmn commented Nov 9, 2016

Derives from #1445

$target_access = og_user_access($group_type, $group['gid'], "create $node_type content");
// Any member can edit a wiki page unless a power user has changed it
// specifically for a specific node.
if (!empty($this->entity->nid) && $node_type == 'wiki_page') {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this one ....

Copy link
Copy Markdown
Contributor Author

@anvmn anvmn Nov 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I see it at code, selector is activated at og.module hook_node_access(), line 523.
This activation is inside following if (line 501):
if ($op == 'create' && og_is_group_content_type('node', $type))

This means that selector is activated only when creating group content. Right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fixed the bug we had, see travis for 84154e0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit doesn't have the !empty($this->entity->nid) condition.
empty($this->entity->nid) will return TRUE when creating node, so
!empty($this->entity->nid) will always return FALSE, if we create a node.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition was added at 56db585.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but here you've removed part of it ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored the condition

| mariecurie | /node/add/event |
| mariecurie | /node/add/document |
| mariecurie | /node/add/discussion |
| mariecurie | /node/add/wiki-page |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anvmn
please add /node/add/news as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Examples:
| user | path |
| isaacnewton | /draft/node/add/photoalbum |
| isaacnewton | /published/node/add/photo |
Copy link
Copy Markdown
Collaborator

@looshkin looshkin Nov 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be /draft/... instead of /published/... for lines 251-272

| mariecurie | /published/node/add/document |
| mariecurie | /published/node/add/discussion |
| mariecurie | /published/node/add/wiki-page |

Copy link
Copy Markdown
Collaborator

@looshkin looshkin Nov 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also need to update the path to /draft/ instead of /pending/ for all lines from 251 to 272

Copy link
Copy Markdown
Contributor Author

@anvmn anvmn Nov 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Also, lines 194-216.

| mariecurie | /published/node/add/document |
| mariecurie | /published/node/add/discussion |
| mariecurie | /published/node/add/wiki-page |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also need to update the path to /draft/ instead of /pending/ for all lines from 307 to 328

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

When I change access of group "Published group" to "Public"
Then I am an anonymous user
And I go to "published"
And I should see "Please log in"
Copy link
Copy Markdown
Collaborator

@looshkin looshkin Nov 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong - a visitor can access and view all contents in a published public group - he does not need to login
to create content though, he needs to become a member via combined workflow

When I change access of group "Archived group" to "Public"
Then I am an anonymous user
And I go to "archived"
And I should see "Please log in"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong - a visitor can access and view all contents in a published archived group - he does not need to login
Archived groups are read only so visitors cannot request membership

| mariecurie | /deleted/node/add/document |
| mariecurie | /deleted/node/add/discussion |
| mariecurie | /deleted/node/add/wiki-page |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no we agreed with Aki this AM that both pending and deleted groups would prevent any user from creating content - so please add lines 716 to 721 in the scenario below, described under line 724

Copy link
Copy Markdown
Contributor Author

@anvmn anvmn Nov 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

| mariecurie | /deleted/node/add/document |
| mariecurie | /deleted/node/add/discussion |
| mariecurie | /deleted/node/add/wiki-page |

Copy link
Copy Markdown
Collaborator

@looshkin looshkin Nov 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no we agreed with Aki this AM that deleted groups would prevent any user from creating content - so please delete scenario described under 765 and add lines 772 to 777 in the scenario described under line 780

| mariecurie | /deleted/node/add/document |
| mariecurie | /deleted/node/add/discussion |
| mariecurie | /deleted/node/add/wiki-page |

Copy link
Copy Markdown
Collaborator

@looshkin looshkin Nov 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no we agreed with Aki this AM that deleted groups would prevent any user from creating content - so please delete scenario described under 821 and add lines 828 to 833 in the scenario described under line 836

@looshkin
Copy link
Copy Markdown
Collaborator

As a general comment for the create content permissions...
Even if news is not meant to be a Group Content Type, today a GM/GA/GO/SA is able to create news inside a group - this generates all the expected behaviour except the display of an item in the discussions overview. So to prevent this behaviour, I would add /node/add/news to the scenarios for all users

@ordavidil
Copy link
Copy Markdown
Contributor

@anvmn ^^

@ordavidil
Copy link
Copy Markdown
Contributor

@anvmn
all permission tests should moved to a new build on travis.

  1. change all tags to @permission
  2. add another env on .travis.yml
  - INSTALL_PROFILE=1
    BEHAT_TAG="permission"
    CODE_REVIEW=0
    SIMPLETEST=0
  1. modify run_behat.sh like:
# Run tests for the permission tag.
if [ "$BEHAT_TAG" = "permission" ]; then
  ./bin/behat --tags='@permission&&~@wip'
fi

anvmn added a commit that referenced this pull request Nov 13, 2016
@anvmn
Copy link
Copy Markdown
Contributor Author

anvmn commented Nov 13, 2016

Closing in favor of #1523

@anvmn anvmn closed this Nov 13, 2016
@anvmn anvmn deleted the feature/CFM-861-permission-behat-tests branch November 13, 2016 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants