I've written some unit tests in my Startinblox server instance to test Circle permissions, how should I share these?
My test for GET circle returns 200 when the circle status is Private, I can change Circle permissions to reject this or is this supposed to be handled elsewhere?
Issue #296 (closed) is dependent on this (which is for Projects milestone) .. I'll MR what I've done so far (multiple circle-members can be made admins) and we can leave this issue open, referring to the remaining permissions work?
I've written some unit tests in my Startinblox server instance to test Circle permissions, how should I share these?
That's a good idea if it's already done. Feel free to see how tests work on djangoldp, you can implement them the same way on the component & @plup will love you.
My test for GET circle returns 200 when the circle status is Private, I can change Circle permissions to reject this or is this supposed to be handled elsewhere?
Yes, you can make the check on too.
How should I test the permissions inheritance scenario you described earlier? I didn't understand the scenario
I think this should be enought: If you put someone as an admin, he may be allowed to delete another member relation. But if it's not, he can only delete himself.
To make sure you go on the right way:
You need a custom permission class on Circles: It'll check if the user of the request is an admin of the circle or not (beware for circle creation) and return right permissions.
You need another custom permission class on CircleMember: It'll check if the user of the request is an admin of the Circle linked to, in fact after that it'll do the same as above.
Thanks for these, got a bunch more tests passing :) to clarify:
What should the permissions on Circles with status "Archived" be?
I should be able to POST a circle if I am authenticated, and only PATCH, DELETE, PUT circles which I am an admin of?
I should be able to remove myself from a circle if I am authenticated, and only add a new member or remove someone else if I am an admin of the circle?
What should the permissions on Circles with status "Archived" be?
Archive mean an hidden circle from left menu, need to be unarchived from admin before use it again. From permission view, I don't think it change anything from Private/Public.
But a good question here is, if my Circle was Private does it become Public+Archived? Or are every Archived Circles == Private but without the left menu? @alexandre ?
I should be able to POST a circle if I am authenticated, and only PATCH, DELETE, PUT circles which I am an admin of?
Yes
POST: auth only
PATCH/PUT/DELETE: admins
I should be able to remove myself from a circle if I am authenticated, and only add a new member or remove someone else if I am an admin of the circle?
No
Add anyone: Any member of, admin or not
Remove myself: Any member of. Can't if I'm last member.
Remove others: Any admins. As it's not really useful on public circle, it's primary for private.
Remove admins: Nobody, only myself. Can't if I'm the last admin.
nearly there I've got tests passing for all conditions except:
Add anyone: Any member of, admin or not
This is difficult because the front-end makes this request by doing PATCH circle, not POST circle-member, and the permissions for PATCH circle block non-admins. I think the only way around this is to analyse the request data, making sure:
it only alters the members field
the new members value includes all of the previous members
This seems hard, unless I'm missing a better solution?
Possibly we could change the requirements to only allow admins to add new users, or the front-end could POST to CircleMembers instead?
This is difficult because the front-end makes this request by doing PATCH circle, not POST circle-member, and the permissions for PATCH circle block non-admins. I think the only way around this is to analyse the request data, making sure:
I'm pretty sure we made a POST on /circles/X/members/ here because of that, could you check?
I think we can workaround like that:
On your first permission class, on PATCH on a Circle: Only admins of are allowed.
On the second one, on POST on a Circle->CircleMember: Any member of can.