renamed python package to cryptobox-server
unittests are working again http-error handling implemented
This commit is contained in:
parent
4bb5c9513b
commit
1438913656
48 changed files with 199 additions and 147 deletions
|
@ -117,11 +117,11 @@ def write_pid_file(pid_file):
|
|||
def parseOptions():
|
||||
version = "%prog" + cryptobox.core.main.VERSION
|
||||
parser = OptionParser(version=version)
|
||||
parser.set_defaults(conffile="/etc/cryptobox/webserver.conf",
|
||||
pidfile="/var/run/cryptobox/webserver.pid",
|
||||
parser.set_defaults(conffile="/etc/cryptobox-server/cryptobox.conf",
|
||||
pidfile="/var/run/cryptobox-server/webserver.pid",
|
||||
background=False,
|
||||
datadir="/usr/share/cryptobox/www-data",
|
||||
logfile="/var/log/cryptobox/webserver.log",
|
||||
datadir="/usr/share/cryptobox-server/www-data",
|
||||
logfile="/var/log/cryptobox-server/webserver.log",
|
||||
port="8080",
|
||||
host="",
|
||||
verbose=True)
|
||||
|
|
|
@ -24,10 +24,12 @@ ConfigVolumeLabel = cbox_config
|
|||
[Locations]
|
||||
# where should we mount volumes?
|
||||
# this directory must be writeable by the cryptobox user (see above)
|
||||
MountParentDir = /var/cache/cryptobox/mnt
|
||||
#MountParentDir = /var/cache/cryptobox/mnt
|
||||
MountParentDir = ../ttt/mnt
|
||||
|
||||
# settings directory: contains name database and plugin configuration
|
||||
SettingsDir = /var/cache/cryptobox/settings
|
||||
#SettingsDir = /var/cache/cryptobox/settings
|
||||
SettingsDir = ../ttt/settings
|
||||
|
||||
# where are the clearsilver templates?
|
||||
#TemplateDir = /usr/share/cryptobox/templates
|
||||
|
@ -47,7 +49,7 @@ PluginDir = ../plugins
|
|||
|
||||
# path to the hook directory (e.g. containing some scripts)
|
||||
#HookDir = /etc/cryptobox/hooks.d
|
||||
HookDir = ../hook-scripts
|
||||
EventDir = ../event-scripts
|
||||
|
||||
|
||||
[Log]
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
# run this script _before_ you do a commit and fix errors before uploading
|
||||
#
|
||||
|
||||
BASE_DIR=$(cd "$(dirname $0)/.."; pwd)
|
||||
|
||||
export PYTHONPATH=$BASE_DIR/src
|
||||
|
||||
# check if /dev/loop1 is available - otherwise some tests will fail!
|
||||
if /sbin/losetup /dev/loop1 &>/dev/null
|
||||
then true
|
||||
|
@ -15,8 +19,11 @@ if /sbin/losetup /dev/loop1 &>/dev/null
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# chdir to 'bin' - all config settings depend on this
|
||||
cd "${BASE_DIR}/bin"
|
||||
|
||||
# do the tests
|
||||
for a in unittests.*.py
|
||||
for a in ${BASE_DIR}/src/cryptobox/tests/test.*.py
|
||||
do testoob -v "$a"
|
||||
done
|
||||
|
||||
|
|
|
@ -24,25 +24,25 @@ ConfigVolumeLabel = cbox_config
|
|||
[Locations]
|
||||
# where should we mount volumes?
|
||||
# this directory must be writeable by the cryptobox user (see above)
|
||||
MountParentDir = /var/cache/cryptobox/mnt
|
||||
MountParentDir = /var/cache/cryptobox-server/mnt
|
||||
|
||||
# settings directory: contains name database and plugin configuration
|
||||
SettingsDir = /var/cache/cryptobox/settings
|
||||
SettingsDir = /var/cache/cryptobox-server/settings
|
||||
|
||||
# where are the clearsilver templates?
|
||||
TemplateDir = /usr/share/cryptobox/templates
|
||||
TemplateDir = /usr/share/cryptobox-server/templates
|
||||
|
||||
# path to language files
|
||||
LangDir = /usr/share/cryptobox/lang
|
||||
LangDir = /usr/share/cryptobox-server/lang
|
||||
|
||||
# path to documentation files
|
||||
DocDir = /usr/share/doc/cryptobox/html
|
||||
DocDir = /usr/share/doc/cryptobox-server/html
|
||||
|
||||
# path to the plugin directory
|
||||
PluginDir = /usr/share/cryptobox/plugins
|
||||
PluginDir = /usr/share/cryptobox-server/plugins
|
||||
|
||||
# path to the hook directory (e.g. containing some scripts)
|
||||
HookDir = /etc/cryptobox/events.d
|
||||
HookDir = /etc/cryptobox-server/events.d
|
||||
|
||||
|
||||
[Log]
|
||||
|
@ -59,7 +59,7 @@ Destination = file
|
|||
# details. Possible values for the different destinations are:
|
||||
# file: $FILENAME
|
||||
# syslog: $LOG_FACILITY
|
||||
Details = /var/log/cryptobox/cryptobox.log
|
||||
Details = /var/log/cryptobox-server/cryptobox.log
|
||||
|
||||
|
||||
[WebSettings]
|
||||
|
|
2
debian/README.Debian
vendored
2
debian/README.Debian
vendored
|
@ -1,5 +1,5 @@
|
|||
CryptoBox for Debian - installation notes
|
||||
|
||||
be aware of one thing:
|
||||
1) you need cryptsetup with luks support (for now only in unstable)
|
||||
1) you need cryptsetup with luks support (for now only in testing)
|
||||
|
||||
|
|
13
debian/control
vendored
13
debian/control
vendored
|
@ -6,15 +6,16 @@ Build-Depends: debhelper (>= 5.0.38), dpatch, python-all-dev (>= 2.4), python-ce
|
|||
XS-Python-Version: >= 2.4
|
||||
Standards-Version: 3.7.2
|
||||
|
||||
Package: cryptobox
|
||||
Package: cryptobox-server
|
||||
Architecture: any
|
||||
Depends: ${python:Depends}, bash (>=2.0), sed (>=4.0), coreutils, grep (>=2.0), cryptsetup (>=20050111), dmsetup, initscripts, e2fsprogs (>= 1.27), adduser, python (>=2.4), python-clearsilver, super, dosfstools, python-cherrypy, python-configobj
|
||||
Suggests: samba, stunnel, openssl
|
||||
Depends: ${python:Depends}, cryptsetup (>=20050111), e2fsprogs (>= 1.27), adduser, python (>=2.4), python-clearsilver, super, dosfstools, python-cherrypy, python-configobj
|
||||
Suggests: samba, apache, stunnel
|
||||
Replaces: cryptobox
|
||||
XB-Python-Version: ${python:Versions}
|
||||
Description: Web interface for an encrypting fileserver
|
||||
This web interface allows you to manage the encrypted and plaintext
|
||||
disks of your system. The data is platform independently available
|
||||
via samba file shares.
|
||||
This web interface allows you to manage encrypted and plaintext
|
||||
disks.
|
||||
This package is especially useful for non-desktop systems.
|
||||
Even non-technical users are able to encrypt their private data with
|
||||
the CryptoBox.
|
||||
|
||||
|
|
|
@ -11,9 +11,6 @@ RUNAS=cryptobox
|
|||
# listening port
|
||||
PORT=8080
|
||||
|
||||
# log file of the webserver
|
||||
LOGFILE=/var/log/cryptobox/webserver.log
|
||||
|
||||
# some more server options (rarely necessary)
|
||||
#SERVER_OPTS="--host localhost --datadir=/usr/share/cryptobox/html"
|
||||
#SERVER_OPTS="--host localhost --datadir=/usr/share/cryptobox-server/html"
|
||||
|
4
debian/cryptobox-server.dirs
vendored
Normal file
4
debian/cryptobox-server.dirs
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
usr/sbin
|
||||
usr/share/cryptobox-server
|
||||
var/log/cryptobox-server
|
||||
var/run/cryptobox-server
|
|
@ -8,7 +8,7 @@
|
|||
#
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: cryptobox
|
||||
# Provides: cryptobox-server
|
||||
# Required-Start: $network $local_fs $remote_fs
|
||||
# Required-Stop: $network $local_fs $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
|
@ -18,24 +18,24 @@
|
|||
|
||||
|
||||
# read the default setting file, if it exists
|
||||
[ -r /etc/default/cryptobox ] && source /etc/default/cryptobox
|
||||
[ -r /etc/default/cryptobox-server ] && source /etc/default/cryptobox-server
|
||||
|
||||
# set default values (if not defined in /etc/default/cryptobox)
|
||||
# set default values (if not defined in /etc/default/cryptobox-server)
|
||||
NO_START=${NO_START:-0}
|
||||
RUNAS=${RUNAS:-cryptobox}
|
||||
PORT=${PORT:-8080}
|
||||
HOST=${HOST:-}
|
||||
LOGFILE=${LOGFILE:-/var/log/cryptobox/webserver.log}
|
||||
LOGFILE=/var/log/cryptobox-server/webserver.log
|
||||
SERVER_OPTS=${SERVER_OPTS:-}
|
||||
CONF_FILE=/etc/cryptobox/cryptobox.conf
|
||||
CONF_FILE=/etc/cryptobox-server/cryptobox.conf
|
||||
|
||||
# quit if NO_START is 1 (see /etc/default/cryptobox)
|
||||
# quit if NO_START is 1 (see /etc/default/cryptobox-server)
|
||||
[ "$NO_START" = "1" ] && exit 0
|
||||
|
||||
DAEMON=/usr/sbin/CryptoBoxWebserver
|
||||
PIDFILE=/var/run/cryptobox/webserver.pid
|
||||
PIDFILE=/var/run/cryptobox-server/webserver.pid
|
||||
DESC="CryptoBox Daemon (webinterface)"
|
||||
OPTIONS="-B --pidfile=$PIDFILE --config=$CONF_FILE $SERVER_OPTS"
|
||||
OPTIONS="-B --pidfile=$PIDFILE --config=$CONF_FILE --logfile=$LOGFILE --host=$HOST --port=$PORT $SERVER_OPTS"
|
||||
|
||||
# check if the package is installed
|
||||
test -e "$DAEMON" || exit 0
|
1
debian/cryptobox-server.lintian
vendored
Normal file
1
debian/cryptobox-server.lintian
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
cryptobox-server: package-has-a-duplicate-relation
|
6
debian/cryptobox-server.logrotate
vendored
Normal file
6
debian/cryptobox-server.logrotate
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/var/log/cryptobox-server/cryptobox.log /var/log/cryptobox-server/webserver.log {
|
||||
rotate 2
|
||||
size 100k
|
||||
copytruncate
|
||||
nocompress
|
||||
}
|
|
@ -1,19 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
LOG_FILE=/var/log/cryptobox/cryptobox.log
|
||||
WEBLOG_FILE=/var/log/cryptobox/webserver.log
|
||||
PID_DIR=/var/run/cryptobox
|
||||
CRYPTOBOX_USER=cryptobox
|
||||
USER_HOME=/var/cache/cryptobox
|
||||
set -u
|
||||
|
||||
# check the current cryptobox user - maybe it was changed manually
|
||||
test -r /etc/default/cryptobox-server && . /etc/default/cryptobox-server
|
||||
|
||||
# RUNAS was probably imported from /etc/default/cryptobox-server - otherwise use the default
|
||||
CRYPTOBOX_USER=${RUNAS:-cryptobox}
|
||||
LOG_FILE=/var/log/cryptobox-server/cryptobox.log
|
||||
WEBLOG_FILE=/var/log/cryptobox-server/webserver.log
|
||||
PID_DIR=/var/run/cryptobox-server
|
||||
USER_HOME=/var/cache/cryptobox-server
|
||||
SUPER_FILE=/etc/super.tab
|
||||
ADDITIONAL_GROUP=disk
|
||||
|
||||
# check the current cryptobox user - maybe it was changed
|
||||
if test -r /etc/default/cryptobox
|
||||
then runas_user=$(grep "^RUNAS=" /etc/default/cryptobox | cut -d "=" -f 2)
|
||||
test -n "$runas_user" && CRYPTOBOX_USER=$runas_user
|
||||
fi
|
||||
|
||||
|
||||
create_user_home()
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ create_dirs_and_files()
|
|||
#################### main ######################
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
reconfigure|configure)
|
||||
create_user_home
|
||||
create_dirs_and_files
|
||||
create_add_super_permission
|
19
debian/postrm → debian/cryptobox-server.postrm
vendored
19
debian/postrm → debian/cryptobox-server.postrm
vendored
|
@ -1,11 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
LOG_FILE=/var/log/cryptobox/cryptobox.log
|
||||
WEBLOG_FILE=/var/log/cryptobox/webserver.log
|
||||
PID_DIR=/var/run/cryptobox
|
||||
set -u
|
||||
|
||||
CRYPTOBOX_USER=cryptobox
|
||||
LOG_FILE=/var/log/cryptobox-server/cryptobox.log
|
||||
WEBLOG_FILE=/var/log/cryptobox-server/webserver.log
|
||||
PID_DIR=/var/run/cryptobox-server
|
||||
SUPER_FILE=/etc/super.tab
|
||||
MNT_DIR=/var/cache/cryptobox/mnt
|
||||
SETTINGS_DIR=/var/cache/cryptobox/settings
|
||||
MNT_DIR=/var/cache/cryptobox-server/mnt
|
||||
SETTINGS_DIR=/var/cache/cryptobox-server/settings
|
||||
|
||||
remove_super_lines()
|
||||
{
|
||||
|
@ -43,10 +46,10 @@ remove_stuff()
|
|||
umount_all
|
||||
|
||||
# remove the user
|
||||
if test "$1" = "purge" && getent passwd cryptobox 2>/dev/null >/dev/null \
|
||||
&& test "$(cd ~cryptobox;pwd)" = /var/cache/cryptobox
|
||||
if test "$1" = "purge" && getent passwd "$CRYPTOBOX_USER" 2>/dev/null >/dev/null \
|
||||
&& test "$(getent passwd $CRYPTOBOX_USER | cut -d : -f 6)" = /var/cache/cryptobox-server
|
||||
then echo "Removing user 'cryptobox' ..."
|
||||
userdel -r cryptobox
|
||||
userdel -r "$CRYPTOBOX_USER"
|
||||
fi
|
||||
|
||||
# always remove the lines from the 'super' configuration file
|
0
debian/prerm → debian/cryptobox-server.prerm
vendored
0
debian/prerm → debian/cryptobox-server.prerm
vendored
1
debian/cryptobox.lintian
vendored
1
debian/cryptobox.lintian
vendored
|
@ -1 +0,0 @@
|
|||
cryptobox: package-has-a-duplicate-relation
|
6
debian/dirs
vendored
6
debian/dirs
vendored
|
@ -1,6 +0,0 @@
|
|||
etc/cryptobox
|
||||
etc/cryptobox/events.d
|
||||
etc/default
|
||||
etc/init.d
|
||||
usr/share/cryptobox
|
||||
usr/sbin
|
19
debian/rules
vendored
19
debian/rules
vendored
|
@ -12,7 +12,7 @@
|
|||
# necessary for dpatch
|
||||
.NOTPARALLEL:
|
||||
|
||||
DEB_BUILD_DIR=$(CURDIR)/debian/cryptobox
|
||||
DEB_BUILD_DIR=$(CURDIR)/debian/cryptobox-server
|
||||
CB_PYDIR=$(DEB_BUILD_DIR)/usr/lib/python$(shell pyversions -vr)/site-packages/cryptobox
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ clean-patched:
|
|||
python setup.py clean
|
||||
rm -f build-stamp
|
||||
rm -rf build
|
||||
find -type f -name '*.py[co]' | xargs rm -f
|
||||
find -type f -name '*.py[co]' -print0 | xargs -0 rm -f
|
||||
rm -f MANIFEST
|
||||
dh_clean
|
||||
|
||||
|
@ -58,16 +58,11 @@ install: build
|
|||
# remove duplicate documentation files
|
||||
rm -r $(CB_PYDIR)/doc
|
||||
# move shared files
|
||||
install -d -m 755 $(DEB_BUILD_DIR)/usr/share/cryptobox
|
||||
mv $(CB_PYDIR)/share/* $(DEB_BUILD_DIR)/usr/share/cryptobox/
|
||||
mv $(CB_PYDIR)/share/* $(DEB_BUILD_DIR)/usr/share/cryptobox-server/
|
||||
rmdir $(CB_PYDIR)/share
|
||||
# create log directory
|
||||
install -d -m 755 $(DEB_BUILD_DIR)/var/log/cryptobox
|
||||
# create pid directory
|
||||
install -d -m 755 $(DEB_BUILD_DIR)/var/run/cryptobox
|
||||
# install lintian override file: for multiple dependency caused by {python:Depends}
|
||||
install -D -m 644 debian/cryptobox.lintian \
|
||||
$(DEB_BUILD_DIR)/usr/share/lintian/overrides/cryptobox
|
||||
install -D -m 644 debian/cryptobox-server.lintian \
|
||||
$(DEB_BUILD_DIR)/usr/share/lintian/overrides/cryptobox-server
|
||||
|
||||
|
||||
# Build architecture-independent files here.
|
||||
|
@ -81,11 +76,13 @@ binary-arch: build install
|
|||
dh_installdocs
|
||||
dh_installexamples
|
||||
dh_installlogrotate
|
||||
dh_installdirs
|
||||
dh_installman
|
||||
dh_install
|
||||
dh_pycentral
|
||||
@# pycentral must be called before installinit - otherwise the DEBHELPER part
|
||||
@# in the postinst script is filled in the wrong order
|
||||
@# in the postinst script is filled in the wrong order - this causes a failing
|
||||
@# shutdown after removal, as the "pycentral pkgremove" call stops the daemon before
|
||||
dh_installinit
|
||||
dh_compress
|
||||
dh_fixperms
|
||||
|
|
14
lang/en.hdf
14
lang/en.hdf
|
@ -59,6 +59,20 @@ WarningMessage {
|
|||
Link.Text = Deactivate volume
|
||||
Link.Rel = volume_mount
|
||||
}
|
||||
|
||||
InvalidAction {
|
||||
Title = Invalid request
|
||||
Text = Sorry - I do not know how to handle this request. If you think, that this is a bug, then you should send the most recent part of the CryptoBox log to info@cryptobox.org.
|
||||
Link.Text = View log
|
||||
Link.Rel = logs
|
||||
}
|
||||
|
||||
RuntimeError {
|
||||
Title = Something weird happened
|
||||
Text = We (the developer of the CryptoBox) would like to fix this problem for you and others. Please send the most recent part of the CryptoBox log to info@cryptobox.org. Thanks for your contribution!
|
||||
Link.Text = View log
|
||||
Link.Rel = logs
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_get_date(self):
|
||||
date = self._getCurrentDate()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
'''display all devices'''
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
from twill.errors import *
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_help_pages(self):
|
||||
'''help pages should be available in different languages'''
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "language_selection?weblang=en"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_logs(self):
|
||||
log_url = self.URL + "logs"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
from network import CHANGE_IP_DELAY
|
||||
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_ip_change(self):
|
||||
'''change of network address'''
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "partition?weblang=en"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "plugin_manager?weblang=en"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "shutdown"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_preferences_overview(self):
|
||||
self.cmd.go(self.URL + "system_preferences?weblang=en")
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
## this user may not be removed
|
||||
from user_manager import RESERVED_USERS
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_users(self):
|
||||
cur_users = self._getUsers()
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "volume_automount?weblang=en&device=%2Fdev%2Floop1"
|
||||
self.register_auth(url)
|
||||
self.cmd.go(url)
|
||||
self.cmd.find('automatic')
|
||||
self.cmd.find('Activate')
|
||||
self.cmd.find('startup')
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "volume_chpasswd?weblang=en&device=%2Fdev%2Floop1"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "volume_details?weblang=en&device=%2Fdev%2Floop1"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "volume_format_fs?weblang=en&device=%2Fdev%2Floop1"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "volume_mount?weblang=en&device=%2Fdev%2Floop1"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "volume_props?weblang=en&device=%2Fdev%2Floop1"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import WebInterfaceTestClass
|
||||
import cryptobox.web.testclass
|
||||
|
||||
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||
class unittests(cryptobox.web.testclass.WebInterfaceTestClass):
|
||||
|
||||
def test_read_form(self):
|
||||
url = self.URL + "volume_rename?weblang=en&device=%2Fdev%2Floop1"
|
||||
|
|
4
setup.py
4
setup.py
|
@ -18,7 +18,7 @@ datadir = os.path.join(pydir, 'share')
|
|||
## doc dir
|
||||
docdir = os.path.join(pydir, 'doc')
|
||||
## configuration directory
|
||||
confdir = os.path.join(os.path.sep, 'etc', 'cryptobox')
|
||||
confdir = os.path.join(os.path.sep, 'etc', 'cryptobox-server')
|
||||
|
||||
|
||||
def listfiles(prefix,src):
|
||||
|
@ -51,7 +51,7 @@ def getdatafiles(prefix,dirs):
|
|||
|
||||
|
||||
setup(
|
||||
name = 'cryptobox',
|
||||
name = 'cryptobox-server',
|
||||
version = '0.3.0',
|
||||
description = 'webinterface for handling encrypted disks',
|
||||
author = 'Lars Kruse',
|
||||
|
|
|
@ -18,7 +18,7 @@ class CryptoBoxSettings:
|
|||
CONF_LOCATIONS = [
|
||||
"./cryptobox.conf",
|
||||
"~/.cryptobox.conf",
|
||||
"/etc/cryptobox/cryptobox.conf"]
|
||||
"/etc/cryptobox-server/cryptobox.conf"]
|
||||
|
||||
VOLUMESDB_FILE = "cryptobox_volumes.db"
|
||||
PLUGINCONF_FILE = "cryptobox_plugins.conf"
|
||||
|
@ -358,13 +358,13 @@ UseConfigPartition = integer(min=0, max=1, default=0)
|
|||
DisabledPlugins = list(default=[])
|
||||
|
||||
[Locations]
|
||||
MountParentDir = directoryExists(default="/var/cache/cryptobox/mnt")
|
||||
SettingsDir = directoryExists(default="/var/cache/cryptobox/settings")
|
||||
TemplateDir = directoryExists(default="/usr/share/cryptobox/template")
|
||||
LangDir = directoryExists(default="/usr/share/cryptobox/lang")
|
||||
DocDir = directoryExists(default="/usr/share/doc/cryptobox/www-data")
|
||||
PluginDir = directoryExists(default="/usr/share/cryptobox/plugins")
|
||||
EventDir = directoryExists(default="/etc/cryptobox/events.d")
|
||||
MountParentDir = directoryExists(default="/var/cache/cryptobox-server/mnt")
|
||||
SettingsDir = directoryExists(default="/var/cache/cryptobox-server/settings")
|
||||
TemplateDir = directoryExists(default="/usr/share/cryptobox-server/template")
|
||||
LangDir = directoryExists(default="/usr/share/cryptobox-server/lang")
|
||||
DocDir = directoryExists(default="/usr/share/doc/cryptobox-server/www-data")
|
||||
PluginDir = directoryExists(default="/usr/share/cryptobox-server/plugins")
|
||||
EventDir = string(default="/etc/cryptobox-server/events.d")
|
||||
|
||||
[Log]
|
||||
Level = option("debug", "info", "warn", "error", default="warn")
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
|
||||
import unittest
|
||||
import sys
|
||||
from CryptoBox import *
|
||||
from CryptoBoxExceptions import *
|
||||
import CryptoBoxSettings
|
||||
import cryptobox.core.main
|
||||
from cryptobox.core.exceptions import *
|
||||
import cryptobox.core.settings
|
||||
|
||||
class CryptoBoxPropsDeviceTests(unittest.TestCase):
|
||||
import CryptoBox
|
||||
cb = CryptoBox.CryptoBoxProps()
|
||||
cb = cryptobox.core.main.CryptoBoxProps()
|
||||
|
||||
def testAllowedDevices(self):
|
||||
'''isDeviceAllowed should accept permitted devices'''
|
||||
|
@ -27,8 +26,6 @@ class CryptoBoxPropsDeviceTests(unittest.TestCase):
|
|||
class CryptoBoxPropsConfigTests(unittest.TestCase):
|
||||
'''test here if everything with the config turns right'''
|
||||
import os
|
||||
import CryptoBox
|
||||
|
||||
files = {
|
||||
"configFileOK" : "cbox-test_ok.conf",
|
||||
"configFileBroken" : "cbox-test_broken.conf",
|
||||
|
@ -91,35 +88,35 @@ CryptoBoxRootActions = CryptoBoxRootActions
|
|||
def testConfigInit(self):
|
||||
'''Check various branches of config file loading'''
|
||||
import os
|
||||
self.assertRaises(CBConfigUnavailableError, self.CryptoBox.CryptoBoxProps,"/invalid/path/to/config/file")
|
||||
self.assertRaises(CBConfigUnavailableError, self.CryptoBox.CryptoBoxProps,"/etc/shadow")
|
||||
self.assertRaises(CBConfigUnavailableError, cryptobox.core.main.CryptoBoxProps,"/invalid/path/to/config/file")
|
||||
self.assertRaises(CBConfigUnavailableError, cryptobox.core.main.CryptoBoxProps,"/etc/shadow")
|
||||
""" check one of the following things:
|
||||
1) are we successfully using an existing config file?
|
||||
2) do we break, if no config file is there?
|
||||
depending on the existence of a config file, only one of these conditions
|
||||
can be checked - hints for more comprehensive tests are appreciated :) """
|
||||
for a in CryptoBoxSettings.CryptoBoxSettings.CONF_LOCATIONS:
|
||||
for a in ['cryptobox.conf']:
|
||||
if os.path.exists(a):
|
||||
self.CryptoBox.CryptoBoxProps()
|
||||
cryptobox.core.main.CryptoBoxProps()
|
||||
break # this skips the 'else' clause
|
||||
else: self.assertRaises(CBConfigUnavailableError, self.CryptoBox.CryptoBoxProps)
|
||||
self.assertRaises(CBConfigUnavailableError, self.CryptoBox.CryptoBoxProps,[])
|
||||
else: self.assertRaises(CBConfigUnavailableError, cryptobox.core.main.CryptoBoxProps)
|
||||
self.assertRaises(CBConfigUnavailableError, cryptobox.core.main.CryptoBoxProps,[])
|
||||
|
||||
|
||||
def testBrokenConfigs(self):
|
||||
"""Check various broken configurations"""
|
||||
self.writeConfig("SettingsDir", "SettingsDir=/foo/bar", filename=self.filenames["configFileBroken"])
|
||||
self.assertRaises(CBConfigError, self.CryptoBox.CryptoBoxProps,self.filenames["configFileBroken"])
|
||||
self.assertRaises(CBConfigError, cryptobox.core.main.CryptoBoxProps,self.filenames["configFileBroken"])
|
||||
self.writeConfig("Level", "Level = ho", filename=self.filenames["configFileBroken"])
|
||||
self.assertRaises(CBConfigError, self.CryptoBox.CryptoBoxProps,self.filenames["configFileBroken"])
|
||||
self.assertRaises(CBConfigError, cryptobox.core.main.CryptoBoxProps,self.filenames["configFileBroken"])
|
||||
self.writeConfig("Details", "#out", filename=self.filenames["configFileBroken"])
|
||||
self.assertRaises(CBConfigError, self.CryptoBox.CryptoBoxProps,self.filenames["configFileBroken"])
|
||||
self.assertRaises(CBConfigError, cryptobox.core.main.CryptoBoxProps,self.filenames["configFileBroken"])
|
||||
self.writeConfig("super", "super=/bin/invalid/no", filename=self.filenames["configFileBroken"])
|
||||
self.assertRaises(CBConfigError, self.CryptoBox.CryptoBoxProps,self.filenames["configFileBroken"])
|
||||
self.assertRaises(CBConfigError, cryptobox.core.main.CryptoBoxProps,self.filenames["configFileBroken"])
|
||||
self.writeConfig("CryptoBoxRootActions", "#not here", filename=self.filenames["configFileBroken"])
|
||||
self.assertRaises(CBConfigError, self.CryptoBox.CryptoBoxProps,self.filenames["configFileBroken"])
|
||||
self.assertRaises(CBConfigError, cryptobox.core.main.CryptoBoxProps,self.filenames["configFileBroken"])
|
||||
self.writeConfig("CryptoBoxRootActions", "CryptoBoxRootActions = /bin/false", filename=self.filenames["configFileBroken"])
|
||||
self.assertRaises(CBEnvironmentError, self.CryptoBox.CryptoBoxProps,self.filenames["configFileBroken"])
|
||||
self.assertRaises(CBEnvironmentError, cryptobox.core.main.CryptoBoxProps,self.filenames["configFileBroken"])
|
||||
|
||||
|
||||
def writeConfig(self, replace=None, newline=None, filename=None):
|
|
@ -1,21 +1,21 @@
|
|||
#!/usr/bin/env python2.4
|
||||
|
||||
import unittest
|
||||
import CryptoBoxTools
|
||||
import cryptobox.core.tools as cbxTools
|
||||
import os
|
||||
|
||||
|
||||
class CryptoBoxToolsTests(unittest.TestCase):
|
||||
|
||||
def testGetAbsoluteDeviceName(self):
|
||||
func = CryptoBoxTools.getAbsoluteDeviceName
|
||||
func = cbxTools.getAbsoluteDeviceName
|
||||
self.assertTrue(func("hda") == "/dev/hda")
|
||||
self.assertTrue(func("loop0") == "/dev/loop0")
|
||||
self.assertTrue(func(os.path.devnull) == os.path.devnull)
|
||||
|
||||
|
||||
def testFindMajorMinorOfDevice(self):
|
||||
func = CryptoBoxTools.findMajorMinorOfDevice
|
||||
func = cbxTools.findMajorMinorOfDevice
|
||||
self.assertTrue(func("/dev/hda") == (3,0))
|
||||
self.assertTrue(func("/dev/hda1") == (3,1))
|
||||
self.assertTrue(func(os.path.devnull) == (1,3))
|
||||
|
@ -23,7 +23,7 @@ class CryptoBoxToolsTests(unittest.TestCase):
|
|||
|
||||
|
||||
def testFindMajorMinorDeviceName(self):
|
||||
func = CryptoBoxTools.findMajorMinorDeviceName
|
||||
func = cbxTools.findMajorMinorDeviceName
|
||||
dir = os.path.join(os.path.sep, "dev")
|
||||
self.assertTrue(os.path.join(dir,"hda") in func(dir,3,0))
|
||||
self.assertTrue(os.path.devnull in func(dir,1,3))
|
||||
|
@ -31,7 +31,7 @@ class CryptoBoxToolsTests(unittest.TestCase):
|
|||
|
||||
|
||||
def testIsPartOfBlockDevice(self):
|
||||
func = CryptoBoxTools.isPartOfBlockDevice
|
||||
func = cbxTools.isPartOfBlockDevice
|
||||
self.assertTrue(func("/dev/hda", "/dev/hda1"))
|
||||
self.assertFalse(func("/dev/hda", "/dev/hda"))
|
||||
self.assertFalse(func("/dev/hda1", "/dev/hda"))
|
|
@ -42,6 +42,8 @@ class WebInterfaceSites:
|
|||
self.log = logging.getLogger("CryptoBox")
|
||||
self.prefs = self.cbox.prefs
|
||||
self.__resetDataset()
|
||||
## store the original http error handler
|
||||
self._cp_on_http_error = self.newHTTPErrorHandler
|
||||
|
||||
|
||||
def __resetDataset(self):
|
||||
|
@ -128,7 +130,35 @@ class WebInterfaceSites:
|
|||
param_dict = {"weblang":weblang}
|
||||
## render "disks" plugin by default
|
||||
return self.return_plugin_action(self.pluginList.getPlugin("disks"))(**param_dict)
|
||||
|
||||
|
||||
def newHTTPErrorHandler(self, errorCode, message):
|
||||
## we ignore uninteresting not-found errors
|
||||
if (errorCode == 404) and \
|
||||
(cherrypy.request.path.startswith("/cryptobox-misc/") or \
|
||||
cherrypy.request.path in ['/robots.txt','/favicon.ico']):
|
||||
cherrypy.response.status = errorCode
|
||||
return
|
||||
## an invalid action was requested
|
||||
if errorCode == 404:
|
||||
## we send a not-found error (with the usual interface)
|
||||
cherrypy.response.status = errorCode
|
||||
self.dataset["Data.Warning"] = "InvalidAction"
|
||||
cherrypy.response.body = self.__render("empty")
|
||||
return
|
||||
## are there still bugs in the code?
|
||||
if errorCode == 500:
|
||||
## we fix the error code (200 is "OK")
|
||||
cherrypy.response.status = 200
|
||||
## TODO: 'message' is None - we should check a stack trace or something?
|
||||
self.cbox.log.warn("HTTP-ERROR[500] - a runtime error occoured: %s" % str(message))
|
||||
self.dataset["Data.Warning"] = "RuntimeError"
|
||||
cherrypy.response.body = self.__render("empty")
|
||||
return
|
||||
## unknown error type
|
||||
cherrypy.response.status = errorCode
|
||||
self.cbox.log.warn("HTTP-ERROR[%d] - an unknown error occoured: %s" % (errorCode, message))
|
||||
cherrypy.response.body = self.__render("empty")
|
||||
|
||||
|
||||
def return_plugin_action(self, plugin):
|
||||
def handler(self, **args):
|
||||
|
|
|
@ -7,7 +7,7 @@ just inherit this class and add some test functions
|
|||
import unittest
|
||||
import twill
|
||||
import cherrypy
|
||||
import cryptobox.web.dataset
|
||||
import cryptobox.web.sites
|
||||
|
||||
## we do the following, for easy surfing
|
||||
## e.g. use: cbx.go(your_url)
|
||||
|
@ -42,7 +42,7 @@ class WebInterfaceTestClass(unittest.TestCase):
|
|||
'server.threadPool': 1,
|
||||
'server.environment': 'production',
|
||||
})
|
||||
cherrypy.root = cryptobox.web.dataset.WebInterfaceSites()
|
||||
cherrypy.root = cryptobox.web.sites.WebInterfaceSites()
|
||||
cherrypy.server.start(initOnly=True, serverClass=None)
|
||||
|
||||
from cherrypy._cpwsgi import wsgiApp
|
||||
|
|
Loading…
Reference in a new issue