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

Adding fix for Role feature state check #2851

Merged
merged 9 commits into from
May 2, 2018
Merged

Adding fix for Role feature state check #2851

merged 9 commits into from
May 2, 2018

Conversation

willdoran
Copy link
Contributor

@willdoran willdoran commented Apr 26, 2018

Notes

I'm not certain how to test this in the integration tests since we can't alter the features via request and I don't immediately see a way to do it from the tests.

This pull request makes the following changes:

  • Fixes case where users could create a role on any plan other than Responder

Test checklist:

  • With Roles feature enabled set to false

  • Attempt to create/update a new role via HTTP Post

  • You should receive a 422

  • I certify that I ran my checklist

Fixes #1617

Ping @ushahidi/platform

@willdoran willdoran requested review from rjmackay and rowasc April 26, 2018 15:04
@rjmackay
Copy link
Contributor

I'm not certain how to test this in the integration tests since we can't alter the features via request and I don't immediately see a way to do it from the tests.

@willdoran if you use the @rolesEnabled tag in behat tests does that work? https://github.com/ushahidi/platform/blob/develop/tests/integration/bootstrap/FeatureContext.php#L43

Copy link
Contributor

@rjmackay rjmackay left a comment

Choose a reason for hiding this comment

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

I think the validation changes are incomplete - needs to be added to rules.

I assume Create validator inherits from Update so this blocks creating new roles too?

@@ -36,6 +38,15 @@ protected function getRules()
];
}

public function checkRolesEnabled(\Kohana\Validation\Validation $validation, $permissions)
Copy link
Contributor

Choose a reason for hiding this comment

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

Couple of things:

  1. Don't you need to add this into getRules above?
  2. Should updates fail entirely? or should we be able to rename roles in the free tier?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just realised this is going back to the lumen branch. You need to change the interface to rely on Ushahidi\Core\Tool\ValidationEngine instead. It should work as written otherwise

Copy link
Contributor Author

@willdoran willdoran Apr 30, 2018

Choose a reason for hiding this comment

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

Should updates fail entirely? or should we be able to rename roles in the free tier?

nope no changes to roles at all allowed

Don't you need to add this into getRules above?

yep

Copy link
Contributor Author

@willdoran willdoran Apr 30, 2018

Choose a reason for hiding this comment

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

You need to change the interface to rely on Ushahidi\Core\Tool\ValidationEngine instead.

Can you link an example from the other validators, not sure I follow.

@willdoran
Copy link
Contributor Author

@rjmackay Yeah I think that will work, will add it.

@willdoran
Copy link
Contributor Author

@rjmackay could you peak at this again when you have a second?

Copy link
Contributor

@rjmackay rjmackay left a comment

Choose a reason for hiding this comment

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

LGTM.

*/
class RoleUpdateTest extends TestCase
{

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we should add a test that actually calls Update::check() with some data too.

@willdoran willdoran merged commit 23d0164 into lumen May 2, 2018
@willdoran willdoran deleted the ush022 branch May 4, 2018 19:52
rjmackay pushed a commit that referenced this pull request Jun 13, 2018
@rjmackay rjmackay mentioned this pull request Jun 15, 2018
25 tasks
rjmackay added a commit that referenced this pull request Jul 6, 2018
rjmackay added a commit that referenced this pull request Jul 6, 2018
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.

2 participants