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