1*eb633035STom Caputi#!/bin/ksh -p 2*eb633035STom Caputi# 3*eb633035STom Caputi# CDDL HEADER START 4*eb633035STom Caputi# 5*eb633035STom Caputi# This file and its contents are supplied under the terms of the 6*eb633035STom Caputi# Common Development and Distribution License ("CDDL"), version 1.0. 7*eb633035STom Caputi# You may only use this file in accordance with the terms of version 8*eb633035STom Caputi# 1.0 of the CDDL. 9*eb633035STom Caputi# 10*eb633035STom Caputi# A full copy of the text of the CDDL should have accompanied this 11*eb633035STom Caputi# source. A copy of the CDDL is also available via the Internet at 12*eb633035STom Caputi# http://www.illumos.org/license/CDDL. 13*eb633035STom Caputi# 14*eb633035STom Caputi# CDDL HEADER END 15*eb633035STom Caputi# 16*eb633035STom Caputi 17*eb633035STom Caputi# 18*eb633035STom Caputi# Copyright (c) 2017 Datto, Inc. All rights reserved. 19*eb633035STom Caputi# 20*eb633035STom Caputi 21*eb633035STom Caputi. $STF_SUITE/include/libtest.shlib 22*eb633035STom Caputi. $STF_SUITE/tests/functional/cli_root/zpool_import/zpool_import.cfg 23*eb633035STom Caputi. $STF_SUITE/tests/functional/cli_root/zfs_load-key/zfs_load-key_common.kshlib 24*eb633035STom Caputi 25*eb633035STom Caputi# 26*eb633035STom Caputi# DESCRIPTION: 27*eb633035STom Caputi# 'zpool import -l' should import a pool with an encrypted dataset and load 28*eb633035STom Caputi# its key. 29*eb633035STom Caputi# 30*eb633035STom Caputi# STRATEGY: 31*eb633035STom Caputi# 1. Create an encrypted pool 32*eb633035STom Caputi# 2. Export the pool 33*eb633035STom Caputi# 3. Attempt to import the pool with the key 34*eb633035STom Caputi# 4. Verify the pool exists and the key is loaded 35*eb633035STom Caputi# 36*eb633035STom Caputi 37*eb633035STom Caputiverify_runnable "both" 38*eb633035STom Caputi 39*eb633035STom Caputifunction cleanup 40*eb633035STom Caputi{ 41*eb633035STom Caputi destroy_pool $TESTPOOL1 42*eb633035STom Caputi log_must rm $VDEV0 43*eb633035STom Caputi log_must mkfile $FILE_SIZE $VDEV0 44*eb633035STom Caputi} 45*eb633035STom Caputilog_onexit cleanup 46*eb633035STom Caputi 47*eb633035STom Caputilog_assert "'zpool import -l' should import a pool with an encrypted dataset" \ 48*eb633035STom Caputi "and load its key" 49*eb633035STom Caputi 50*eb633035STom Caputilog_must eval "echo $PASSPHRASE | zpool create -O encryption=on" \ 51*eb633035STom Caputi "-O keyformat=passphrase -O keylocation=prompt $TESTPOOL1 $VDEV0" 52*eb633035STom Caputilog_must zpool export $TESTPOOL1 53*eb633035STom Caputilog_must eval "echo $PASSPHRASE | zpool import -l -d $DEVICE_DIR $TESTPOOL1" 54*eb633035STom Caputilog_must poolexists $TESTPOOL1 55*eb633035STom Caputilog_must key_available $TESTPOOL1 56*eb633035STom Caputilog_must mounted $TESTPOOL1 57*eb633035STom Caputi 58*eb633035STom Caputilog_pass "'zpool import -l' imports a pool with an encrypted dataset and" \ 59*eb633035STom Caputi "loads its key" 60