Skip to content
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

Clean up and clarify the OgAccess unit tests #230

Merged
merged 5 commits into from
Jun 29, 2016

Conversation

pfrenssen
Copy link
Collaborator

The OgAccess unit tests are sparsely documented which makes them very confusing to work with. Also it has a property which is very vaguely named $entity, but it is not clear when looking at the tests whether this is a group, or group content, or any other entity.

Let's add some documentation and do some general spring cleaning.

@pfrenssen
Copy link
Collaborator Author

This is still in progress since it builds on top of #226.

@pfrenssen pfrenssen changed the title WIP: Clean up and clarify the OgAccess unit tests Clean up and clarify the OgAccess unit tests Jun 10, 2016
@pfrenssen
Copy link
Collaborator Author

Great, #226 is in so this is unblocked!

// @todo This is strange, 'view' is not part of the operations supplied by
// ::operationProvider(). And why would a group administrator be allowed
// access to all operations, except 'view'? Shouldn't this also return
// 'allowed'?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is puzzling to me. It seems to be the intention to hand off the 'view' permission to core, but this is counterintuitive. What would be the use case of not granting 'view' access to a group admin, while all the other permissions and operations are granted?

Copy link
Owner

Choose a reason for hiding this comment

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

I'll have to go in and check - I don't really remember what's going on here ;)

Copy link
Owner

@amitaibu amitaibu Jun 15, 2016

Choose a reason for hiding this comment

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

this is related to the incorrect crud operation To permission name bug/ feature we have.

The gist of things is - OG's hook_entity_access() cares only about non-view operations. If it's a view we are neutral about it. The reason is that for example node access should be determined by the node grants, and not on the fly.

So this

$user_entity_access = og_entity_access($this->entity->reveal(), $operation, $this->user->reveal());

should probably change to something like

$permission_name = OgPermissionHandler::getPermissionFromEntityOperation($entity, 'view');
$user_entity_access = og_entity_access($this->entity->reveal(), $permissions_name, $this->user->reveal());

It can probably be a follow up, as it's out of the scope of this PR. So maybe open an issue instead of the @todo?

Copy link
Owner

Choose a reason for hiding this comment

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

sorry I mean $permission_name = OgPermissionHandler::getPermissionFromEntityOperation($entity, 'view'); should happen inside \Drupal\og\OgAccess::userAccessEntity, so the test can remain as is.

@damiankloip
Copy link
Collaborator

This also conflicts alot with my PR. Seems like this can totally wait?
On 10 Jun 2016 17:55, "Pieter Frenssen" notifications@github.com wrote:

This is still in progress since it builds on top of #226
#226.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#230 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ABAUw3030wSDnj0eUrOXlXRw1dZ1c1Duks5qKZb1gaJpZM4IzIjQ
.

@damiankloip
Copy link
Collaborator

damiankloip commented Jun 10, 2016

@pfrenssen cut me a break, #225 should at least get a look in first, after #226 was merged :)

@pfrenssen
Copy link
Collaborator Author

pfrenssen commented Jun 13, 2016

I'm relentless! :D

No this is obviously low priority, let's not have it complicate more important PRs.

@pfrenssen
Copy link
Collaborator Author

#225 is in, as far as I know this will not impact anything else any more. I merged in the latest changes from 8.x-1.x.

* @return array
* An array of test operations.
*
* @todo These are not really 'operations' but rather 'permissions', rename
Copy link
Owner

Choose a reason for hiding this comment

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

permissionsProvider() sounds better.

@pfrenssen
Copy link
Collaborator Author

Thanks for the review. I am going to have a look at this again later. I have other fish to fry at the moment :)

@pfrenssen
Copy link
Collaborator Author

Found the time to address this. Tests will now probably fail due to https://www.drupal.org/node/2752315

@pfrenssen
Copy link
Collaborator Author

This is becoming like a game of whack-a-mole, issue #2752315: Fix visibility of AssertLegacyTrait::assertNoEscaped() is now fixed, and just a few hours later a similar issue popped up: issue #2757139: Fix visibility of AssertLegacyTrait::buildXPathQuery().

I have posted a fix in that issue, if by tomorrow it is not accepted I will make a workaround for us so we can continue working on OG.

@pfrenssen
Copy link
Collaborator Author

The bug in core is fixed! I have restarted the test and now everything is green. This is ready for review again!

@pfrenssen pfrenssen removed their assignment Jun 28, 2016
@amitaibu amitaibu merged commit 8b1009c into 8.x-1.x Jun 29, 2016
@amitaibu amitaibu deleted the cleanup-og-access-test branch June 29, 2016 17:44
@amitaibu
Copy link
Owner

Thanks!

sandervd pushed a commit to ec-europa/og that referenced this pull request Feb 27, 2017
OgDeleteOrphans Simple Plugin does not delete content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants