]> www.infradead.org Git - users/hch/blktests.git/commitdiff
nvme/041: create authenticated connections
authorHannes Reinecke <hare@suse.de>
Thu, 30 Sep 2021 12:19:30 +0000 (14:19 +0200)
committerHannes Reinecke <hare@suse.com>
Wed, 20 Jul 2022 14:42:43 +0000 (16:42 +0200)
Signed-off-by: Hannes Reinecke <hare@suse.de>
tests/nvme/041 [new file with mode: 0755]
tests/nvme/041.out [new file with mode: 0644]

diff --git a/tests/nvme/041 b/tests/nvme/041
new file mode 100755 (executable)
index 0000000..98c443e
--- /dev/null
@@ -0,0 +1,82 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2022 Hannes Reinecke, SUSE Labs
+#
+# Create authenticated connections
+
+. tests/nvme/rc
+
+DESCRIPTION="Create authenticated connections"
+QUICK=1
+
+requires() {
+       _nvme_requires
+       _have_loop
+       _have_kernel_option NVME_AUTH
+       _have_kernel_option NVME_TARGET_AUTH
+       _require_nvme_trtype_is_fabrics
+       _require_nvme_cli_auth
+}
+
+
+test() {
+       local port
+       local subsys_name="blktests-subsystem-1"
+       local hostid
+       local hostnqn="nqn.2014-08.org.nvmexpress:uuid:${hostid}"
+       local file_path="${TMPDIR}/img"
+       local hostkey
+       local ctrldev
+
+       echo "Running ${TEST_NAME}"
+
+       hostid="$(uuidgen)"
+       if [ -z "$hostid" ] ; then
+               echo "uuidgen failed"
+               return 1
+       fi
+       hostkey="$(nvme gen-dhchap-key -n ${subsys_name} 2> /dev/null)"
+       if [ -z "$hostkey" ] ; then
+               echo "nvme gen-dhchap-key failed"
+               return 1
+       fi
+
+       _setup_nvmet
+
+       truncate -s 512M "${file_path}"
+
+       _create_nvmet_subsystem "${subsys_name}" "${file_path}" \
+               "b92842df-a394-44b1-84a4-92ae7d112861"
+       port="$(_create_nvmet_port "${nvme_trtype}")"
+       _add_nvmet_subsys_to_port "${port}" "${subsys_name}"
+       _create_nvmet_host "${subsys_name}" "${hostnqn}" "${hostkey}"
+
+       # Test unauthenticated connection (should fail)
+       echo "Test unauthenticated connection (should fail)"
+       _nvme_connect_subsys "${nvme_trtype}" "${subsys_name}" \
+                            "${def_traddr}" "${def_trsvcid}" \
+                            "${hostnqn}" "${hostid}"
+
+       _nvme_disconnect_subsys "${subsys_name}"
+
+       # Test authenticated connection
+       echo "Test authenticated connection"
+       _nvme_connect_subsys "${nvme_trtype}" "${subsys_name}" \
+                            "${def_traddr}" "${def_trsvcid}" \
+                            "${hostnqn}" "${hostid}" "${hostkey}"
+
+       udevadm settle
+
+       _nvme_disconnect_subsys "${subsys_name}"
+
+       _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
+       _remove_nvmet_subsystem "${subsys_name}"
+
+       _remove_nvmet_port "${port}"
+
+       _remove_nvmet_host "${hostnqn}"
+
+       rm "${file_path}"
+
+       echo "Test complete"
+}
diff --git a/tests/nvme/041.out b/tests/nvme/041.out
new file mode 100644 (file)
index 0000000..35aaf58
--- /dev/null
@@ -0,0 +1,7 @@
+Running nvme/041
+Test unauthenticated connection (should fail)
+no controller found: failed to write to nvme-fabrics device
+NQN:blktests-subsystem-1 disconnected 0 controller(s)
+Test authenticated connection
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Test complete