{"action":"reopened","issue":{"url":"https://api.github.com/repos/moqui/moqui/issues/186","labels_url":"https://api.github.com/repos/moqui/moqui/issues/186/labels{/name}","comments_url":"https://api.github.com/repos/moqui/moqui/issues/186/comments","events_url":"https://api.github.com/repos/moqui/moqui/issues/186/events","html_url":"https://github.com/moqui/moqui/issues/186","id":118340807,"number":186,"title":"Support record level authz in entity find including one, list, iterator, count","user":{"login":"locnguyenx","id":7638127,"avatar_url":"https://avatars.githubusercontent.com/u/7638127?v=3","gravatar_id":"","url":"https://api.github.com/users/locnguyenx","html_url":"https://github.com/locnguyenx","followers_url":"https://api.github.com/users/locnguyenx/followers","following_url":"https://api.github.com/users/locnguyenx/following{/other_user}","gists_url":"https://api.github.com/users/locnguyenx/gists{/gist_id}","starred_url":"https://api.github.com/users/locnguyenx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/locnguyenx/subscriptions","organizations_url":"https://api.github.com/users/locnguyenx/orgs","repos_url":"https://api.github.com/users/locnguyenx/repos","events_url":"https://api.github.com/users/locnguyenx/events{/privacy}","received_events_url":"https://api.github.com/users/locnguyenx/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/moqui/moqui/labels/Feature","name":"Feature","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-11-23T09:00:54Z","updated_at":"2015-12-30T22:26:27Z","closed_at":null,"body":"I'm testing following feature :\"The record level authz is checked by doing a query on the view entity with the current userId and the PK fields of the entity the operation is being done on\"\r\nSetup:\r\n1- New entity:\r\n```\r\n<entity entity-name=\"ExampleUserAssignment\" package-name=\"example\" short-alias=\"exampleUser\">\r\n        <field name=\"exampleId\" type=\"id\" is-pk=\"true\"/>\r\n        <field name=\"userId\" type=\"id\" is-pk=\"true\"/>\r\n        <relationship type=\"one\" related-entity-name=\"example.Example\"/>\r\n        <relationship type=\"one\" title=\"ExampleAssignment\" related-entity-name=\"moqui.security.UserAccount\"/>\r\n    </entity>\r\n```\r\n2- Demo data:\r\n```\r\n<moqui.security.UserAccount userId=\"locnx\" username=\"locnx.viewer\" userFullName=\"Example Viewer User\" currentPassword=\"16ac58bbfa332c1c55bd98b53e60720bfa90d394\" passwordHashType=\"SHA\" passwordHint=\"framework name, lowercase\" currencyUomId=\"USD\" locale=\"en_US\" timeZone=\"US/Central\"/>\r\n\r\n    <moqui.security.UserGroupMember userGroupId=\"EXAMPLE_VIEWER\" userId=\"locnx\" fromDate=\"1265184000000\"/>\r\n\r\n    <example.Example exampleId=\"EXTST1\" description= \"Example Test Name 1\"  exampleName=\"Test Name 1\" exampleSize= \"10\"  exampleDate=\"2014-01-01\"/>\r\n\r\n    <example.Example exampleId=\"EXTST2\" description= \"Example Test Name 2\"  exampleName=\"Test Name 2\" exampleSize= \"10\"  exampleDate=\"2014-01-01\"/>    \r\n\r\n    <example.ExampleUserAssignment exampleId=\"EXTST1\" userId= \"locnx\"/>\r\n\r\n    <example.ExampleUserAssignment exampleId=\"EXTST2\" userId= \"EX_TLD\"/>\r\n\r\n    <moqui.security.ArtifactAuthzRecord artifactAuthzId=\"EXAMPLE_AUTHZ_VW\" viewEntityName=\"example.ExampleUserAssignment\"/>\r\n```\r\n\r\n3- Test Features:\r\n```\r\ndef \"find Example 1 by locnx\"() {\r\n        when:\r\n        ec.user.logoutUser()\r\n        ec.user.loginUser(\"locnx.viewer\", \"moqui\", null)\r\n        EntityValue example = ec.entity.find(\"example.Example\").condition(\"exampleId\", \"EXTST1\").one()\r\n        then:\r\n        notThrown(Exception)\r\n        example.exampleName == \"Test Name 1\"\r\n    }\r\n\r\n    def \"find Example 2 by locnx\"() {\r\n\r\n        when:\r\n        ec.user.logoutUser()\r\n        ec.user.loginUser(\"locnx.viewer\", \"moqui\", null)\r\n        EntityValue example = ec.entity.find(\"example.Example\").condition(\"exampleId\", \"EXTST2\").one()\r\n\r\n        then:\r\n        thrown(Exception)\r\n        // this testcase must be fail as locnx was assigned Example 1 only\r\n\r\n    }\r\n\r\n    def \"find Example 1 by VIEWER\"() {\r\n        when:\r\n        ec.user.logoutUser()\r\n        ec.user.loginUser(\"example.viewer\", \"moqui\", null)\r\n\r\n        EntityValue example = ec.entity.find(\"example.Example\").condition(\"exampleId\", \"EXTST1\").one()\r\n\r\n        then:\r\n        thrown(Exception)\r\n        // this testcase must be fail as VIEWER hasn't been assigned\r\n    }\r\n```\r\n\r\nI expected feature \"find Example 1 by locnx\" Passed and the rest will Fail. However, both \"find Example 1 by locnx\" & \"find Example 2 by locnx\" are Passed, only the last Fail."}}