Author: chetanm
Date: Mon Jun 19 08:48:28 2017
New Revision: 1799156

URL: http://svn.apache.org/viewvc?rev=1799156&view=rev
Log:
OAK-6364 - BlobStoreFixtureProvider should configure a default 'secret' value 
if none specified

Modified:
    
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java

Modified: 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java?rev=1799156&r1=1799155&r2=1799156&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/run/cli/BlobStoreFixtureProvider.java
 Mon Jun 19 08:48:28 2017
@@ -27,6 +27,7 @@ import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Map;
 import java.util.Properties;
+import java.util.UUID;
 
 import javax.annotation.CheckForNull;
 
@@ -66,18 +67,20 @@ public class BlobStoreFixtureProvider {
         DataStore delegate;
         if (bsType == Type.S3){
             SharedS3DataStore s3ds = new SharedS3DataStore();
-            Properties props = loadAndTransformProps(bsopts.getS3ConfigPath());
+            Properties props = loadConfig(bsopts.getS3ConfigPath());
             s3ds.setProperties(props);
             File homeDir =  Files.createTempDir();
             closer.register(asCloseable(homeDir));
+            populate(s3ds, asMap(props), false);
             s3ds.init(homeDir.getAbsolutePath());
             delegate = s3ds;
         } else if(bsType == Type.AZURE){
             AzureDataStore azureds = new AzureDataStore();
             String cfgPath = bsopts.getAzureConfigPath();
-            Properties props = loadAndTransformProps(cfgPath);
+            Properties props = loadConfig(cfgPath);
             azureds.setProperties(props);
             File homeDir =  Files.createTempDir();
+            populate(azureds, asMap(props), false);
             azureds.init(homeDir.getAbsolutePath());
             closer.register(asCloseable(homeDir));
             delegate = azureds;
@@ -102,6 +105,18 @@ public class BlobStoreFixtureProvider {
         return new DataStoreFixture(blobStore, closer, 
!options.getCommonOpts().isReadWrite());
     }
 
+    private static Properties loadConfig(String cfgPath) throws IOException {
+        Properties props = loadAndTransformProps(cfgPath);
+        configureDefaultProps(props);
+        return props;
+    }
+
+    private static void configureDefaultProps(Properties props) {
+        if (!props.containsKey("secret")){
+            props.setProperty("secret", UUID.randomUUID().toString());
+        }
+    }
+
     private static class DataStoreFixture implements BlobStoreFixture {
         private final DataStoreBlobStore blobStore;
         private final Closer closer;


Reply via email to