2012-06-21 13:28:21 +09:30
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Tests for Serval DNA server operations.
|
|
|
|
#
|
2013-02-06 18:55:31 +10:30
|
|
|
# Copyright 2012 Serval Project, Inc.
|
2012-06-21 13:28:21 +09:30
|
|
|
#
|
|
|
|
# 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"
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
2012-09-17 15:30:05 +09:30
|
|
|
foreach_instance +A +B create_single_identity
|
2013-12-13 17:48:58 +10:30
|
|
|
configure_servald_server() { add_servald_interface; set_server_vars; }
|
2012-07-04 14:12:36 +09:30
|
|
|
start_servald_instances +A +B
|
|
|
|
set_instance +A
|
2012-06-21 13:28:21 +09:30
|
|
|
}
|
|
|
|
|
2012-10-18 11:46:32 +10:30
|
|
|
finally() {
|
2012-06-26 16:44:34 +09:30
|
|
|
stop_all_servald_servers
|
2012-10-18 11:46:32 +10:30
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
2012-06-21 13:28:21 +09:30
|
|
|
kill_all_servald_processes
|
|
|
|
assert_no_servald_processes
|
2012-10-18 11:46:32 +10:30
|
|
|
report_all_servald_servers
|
2012-06-21 13:28:21 +09:30
|
|
|
}
|
|
|
|
|
2012-08-02 17:18:04 +09:30
|
|
|
set_server_vars() {
|
2012-12-06 12:31:19 +10:30
|
|
|
executeOk_servald config \
|
2013-04-05 16:55:14 +10:30
|
|
|
set log.console.level debug \
|
|
|
|
set log.console.show_pid on \
|
|
|
|
set log.console.show_time on \
|
2012-12-11 09:56:21 +10:30
|
|
|
set rhizome.enable No \
|
2012-12-06 12:31:19 +10:30
|
|
|
set debug.mdprequests Yes \
|
2013-12-16 14:54:16 +10:30
|
|
|
set debug.keyring Yes \
|
|
|
|
set debug.linkstate Yes
|
2012-06-21 15:04:34 +09:30
|
|
|
}
|
|
|
|
|
2012-07-02 14:44:11 +09:30
|
|
|
doc_LookupWildcard="Lookup by wildcard"
|
|
|
|
test_LookupWildcard() {
|
2012-06-21 13:43:28 +09:30
|
|
|
executeOk_servald dna lookup "*"
|
2014-02-19 15:35:08 +10:30
|
|
|
assertStdoutLineCount '==' 4
|
2012-09-21 15:17:56 +09:30
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDA/local/$DIDA:$DIDA:$NAMEA\$"
|
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDB/local/$DIDB:$DIDB:$NAMEB\$"
|
2012-06-21 13:28:21 +09:30
|
|
|
}
|
|
|
|
|
2012-07-02 14:44:11 +09:30
|
|
|
doc_LookupEmpty="Lookup by empty string"
|
|
|
|
test_LookupEmpty() {
|
2012-06-21 13:43:28 +09:30
|
|
|
executeOk_servald dna lookup ""
|
2014-02-19 15:35:08 +10:30
|
|
|
assertStdoutLineCount '==' 4
|
2012-10-05 17:45:30 +09:30
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDA/local/$DIDA:$DIDA:$NAMEA\$"
|
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDB/local/$DIDB:$DIDB:$NAMEB\$"
|
2012-06-21 13:43:28 +09:30
|
|
|
}
|
|
|
|
|
2012-08-06 16:45:07 +09:30
|
|
|
doc_LookupNonExistent="Lookup non-existent phone number"
|
|
|
|
test_LookupNonExistent() {
|
2012-06-21 16:08:39 +09:30
|
|
|
executeOk_servald dna lookup "5551234"
|
2014-02-19 15:35:08 +10:30
|
|
|
assertStdoutLineCount '==' 2
|
2012-08-06 16:45:07 +09:30
|
|
|
}
|
|
|
|
|
|
|
|
doc_LookupLocal="Lookup local phone number"
|
|
|
|
test_LookupLocal() {
|
2012-08-02 15:46:53 +09:30
|
|
|
executeOk_servald dna lookup "$DIDA"
|
2014-02-19 15:35:08 +10:30
|
|
|
assertStdoutLineCount '==' 3
|
2012-10-05 17:45:30 +09:30
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDA/local/$DIDA:$DIDA:$NAMEA\$"
|
2012-08-06 16:45:07 +09:30
|
|
|
}
|
|
|
|
|
|
|
|
doc_LookupRemote="Lookup remote phone number"
|
|
|
|
test_LookupRemote() {
|
2012-08-02 15:46:53 +09:30
|
|
|
executeOk_servald dna lookup "$DIDB"
|
2014-02-19 15:35:08 +10:30
|
|
|
assertStdoutLineCount '==' 3
|
2012-10-05 17:45:30 +09:30
|
|
|
assertStdoutGrep --matches=1 "^sid://$SIDB/local/$DIDB:$DIDB:$NAMEB\$"
|
2012-06-21 16:08:39 +09:30
|
|
|
}
|
2012-06-21 13:43:28 +09:30
|
|
|
|
2012-11-14 11:49:03 +10:30
|
|
|
doc_ReverseLookup="Resolve a remote identity"
|
|
|
|
test_ReverseLookup() {
|
|
|
|
executeOk_servald reverse lookup $SIDB
|
|
|
|
assertStdoutGrep --matches=1 ":$DIDB"
|
|
|
|
assertStdoutGrep --matches=1 ":$NAMEB"
|
|
|
|
}
|
|
|
|
|
2012-08-06 16:45:07 +09:30
|
|
|
setup_multi_helper() {
|
2012-08-02 17:18:04 +09:30
|
|
|
setup_servald
|
|
|
|
assert_no_servald_processes
|
|
|
|
dnahelper="$TFWTMP/dnahelper"
|
2012-09-27 16:50:29 +09:30
|
|
|
echo "#!$BASH" >"$dnahelper"
|
|
|
|
cat >>"$dnahelper" <<'EOF'
|
2012-08-02 17:18:04 +09:30
|
|
|
echo STARTED
|
|
|
|
while read line
|
|
|
|
do
|
|
|
|
token="${line%%|*}"
|
|
|
|
case "$1:$line" in
|
2012-08-06 16:45:07 +09:30
|
|
|
A:*'|00003|') echo "$token|uri:A1|00003|Name One|";;
|
2012-08-02 17:18:04 +09:30
|
|
|
A:*'|00002|') echo "$token|uri:A2|00002|Name Two|";;
|
2012-08-06 16:45:07 +09:30
|
|
|
B:*'|00003|') echo "$token|uri:B1|00003|Name Three|";;
|
2012-08-02 17:18:04 +09:30
|
|
|
B:*'|00002|') echo "$token|uri:B2|00002|Name Four|";;
|
2012-08-06 16:45:07 +09:30
|
|
|
B:*'|00001|') echo "$token|uri:B3|00001|Name Five|";;
|
|
|
|
C:*'|00003|') echo "$token|uri:C1|00003|Name Six|";;
|
2012-08-02 17:18:04 +09:30
|
|
|
esac
|
|
|
|
echo DONE
|
|
|
|
done
|
|
|
|
EOF
|
|
|
|
chmod 0755 "$dnahelper"
|
2012-09-17 15:30:05 +09:30
|
|
|
foreach_instance +A +B +C +D create_single_identity
|
2012-08-02 17:18:04 +09:30
|
|
|
configure_servald_server() {
|
2013-12-13 17:48:58 +10:30
|
|
|
add_servald_interface
|
2012-08-02 17:18:04 +09:30
|
|
|
set_server_vars
|
2012-12-06 12:31:19 +10:30
|
|
|
executeOk_servald config \
|
|
|
|
set debug.dnahelper on \
|
|
|
|
set dna.helper.executable "$dnahelper" \
|
|
|
|
set dna.helper.argv.1 "$instance_name"
|
2012-08-02 17:18:04 +09:30
|
|
|
}
|
|
|
|
start_servald_instances +A +B +C +D
|
|
|
|
set_instance +D
|
|
|
|
}
|
2012-08-06 16:45:07 +09:30
|
|
|
|
|
|
|
doc_MultiLookupHelperThree="Lookup phone number three nodes reply"
|
|
|
|
setup_MultiLookupHelperThree() {
|
|
|
|
setup_multi_helper
|
|
|
|
}
|
|
|
|
test_MultiLookupHelperThree() {
|
|
|
|
executeOk_servald dna lookup 00003
|
2014-02-19 15:35:08 +10:30
|
|
|
assertStdoutLineCount '==' 5
|
2012-08-06 16:45:07 +09:30
|
|
|
assertStdoutGrep --matches=1 "uri:A1:00003:Name One$"
|
|
|
|
assertStdoutGrep --matches=1 "uri:B1:00003:Name Three$"
|
|
|
|
assertStdoutGrep --matches=1 "uri:C1:00003:Name Six$"
|
|
|
|
}
|
|
|
|
|
|
|
|
doc_MultiLookupHelperTwo="Lookup phone number two nodes reply"
|
|
|
|
setup_MultiLookupHelperTwo() {
|
|
|
|
setup_multi_helper
|
|
|
|
}
|
|
|
|
test_MultiLookupHelperTwo() {
|
2012-08-02 17:18:04 +09:30
|
|
|
executeOk_servald dna lookup 00002
|
2014-02-19 15:35:08 +10:30
|
|
|
assertStdoutLineCount '==' 4
|
2012-10-05 17:45:30 +09:30
|
|
|
assertStdoutGrep --matches=1 "uri:A2:00002:Name Two\$"
|
|
|
|
assertStdoutGrep --matches=1 "uri:B2:00002:Name Four\$"
|
2012-08-06 16:45:07 +09:30
|
|
|
}
|
|
|
|
|
|
|
|
doc_MultiLookupHelperOne="Lookup phone number one node replies"
|
|
|
|
setup_MultiLookupHelperOne() {
|
|
|
|
setup_multi_helper
|
|
|
|
}
|
|
|
|
test_MultiLookupHelperOne() {
|
|
|
|
executeOk_servald dna lookup 00001
|
2014-02-19 15:35:08 +10:30
|
|
|
assertStdoutLineCount '==' 3
|
2012-10-05 17:45:30 +09:30
|
|
|
assertStdoutGrep --matches=1 "uri:B3:00001:Name Five\$"
|
2012-08-02 17:18:04 +09:30
|
|
|
}
|
|
|
|
|
2012-06-21 13:28:21 +09:30
|
|
|
runTests "$@"
|