GitHub PullRequestReviewCommentEvent at 2014-10-02 20:20:51
Repository: robottelo
Actor: Ichimonji10
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/comments/18364634","id":18364634,"diff_hunk":"@@ -64,3 +69,178 @@ def test_search_permissions(self):\n         result = entities.Permission().search()\n         result_name = [permission['name'] for permission in result]\n         self.assertItemsEqual(PERMISSIONS_NAME, result_name)\n+\n+\n+# FIXME: This method is a hack. This information should somehow be tied\n+# directly to the `Entity` classes.\n+def _permission_name(entity, which_perm):\n+    \"\"\"Find a permission name.\n+\n+    Attempt to locate a permission in\n+    :data:`robottelo.common.constants.PERMISSIONS`. For example, return\n+    'view_architectures' if ``entity`` is ``Architecture`` and ``which_perm``\n+    is 'read'.\n+\n+    :param robottelo.orm.Entity entity: An ``Entity`` subclass.\n+    :param str which_perm: Either the word \"create\", \"read\", \"update\" or\n+        \"delete\".\n+    :raise: ``LookupError`` if a relevant permission cannot be found, or if\n+        multiple results are found.\n+\n+    \"\"\"\n+    pattern = {\n+        'create': '^create_',\n+        'delete': '^destroy_',\n+        'read': '^view_',\n+        'update': '^edit_',\n+    }[which_perm]\n+    perm_names = []\n+    for permission in PERMISSIONS[entity.__name__]:\n+        match = re.match(pattern, permission)\n+        if match is not None:\n+            perm_names.append(permission)\n+    if len(perm_names) != 1:\n+        raise LookupError(\n+            'Could not find the requested permission. Found: {0}'\n+            .format(perm_names)\n+        )\n+    return perm_names[0]\n+\n+\n+# This class might better belong in module test_multiple_paths.\n+@ddt.ddt\n+class UserRoleTestCase(TestCase):\n+    \"\"\"Give a user various permissions and see if they are enforced.\"\"\"\n+\n+    def setUp(self):\n+        \"\"\"Create a set of credentials and a user.\"\"\"\n+        self.auth = (gen_alphanumeric(), gen_alphanumeric())  # login, password\n+        self.user = entities.User(\n+            id=entities.User(\n+                login=self.auth[0],\n+                password=self.auth[1]\n+            ).create()['id']\n+        )\n+\n+    def give_user_permission(self, perm_name):\n+        \"\"\"Give ``self.user`` the ``perm_name`` permission.\n+\n+        This method creates a role and filter to accomplish the above goal.\n+        When complete, the relevant relationhips look like this:\n+\n+            user -> role <- filter -> permission\n+\n+        :param str perm_name: The name of a permission. For example:\n+            'create_architectures'.\n+        :raises: ``AssertionError`` if more than one permission is found when\n+            searching for the permission with name ``perm_name``.\n+        :raises: ``requests.exceptions.HTTPError`` if an error occurs when\n+            updating ``self.user``'s roles.\n+        :rtype: None\n+\n+        \"\"\"\n+        role_id = entities.Role().create()['id']\n+        permission_ids = [\n+            permission['id']\n+            for permission\n+            in entities.Permission(name=perm_name).search()\n+        ]\n+        self.assertEqual(len(permission_ids), 1)\n+        entities.Filter(permission=permission_ids, role=role_id).create()\n+        # NOTE: An extra hash is used due to an API bug.\n+        client.put(\n+            self.user.path(),\n+            {u'user': {u'role_ids': [role_id]}},\n+            auth=get_server_credentials(),\n+            verify=False,\n+        ).raise_for_status()\n+\n+    @decorators.data(\n+        entities.Architecture,\n+        entities.Domain,\n+    )","path":"tests/foreman/api/test_permission_v2.py","position":141,"original_position":141,"commit_id":"f26d1348e9ef2d8fbfbcdfbc557ba5d232d78c2f","original_commit_id":"f26d1348e9ef2d8fbfbcdfbc557ba5d232d78c2f","user":{"login":"Ichimonji10","id":1012989,"avatar_url":"https://avatars.githubusercontent.com/u/1012989?v=2","gravatar_id":"","url":"https://api.github.com/users/Ichimonji10","html_url":"https://github.com/Ichimonji10","followers_url":"https://api.github.com/users/Ichimonji10/followers","following_url":"https://api.github.com/users/Ichimonji10/following{/other_user}","gists_url":"https://api.github.com/users/Ichimonji10/gists{/gist_id}","starred_url":"https://api.github.com/users/Ichimonji10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ichimonji10/subscriptions","organizations_url":"https://api.github.com/users/Ichimonji10/orgs","repos_url":"https://api.github.com/users/Ichimonji10/repos","events_url":"https://api.github.com/users/Ichimonji10/events{/privacy}","received_events_url":"https://api.github.com/users/Ichimonji10/received_events","type":"User","site_admin":false},"body":"All four permission-related tests only use the Architecture and Domain classes. This is simply because the existing `test_permission` module touched the same two classes. This list can probably be expanded.","created_at":"2014-10-02T20:20:51Z","updated_at":"2014-10-02T20:20:51Z","html_url":"https://github.com/SatelliteQE/robottelo/pull/1492#discussion_r18364634","pull_request_url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/1492","_links":{"self":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/comments/18364634"},"html":{"href":"https://github.com/SatelliteQE/robottelo/pull/1492#discussion_r18364634"},"pull_request":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/1492"}}},"pull_request":{"url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/1492","id":22166917,"html_url":"https://github.com/SatelliteQE/robottelo/pull/1492","diff_url":"https://github.com/SatelliteQE/robottelo/pull/1492.diff","patch_url":"https://github.com/SatelliteQE/robottelo/pull/1492.patch","issue_url":"https://api.github.com/repos/SatelliteQE/robottelo/issues/1492","number":1492,"state":"open","locked":false,"title":"Port API tests in module test_permission","user":{"login":"Ichimonji10","id":1012989,"avatar_url":"https://avatars.githubusercontent.com/u/1012989?v=2","gravatar_id":"","url":"https://api.github.com/users/Ichimonji10","html_url":"https://github.com/Ichimonji10","followers_url":"https://api.github.com/users/Ichimonji10/followers","following_url":"https://api.github.com/users/Ichimonji10/following{/other_user}","gists_url":"https://api.github.com/users/Ichimonji10/gists{/gist_id}","starred_url":"https://api.github.com/users/Ichimonji10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ichimonji10/subscriptions","organizations_url":"https://api.github.com/users/Ichimonji10/orgs","repos_url":"https://api.github.com/users/Ichimonji10/repos","events_url":"https://api.github.com/users/Ichimonji10/events{/privacy}","received_events_url":"https://api.github.com/users/Ichimonji10/received_events","type":"User","site_admin":false},"body":"Subsume module `test_permission` into module `test_permission_v2`. Make the\r\nrelevant tests use the new API testing tools, not the old API testing tools.\r\n\r\nFix #1447.","created_at":"2014-10-02T20:15:04Z","updated_at":"2014-10-02T20:20:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e8b1bbfafb425bacc1018aceb2f0c57c2e5034d0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/1492/commits","review_comments_url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/1492/comments","review_comment_url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/comments/{number}","comments_url":"https://api.github.com/repos/SatelliteQE/robottelo/issues/1492/comments","statuses_url":"https://api.github.com/repos/SatelliteQE/robottelo/statuses/f26d1348e9ef2d8fbfbcdfbc557ba5d232d78c2f","head":{"label":"Ichimonji10:drop-test-permissions","ref":"drop-test-permissions","sha":"f26d1348e9ef2d8fbfbcdfbc557ba5d232d78c2f","user":{"login":"Ichimonji10","id":1012989,"avatar_url":"https://avatars.githubusercontent.com/u/1012989?v=2","gravatar_id":"","url":"https://api.github.com/users/Ichimonji10","html_url":"https://github.com/Ichimonji10","followers_url":"https://api.github.com/users/Ichimonji10/followers","following_url":"https://api.github.com/users/Ichimonji10/following{/other_user}","gists_url":"https://api.github.com/users/Ichimonji10/gists{/gist_id}","starred_url":"https://api.github.com/users/Ichimonji10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ichimonji10/subscriptions","organizations_url":"https://api.github.com/users/Ichimonji10/orgs","repos_url":"https://api.github.com/users/Ichimonji10/repos","events_url":"https://api.github.com/users/Ichimonji10/events{/privacy}","received_events_url":"https://api.github.com/users/Ichimonji10/received_events","type":"User","site_admin":false},"repo":{"id":20566902,"name":"robottelo","full_name":"Ichimonji10/robottelo","owner":{"login":"Ichimonji10","id":1012989,"avatar_url":"https://avatars.githubusercontent.com/u/1012989?v=2","gravatar_id":"","url":"https://api.github.com/users/Ichimonji10","html_url":"https://github.com/Ichimonji10","followers_url":"https://api.github.com/users/Ichimonji10/followers","following_url":"https://api.github.com/users/Ichimonji10/following{/other_user}","gists_url":"https://api.github.com/users/Ichimonji10/gists{/gist_id}","starred_url":"https://api.github.com/users/Ichimonji10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ichimonji10/subscriptions","organizations_url":"https://api.github.com/users/Ichimonji10/orgs","repos_url":"https://api.github.com/users/Ichimonji10/repos","events_url":"https://api.github.com/users/Ichimonji10/events{/privacy}","received_events_url":"https://api.github.com/users/Ichimonji10/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Ichimonji10/robottelo","description":"An automation testing framework for the Katello project.","fork":true,"url":"https://api.github.com/repos/Ichimonji10/robottelo","forks_url":"https://api.github.com/repos/Ichimonji10/robottelo/forks","keys_url":"https://api.github.com/repos/Ichimonji10/robottelo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Ichimonji10/robottelo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Ichimonji10/robottelo/teams","hooks_url":"https://api.github.com/repos/Ichimonji10/robottelo/hooks","issue_events_url":"https://api.github.com/repos/Ichimonji10/robottelo/issues/events{/number}","events_url":"https://api.github.com/repos/Ichimonji10/robottelo/events","assignees_url":"https://api.github.com/repos/Ichimonji10/robottelo/assignees{/user}","branches_url":"https://api.github.com/repos/Ichimonji10/robottelo/branches{/branch}","tags_url":"https://api.github.com/repos/Ichimonji10/robottelo/tags","blobs_url":"https://api.github.com/repos/Ichimonji10/robottelo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Ichimonji10/robottelo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Ichimonji10/robottelo/git/refs{/sha}","trees_url":"https://api.github.com/repos/Ichimonji10/robottelo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Ichimonji10/robottelo/statuses/{sha}","languages_url":"https://api.github.com/repos/Ichimonji10/robottelo/languages","stargazers_url":"https://api.github.com/repos/Ichimonji10/robottelo/stargazers","contributors_url":"https://api.github.com/repos/Ichimonji10/robottelo/contributors","subscribers_url":"https://api.github.com/repos/Ichimonji10/robottelo/subscribers","subscription_url":"https://api.github.com/repos/Ichimonji10/robottelo/subscription","commits_url":"https://api.github.com/repos/Ichimonji10/robottelo/commits{/sha}","git_commits_url":"https://api.github.com/repos/Ichimonji10/robottelo/git/commits{/sha}","comments_url":"https://api.github.com/repos/Ichimonji10/robottelo/comments{/number}","issue_comment_url":"https://api.github.com/repos/Ichimonji10/robottelo/issues/comments/{number}","contents_url":"https://api.github.com/repos/Ichimonji10/robottelo/contents/{+path}","compare_url":"https://api.github.com/repos/Ichimonji10/robottelo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Ichimonji10/robottelo/merges","archive_url":"https://api.github.com/repos/Ichimonji10/robottelo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Ichimonji10/robottelo/downloads","issues_url":"https://api.github.com/repos/Ichimonji10/robottelo/issues{/number}","pulls_url":"https://api.github.com/repos/Ichimonji10/robottelo/pulls{/number}","milestones_url":"https://api.github.com/repos/Ichimonji10/robottelo/milestones{/number}","notifications_url":"https://api.github.com/repos/Ichimonji10/robottelo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Ichimonji10/robottelo/labels{/name}","releases_url":"https://api.github.com/repos/Ichimonji10/robottelo/releases{/id}","created_at":"2014-06-06T14:38:05Z","updated_at":"2014-06-25T13:36:09Z","pushed_at":"2014-10-02T20:14:45Z","git_url":"git://github.com/Ichimonji10/robottelo.git","ssh_url":"git@github.com:Ichimonji10/robottelo.git","clone_url":"https://github.com/Ichimonji10/robottelo.git","svn_url":"https://github.com/Ichimonji10/robottelo","homepage":null,"size":10760,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"SatelliteQE:master","ref":"master","sha":"2fd8a3c0e0adbd02324853c57a9942a8668cce6d","user":{"login":"SatelliteQE","id":8754276,"avatar_url":"https://avatars.githubusercontent.com/u/8754276?v=2","gravatar_id":"","url":"https://api.github.com/users/SatelliteQE","html_url":"https://github.com/SatelliteQE","followers_url":"https://api.github.com/users/SatelliteQE/followers","following_url":"https://api.github.com/users/SatelliteQE/following{/other_user}","gists_url":"https://api.github.com/users/SatelliteQE/gists{/gist_id}","starred_url":"https://api.github.com/users/SatelliteQE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SatelliteQE/subscriptions","organizations_url":"https://api.github.com/users/SatelliteQE/orgs","repos_url":"https://api.github.com/users/SatelliteQE/repos","events_url":"https://api.github.com/users/SatelliteQE/events{/privacy}","received_events_url":"https://api.github.com/users/SatelliteQE/received_events","type":"Organization","site_admin":false},"repo":{"id":4000279,"name":"robottelo","full_name":"SatelliteQE/robottelo","owner":{"login":"SatelliteQE","id":8754276,"avatar_url":"https://avatars.githubusercontent.com/u/8754276?v=2","gravatar_id":"","url":"https://api.github.com/users/SatelliteQE","html_url":"https://github.com/SatelliteQE","followers_url":"https://api.github.com/users/SatelliteQE/followers","following_url":"https://api.github.com/users/SatelliteQE/following{/other_user}","gists_url":"https://api.github.com/users/SatelliteQE/gists{/gist_id}","starred_url":"https://api.github.com/users/SatelliteQE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SatelliteQE/subscriptions","organizations_url":"https://api.github.com/users/SatelliteQE/orgs","repos_url":"https://api.github.com/users/SatelliteQE/repos","events_url":"https://api.github.com/users/SatelliteQE/events{/privacy}","received_events_url":"https://api.github.com/users/SatelliteQE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SatelliteQE/robottelo","description":"An automation testing framework for the Katello project.","fork":false,"url":"https://api.github.com/repos/SatelliteQE/robottelo","forks_url":"https://api.github.com/repos/SatelliteQE/robottelo/forks","keys_url":"https://api.github.com/repos/SatelliteQE/robottelo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SatelliteQE/robottelo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SatelliteQE/robottelo/teams","hooks_url":"https://api.github.com/repos/SatelliteQE/robottelo/hooks","issue_events_url":"https://api.github.com/repos/SatelliteQE/robottelo/issues/events{/number}","events_url":"https://api.github.com/repos/SatelliteQE/robottelo/events","assignees_url":"https://api.github.com/repos/SatelliteQE/robottelo/assignees{/user}","branches_url":"https://api.github.com/repos/SatelliteQE/robottelo/branches{/branch}","tags_url":"https://api.github.com/repos/SatelliteQE/robottelo/tags","blobs_url":"https://api.github.com/repos/SatelliteQE/robottelo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SatelliteQE/robottelo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SatelliteQE/robottelo/git/refs{/sha}","trees_url":"https://api.github.com/repos/SatelliteQE/robottelo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SatelliteQE/robottelo/statuses/{sha}","languages_url":"https://api.github.com/repos/SatelliteQE/robottelo/languages","stargazers_url":"https://api.github.com/repos/SatelliteQE/robottelo/stargazers","contributors_url":"https://api.github.com/repos/SatelliteQE/robottelo/contributors","subscribers_url":"https://api.github.com/repos/SatelliteQE/robottelo/subscribers","subscription_url":"https://api.github.com/repos/SatelliteQE/robottelo/subscription","commits_url":"https://api.github.com/repos/SatelliteQE/robottelo/commits{/sha}","git_commits_url":"https://api.github.com/repos/SatelliteQE/robottelo/git/commits{/sha}","comments_url":"https://api.github.com/repos/SatelliteQE/robottelo/comments{/number}","issue_comment_url":"https://api.github.com/repos/SatelliteQE/robottelo/issues/comments/{number}","contents_url":"https://api.github.com/repos/SatelliteQE/robottelo/contents/{+path}","compare_url":"https://api.github.com/repos/SatelliteQE/robottelo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SatelliteQE/robottelo/merges","archive_url":"https://api.github.com/repos/SatelliteQE/robottelo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SatelliteQE/robottelo/downloads","issues_url":"https://api.github.com/repos/SatelliteQE/robottelo/issues{/number}","pulls_url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls{/number}","milestones_url":"https://api.github.com/repos/SatelliteQE/robottelo/milestones{/number}","notifications_url":"https://api.github.com/repos/SatelliteQE/robottelo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SatelliteQE/robottelo/labels{/name}","releases_url":"https://api.github.com/repos/SatelliteQE/robottelo/releases{/id}","created_at":"2012-04-12T01:36:39Z","updated_at":"2014-09-15T15:19:49Z","pushed_at":"2014-10-02T19:37:19Z","git_url":"git://github.com/SatelliteQE/robottelo.git","ssh_url":"git@github.com:SatelliteQE/robottelo.git","clone_url":"https://github.com/SatelliteQE/robottelo.git","svn_url":"https://github.com/SatelliteQE/robottelo","homepage":null,"size":24354,"stargazers_count":16,"watchers_count":16,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":20,"mirror_url":null,"open_issues_count":95,"forks":20,"open_issues":95,"watchers":16,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/1492"},"html":{"href":"https://github.com/SatelliteQE/robottelo/pull/1492"},"issue":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/issues/1492"},"comments":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/issues/1492/comments"},"review_comments":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/1492/comments"},"review_comment":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/1492/commits"},"statuses":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/statuses/f26d1348e9ef2d8fbfbcdfbc557ba5d232d78c2f"}}}}