serval-dna/tests/keyring
Andrew Bettison f66a894a63 Improve keyring PIN handling
Replace explicit [<pin,pin...>] command-line arguments with --entry-pin=<pin>
options.  Update test scripts accordlingly.

Add --keyring-pin=<pin> option (with one test case).
2013-02-13 16:49:52 +10:30

103 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
# Stress tests for Serval rhizome protocol.
#
# Copyright 2012 Serval Project, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
source "${0%/*}/../testframework.sh"
source "${0%/*}/../testdefs.sh"
shopt -s extglob
setup() {
setup_servald
}
assert_keyring_list() {
assertStdoutLineCount --stdout --stderr '==' $1
tfw_cat --stdout
}
doc_KeyringCreate="Create keyring destroys existing keys"
test_KeyringCreate() {
executeOk_servald keyring add ''
executeOk_servald keyring add ''
executeOk_servald keyring list
assert_keyring_list 2
executeOk_servald keyring create
assert_keyring_list 0
}
doc_Pinless="No keyring PIN with PIN-less identities"
test_Pinless() {
executeOk_servald keyring add ''
executeOk_servald keyring list
assert_keyring_list 1
executeOk_servald keyring add ''
executeOk_servald keyring list
assert_keyring_list 2
executeOk_servald keyring add ''
executeOk_servald keyring list
assert_keyring_list 3
}
doc_IdentityPins="No keyring PIN with identity PINs"
test_IdentityPins() {
executeOk_servald keyring add 'one'
executeOk_servald keyring list
assert_keyring_list 0
executeOk_servald keyring list --entry-pin 'one'
assert_keyring_list 1
executeOk_servald keyring add 'two'
executeOk_servald keyring list
assert_keyring_list 0
executeOk_servald keyring list --entry-pin 'one'
assert_keyring_list 1
executeOk_servald keyring list --entry-pin 'one' --entry-pin 'two'
assert_keyring_list 2
executeOk_servald keyring add 'three'
executeOk_servald keyring list
assert_keyring_list 0
executeOk_servald keyring list --entry-pin 'one'
assert_keyring_list 1
executeOk_servald keyring list --entry-pin 'one' --entry-pin 'two'
assert_keyring_list 2
executeOk_servald keyring list --entry-pin 'one' --entry-pin 'two' --entry-pin 'three'
assert_keyring_list 3
executeOk_servald keyring list --entry-pin 'two' --entry-pin 'three'
assert_keyring_list 2
executeOk_servald keyring list --entry-pin 'three'
assert_keyring_list 1
}
doc_KeyringPinIdentityPinless="Keyring PIN with PIN-less identities"
test_KeyringPinIdentityPinless() {
executeOk_servald keyring add --keyring-pin=hello ''
executeOk_servald keyring list --keyring-pin=hello
assert_keyring_list 1
executeOk_servald keyring add --keyring-pin=hello ''
executeOk_servald keyring list --keyring-pin=hello
assert_keyring_list 2
executeOk_servald keyring add --keyring-pin=hello ''
executeOk_servald keyring list --keyring-pin=hello
assert_keyring_list 3
executeOk_servald keyring list
assert_keyring_list 0
}
runTests "$@"