unittests added to some plugins
added "name" tag to all form elements
This commit is contained in:
parent
0a8fc07556
commit
1dc0da0382
23 changed files with 199 additions and 28 deletions
|
@ -35,7 +35,8 @@ class date(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||||
|
|
||||||
|
|
||||||
def getStatus(self):
|
def getStatus(self):
|
||||||
return str(self.__getCurrentDate())
|
now = self.__getCurrentDate()
|
||||||
|
return "%d/%d/%d/%d/%d/%d" % (now.year, now.month, now.day, now.hour, now.minute, now.second)
|
||||||
|
|
||||||
|
|
||||||
def __prepareFormData(self):
|
def __prepareFormData(self):
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<h1><?cs var:html_escape(Lang.Plugins.date.Title.ConfigDate) ?></h1>
|
<h1><?cs var:html_escape(Lang.Plugins.date.Title.ConfigDate) ?></h1>
|
||||||
|
|
||||||
<?cs call:print_form_header("plugins/date") ?>
|
<?cs call:print_form_header("set_date", "plugins/date") ?>
|
||||||
|
|
||||||
<p><label for="date"><?cs var:html_escape(Lang.Plugins.date.Text.Date) ?>: </label><br/>
|
<p><label for="date"><?cs var:html_escape(Lang.Plugins.date.Text.Date) ?>: </label><br/>
|
||||||
<select name="day" tabindex="1" size="0"><?cs
|
<select name="day" tabindex="1" size="0"><?cs
|
||||||
|
|
|
@ -29,6 +29,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
proc = subprocess.Popen(
|
proc = subprocess.Popen(
|
||||||
shell = False,
|
shell = False,
|
||||||
|
stdout = subprocess.PIPE,
|
||||||
args = [DATE_BIN, args[0]])
|
args = [DATE_BIN, args[0]])
|
||||||
proc.communicate()
|
proc.communicate()
|
||||||
sys.exit(proc.returncode)
|
sys.exit(proc.returncode)
|
||||||
|
|
52
pythonrewrite/plugins/date/unittests.py
Normal file
52
pythonrewrite/plugins/date/unittests.py
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
import WebInterfaceTestClass
|
||||||
|
|
||||||
|
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||||
|
|
||||||
|
def test_get_date(self):
|
||||||
|
date = self._getCurrentDate()
|
||||||
|
|
||||||
|
|
||||||
|
def test_change_date(self):
|
||||||
|
now = self._getCurrentDate()
|
||||||
|
## copy current time
|
||||||
|
new_date = dict(now)
|
||||||
|
## move three minutes forward (more is not nice because of screensavers)
|
||||||
|
new_date["minute"] = (now["minute"] + 3) % 60
|
||||||
|
## in case of minute-overflow we also have to move the hour a little bit forward
|
||||||
|
new_date["hour"] = now["hour"] + ((now["minute"] + 3) / 60)
|
||||||
|
## move forward ...
|
||||||
|
self._setDate(new_date)
|
||||||
|
self.assertEquals(new_date, self._getCurrentDate())
|
||||||
|
## ... and backward
|
||||||
|
self._setDate(now)
|
||||||
|
self.assertEquals(now, self._getCurrentDate())
|
||||||
|
|
||||||
|
|
||||||
|
def _getCurrentDate(self):
|
||||||
|
date_url = self.URL + "plugins/date"
|
||||||
|
self.register_auth(date_url)
|
||||||
|
self.cmd.go(date_url)
|
||||||
|
self.cmd.find("Data.Status.Plugins.date=([0-9]+/[0-9]+/[0-9]+/[0-9]+/[0-9]+/[0-9]+)$", "m")
|
||||||
|
dateNumbers = self.locals["__match__"].split("/")
|
||||||
|
self.assertEquals(len(dateNumbers), 6)
|
||||||
|
## we ignore seconds
|
||||||
|
dateField = {
|
||||||
|
"year" : int(dateNumbers[0]),
|
||||||
|
"month" : int(dateNumbers[1]),
|
||||||
|
"day" : int(dateNumbers[2]),
|
||||||
|
"hour" : int(dateNumbers[3]),
|
||||||
|
"minute" : int(dateNumbers[4])}
|
||||||
|
return dateField
|
||||||
|
|
||||||
|
|
||||||
|
def _setDate(self, date):
|
||||||
|
date_url = self.URL + "plugins/date"
|
||||||
|
self.register_auth(date_url)
|
||||||
|
self.cmd.go(date_url)
|
||||||
|
self.cmd.formvalue("set_date", "year", str(date["year"]))
|
||||||
|
self.cmd.formvalue("set_date", "month", str(date["month"]))
|
||||||
|
self.cmd.formvalue("set_date", "day", str(date["day"]))
|
||||||
|
self.cmd.formvalue("set_date", "hour", str(date["hour"]))
|
||||||
|
self.cmd.formvalue("set_date", "minute", str(date["minute"]))
|
||||||
|
self.cmd.submit()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import CryptoBoxPlugin
|
import CryptoBoxPlugin
|
||||||
|
from CryptoBoxExceptions import *
|
||||||
|
|
||||||
class format_fs(CryptoBoxPlugin.CryptoBoxPlugin):
|
class format_fs(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
<?cs else ?>
|
<?cs else ?>
|
||||||
|
|
||||||
<?cs call:print_form_header("plugins/format_fs") ?>
|
<?cs call:print_form_header("set_type", "plugins/format_fs") ?>
|
||||||
|
|
||||||
<p><label for="fs_type"><?cs var:html_escape(Lang.Plugins.format_fs.Text.FSType)
|
<p><label for="fs_type"><?cs var:html_escape(Lang.Plugins.format_fs.Text.FSType)
|
||||||
?>: </label><select name="fs_type" id="fs_type" size="0" ?>
|
?>: </label><select name="fs_type" id="fs_type" size="0" ?>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</div>
|
</div>
|
||||||
<?cs else ?>
|
<?cs else ?>
|
||||||
|
|
||||||
<?cs call:print_form_header("plugins/format_fs") ?>
|
<?cs call:print_form_header("set_luks", "plugins/format_fs") ?>
|
||||||
|
|
||||||
<p class="note"><?cs var:html_escape(Lang.Plugins.format_fs.Text.FormatWarning) ?></p>
|
<p class="note"><?cs var:html_escape(Lang.Plugins.format_fs.Text.FormatWarning) ?></p>
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@
|
||||||
var:html_escape(Lang.Plugins.format_fs.Text.Yes) ?><?cs else ?><?cs
|
var:html_escape(Lang.Plugins.format_fs.Text.Yes) ?><?cs else ?><?cs
|
||||||
var:html_escape(Lang.Plugins.format_fs.Text.No) ?><?cs /if ?></p>
|
var:html_escape(Lang.Plugins.format_fs.Text.No) ?><?cs /if ?></p>
|
||||||
|
|
||||||
<p><label for="crypto_password"><?cs var:html_escape(Lang.Text.EnterNewPassword) ?></label> <input type="password" id="crypto_password" name="crypto_password" /></p>
|
<p><label for="crypto_password"><?cs var:html_escape(Lang.Text.EnterNewPassword) ?>: </label> <input type="password" id="crypto_password" name="crypto_password" /></p>
|
||||||
<p><label for="crypto_password2"><?cs var:html_escape(Lang.Text.EnterSamePassword) ?></label> <input type="password" id="crypto_password2" name="crypto_password2" /></p>
|
<p><label for="crypto_password2"><?cs var:html_escape(Lang.Text.EnterSamePassword) ?>: </label> <input type="password" id="crypto_password2" name="crypto_password2" /></p>
|
||||||
<input type="hidden" name="device" value="<?cs var:Data.CurrentDisk.device ?>" />
|
<input type="hidden" name="device" value="<?cs var:Data.CurrentDisk.device ?>" />
|
||||||
<input type="hidden" name="fs_type" value="<?cs var:html_escape(Data.Plugins.format_fs.fs_type) ?>" />
|
<input type="hidden" name="fs_type" value="<?cs var:html_escape(Data.Plugins.format_fs.fs_type) ?>" />
|
||||||
<input type="hidden" name="container_type" value="<?cs var:html_escape(Data.Plugins.format_fs.container_type) ?>" />
|
<input type="hidden" name="container_type" value="<?cs var:html_escape(Data.Plugins.format_fs.container_type) ?>" />
|
||||||
|
|
21
pythonrewrite/plugins/logs/unittests.py
Normal file
21
pythonrewrite/plugins/logs/unittests.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import WebInterfaceTestClass
|
||||||
|
|
||||||
|
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||||
|
|
||||||
|
def test_read_logs(self):
|
||||||
|
log_url = self.URL + "plugins/logs"
|
||||||
|
self.register_auth(log_url)
|
||||||
|
self.cmd.go(log_url)
|
||||||
|
self.cmd.find('class="console"')
|
||||||
|
|
||||||
|
def test_write_logs(self):
|
||||||
|
## we have to assume two things:
|
||||||
|
## 1) log level is at least "error"
|
||||||
|
## 2) the log message does not get lost in a possible stream of log messages
|
||||||
|
log_text = "unittest - just a marker - please ignore"
|
||||||
|
self.cbox.log.error(log_text)
|
||||||
|
log_url = self.URL + "plugins/logs"
|
||||||
|
self.register_auth(log_url)
|
||||||
|
self.cmd.go(log_url)
|
||||||
|
self.cmd.find(log_text)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<h1><?cs var:html_escape(Lang.Plugins.network.Title.Network) ?></h1>
|
<h1><?cs var:html_escape(Lang.Plugins.network.Title.Network) ?></h1>
|
||||||
|
|
||||||
<?cs call:print_form_header("plugins/network") ?>
|
<?cs call:print_form_header("set_ip", "plugins/network") ?>
|
||||||
|
|
||||||
<p><label for="ip"><?cs var:html_escape(Lang.Plugins.network.Text.IP) ?>: </label>
|
<p><label for="ip"><?cs var:html_escape(Lang.Plugins.network.Text.IP) ?>: </label>
|
||||||
<input class="ipnum" type="text" tabindex="1" name="ip1" size="3" id="ip"
|
<input class="ipnum" type="text" tabindex="1" name="ip1" size="3" id="ip"
|
||||||
|
|
|
@ -2,9 +2,10 @@ import subprocess
|
||||||
import os
|
import os
|
||||||
import CryptoBoxPlugin
|
import CryptoBoxPlugin
|
||||||
|
|
||||||
|
|
||||||
## specify (in seconds), how long we should wait before redirecting and ip change
|
## specify (in seconds), how long we should wait before redirecting and ip change
|
||||||
REDIRECT_DELAY=20
|
REDIRECT_DELAY=20
|
||||||
CHANGE_IP_DELAY=5
|
CHANGE_IP_DELAY=1
|
||||||
|
|
||||||
class network(CryptoBoxPlugin.CryptoBoxPlugin):
|
class network(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||||
|
|
||||||
|
@ -14,10 +15,13 @@ class network(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||||
|
|
||||||
def doAction(self, store=None, redirected="", ip1="", ip2="", ip3="", ip4=""):
|
def doAction(self, store=None, redirected="", ip1="", ip2="", ip3="", ip4=""):
|
||||||
## if we were redirected, then we should display the default page
|
## if we were redirected, then we should display the default page
|
||||||
|
self.cbox.log.debug("executing network plugin")
|
||||||
if redirected == "1":
|
if redirected == "1":
|
||||||
|
self.cbox.log.debug("network plugin: redirected")
|
||||||
return None
|
return None
|
||||||
## request for IP change?
|
## request for IP change?
|
||||||
if store:
|
if store:
|
||||||
|
self.cbox.log.debug("network plugin: changing IP")
|
||||||
try:
|
try:
|
||||||
for ip_in in (ip1, ip2, ip3, ip4):
|
for ip_in in (ip1, ip2, ip3, ip4):
|
||||||
if (int(ip_in) < 0) or (int(ip_in) > 255):
|
if (int(ip_in) < 0) or (int(ip_in) > 255):
|
||||||
|
@ -39,6 +43,7 @@ class network(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||||
self.__prepareFormData()
|
self.__prepareFormData()
|
||||||
return "form_network"
|
return "form_network"
|
||||||
else:
|
else:
|
||||||
|
self.cbox.log.debug("network plugin: show form")
|
||||||
## just show the form
|
## just show the form
|
||||||
self.__prepareFormData()
|
self.__prepareFormData()
|
||||||
return "form_network"
|
return "form_network"
|
||||||
|
@ -48,11 +53,11 @@ class network(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||||
return "%d.%d.%d.%d" % self.__getCurrentIP()
|
return "%d.%d.%d.%d" % self.__getCurrentIP()
|
||||||
|
|
||||||
|
|
||||||
def __getRedirectDestionation(self, ip):
|
def __getRedirectDestination(self, ip):
|
||||||
import cherrypy
|
import cherrypy
|
||||||
req = cherrypy.request
|
req = cherrypy.request
|
||||||
dest = ip
|
|
||||||
base_parts = req.base.split(":")
|
base_parts = req.base.split(":")
|
||||||
|
dest = "%s:%s" % (base_parts[0], ip)
|
||||||
if len(base_parts) == 3:
|
if len(base_parts) == 3:
|
||||||
dest += ":%s" % base_parts[2]
|
dest += ":%s" % base_parts[2]
|
||||||
return dest
|
return dest
|
||||||
|
@ -97,6 +102,7 @@ class network(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||||
time.sleep(CHANGE_IP_DELAY)
|
time.sleep(CHANGE_IP_DELAY)
|
||||||
proc = subprocess.Popen(
|
proc = subprocess.Popen(
|
||||||
shell = False,
|
shell = False,
|
||||||
|
stderr = subprocess.PIPE,
|
||||||
args = [
|
args = [
|
||||||
self.cbox.prefs["Programs"]["super"],
|
self.cbox.prefs["Programs"]["super"],
|
||||||
self.cbox.prefs["Programs"]["CryptoBoxRootActions"],
|
self.cbox.prefs["Programs"]["CryptoBoxRootActions"],
|
||||||
|
@ -104,6 +110,9 @@ class network(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||||
os.path.join(self.pluginDir, "root_action.py"),
|
os.path.join(self.pluginDir, "root_action.py"),
|
||||||
ip])
|
ip])
|
||||||
proc.communicate()
|
proc.communicate()
|
||||||
|
if proc.returncode != 0:
|
||||||
|
self.cbox.log.warn("failed to change IP address: %s" % ip)
|
||||||
|
self.cbox.log.warn("error output: %s" % str(proc.stderr.read()))
|
||||||
return
|
return
|
||||||
thread = threading.Thread()
|
thread = threading.Thread()
|
||||||
thread.run = delayedIPchange
|
thread.run = delayedIPchange
|
||||||
|
@ -112,3 +121,5 @@ class network(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||||
# TODO: how could we guess, if it failed?
|
# TODO: how could we guess, if it failed?
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
45
pythonrewrite/plugins/network/unittests.py
Normal file
45
pythonrewrite/plugins/network/unittests.py
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
import WebInterfaceTestClass
|
||||||
|
from network import CHANGE_IP_DELAY
|
||||||
|
|
||||||
|
|
||||||
|
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||||
|
|
||||||
|
def atest_ip_change(self):
|
||||||
|
'''change of network address'''
|
||||||
|
## the time module is necessary for the CHANGE_IP_DELAY
|
||||||
|
import time
|
||||||
|
self.register_auth(self.URL + "plugins/network")
|
||||||
|
self.cmd.go(self.URL + "plugins/network")
|
||||||
|
## extract the current IP from the network plugin output
|
||||||
|
def getCurrentIP():
|
||||||
|
self.cmd.go(self.URL + "plugins/network")
|
||||||
|
self.cmd.show()
|
||||||
|
self.cmd.find(u'Data.Status.Plugins.network=([0-9\.]*)$', "m")
|
||||||
|
return self.locals["__match__"]
|
||||||
|
origIPtext = getCurrentIP()
|
||||||
|
origIPocts = origIPtext.split(".")
|
||||||
|
## check, if the original IP is valid (contains four octets)
|
||||||
|
self.assertEquals(4, len(origIPocts))
|
||||||
|
self.cmd.echo(origIPocts)
|
||||||
|
wrongIP = "192.168.123.321"
|
||||||
|
def setIP((ip1, ip2, ip3, ip4)):
|
||||||
|
self.cmd.go(self.URL + "plugins/network")
|
||||||
|
self.cmd.formvalue("set_ip", "ip1", str(ip1))
|
||||||
|
self.cmd.formvalue("set_ip", "ip2", str(ip2))
|
||||||
|
self.cmd.formvalue("set_ip", "ip3", str(ip3))
|
||||||
|
self.cmd.formvalue("set_ip", "ip4", str(ip4))
|
||||||
|
self.cmd.submit()
|
||||||
|
## sleep a little bit longer than the delay necessary for ip-change
|
||||||
|
time.sleep(CHANGE_IP_DELAY + 0.2)
|
||||||
|
setIP([1,-2,0,1])
|
||||||
|
self.assertEquals(origIPtext, getCurrentIP())
|
||||||
|
setIP([1,0,0,256])
|
||||||
|
self.assertEquals(origIPtext, getCurrentIP())
|
||||||
|
setIP([1,"foo",0,1])
|
||||||
|
self.assertEquals(origIPtext, getCurrentIP())
|
||||||
|
setIP([10,12,0,2])
|
||||||
|
self.assertEquals("10.12.0.2", getCurrentIP())
|
||||||
|
setIP(origIPocts)
|
||||||
|
self.assertEquals(origIPtext, getCurrentIP())
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<?cs if:subcount(Data.Plugins.partition.BlockDevices) > 0 ?>
|
<?cs if:subcount(Data.Plugins.partition.BlockDevices) > 0 ?>
|
||||||
|
|
||||||
<?cs call:print_form_header("plugins/partition") ?>
|
<?cs call:print_form_header("select_device", "plugins/partition") ?>
|
||||||
|
|
||||||
<p><label for="block_device"><?cs var:html_escape(Lang.Plugins.partition.Text.SelectDevice) ?>: </label><br/>
|
<p><label for="block_device"><?cs var:html_escape(Lang.Plugins.partition.Text.SelectDevice) ?>: </label><br/>
|
||||||
<select name="block_device" id="block_device" tabindex="1" size="0">
|
<select name="block_device" id="block_device" tabindex="1" size="0">
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<td><?cs var:Data.Plugins.partition.Parts[x].Size ?></td>
|
<td><?cs var:Data.Plugins.partition.Parts[x].Size ?></td>
|
||||||
<td><?cs var:Data.Plugins.partition.Parts[x].Type ?></td>
|
<td><?cs var:Data.Plugins.partition.Parts[x].Type ?></td>
|
||||||
<td>
|
<td>
|
||||||
<?cs call:print_form_header("plugins/partition") ?>
|
<?cs call:print_form_header("part_del_" + x, "plugins/partition") ?>
|
||||||
<?cs include:Settings.PluginDir + "/partition/current_partition_info.cs" ?>
|
<?cs include:Settings.PluginDir + "/partition/current_partition_info.cs" ?>
|
||||||
<input type="hidden" name="step" value="del_partition" />
|
<input type="hidden" name="step" value="del_partition" />
|
||||||
<input type="hidden" name="del_num" value="<?cs var:x ?>" />
|
<input type="hidden" name="del_num" value="<?cs var:x ?>" />
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
<?cs # new partition input if space is available ?>
|
<?cs # new partition input if space is available ?>
|
||||||
<?cs if:Data.Plugins.partition.availSize > 0 ?>
|
<?cs if:Data.Plugins.partition.availSize > 0 ?>
|
||||||
<tr>
|
<tr>
|
||||||
<?cs call:print_form_header("plugins/partition") ?>
|
<?cs call:print_form_header("part_add", "plugins/partition") ?>
|
||||||
<?cs include:Settings.PluginDir + "/partition/current_partition_info.cs" ?>
|
<?cs include:Settings.PluginDir + "/partition/current_partition_info.cs" ?>
|
||||||
<input type="hidden" name="step" value="add_partition" />
|
<input type="hidden" name="step" value="add_partition" />
|
||||||
<?cs set: x = subcount(Data.Plugins.partition.Parts) ?>
|
<?cs set: x = subcount(Data.Plugins.partition.Parts) ?>
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
<?cs var:html_escape(Lang.Plugins.partition.Text.WarningMessage) ?>
|
<?cs var:html_escape(Lang.Plugins.partition.Text.WarningMessage) ?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?cs call:print_form_header("plugins/partition") ?>
|
<?cs call:print_form_header("part_finish", "plugins/partition") ?>
|
||||||
<?cs include:Settings.PluginDir + "/partition/current_partition_info.cs" ?>
|
<?cs include:Settings.PluginDir + "/partition/current_partition_info.cs" ?>
|
||||||
<input type="hidden" name="step" value="finish" />
|
<input type="hidden" name="step" value="finish" />
|
||||||
<button type="submit"><?cs var:html_escape(Lang.Plugins.partition.Button.SavePartitions) ?></button>
|
<button type="submit"><?cs var:html_escape(Lang.Plugins.partition.Button.SavePartitions) ?></button>
|
||||||
|
|
|
@ -34,6 +34,8 @@ Python code interface:
|
||||||
- the class variable "enabled" is boolean and detemines the default availability of the plugin
|
- the class variable "enabled" is boolean and detemines the default availability of the plugin
|
||||||
- volume plugins contain the attribute "device" (you may trust this value - a volume plugin will
|
- volume plugins contain the attribute "device" (you may trust this value - a volume plugin will
|
||||||
never get called with an invalid device)
|
never get called with an invalid device)
|
||||||
|
- the python module which contains the plugin's class should also contain a class called
|
||||||
|
'unittests' - it should inherit WebInterfaceTestClass.WebInterfaceTestClass
|
||||||
|
|
||||||
|
|
||||||
Language file structure:
|
Language file structure:
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<h1><?cs var:html_escape(Lang.Plugins.plugin_manager.Title.PluginManager) ?></h1>
|
<h1><?cs var:html_escape(Lang.Plugins.plugin_manager.Title.PluginManager) ?></h1>
|
||||||
|
|
||||||
|
|
||||||
<?cs call:print_form_header("plugins/plugin_manager") ?>
|
<?cs call:print_form_header("manage_plugins", "plugins/plugin_manager") ?>
|
||||||
|
|
||||||
<h2><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.SystemPlugins) ?></h2>
|
<h2><?cs var:html_escape(Lang.Plugins.plugin_manager.Text.SystemPlugins) ?></h2>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -10,14 +10,14 @@
|
||||||
<table style="text-align:center; width:100%">
|
<table style="text-align:center; width:100%">
|
||||||
<tr>
|
<tr>
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
<?cs call:print_form_header("plugins/shutdown") ?>
|
<?cs call:print_form_header("reboot", "plugins/shutdown") ?>
|
||||||
<input type="hidden" name="type" value="reboot" />
|
<input type="hidden" name="type" value="reboot" />
|
||||||
<button type="submit" tabindex="2"><?cs var:html_escape(Lang.Plugins.shutdown.Button.Reboot) ?></button>
|
<button type="submit" tabindex="2"><?cs var:html_escape(Lang.Plugins.shutdown.Button.Reboot) ?></button>
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
<td style="width:5%"></td>
|
<td style="width:5%"></td>
|
||||||
<td style="text-align: left">
|
<td style="text-align: left">
|
||||||
<?cs call:print_form_header("plugins/shutdown") ?>
|
<?cs call:print_form_header("shutdown", "plugins/shutdown") ?>
|
||||||
<input type="hidden" name="type" value="shutdown" />
|
<input type="hidden" name="type" value="shutdown" />
|
||||||
<button type="submit" tabindex="1"><?cs var:html_escape(Lang.Plugins.shutdown.Button.Shutdown) ?></button>
|
<button type="submit" tabindex="1"><?cs var:html_escape(Lang.Plugins.shutdown.Button.Shutdown) ?></button>
|
||||||
</form>
|
</form>
|
||||||
|
|
11
pythonrewrite/plugins/shutdown/unittests.py
Normal file
11
pythonrewrite/plugins/shutdown/unittests.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import WebInterfaceTestClass
|
||||||
|
|
||||||
|
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||||
|
|
||||||
|
def test_read_form(self):
|
||||||
|
url = self.URL + "plugins/shutdown"
|
||||||
|
self.register_auth(url)
|
||||||
|
self.cmd.go(url)
|
||||||
|
self.cmd.find('<form name="shutdown"')
|
||||||
|
self.cmd.find('<form name="reboot"')
|
||||||
|
|
27
pythonrewrite/plugins/user_manager/unittests.py
Normal file
27
pythonrewrite/plugins/user_manager/unittests.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import WebInterfaceTestClass
|
||||||
|
|
||||||
|
## this user may not be removed
|
||||||
|
from user_manager import RESERVED_USERS
|
||||||
|
|
||||||
|
class unittests(WebInterfaceTestClass.WebInterfaceTestClass):
|
||||||
|
|
||||||
|
def test_read_users(self):
|
||||||
|
print self._getUsers()
|
||||||
|
#self.cmd.showforms()
|
||||||
|
|
||||||
|
|
||||||
|
def _addUser(self, user, password):
|
||||||
|
self._gotPage()
|
||||||
|
## TODO: finish
|
||||||
|
|
||||||
|
|
||||||
|
def _gotoPage(self):
|
||||||
|
url = self.URL + "plugins/user_manager"
|
||||||
|
self.register_auth(url)
|
||||||
|
self.cmd.go(url)
|
||||||
|
|
||||||
|
|
||||||
|
def _getUsers(self):
|
||||||
|
self._gotoPage()
|
||||||
|
self.cmd.find("Data.Status.Plugins.user_manager=([\w/]+)")
|
||||||
|
return self.locals["__match__"].split("/")
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
<h2><?cs var:html_escape(Lang.Plugins.user_manager.Title.AddUser) ?></h2>
|
<h2><?cs var:html_escape(Lang.Plugins.user_manager.Title.AddUser) ?></h2>
|
||||||
<p>
|
<p>
|
||||||
<?cs call:print_form_header("plugins/user_manager") ?>
|
<?cs call:print_form_header("add_user", "plugins/user_manager") ?>
|
||||||
<table>
|
<table>
|
||||||
<tr><td class="left_column">
|
<tr><td class="left_column">
|
||||||
<label for="new_user"><?cs var:html_escape(Lang.Plugins.user_manager.Text.NewUser) ?>:</label></td>
|
<label for="new_user"><?cs var:html_escape(Lang.Plugins.user_manager.Text.NewUser) ?>:</label></td>
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
<h2><?cs var:html_escape(Lang.Plugins.user_manager.Title.ChangePassword) ?></h2>
|
<h2><?cs var:html_escape(Lang.Plugins.user_manager.Title.ChangePassword) ?></h2>
|
||||||
<p>
|
<p>
|
||||||
<?cs call:print_form_header("plugins/user_manager") ?>
|
<?cs call:print_form_header("change_password", "plugins/user_manager") ?>
|
||||||
<table>
|
<table>
|
||||||
<tr><td class="left_column">
|
<tr><td class="left_column">
|
||||||
<label for="chpw_user"><?cs var:html_escape(Lang.Plugins.user_manager.Text.ChangePasswordUser) ?>:</label></td>
|
<label for="chpw_user"><?cs var:html_escape(Lang.Plugins.user_manager.Text.ChangePasswordUser) ?>:</label></td>
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
<h2><?cs var:html_escape(Lang.Plugins.user_manager.Title.DelUser) ?></h2>
|
<h2><?cs var:html_escape(Lang.Plugins.user_manager.Title.DelUser) ?></h2>
|
||||||
<p>
|
<p>
|
||||||
<table><tr><td class="left_column">
|
<table><tr><td class="left_column">
|
||||||
<?cs call:print_form_header("plugins/user_manager") ?>
|
<?cs call:print_form_header("del_user", "plugins/user_manager") ?>
|
||||||
<label for="user"><?cs var:html_escape(Lang.Plugins.user_manager.Text.DelUser) ?>: </label><select id="user" name="user" size="0">
|
<label for="user"><?cs var:html_escape(Lang.Plugins.user_manager.Text.DelUser) ?>: </label><select id="user" name="user" size="0">
|
||||||
<?cs each:x=Data.Plugins.user_manager.Users ?><?cs if:x != "admin" ?>
|
<?cs each:x=Data.Plugins.user_manager.Users ?><?cs if:x != "admin" ?>
|
||||||
<option><?cs var:html_escape(x) ?></option>
|
<option><?cs var:html_escape(x) ?></option>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import CryptoBoxPlugin
|
import CryptoBoxPlugin
|
||||||
|
|
||||||
|
RESERVED_USERS = [ "admin" ]
|
||||||
|
|
||||||
class user_manager(CryptoBoxPlugin.CryptoBoxPlugin):
|
class user_manager(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||||
|
|
||||||
|
@ -7,8 +8,6 @@ class user_manager(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||||
requestAuth = True
|
requestAuth = True
|
||||||
rank = 45
|
rank = 45
|
||||||
|
|
||||||
reservedUsers = [ "admin" ]
|
|
||||||
|
|
||||||
def doAction(self, store=None, user=None, new_pw=None, new_pw2=None):
|
def doAction(self, store=None, user=None, new_pw=None, new_pw2=None):
|
||||||
import re
|
import re
|
||||||
adminDict = self.cbox.prefs.userDB["admins"]
|
adminDict = self.cbox.prefs.userDB["admins"]
|
||||||
|
@ -46,7 +45,7 @@ class user_manager(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||||
else:
|
else:
|
||||||
self.cbox.log.info("user_manager: invalid user choosen (%s)" % str(user))
|
self.cbox.log.info("user_manager: invalid user choosen (%s)" % str(user))
|
||||||
elif store == "del_user":
|
elif store == "del_user":
|
||||||
if user in self.reservedUsers:
|
if user in RESERVED_USERS:
|
||||||
self.cbox.log.info("user_manager: tried to remove reserved user (%s)" % user)
|
self.cbox.log.info("user_manager: tried to remove reserved user (%s)" % user)
|
||||||
elif user in adminDict.keys():
|
elif user in adminDict.keys():
|
||||||
del adminDict[user]
|
del adminDict[user]
|
||||||
|
@ -64,7 +63,7 @@ class user_manager(CryptoBoxPlugin.CryptoBoxPlugin):
|
||||||
|
|
||||||
|
|
||||||
def getStatus(self):
|
def getStatus(self):
|
||||||
return str(self.cbox.prefs.userDB["admins"].keys())
|
return "/".join(self.cbox.prefs.userDB["admins"].keys())
|
||||||
|
|
||||||
|
|
||||||
def __cleanHDF(self):
|
def __cleanHDF(self):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<h2><?cs var:html_escape(Lang.Plugins.volume_mount.Title.Mount) ?></h2>
|
<h2><?cs var:html_escape(Lang.Plugins.volume_mount.Title.Mount) ?></h2>
|
||||||
|
|
||||||
<p><?cs call:print_form_header("plugins/volume_mount") ?>
|
<p><?cs call:print_form_header("mount", "plugins/volume_mount") ?>
|
||||||
<input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
<input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
||||||
<?cs if:Data.CurrentDisk.encryption ?>
|
<?cs if:Data.CurrentDisk.encryption ?>
|
||||||
<input type="hidden" name="action" value="mount_luks" />
|
<input type="hidden" name="action" value="mount_luks" />
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<h2><?cs var:html_escape(Lang.Plugins.volume_mount.Title.Umount) ?></h2>
|
<h2><?cs var:html_escape(Lang.Plugins.volume_mount.Title.Umount) ?></h2>
|
||||||
|
|
||||||
<?cs call:print_form_header("plugins/volume_mount") ?>
|
<?cs call:print_form_header("umount", "plugins/volume_mount") ?>
|
||||||
<p><input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
<p><input type="hidden" name="device" value="<?cs var:html_escape(Data.CurrentDisk.device) ?>" />
|
||||||
<input type="hidden" name="action" value="umount" />
|
<input type="hidden" name="action" value="umount" />
|
||||||
<button type="submit" tabindex="2"><?cs var:html_escape(Lang.Button.Umount) ?></button></p>
|
<button type="submit" tabindex="2"><?cs var:html_escape(Lang.Button.Umount) ?></button></p>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<tr><td colspan="3">
|
<tr><td colspan="3">
|
||||||
<h3><?cs var:html_escape(Lang.Plugins.volume_props.Title.ChangeVolumeName) ?></h3>
|
<h3><?cs var:html_escape(Lang.Plugins.volume_props.Title.ChangeVolumeName) ?></h3>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<?cs call:print_form_header("plugins/volume_props") ?><tr>
|
<?cs call:print_form_header("set_name", "plugins/volume_props") ?><tr>
|
||||||
<td align="right"><label for="vol_name"><?cs var:html_escape(Lang.Text.ContainerName) ?>: </label></td>
|
<td align="right"><label for="vol_name"><?cs var:html_escape(Lang.Text.ContainerName) ?>: </label></td>
|
||||||
<td><input type="text" name="vol_name" tabindex="10" size="15" id="vol_name" value="<?cs var:html_escape(Data.CurrentDisk.name) ?>" /></td>
|
<td><input type="text" name="vol_name" tabindex="10" size="15" id="vol_name" value="<?cs var:html_escape(Data.CurrentDisk.name) ?>" /></td>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
<tr><td colspan="3">
|
<tr><td colspan="3">
|
||||||
<h3><?cs var:html_escape(Lang.Plugins.volume_props.Title.ChangePassword) ?></h3>
|
<h3><?cs var:html_escape(Lang.Plugins.volume_props.Title.ChangePassword) ?></h3>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<?cs call:print_form_header("plugins/volume_props") ?>
|
<?cs call:print_form_header("set_password", "plugins/volume_props") ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="right"><label for="old_pw"><?cs var:html_escape(Lang.Text.EnterCurrentPassword) ?>: </label></td>
|
<td align="right"><label for="old_pw"><?cs var:html_escape(Lang.Text.EnterCurrentPassword) ?>: </label></td>
|
||||||
<td><input type="password" name="old_pw" tabindex="20" size="15" id="old_pw" /></td>
|
<td><input type="password" name="old_pw" tabindex="20" size="15" id="old_pw" /></td>
|
||||||
|
|
Loading…
Reference in a new issue