{"action":"created","comment":{"url":"https://api.github.com/repos/caskdata/cdap/pulls/comments/72446016","id":72446016,"diff_hunk":"@@ -74,19 +111,142 @@ public void testCreateExist() throws Exception {\n     Assert.assertFalse(streamAdmin.exists(streamId));\n     Assert.assertFalse(streamAdmin.exists(otherStreamId));\n \n+    try {\n+      streamAdmin.create(streamId);\n+      Assert.fail(\"User should not be able to create a stream in this namespace.\");\n+    } catch (UnauthorizedException e) {\n+      // expected\n+    }\n+\n+    // grant write access for user to foo_namespace\n+    grantAndAssertSuccess(streamId.getNamespace().toEntityId(), USER, ImmutableSet.of(Action.WRITE));\n     streamAdmin.create(streamId);\n+\n     // Even though both streams have the same name, {@code otherStreamId} does not exist because it is in a different\n     // namespace than the one created above.\n     Assert.assertTrue(streamAdmin.exists(streamId));\n     Assert.assertFalse(streamAdmin.exists(otherStreamId));\n \n+    try {\n+      streamAdmin.create(otherStreamId);\n+      Assert.fail(\"User should not be able to create a stream in this namespace.\");\n+    } catch (UnauthorizedException e) {\n+      // expected\n+    }\n+\n+    // grant write access for user to other_namespace\n+    grantAndAssertSuccess(otherStreamId.getNamespace().toEntityId(), USER, ImmutableSet.of(Action.WRITE));\n     streamAdmin.create(otherStreamId);\n     Assert.assertTrue(streamAdmin.exists(otherStreamId));\n+\n+    // the user should be able to drop the stream, they had created\n+    streamAdmin.drop(otherStreamId);\n+    Assert.assertFalse(streamAdmin.exists(otherStreamId));\n+\n+    // revoke the permission for the user on the stream in foo_namespace\n+    revokeAndAssertSuccess(streamId.toEntityId(), USER, ImmutableSet.of(Action.ADMIN, Action.ALL));\n+\n+    try {\n+      streamAdmin.drop(streamId);\n+      Assert.fail(\"User should not be able to delete a stream in this namespace.\");\n+    } catch (UnauthorizedException e) {\n+      // expected\n+    }\n+\n+    // grant WRITE permission to the user but they still should not be able to drop the stream\n+    grantAndAssertSuccess(streamId.toEntityId(), USER, ImmutableSet.of(Action.WRITE));\n+\n+    try {\n+      streamAdmin.drop(streamId);\n+      Assert.fail(\"User should not be able to delete a stream with only Write Action access.\");\n+    } catch (UnauthorizedException e) {\n+      // expected\n+    }\n+\n+    // grant admin access and the user should then be able to drop the stream\n+    grantAndAssertSuccess(streamId.toEntityId(), USER, ImmutableSet.of(Action.ADMIN));\n+    streamAdmin.drop(streamId);\n+    Assert.assertFalse(streamAdmin.exists(streamId));\n+  }\n+\n+  @Test\n+  public void testConfigAndTruncate() throws Exception {\n+    StreamAdmin streamAdmin = getStreamAdmin();\n+    grantAndAssertSuccess(new NamespaceId(FOO_NAMESPACE), USER, ImmutableSet.of(Action.WRITE));\n+    Id.Stream stream = Id.Stream.from(FOO_NAMESPACE, \"stream\");\n+\n+    streamAdmin.create(stream);\n+    Assert.assertTrue(streamAdmin.exists(stream));\n+    writeEvent(stream);\n+\n+    // Getting config / properties should work\n+    streamAdmin.getConfig(stream);\n+    streamAdmin.getProperties(stream);\n+\n+    // Now revoke access to the user to the stream\n+    revokeAndAssertSuccess(stream.toEntityId(), USER, ImmutableSet.of(Action.ALL));\n+    streamAdmin.getConfig(stream);\n+\n+    try {\n+      streamAdmin.getProperties(stream);\n+      Assert.fail(\"USer should not be able to get the properties.\");\n+    } catch (UnauthorizedException e) {\n+      // expected\n+    } catch (IOException e) {","path":"cdap-data-fabric-tests/src/test/java/co/cask/cdap/data2/transaction/stream/StreamAdminTest.java","position":171,"original_position":171,"commit_id":"bb5c97089f6b7ceb3720d4326ecf052de97cc9f3","original_commit_id":"bb5c97089f6b7ceb3720d4326ecf052de97cc9f3","user":{"login":"bdmogal","id":3895099,"avatar_url":"https://avatars.githubusercontent.com/u/3895099?v=3","gravatar_id":"","url":"https://api.github.com/users/bdmogal","html_url":"https://github.com/bdmogal","followers_url":"https://api.github.com/users/bdmogal/followers","following_url":"https://api.github.com/users/bdmogal/following{/other_user}","gists_url":"https://api.github.com/users/bdmogal/gists{/gist_id}","starred_url":"https://api.github.com/users/bdmogal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdmogal/subscriptions","organizations_url":"https://api.github.com/users/bdmogal/orgs","repos_url":"https://api.github.com/users/bdmogal/repos","events_url":"https://api.github.com/users/bdmogal/events{/privacy}","received_events_url":"https://api.github.com/users/bdmogal/received_events","type":"User","site_admin":false},"body":"why does this happen?","created_at":"2016-07-27T14:11:30Z","updated_at":"2016-07-27T14:11:30Z","html_url":"https://github.com/caskdata/cdap/pull/6216#discussion_r72446016","pull_request_url":"https://api.github.com/repos/caskdata/cdap/pulls/6216","_links":{"self":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/comments/72446016"},"html":{"href":"https://github.com/caskdata/cdap/pull/6216#discussion_r72446016"},"pull_request":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/6216"}}},"pull_request":{"url":"https://api.github.com/repos/caskdata/cdap/pulls/6216","id":78930170,"html_url":"https://github.com/caskdata/cdap/pull/6216","diff_url":"https://github.com/caskdata/cdap/pull/6216.diff","patch_url":"https://github.com/caskdata/cdap/pull/6216.patch","issue_url":"https://api.github.com/repos/caskdata/cdap/issues/6216","number":6216,"state":"open","locked":false,"title":"Stream authorization for REST endpoints","user":{"login":"gokulavasan","id":558459,"avatar_url":"https://avatars.githubusercontent.com/u/558459?v=3","gravatar_id":"","url":"https://api.github.com/users/gokulavasan","html_url":"https://github.com/gokulavasan","followers_url":"https://api.github.com/users/gokulavasan/followers","following_url":"https://api.github.com/users/gokulavasan/following{/other_user}","gists_url":"https://api.github.com/users/gokulavasan/gists{/gist_id}","starred_url":"https://api.github.com/users/gokulavasan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gokulavasan/subscriptions","organizations_url":"https://api.github.com/users/gokulavasan/orgs","repos_url":"https://api.github.com/users/gokulavasan/repos","events_url":"https://api.github.com/users/gokulavasan/events{/privacy}","received_events_url":"https://api.github.com/users/gokulavasan/received_events","type":"User","site_admin":false},"body":"JIRA : https://issues.cask.co/browse/CDAP-882\r\n\r\nBuild : http://builds.cask.co/browse/CDAP-DUT4535-1\r\n\r\nSummary:\r\nAdd authorization checks for Stream REST endpoints according to the guidelines mentioned here: https://wiki.cask.co/display/CE/Authorization+-+CDAP+3.5.\r\n\r\nComing up:\r\nAuthorization checks in programs => Flow/MR/Spark when they try to read events from Streams. Also in Worker (rather in StreamWriter) to make sure those requests have the required auth to perform stream writes.","created_at":"2016-07-26T21:37:44Z","updated_at":"2016-07-27T14:11:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6e110d41f80f0ef74c111bd35683044d11eabc32","assignee":{"login":"bdmogal","id":3895099,"avatar_url":"https://avatars.githubusercontent.com/u/3895099?v=3","gravatar_id":"","url":"https://api.github.com/users/bdmogal","html_url":"https://github.com/bdmogal","followers_url":"https://api.github.com/users/bdmogal/followers","following_url":"https://api.github.com/users/bdmogal/following{/other_user}","gists_url":"https://api.github.com/users/bdmogal/gists{/gist_id}","starred_url":"https://api.github.com/users/bdmogal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdmogal/subscriptions","organizations_url":"https://api.github.com/users/bdmogal/orgs","repos_url":"https://api.github.com/users/bdmogal/repos","events_url":"https://api.github.com/users/bdmogal/events{/privacy}","received_events_url":"https://api.github.com/users/bdmogal/received_events","type":"User","site_admin":false},"assignees":[{"login":"bdmogal","id":3895099,"avatar_url":"https://avatars.githubusercontent.com/u/3895099?v=3","gravatar_id":"","url":"https://api.github.com/users/bdmogal","html_url":"https://github.com/bdmogal","followers_url":"https://api.github.com/users/bdmogal/followers","following_url":"https://api.github.com/users/bdmogal/following{/other_user}","gists_url":"https://api.github.com/users/bdmogal/gists{/gist_id}","starred_url":"https://api.github.com/users/bdmogal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdmogal/subscriptions","organizations_url":"https://api.github.com/users/bdmogal/orgs","repos_url":"https://api.github.com/users/bdmogal/repos","events_url":"https://api.github.com/users/bdmogal/events{/privacy}","received_events_url":"https://api.github.com/users/bdmogal/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/caskdata/cdap/pulls/6216/commits","review_comments_url":"https://api.github.com/repos/caskdata/cdap/pulls/6216/comments","review_comment_url":"https://api.github.com/repos/caskdata/cdap/pulls/comments{/number}","comments_url":"https://api.github.com/repos/caskdata/cdap/issues/6216/comments","statuses_url":"https://api.github.com/repos/caskdata/cdap/statuses/bb5c97089f6b7ceb3720d4326ecf052de97cc9f3","head":{"label":"caskdata:fix/stream-authorization","ref":"fix/stream-authorization","sha":"bb5c97089f6b7ceb3720d4326ecf052de97cc9f3","user":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"repo":{"id":22542759,"name":"cdap","full_name":"caskdata/cdap","owner":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/caskdata/cdap","description":"Cask Data Application Platform (CDAP)","fork":false,"url":"https://api.github.com/repos/caskdata/cdap","forks_url":"https://api.github.com/repos/caskdata/cdap/forks","keys_url":"https://api.github.com/repos/caskdata/cdap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caskdata/cdap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caskdata/cdap/teams","hooks_url":"https://api.github.com/repos/caskdata/cdap/hooks","issue_events_url":"https://api.github.com/repos/caskdata/cdap/issues/events{/number}","events_url":"https://api.github.com/repos/caskdata/cdap/events","assignees_url":"https://api.github.com/repos/caskdata/cdap/assignees{/user}","branches_url":"https://api.github.com/repos/caskdata/cdap/branches{/branch}","tags_url":"https://api.github.com/repos/caskdata/cdap/tags","blobs_url":"https://api.github.com/repos/caskdata/cdap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caskdata/cdap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caskdata/cdap/git/refs{/sha}","trees_url":"https://api.github.com/repos/caskdata/cdap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caskdata/cdap/statuses/{sha}","languages_url":"https://api.github.com/repos/caskdata/cdap/languages","stargazers_url":"https://api.github.com/repos/caskdata/cdap/stargazers","contributors_url":"https://api.github.com/repos/caskdata/cdap/contributors","subscribers_url":"https://api.github.com/repos/caskdata/cdap/subscribers","subscription_url":"https://api.github.com/repos/caskdata/cdap/subscription","commits_url":"https://api.github.com/repos/caskdata/cdap/commits{/sha}","git_commits_url":"https://api.github.com/repos/caskdata/cdap/git/commits{/sha}","comments_url":"https://api.github.com/repos/caskdata/cdap/comments{/number}","issue_comment_url":"https://api.github.com/repos/caskdata/cdap/issues/comments{/number}","contents_url":"https://api.github.com/repos/caskdata/cdap/contents/{+path}","compare_url":"https://api.github.com/repos/caskdata/cdap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caskdata/cdap/merges","archive_url":"https://api.github.com/repos/caskdata/cdap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caskdata/cdap/downloads","issues_url":"https://api.github.com/repos/caskdata/cdap/issues{/number}","pulls_url":"https://api.github.com/repos/caskdata/cdap/pulls{/number}","milestones_url":"https://api.github.com/repos/caskdata/cdap/milestones{/number}","notifications_url":"https://api.github.com/repos/caskdata/cdap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caskdata/cdap/labels{/name}","releases_url":"https://api.github.com/repos/caskdata/cdap/releases{/id}","deployments_url":"https://api.github.com/repos/caskdata/cdap/deployments","created_at":"2014-08-02T09:00:10Z","updated_at":"2016-07-25T20:02:59Z","pushed_at":"2016-07-27T12:08:51Z","git_url":"git://github.com/caskdata/cdap.git","ssh_url":"git@github.com:caskdata/cdap.git","clone_url":"https://github.com/caskdata/cdap.git","svn_url":"https://github.com/caskdata/cdap","homepage":"http://cdap.io","size":627397,"stargazers_count":137,"watchers_count":137,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":49,"mirror_url":null,"open_issues_count":18,"forks":49,"open_issues":18,"watchers":137,"default_branch":"release/3.5"}},"base":{"label":"caskdata:release/3.5","ref":"release/3.5","sha":"3cbc78d728b614db328772e1a1184eb226870bd8","user":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"repo":{"id":22542759,"name":"cdap","full_name":"caskdata/cdap","owner":{"login":"caskdata","id":8123023,"avatar_url":"https://avatars.githubusercontent.com/u/8123023?v=3","gravatar_id":"","url":"https://api.github.com/users/caskdata","html_url":"https://github.com/caskdata","followers_url":"https://api.github.com/users/caskdata/followers","following_url":"https://api.github.com/users/caskdata/following{/other_user}","gists_url":"https://api.github.com/users/caskdata/gists{/gist_id}","starred_url":"https://api.github.com/users/caskdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caskdata/subscriptions","organizations_url":"https://api.github.com/users/caskdata/orgs","repos_url":"https://api.github.com/users/caskdata/repos","events_url":"https://api.github.com/users/caskdata/events{/privacy}","received_events_url":"https://api.github.com/users/caskdata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/caskdata/cdap","description":"Cask Data Application Platform (CDAP)","fork":false,"url":"https://api.github.com/repos/caskdata/cdap","forks_url":"https://api.github.com/repos/caskdata/cdap/forks","keys_url":"https://api.github.com/repos/caskdata/cdap/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caskdata/cdap/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caskdata/cdap/teams","hooks_url":"https://api.github.com/repos/caskdata/cdap/hooks","issue_events_url":"https://api.github.com/repos/caskdata/cdap/issues/events{/number}","events_url":"https://api.github.com/repos/caskdata/cdap/events","assignees_url":"https://api.github.com/repos/caskdata/cdap/assignees{/user}","branches_url":"https://api.github.com/repos/caskdata/cdap/branches{/branch}","tags_url":"https://api.github.com/repos/caskdata/cdap/tags","blobs_url":"https://api.github.com/repos/caskdata/cdap/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caskdata/cdap/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caskdata/cdap/git/refs{/sha}","trees_url":"https://api.github.com/repos/caskdata/cdap/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caskdata/cdap/statuses/{sha}","languages_url":"https://api.github.com/repos/caskdata/cdap/languages","stargazers_url":"https://api.github.com/repos/caskdata/cdap/stargazers","contributors_url":"https://api.github.com/repos/caskdata/cdap/contributors","subscribers_url":"https://api.github.com/repos/caskdata/cdap/subscribers","subscription_url":"https://api.github.com/repos/caskdata/cdap/subscription","commits_url":"https://api.github.com/repos/caskdata/cdap/commits{/sha}","git_commits_url":"https://api.github.com/repos/caskdata/cdap/git/commits{/sha}","comments_url":"https://api.github.com/repos/caskdata/cdap/comments{/number}","issue_comment_url":"https://api.github.com/repos/caskdata/cdap/issues/comments{/number}","contents_url":"https://api.github.com/repos/caskdata/cdap/contents/{+path}","compare_url":"https://api.github.com/repos/caskdata/cdap/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caskdata/cdap/merges","archive_url":"https://api.github.com/repos/caskdata/cdap/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caskdata/cdap/downloads","issues_url":"https://api.github.com/repos/caskdata/cdap/issues{/number}","pulls_url":"https://api.github.com/repos/caskdata/cdap/pulls{/number}","milestones_url":"https://api.github.com/repos/caskdata/cdap/milestones{/number}","notifications_url":"https://api.github.com/repos/caskdata/cdap/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caskdata/cdap/labels{/name}","releases_url":"https://api.github.com/repos/caskdata/cdap/releases{/id}","deployments_url":"https://api.github.com/repos/caskdata/cdap/deployments","created_at":"2014-08-02T09:00:10Z","updated_at":"2016-07-25T20:02:59Z","pushed_at":"2016-07-27T12:08:51Z","git_url":"git://github.com/caskdata/cdap.git","ssh_url":"git@github.com:caskdata/cdap.git","clone_url":"https://github.com/caskdata/cdap.git","svn_url":"https://github.com/caskdata/cdap","homepage":"http://cdap.io","size":627397,"stargazers_count":137,"watchers_count":137,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":49,"mirror_url":null,"open_issues_count":18,"forks":49,"open_issues":18,"watchers":137,"default_branch":"release/3.5"}},"_links":{"self":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/6216"},"html":{"href":"https://github.com/caskdata/cdap/pull/6216"},"issue":{"href":"https://api.github.com/repos/caskdata/cdap/issues/6216"},"comments":{"href":"https://api.github.com/repos/caskdata/cdap/issues/6216/comments"},"review_comments":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/6216/comments"},"review_comment":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/caskdata/cdap/pulls/6216/commits"},"statuses":{"href":"https://api.github.com/repos/caskdata/cdap/statuses/bb5c97089f6b7ceb3720d4326ecf052de97cc9f3"}}}}
{"actor":{"display_login":"bdmogal"}}