Permalink
Browse files

tests suite files for https

  • Loading branch information...
BuzzTroll
BuzzTroll committed Jun 2, 2010
1 parent 12318e5 commit 7c2988978d2ab9c4cd180aafdcf2e01184e2b897

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -21,6 +21,6 @@ file=@@INSTALLDIR@@/log/cumulus.log
[https]
enabled=False
-#key=
-#cert=
+#key=@@KEYFILE@@
+#cert=@@CERT_FILE
View
@@ -25,7 +25,7 @@ list_md5 = False
preserve_attrs = True
progress_meter = True
proxy_host =
-proxy_port = 8888
+proxy_port = 9898
recursive = False
recv_chunk = 4096
secret_key = @@KEY@@
View
@@ -5,26 +5,35 @@ if ([ "X$1" == "X--help" ] || [ "X$1" == "X-h" ]); then
exit 0
fi
+
start_dir=`pwd`
source_dir=`dirname $0`
cd $source_dir
source_dir=`pwd`
+cp_files=""
+for i in *
+do
+ cp_files="$cp_files $source_dir/$i"
+done
cd $start_dir
if [ "X$1" == "X" ]; then
installdir=$source_dir
else
installdir=$1
mkdir $installdir 2> /dev/null
+ if [ "X$?" != "X0" ]; then
+ echo "WARNING: Install directory already exists"
+ fi
cd $installdir
# just in case they enter the same dir as the source distro
installdir=`pwd`
echo "Installing cumulus to $installdir"
- cp -r $source_dir/* $installdir
- if [ "X$?" != "X0" ]; then
- echo "Copy to $installdir failed"
- echo "verify that you can write to that directory"
- exit 1
- fi
+ cp -r $cp_files $installdir
+ if [ "X$?" != "X0" ]; then
+ echo "Copy to $installdir failed"
+ echo "verify that you can write to that directory"
+ exit 1
+ fi
cd $source_dir
fi
@@ -97,5 +106,15 @@ if [ $? -ne 0 ]; then
exit 1
fi
+sed -e "s^@@INSTALLDIR@@^$installdir^g" -e "s^@@HTTPS@@^True^g" $installdir/etc/cumulus_test.ini.in > $installdir/tests/cumulus_https.ini
+if [ $? -ne 0 ]; then
+ echo "problem setting up test suite configuration files"
+fi
+
+sed -e "s^@@INSTALLDIR@@^$installdir^g" -e "s^@@HTTPS@@^False^g" $installdir/etc/cumulus_test.ini.in > $installdir/tests/cumulus.ini
+if [ $? -ne 0 ]; then
+ echo "problem setting up test suite configuration files"
+fi
+
echo "Make further customizations by editing $outf"
@@ -46,7 +46,7 @@ def add_user_generate_pw(len):
newpasswd = newpasswd + random.choice(chars)
return newpasswd
-def main(argv=sys.argv[1:]):
+def main_trap(argv=sys.argv[1:]):
auth = pycb.config.auth
@@ -84,16 +84,20 @@ def main(argv=sys.argv[1:]):
return 0
-if __name__ == "__main__":
+def main(argv=sys.argv[1:]):
try:
- rc = main()
+ rc = main_trap(argv)
except cbToolsException, tex:
print tex
rc = tex.get_rc()
except SystemExit:
- rc = 127
+ rc = 0
except:
traceback.print_exc(file=sys.stdout)
print 'An unknown error occurred'
rc = 128
+ return rc
+
+if __name__ == "__main__":
+ rc = main()
sys.exit(rc)
@@ -36,7 +36,7 @@ def setup_options(argv):
return (o, args)
-def main(argv=sys.argv[1:]):
+def main_trap(argv=sys.argv[1:]):
auth = pycb.config.auth
@@ -61,17 +61,22 @@ def main(argv=sys.argv[1:]):
return 0
-if __name__ == "__main__":
+def main(argv=sys.argv[1:]):
try:
- rc = main()
+ rc = main_trap(argv)
except cbToolsException, tex:
print tex
rc = tex.get_rc()
except SystemExit:
- rc = 127
+ rc = 0
except:
traceback.print_exc(file=sys.stdout)
print 'An unknown error occurred'
rc = 128
+
+ return rc
+
+if __name__ == "__main__":
+ rc = main()
sys.exit(rc)
@@ -28,13 +28,13 @@ def setup_options(argv):
return (o, args)
-def main(argv=sys.argv[1:]):
+def main_trap(argv=sys.argv[1:]):
auth = pycb.config.auth
(opts, args) = setup_options(argv)
if len(args) == 0:
- raise cbToolsException('CMDLINE', ["You must provide a display name"])
+ raise cbToolsException('CMDLINE', ("You must provide a display name"))
display_name = args[0]
@@ -48,17 +48,22 @@ def main(argv=sys.argv[1:]):
return 0
-if __name__ == "__main__":
+def main(argv=sys.argv[1:]):
try:
- rc = main()
+ rc = main_trap(argv)
except cbToolsException, tex:
print tex
rc = tex.get_rc()
+ except SystemExit:
+ rc = 0
except:
traceback.print_exc(file=sys.stdout)
print 'An unknown error occurred'
rc = 128
+ return rc
+if __name__ == "__main__":
+ rc = main()
sys.exit(rc)
@@ -26,7 +26,7 @@ def setup_options(argv):
return (o, args)
-def main(argv=sys.argv[1:]):
+def main_trap(argv=sys.argv[1:]):
auth = pycb.config.auth
@@ -44,6 +44,8 @@ def main(argv=sys.argv[1:]):
q = int(qstr)
except:
raise cbToolsException('CMDLINE', ("The quota must be an integer > 0 or the string UNLIMITED"))
+
+ print q
if q < 1:
raise cbToolsException('CMDLINE', ("The quota must be an integer > 0 or the string UNLIMITED"))
@@ -60,17 +62,22 @@ def main(argv=sys.argv[1:]):
return 0
-if __name__ == "__main__":
+def main(argv=sys.argv[1:]):
try:
- rc = main()
+ rc = main_trap(argv)
except cbToolsException, tex:
print tex
rc = tex.get_rc()
+ except SystemExit:
+ rc = 0
except:
traceback.print_exc(file=sys.stdout)
print 'An unknown error occurred'
rc = 128
+ return rc
+if __name__ == "__main__":
+ rc = main()
sys.exit(rc)
@@ -111,4 +111,107 @@ def test_quota(self):
rc = pycb.tools.remove_user.main([display_name])
self.assertEqual(rc, 0, "rc = %d" % (rc))
+ def test_error_cmdline(self):
+ rc = pycb.tools.add_user.main([])
+ self.assertNotEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.remove_user.main([])
+ self.assertNotEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.set_quota.main([])
+ self.assertNotEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.list_users.main([])
+ self.assertNotEqual(rc, 0, "rc = %d" % (rc))
+
+ def test_help(self):
+ rc = pycb.tools.add_user.main(["--help"])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.remove_user.main(["--help"])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.set_quota.main(["--help"])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.list_users.main(["--help"])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.add_user.main(["-h"])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.remove_user.main(["-h"])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.set_quota.main(["-h"])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.list_users.main(["-h"])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ def test_user_not_found(self):
+ display_name = str(uuid.uuid1())
+ rc = pycb.tools.remove_user.main([display_name])
+ self.assertNotEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.set_quota.main([display_name])
+ self.assertNotEqual(rc, 0, "rc = %d" % (rc))
+
+ def test_quota_bad_cmd(self):
+ display_name = str(uuid.uuid1())
+ rc = pycb.tools.add_user.main([display_name])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.set_quota.main([display_name])
+ self.assertNotEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.set_quota.main([display_name, "BAD"])
+ self.assertNotEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.set_quota.main([display_name, "\-10"])
+ self.assertNotEqual(rc, 0, "rc = %d" % (rc))
+
+
+ def test_quota_unlimited(self):
+ display_name = str(uuid.uuid1())
+ rc = pycb.tools.add_user.main([display_name])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ (tmpFD, outFileName) = tempfile.mkstemp("cumulustests")
+ os.close(tmpFD)
+
+ q = "UNLIMITED"
+ rc = pycb.tools.set_quota.main([display_name, q])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.list_users.main(["-O", outFileName, "-b", "-r", "friendly,quota", display_name])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ n = "%s,%s" % (display_name, q)
+ rc = self.find_in_file(outFileName, display_name)
+ self.assertTrue(rc, "display name not found in list")
+
+ rc = pycb.tools.remove_user.main([display_name])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ def test_add_user(self):
+ display_name = str(uuid.uuid1())
+ rc = pycb.tools.add_user.main([display_name])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ rc = pycb.tools.add_user.main(["-e", "-p", "hello", display_name])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ (tmpFD, outFileName) = tempfile.mkstemp("cumulustests")
+ os.close(tmpFD)
+ rc = pycb.tools.list_users.main(["-O", outFileName, "-b", "-r", "password", display_name])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+ rc = self.find_in_file(outFileName, "hello")
+
+ rc = pycb.tools.remove_user.main([display_name])
+ self.assertEqual(rc, 0, "rc = %d" % (rc))
+
+ def test_add_user_unknown(self):
+ rc = pycb.tools.add_user.main(["-e", "hello"])
+ self.assertNotEqual(rc, 0, "rc = %d" % (rc))
View
@@ -1,12 +1,20 @@
#!/bin/bash
+cd ..
+source env.sh
+cd -
+
echo "Running without security"
echo "=========================="
+
+export CUMULUS_SETTINGS_FILE=${CUMULUS_HOME}/tests/cumulus.ini
./run-pass.sh
if [ $? -ne 0 ]; then
echo "Insecure tests failed"
exit 1
fi
+
+export CUMULUS_SETTINGS_FILE=${CUMULUS_HOME}/tests/cumulus_https.ini
export CUMULUS_TEST_HTTPS="True"
echo "Running with security"
echo "=========================="
@@ -6,8 +6,8 @@ cd -
mv ~/.s3cfg ~/.s3cfg.cumulus.test
-cumulus_host=`hostname -f`
-cumulus_port=8888
+cumulus_host=localhost
+cumulus_port=9898
export CUMULUS_TEST_HOST=$cumulus_host
export CUMULUS_TEST_PORT=$cumulus_port
@@ -23,7 +23,7 @@ fi
$CUMULUS_HOME/bin/cumulus.sh -p $cumulus_port $https_opt &
cumulus_pid=$!
echo $cumulus_pid
-trap "pkill cumulus; mv ~/.s3cfg.cumulus.test ~/.s3cfg; $CUMULUS_HOME/bin/cumulus-remove-user.sh tests3cmd1@nimbus.test" EXIT
+trap "kill $cumulus_pid; mv ~/.s3cfg.cumulus.test ~/.s3cfg; $CUMULUS_HOME/bin/cumulus-remove-user.sh tests3cmd1@nimbus.test" EXIT
sleep 2
log_file=`mktemp`
echo "Logging output to $log_file"

0 comments on commit 7c29889

Please sign in to comment.