summaryrefslogtreecommitdiffstats
path: root/commands/storage/test
diff options
context:
space:
mode:
authorJan Safranek <jsafrane@redhat.com>2014-02-18 13:48:26 +0100
committerJan Safranek <jsafrane@redhat.com>2014-02-18 13:48:26 +0100
commit8f3a6a5c0985a4367b9730b6dc9ad68f88db9fb8 (patch)
treee4a762034d42e6b58e22876ef2650b355d519e38 /commands/storage/test
parentbb2ad503bb978b53cbf8e423750977d40ff4eaf4 (diff)
downloadopenlmi-scripts-8f3a6a5c0985a4367b9730b6dc9ad68f88db9fb8.tar.gz
openlmi-scripts-8f3a6a5c0985a4367b9730b6dc9ad68f88db9fb8.tar.xz
openlmi-scripts-8f3a6a5c0985a4367b9730b6dc9ad68f88db9fb8.zip
Add LUKS scripts.
Diffstat (limited to 'commands/storage/test')
-rw-r--r--commands/storage/test/lmi/test_luks.sh100
1 files changed, 100 insertions, 0 deletions
diff --git a/commands/storage/test/lmi/test_luks.sh b/commands/storage/test/lmi/test_luks.sh
new file mode 100644
index 0000000..1e1be7e
--- /dev/null
+++ b/commands/storage/test/lmi/test_luks.sh
@@ -0,0 +1,100 @@
+#!/bin/bash
+#
+# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# The views and conclusions contained in the software and documentation are
+# those of the authors and should not be interpreted as representing official
+# policies, either expressed or implied, of the FreeBSD Project.
+#
+# Authors: Jan Safranek <jsafrane@redhat.com>
+
+
+# 'lmi storage luks' test.
+
+. ./base.sh
+
+rlJournalStart
+
+part=${PARTITIONS[0]}
+pw="heslo"
+
+rlPhaseStartTest "Create LUKS"
+ rlRun "$LMI storage luks create $part -p $pw"
+ rlRun -s "file -s $part"
+ rlAssertGrep "LUKS encrypted file" $rlRun_LOG
+ rm $rlRun_LOG
+rlPhaseEnd
+
+rlPhaseStartTest "Open and close LUKS"
+ rlRun -s "$LMI -N -H -L csv storage luks list"
+ rlAssertGrep "\"$part\",\"\"" $rlRun_LOG
+ rm $rlRun_LOG
+
+ rlAssertNotExists "/dev/mapper/mydev"
+ rlRun "$LMI storage luks open $part mydev -p $pw"
+ rlAssertExists "/dev/mapper/mydev"
+
+ rlRun -s "$LMI -N -H -L csv storage luks list"
+ rlAssertGrep "\"$part\",\"/dev/mapper/mydev\"" $rlRun_LOG
+ rm $rlRun_LOG
+
+ rlRun "$LMI storage luks close $part"
+ rlAssertNotExists "/dev/mapper/mydev"
+
+ rlRun -s "$LMI -N -H -L csv storage luks list"
+ rlAssertGrep "\"$part\",\"\"" $rlRun_LOG
+ rm $rlRun_LOG
+rlPhaseEnd
+
+rlPhaseStartTest "Add and remove passphrase"
+ oldpw=$pw
+ rlLogInfo "Add 7 passwords (=together with the initial one = 8 passwords)"
+ for i in `seq 7`; do
+ newpw=$pw$i
+ rlLogInfo "Add password $newpw using $oldpw"
+ # this also checks that addpass in the previous loop was successfull
+ # and the password was really added
+ rlRun "$LMI storage luks addpass $part -p $oldpw -n $newpw"
+ oldpw=$newpw
+ done
+
+ rlLogInfo "Adding 9th password -> error"
+ rlRun "$LMI storage luks addpass $part -p $oldpw -n ${pw}999" 1
+
+ oldpw=$pw
+ for i in `seq 7 | tac`; do
+ newpw=$pw$i
+ rlRun "$LMI storage luks deletepass $part -p $newpw"
+ rlLogInfo "Checking the old password cannot be used"
+ rlRun "$LMI storage luks open $part mydev -p $newpw" 1
+ done
+rlPhaseEnd
+
+rlPhaseStartCleanup
+ rlLogInfo "remove the luks format"
+ rlRun "$LMI storage fs delete $part"
+rlPhaseEnd
+
+rlJournalPrintText
+rlJournalEnd