aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_import/zpool_import_encrypted.ksh
blob: 4e9013afeb147d87f2c868569a595c8a63d754dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/ksh -p
#
# CDDL HEADER START
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# CDDL HEADER END
#

#
# Copyright (c) 2017 Datto, Inc. All rights reserved.
#

. $STF_SUITE/include/libtest.shlib
. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.cfg
. $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib

#
# DESCRIPTION:
# 'zpool import' should import a pool with an encrypted dataset without
# mounting it.
#
# STRATEGY:
# 1. Create an encrypted pool
# 2. Export the pool
# 3. Attempt to import the pool
# 4. Verify the pool exists and the key is not loaded
#

verify_runnable "both"

function cleanup
{
	destroy_pool $TESTPOOL1
	log_must rm $VDEV0
	log_must mkfile $FILE_SIZE $VDEV0
}
log_onexit cleanup

log_assert "'zpool import' should import a pool with an encrypted dataset" \
	"without mounting it"

log_must eval "echo $PASSPHRASE | zpool create -O encryption=on" \
	"-O keyformat=passphrase -O keylocation=prompt $TESTPOOL1 $VDEV0"
log_must zpool export $TESTPOOL1
log_must zpool import -d $DEVICE_DIR $TESTPOOL1
log_must poolexists $TESTPOOL1
log_must key_unavailable $TESTPOOL1
log_must unmounted $TESTPOOL1

log_pass "'zpool import' imports a pool with an encrypted dataset without" \
	"mounting it"