storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srihar...@apache.org
Subject [1/2] storm git commit: STORM-2496 Dependency artifacts should be uploaded to blobstore with READ permission for all
Date Mon, 15 May 2017 15:13:17 GMT
Repository: storm
Updated Branches:
  refs/heads/master 7043dea8e -> dd6b48708


STORM-2496 Dependency artifacts should be uploaded to blobstore with READ permission for all

* When uploading dependencies, set ACL properly so that it can be shared to other users as
well
  * but allows only READ so that it can't be deleted from others


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/f56ab447
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/f56ab447
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/f56ab447

Branch: refs/heads/master
Commit: f56ab4477e28c500575934c987780478bc1319b7
Parents: 5b270d3
Author: Jungtaek Lim <kabhwan@gmail.com>
Authored: Mon May 8 12:14:25 2017 +0900
Committer: Jungtaek Lim <kabhwan@gmail.com>
Committed: Mon May 8 12:25:30 2017 +0900

----------------------------------------------------------------------
 .../apache/storm/dependency/DependencyUploader.java   | 13 ++++++++++---
 .../storm/dependency/DependencyUploaderTest.java      | 14 ++++++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/f56ab447/storm-client/src/jvm/org/apache/storm/dependency/DependencyUploader.java
----------------------------------------------------------------------
diff --git a/storm-client/src/jvm/org/apache/storm/dependency/DependencyUploader.java b/storm-client/src/jvm/org/apache/storm/dependency/DependencyUploader.java
index 6fac380..3514a86 100644
--- a/storm-client/src/jvm/org/apache/storm/dependency/DependencyUploader.java
+++ b/storm-client/src/jvm/org/apache/storm/dependency/DependencyUploader.java
@@ -19,8 +19,10 @@ package org.apache.storm.dependency;
 
 import com.google.common.annotations.VisibleForTesting;
 import org.apache.storm.blobstore.AtomicOutputStream;
+import org.apache.storm.blobstore.BlobStoreAclHandler;
 import org.apache.storm.blobstore.ClientBlobStore;
 import org.apache.storm.generated.AccessControl;
+import org.apache.storm.generated.AccessControlType;
 import org.apache.storm.generated.AuthorizationException;
 import org.apache.storm.generated.KeyAlreadyExistsException;
 import org.apache.storm.generated.KeyNotFoundException;
@@ -145,9 +147,14 @@ public class DependencyUploader {
             // as a workaround, we call getBlobMeta() for all keys
             getBlobStore().getBlobMeta(key);
         } catch (KeyNotFoundException e) {
-            // TODO: do we want to add ACL here?
-            AtomicOutputStream blob = getBlobStore()
-                    .createBlob(key, new SettableBlobMeta(new ArrayList<AccessControl>()));
+            // set acl to below so that it can be shared by other users as well, but allows
only read
+            List<AccessControl> acls = new ArrayList<>();
+            acls.add(new AccessControl(AccessControlType.USER,
+                    BlobStoreAclHandler.READ | BlobStoreAclHandler.WRITE | BlobStoreAclHandler.ADMIN));
+            acls.add(new AccessControl(AccessControlType.OTHER,
+                    BlobStoreAclHandler.READ));
+
+            AtomicOutputStream blob = getBlobStore().createBlob(key, new SettableBlobMeta(acls));
             Files.copy(dependency.toPath(), blob);
             blob.close();
 

http://git-wip-us.apache.org/repos/asf/storm/blob/f56ab447/storm-client/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java
----------------------------------------------------------------------
diff --git a/storm-client/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java
b/storm-client/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java
index 0ea9479..90d6d4d 100644
--- a/storm-client/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java
+++ b/storm-client/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java
@@ -20,13 +20,17 @@ package org.apache.storm.dependency;
 import com.google.common.collect.Lists;
 import com.google.common.io.Files;
 import org.apache.storm.blobstore.AtomicOutputStream;
+import org.apache.storm.blobstore.BlobStoreAclHandler;
 import org.apache.storm.blobstore.ClientBlobStore;
+import org.apache.storm.generated.AccessControl;
+import org.apache.storm.generated.AccessControlType;
 import org.apache.storm.generated.KeyNotFoundException;
 import org.apache.storm.generated.ReadableBlobMeta;
 import org.apache.storm.generated.SettableBlobMeta;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.ArgumentCaptor;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
@@ -170,6 +174,16 @@ public class DependencyUploaderTest {
 
         assertTrue(counter.get() > 0);
         verify(mockOutputStream).close();
+
+        ArgumentCaptor<SettableBlobMeta> blobMetaArgumentCaptor = ArgumentCaptor.forClass(SettableBlobMeta.class);
+        verify(mockBlobStore).createBlob(anyString(), blobMetaArgumentCaptor.capture());
+
+        SettableBlobMeta actualBlobMeta = blobMetaArgumentCaptor.getValue();
+        List<AccessControl> actualAcls = actualBlobMeta.get_acl();
+        assertTrue(actualAcls.contains(new AccessControl(AccessControlType.USER,
+                BlobStoreAclHandler.READ | BlobStoreAclHandler.WRITE | BlobStoreAclHandler.ADMIN)));
+        assertTrue(actualAcls.contains(new AccessControl(AccessControlType.OTHER,
+                BlobStoreAclHandler.READ)));
     }
 
     @Test(expected = FileNotAvailableException.class)


Mime
View raw message