mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-20 21:53:12 +00:00
Fix a failing keyringrestful test
The recent randomising of keyring slots broke an assumption about the order of the 'keyring list' output. Now the test's assertions do not assume any order.
This commit is contained in:
parent
f615a1deca
commit
298b83f97b
10
testdefs.sh
10
testdefs.sh
@ -716,6 +716,9 @@ create_single_identity() {
|
||||
# - set variables SID{I}{1..N} to SIDs of identities, eg, SIDA1, SIDA2...
|
||||
# - set variables DID{I}{1..N} to DIDs of identities, eg, DIDA1, DIDA2...
|
||||
# - set variables NAME{I}{1..N} to names of identities, eg, NAMEA1, NAMEA2...
|
||||
# - set array variable SID{I} to SIDs of identities, eg, SIDA[0], SIDA[1]...
|
||||
# - set array variable DID{I} to DIDs of identities, eg, DIDA[0], DIDA[1]...
|
||||
# - set array variable NAME{I} to names of identities, eg, NAMEA[0], NAMEA[1]...
|
||||
create_identities() {
|
||||
local servald_options=()
|
||||
while [ $# -gt 0 ]; do
|
||||
@ -742,6 +745,9 @@ create_identities() {
|
||||
local idvar=ID$instance_name$i
|
||||
local didvar=DID$instance_name$i
|
||||
local namevar=NAME$instance_name$i
|
||||
local sidarrayvar=SID$instance_name
|
||||
local didarrayvar=DID$instance_name
|
||||
local namearrayvar=NAME$instance_name
|
||||
local pin="${!pinvar}"
|
||||
[ -n "$pin" ] && tfw_log "$pinvar=$(shellarg "$pin")"
|
||||
executeOk_servald keyring add "${servald_options[@]}" "$pin"
|
||||
@ -762,6 +768,10 @@ create_identities() {
|
||||
extract_stdout_keyvalue_optional $didvar did "$rexp_did"
|
||||
extract_stdout_keyvalue_optional $namevar name ".*"
|
||||
fi
|
||||
let a=i-1
|
||||
eval "$sidarrayvar[$a]=\${!sidvar}"
|
||||
eval "$didarrayvar[$a]=\${!didvar}"
|
||||
eval "$namearrayvar[$a]=\${!namevar}"
|
||||
done
|
||||
for ((i = 1; i <= N; ++i)); do
|
||||
for ((j = 1; j <= N; ++j)); do
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
# Tests for Serval DNA HTTP RESTful interface
|
||||
#
|
||||
# Copyright 2013-2014 Serval Project, Inc.
|
||||
# Copyright 2013-2015 Serval Project, Inc.
|
||||
# Copyright 2016 Flinders Univerity
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
@ -82,13 +83,10 @@ test_keyringList() {
|
||||
tfw_cat http.headers list.json
|
||||
tfw_preserve list.json
|
||||
assert [ "$(jq '.rows | length' list.json)" = $IDENTITY_COUNT ]
|
||||
# TODO: these tests only work because the listed order of identities is the
|
||||
# order of creation, which makes locked identities easy to attack. When the
|
||||
# random search TODO in keyring.c:find_free_slot() is done, then these tests
|
||||
# should fail.
|
||||
assert [ "$(jq -r '.rows[0][0]' list.json)" = $SIDA1 ]
|
||||
assert [ "$(jq -r '.rows[4][0]' list.json)" = $SIDA5 ]
|
||||
assert [ "$(jq -r '.rows[9][0]' list.json)" = $SIDA10 ]
|
||||
# All SIDs are present in the list.
|
||||
for SID in ${SIDA[*]}; do
|
||||
assert [ "$(jq -r '.rows | contains([["'"$SID"'"]])' list.json)" = true ]
|
||||
done
|
||||
}
|
||||
|
||||
doc_keyringListPin="HTTP RESTful list keyring identities as JSON, with PIN"
|
||||
|
Loading…
Reference in New Issue
Block a user