]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: don't allow running rgwfile tests as anon
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 23 Oct 2015 17:18:12 +0000 (13:18 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:04:58 +0000 (12:04 -0500)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/test/librgw_file.cc
src/test/librgw_file_cd.cc

index e0ced5866d8ae78f36f00d89ec83b623d84d45b2..079272ae76357c3b90641b4f05c78286ab99a5c7 100644 (file)
@@ -194,6 +194,13 @@ int main(int argc, char *argv[])
     }
   }
 
+  /* dont accidentally run as anonymous */
+  if ((access_key == "") ||
+      (secret_key == "")) {
+    std::cout << argv[0] << " no AWS credentials, exiting" << std::endl;
+    return EPERM;
+  }
+
   saved_args.argc = argc;
   saved_args.argv = argv;
 
index 1ebc5c0a900b5ff300b58c18ffdd982737c29cbf..ab6de3865fcf6cc73d329ef4acdf01331f39990d 100644 (file)
@@ -32,8 +32,6 @@ namespace {
   string access_key("");
   string secret_key("");
   struct rgw_fs *fs = nullptr;
-  typedef std::tuple<string,uint64_t, struct rgw_file_handle*> fid_type; //in c++2014 can alias...
-  std::vector<fid_type> fids1;
 
   bool do_create = false;
   string bucket_name = "sorry_dave";
@@ -71,38 +69,8 @@ TEST(LibRGW, DELETE_BUCKET) {
   ASSERT_EQ(ret, 0);
 }
 
-extern "C" {
-  static bool r1_cb(const char* name, void *arg, uint64_t offset) {
-    // don't need arg--it would point to fids1
-    fids1.push_back(fid_type(name, offset, nullptr /* handle */));
-    return true; /* XXX ? */
-  }
-}
-
-TEST(LibRGW, LIST_BUCKETS) {
-  /* list buckets via readdir in fs root */
-  using std::get;
-
-  if (! fs)
-    return;
-
-  bool eof = false;
-  uint64_t offset = 0;
-  int ret = rgw_readdir(fs, &fs->root_fh, &offset, r1_cb, &fids1, &eof);
-  for (auto& fid : fids1) {
-    std::cout << "fname: " << get<0>(fid) << " fid: " << get<1>(fid)
-             << std::endl;
-  }
-  ASSERT_EQ(ret, 0);
-}
-
 TEST(LibRGW, CLEANUP) {
-  using std::get;
-  for (auto& fids : { fids1 }) {
-    for (auto& fid : fids) {
-      delete get<2>(fid);
-    }
-  }
+  // do nothing
 }
 
 TEST(LibRGW, UMOUNT) {
@@ -152,6 +120,13 @@ int main(int argc, char *argv[])
     }
   }
 
+  /* dont accidentally run as anonymous */
+  if ((access_key == "") ||
+      (secret_key == "")) {
+    std::cout << argv[0] << " no AWS credentials, exiting" << std::endl;
+    return EPERM;
+  }
+
   saved_args.argc = argc;
   saved_args.argv = argv;