{"action":"created","comment":{"url":"https://api.github.com/repos/dcos/dcos/pulls/comments/223480672","pull_request_review_id":162618398,"id":223480672,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMzQ4MDY3Mg==","diff_hunk":"@@ -0,0 +1,162 @@\n+\"\"\"\n+A collection of tests covering user management in DC/OS.\n+\n+Assume that access control is activated in Master Admin Router (could be\n+disabled with `oauth_enabled`) and therefore authenticate individual HTTP\n+requests.\n+\n+One aspect of DC/OS user management is that once authenticated a user can add\n+other users. Unauthenticated HTTP requests are rejected by Master Admin Router\n+and user management fails (this is the coarse-grained authorization model of\n+(open) DC/OS). Here, test that unauthenticated HTTP requests cannot manage\n+users. However, do not test that newly added users can add other users: in this\n+test suite we are limited to having authentication state for just a single user\n+available. This is why we can test managing other users only from that first\n+user's point of view. That is, we can not test that a user (e.g. user2) which\n+was added by the first user (user1) can add another user (user3).\n+\"\"\"\n+import logging\n+\n+import pytest\n+\n+from test_helpers import expanded_config\n+\n+\n+__maintainer__ = 'jgehrcke'\n+__contact__ = 'security-team@mesosphere.io'\n+\n+\n+log = logging.getLogger(__name__)\n+\n+\n+# Skip entire module in downstream integration tests.\n+if 'security' in expanded_config:\n+    pytest.skip(\n+        'Skip upstream-specific user management tests',\n+        allow_module_level=True\n+    )\n+\n+\n+def get_users(apisession):\n+    r = apisession.get('/acs/api/v1/users')\n+    r.raise_for_status()\n+    users = {u['uid']: u for u in r.json()['array']}\n+    return users\n+\n+\n+def delete_user(apisession, uid):\n+    r = apisession.delete('/acs/api/v1/users/%s' % (uid, ))\n+    r.raise_for_status()\n+    assert r.status_code == 204\n+\n+\n+@pytest.fixture()\n+def remove_users_added_by_test(dcos_api_session):\n+    users_before = set(get_users(dcos_api_session))\n+    log.info('remove_users_added_by_test pre test: users are %s', users_before)\n+    try:\n+        yield\n+    finally:\n+        users_after = set(get_users(dcos_api_session))\n+        new_uids = users_after - users_before\n+        for uid in new_uids:\n+            log.info('remove_users_added_by_test post test: remove `%s`', uid)\n+            delete_user(dcos_api_session, uid)\n+\n+\n+def test_users_get(dcos_api_session):\n+    users = get_users(dcos_api_session)\n+    assert users\n+\n+    required_keys = ('uid', 'description')\n+    for _, userdict in users.items():\n+        for k in required_keys:\n+            assert k in userdict\n+\n+\n+def test_user_put_no_email_uid(dcos_api_session):\n+    r = dcos_api_session.put('/acs/api/v1/users/user1')\n+\n+    # This is the current behavior. It does not need to stay in future versions.\n+    assert r.status_code == 500\n+    assert 'invalid email' in r.text\n+\n+\n+@pytest.mark.usefixtures('remove_users_added_by_test')\n+def test_user_put_email_uid(dcos_api_session):\n+    # The current behavior is that the request body can be an empty JSON\n+    # document. It does not need to stay in future versions.\n+    r = dcos_api_session.put('/acs/api/v1/users/user1@email.de', json={})","path":"packages/dcos-integration-test/extra/test_users.py","position":89,"original_position":89,"commit_id":"f7718348f6d2913402e9961bc0b4f47ffa108dae","original_commit_id":"f7718348f6d2913402e9961bc0b4f47ffa108dae","user":{"login":"jgehrcke","id":265630,"node_id":"MDQ6VXNlcjI2NTYzMA==","avatar_url":"https://avatars0.githubusercontent.com/u/265630?v=4","gravatar_id":"","url":"https://api.github.com/users/jgehrcke","html_url":"https://github.com/jgehrcke","followers_url":"https://api.github.com/users/jgehrcke/followers","following_url":"https://api.github.com/users/jgehrcke/following{/other_user}","gists_url":"https://api.github.com/users/jgehrcke/gists{/gist_id}","starred_url":"https://api.github.com/users/jgehrcke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgehrcke/subscriptions","organizations_url":"https://api.github.com/users/jgehrcke/orgs","repos_url":"https://api.github.com/users/jgehrcke/repos","events_url":"https://api.github.com/users/jgehrcke/events{/privacy}","received_events_url":"https://api.github.com/users/jgehrcke/received_events","type":"User","site_admin":false},"body":"Ha, good point. Well :-) I think in one of the next iterations I will indeed get rid of that again.","created_at":"2018-10-08T19:59:07Z","updated_at":"2018-10-08T19:59:07Z","html_url":"https://github.com/dcos/dcos/pull/3558#discussion_r223480672","pull_request_url":"https://api.github.com/repos/dcos/dcos/pulls/3558","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/dcos/dcos/pulls/comments/223480672"},"html":{"href":"https://github.com/dcos/dcos/pull/3558#discussion_r223480672"},"pull_request":{"href":"https://api.github.com/repos/dcos/dcos/pulls/3558"}},"in_reply_to_id":223451010},"pull_request":{"url":"https://api.github.com/repos/dcos/dcos/pulls/3558","id":220383050,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwMzgzMDUw","html_url":"https://github.com/dcos/dcos/pull/3558","diff_url":"https://github.com/dcos/dcos/pull/3558.diff","patch_url":"https://github.com/dcos/dcos/pull/3558.patch","issue_url":"https://api.github.com/repos/dcos/dcos/issues/3558","number":3558,"state":"open","locked":false,"title":"Add dcos-integration-test/extra/test_users.py","user":{"login":"jgehrcke","id":265630,"node_id":"MDQ6VXNlcjI2NTYzMA==","avatar_url":"https://avatars0.githubusercontent.com/u/265630?v=4","gravatar_id":"","url":"https://api.github.com/users/jgehrcke","html_url":"https://github.com/jgehrcke","followers_url":"https://api.github.com/users/jgehrcke/followers","following_url":"https://api.github.com/users/jgehrcke/following{/other_user}","gists_url":"https://api.github.com/users/jgehrcke/gists{/gist_id}","starred_url":"https://api.github.com/users/jgehrcke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgehrcke/subscriptions","organizations_url":"https://api.github.com/users/jgehrcke/orgs","repos_url":"https://api.github.com/users/jgehrcke/repos","events_url":"https://api.github.com/users/jgehrcke/events{/privacy}","received_events_url":"https://api.github.com/users/jgehrcke/received_events","type":"User","site_admin":false},"body":"## Corresponding DC/OS tickets (obligatory)\r\n\r\nThese DC/OS JIRA ticket(s) must be updated (ideally closed) in the moment this PR lands:\r\n\r\n  - https://jira.mesosphere.com/browse/DCOS_OSS-3995 (Bump platform CPython to 3.6.6 (or 3.6 latest)\r\n  - https://jira.mesosphere.com/browse/DCOS-43029 (Write basic integration tests for (open) DC/OS user management)\r\n\r\n\r\nThis pull request updates pytest for supporting the `allow_module_level` argument.\r\n","created_at":"2018-10-04T13:45:34Z","updated_at":"2018-10-08T19:59:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cad215b03cbd41a59aad8741787ba2ba5d723204","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":528929763,"node_id":"MDU6TGFiZWw1Mjg5Mjk3NjM=","url":"https://api.github.com/repos/dcos/dcos/labels/Ship%20It","name":"Ship It","color":"fbca04","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/dcos/dcos/pulls/3558/commits","review_comments_url":"https://api.github.com/repos/dcos/dcos/pulls/3558/comments","review_comment_url":"https://api.github.com/repos/dcos/dcos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dcos/dcos/issues/3558/comments","statuses_url":"https://api.github.com/repos/dcos/dcos/statuses/f7718348f6d2913402e9961bc0b4f47ffa108dae","head":{"label":"jgehrcke:jp/build-user-management-integration-tests","ref":"jp/build-user-management-integration-tests","sha":"f7718348f6d2913402e9961bc0b4f47ffa108dae","user":{"login":"jgehrcke","id":265630,"node_id":"MDQ6VXNlcjI2NTYzMA==","avatar_url":"https://avatars0.githubusercontent.com/u/265630?v=4","gravatar_id":"","url":"https://api.github.com/users/jgehrcke","html_url":"https://github.com/jgehrcke","followers_url":"https://api.github.com/users/jgehrcke/followers","following_url":"https://api.github.com/users/jgehrcke/following{/other_user}","gists_url":"https://api.github.com/users/jgehrcke/gists{/gist_id}","starred_url":"https://api.github.com/users/jgehrcke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgehrcke/subscriptions","organizations_url":"https://api.github.com/users/jgehrcke/orgs","repos_url":"https://api.github.com/users/jgehrcke/repos","events_url":"https://api.github.com/users/jgehrcke/events{/privacy}","received_events_url":"https://api.github.com/users/jgehrcke/received_events","type":"User","site_admin":false},"repo":{"id":56586749,"node_id":"MDEwOlJlcG9zaXRvcnk1NjU4Njc0OQ==","name":"dcos","full_name":"jgehrcke/dcos","private":false,"owner":{"login":"jgehrcke","id":265630,"node_id":"MDQ6VXNlcjI2NTYzMA==","avatar_url":"https://avatars0.githubusercontent.com/u/265630?v=4","gravatar_id":"","url":"https://api.github.com/users/jgehrcke","html_url":"https://github.com/jgehrcke","followers_url":"https://api.github.com/users/jgehrcke/followers","following_url":"https://api.github.com/users/jgehrcke/following{/other_user}","gists_url":"https://api.github.com/users/jgehrcke/gists{/gist_id}","starred_url":"https://api.github.com/users/jgehrcke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgehrcke/subscriptions","organizations_url":"https://api.github.com/users/jgehrcke/orgs","repos_url":"https://api.github.com/users/jgehrcke/repos","events_url":"https://api.github.com/users/jgehrcke/events{/privacy}","received_events_url":"https://api.github.com/users/jgehrcke/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jgehrcke/dcos","description":"DC/OS Build and Release tools","fork":true,"url":"https://api.github.com/repos/jgehrcke/dcos","forks_url":"https://api.github.com/repos/jgehrcke/dcos/forks","keys_url":"https://api.github.com/repos/jgehrcke/dcos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jgehrcke/dcos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jgehrcke/dcos/teams","hooks_url":"https://api.github.com/repos/jgehrcke/dcos/hooks","issue_events_url":"https://api.github.com/repos/jgehrcke/dcos/issues/events{/number}","events_url":"https://api.github.com/repos/jgehrcke/dcos/events","assignees_url":"https://api.github.com/repos/jgehrcke/dcos/assignees{/user}","branches_url":"https://api.github.com/repos/jgehrcke/dcos/branches{/branch}","tags_url":"https://api.github.com/repos/jgehrcke/dcos/tags","blobs_url":"https://api.github.com/repos/jgehrcke/dcos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jgehrcke/dcos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jgehrcke/dcos/git/refs{/sha}","trees_url":"https://api.github.com/repos/jgehrcke/dcos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jgehrcke/dcos/statuses/{sha}","languages_url":"https://api.github.com/repos/jgehrcke/dcos/languages","stargazers_url":"https://api.github.com/repos/jgehrcke/dcos/stargazers","contributors_url":"https://api.github.com/repos/jgehrcke/dcos/contributors","subscribers_url":"https://api.github.com/repos/jgehrcke/dcos/subscribers","subscription_url":"https://api.github.com/repos/jgehrcke/dcos/subscription","commits_url":"https://api.github.com/repos/jgehrcke/dcos/commits{/sha}","git_commits_url":"https://api.github.com/repos/jgehrcke/dcos/git/commits{/sha}","comments_url":"https://api.github.com/repos/jgehrcke/dcos/comments{/number}","issue_comment_url":"https://api.github.com/repos/jgehrcke/dcos/issues/comments{/number}","contents_url":"https://api.github.com/repos/jgehrcke/dcos/contents/{+path}","compare_url":"https://api.github.com/repos/jgehrcke/dcos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jgehrcke/dcos/merges","archive_url":"https://api.github.com/repos/jgehrcke/dcos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jgehrcke/dcos/downloads","issues_url":"https://api.github.com/repos/jgehrcke/dcos/issues{/number}","pulls_url":"https://api.github.com/repos/jgehrcke/dcos/pulls{/number}","milestones_url":"https://api.github.com/repos/jgehrcke/dcos/milestones{/number}","notifications_url":"https://api.github.com/repos/jgehrcke/dcos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jgehrcke/dcos/labels{/name}","releases_url":"https://api.github.com/repos/jgehrcke/dcos/releases{/id}","deployments_url":"https://api.github.com/repos/jgehrcke/dcos/deployments","created_at":"2016-04-19T10:15:36Z","updated_at":"2016-04-19T10:15:38Z","pushed_at":"2018-10-08T14:17:00Z","git_url":"git://github.com/jgehrcke/dcos.git","ssh_url":"git@github.com:jgehrcke/dcos.git","clone_url":"https://github.com/jgehrcke/dcos.git","svn_url":"https://github.com/jgehrcke/dcos","homepage":null,"size":6644,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dcos:master","ref":"master","sha":"fc195b33fe1f09ad87c6809f022b7b9b6386e63d","user":{"login":"dcos","id":17648048,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NjQ4MDQ4","avatar_url":"https://avatars1.githubusercontent.com/u/17648048?v=4","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"repo":{"id":56184050,"node_id":"MDEwOlJlcG9zaXRvcnk1NjE4NDA1MA==","name":"dcos","full_name":"dcos/dcos","private":false,"owner":{"login":"dcos","id":17648048,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NjQ4MDQ4","avatar_url":"https://avatars1.githubusercontent.com/u/17648048?v=4","gravatar_id":"","url":"https://api.github.com/users/dcos","html_url":"https://github.com/dcos","followers_url":"https://api.github.com/users/dcos/followers","following_url":"https://api.github.com/users/dcos/following{/other_user}","gists_url":"https://api.github.com/users/dcos/gists{/gist_id}","starred_url":"https://api.github.com/users/dcos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcos/subscriptions","organizations_url":"https://api.github.com/users/dcos/orgs","repos_url":"https://api.github.com/users/dcos/repos","events_url":"https://api.github.com/users/dcos/events{/privacy}","received_events_url":"https://api.github.com/users/dcos/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/dcos/dcos","description":"DC/OS - The Datacenter Operating System ","fork":false,"url":"https://api.github.com/repos/dcos/dcos","forks_url":"https://api.github.com/repos/dcos/dcos/forks","keys_url":"https://api.github.com/repos/dcos/dcos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dcos/dcos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dcos/dcos/teams","hooks_url":"https://api.github.com/repos/dcos/dcos/hooks","issue_events_url":"https://api.github.com/repos/dcos/dcos/issues/events{/number}","events_url":"https://api.github.com/repos/dcos/dcos/events","assignees_url":"https://api.github.com/repos/dcos/dcos/assignees{/user}","branches_url":"https://api.github.com/repos/dcos/dcos/branches{/branch}","tags_url":"https://api.github.com/repos/dcos/dcos/tags","blobs_url":"https://api.github.com/repos/dcos/dcos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dcos/dcos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dcos/dcos/git/refs{/sha}","trees_url":"https://api.github.com/repos/dcos/dcos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dcos/dcos/statuses/{sha}","languages_url":"https://api.github.com/repos/dcos/dcos/languages","stargazers_url":"https://api.github.com/repos/dcos/dcos/stargazers","contributors_url":"https://api.github.com/repos/dcos/dcos/contributors","subscribers_url":"https://api.github.com/repos/dcos/dcos/subscribers","subscription_url":"https://api.github.com/repos/dcos/dcos/subscription","commits_url":"https://api.github.com/repos/dcos/dcos/commits{/sha}","git_commits_url":"https://api.github.com/repos/dcos/dcos/git/commits{/sha}","comments_url":"https://api.github.com/repos/dcos/dcos/comments{/number}","issue_comment_url":"https://api.github.com/repos/dcos/dcos/issues/comments{/number}","contents_url":"https://api.github.com/repos/dcos/dcos/contents/{+path}","compare_url":"https://api.github.com/repos/dcos/dcos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dcos/dcos/merges","archive_url":"https://api.github.com/repos/dcos/dcos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dcos/dcos/downloads","issues_url":"https://api.github.com/repos/dcos/dcos/issues{/number}","pulls_url":"https://api.github.com/repos/dcos/dcos/pulls{/number}","milestones_url":"https://api.github.com/repos/dcos/dcos/milestones{/number}","notifications_url":"https://api.github.com/repos/dcos/dcos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dcos/dcos/labels{/name}","releases_url":"https://api.github.com/repos/dcos/dcos/releases{/id}","deployments_url":"https://api.github.com/repos/dcos/dcos/deployments","created_at":"2016-04-13T20:31:58Z","updated_at":"2018-10-08T02:20:48Z","pushed_at":"2018-10-08T18:14:33Z","git_url":"git://github.com/dcos/dcos.git","ssh_url":"git@github.com:dcos/dcos.git","clone_url":"https://github.com/dcos/dcos.git","svn_url":"https://github.com/dcos/dcos","homepage":"https://dcos.io","size":7224,"stargazers_count":2043,"watchers_count":2043,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":422,"mirror_url":null,"archived":false,"open_issues_count":97,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":422,"open_issues":97,"watchers":2043,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dcos/dcos/pulls/3558"},"html":{"href":"https://github.com/dcos/dcos/pull/3558"},"issue":{"href":"https://api.github.com/repos/dcos/dcos/issues/3558"},"comments":{"href":"https://api.github.com/repos/dcos/dcos/issues/3558/comments"},"review_comments":{"href":"https://api.github.com/repos/dcos/dcos/pulls/3558/comments"},"review_comment":{"href":"https://api.github.com/repos/dcos/dcos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dcos/dcos/pulls/3558/commits"},"statuses":{"href":"https://api.github.com/repos/dcos/dcos/statuses/f7718348f6d2913402e9961bc0b4f47ffa108dae"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"jgehrcke"}}