2013-11-08 10:32:12 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
if [ "x$DB" = "xmysql" ]; then
|
|
|
|
dbuser=travis
|
|
|
|
|
|
|
|
mysql -u $dbuser -e 'create database ykval;'
|
|
|
|
mysql -u $dbuser ykval < ykval-db.sql
|
|
|
|
elif [ "x$DB" = "xpgsql" ]; then
|
|
|
|
dbuser=postgres
|
|
|
|
|
|
|
|
psql -U $dbuser -c 'create database ykval;'
|
|
|
|
psql -U $dbuser ykval < ykval-db.sql
|
|
|
|
elif [ "x$DB" = "xsqlite" ]; then
|
|
|
|
dbuser=""
|
|
|
|
dblocation=`mktemp`
|
|
|
|
sqlite3 $dblocation < ykval-db.sql
|
|
|
|
sed -i "s,^.*YKVAL_DB_DSN.*$,\$baseParams['__YKVAL_DB_DSN__'] = \"sqlite:$dblocation\";," ykval-config.php
|
|
|
|
else
|
|
|
|
echo "unknown DB $DB"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat > config-db.php << EOF
|
|
|
|
<?php
|
|
|
|
\$dbuser = '$dbuser';
|
|
|
|
\$dbpass = '';
|
|
|
|
\$dbname = 'ykval';
|
|
|
|
\$dbtype = '$DB';
|
|
|
|
?>
|
|
|
|
EOF
|
|
|
|
sudo mkdir -p /etc/yubico/val/
|
|
|
|
sudo chmod 0755 /etc/yubico/val/
|
|
|
|
sudo mv config-db.php /etc/yubico/val/
|
|
|
|
|
2013-11-08 10:33:29 +01:00
|
|
|
sudo perl travis/server.pl &
|
|
|
|
|
2013-11-08 10:32:12 +01:00
|
|
|
echo '1,1,1383728711,EHmo8FMxuhumBlTinC4uYL0Mgwg=,,,' | php ykval-import-clients
|
|
|
|
|
|
|
|
set +e
|
|
|
|
|
|
|
|
function run_command () {
|
|
|
|
id=$1
|
|
|
|
otp=$2
|
|
|
|
nonce=$3
|
|
|
|
echo '' | php -B "\$_SERVER = array('REMOTE_ADDR' => '127.0.0.1', 'QUERY_STRING' => 'id=$id&otp=$otp&nonce=$nonce', 'REQUEST_URI' => '/wsapi/2.0/verify');\$_GET = array('otp' => '$otp', 'id' => '$id', 'nonce' => '$nonce');" -F ykval-verify.php
|
|
|
|
}
|
|
|
|
|
|
|
|
id="1"
|
|
|
|
otp="idkfefrdhtrutjduvtcjbfeuvhehdvjjlbchtlenfgku"
|
|
|
|
nonce="kakakakakakakakakakakaka"
|
|
|
|
run_command $id $otp $nonce | grep -q 'status=OK'
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
sudo tail /var/log/syslog
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Success 1"
|
|
|
|
fi
|
|
|
|
|
2013-11-11 10:50:16 +01:00
|
|
|
id="2"
|
|
|
|
run_command $id $otp $nonce | grep -q 'status=NO_SUCH_CLIENT'
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
sudo tail /var/log/syslog
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Success 1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
id="1"
|
2013-11-08 10:32:12 +01:00
|
|
|
run_command $id $otp $nonce | grep -q 'status=REPLAYED_REQUEST'
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
sudo tail /var/log/syslog
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Success 2"
|
|
|
|
fi
|
|
|
|
|
|
|
|
nonce="bakabakabakabaka"
|
|
|
|
run_command $id $otp $nonce | grep -q 'status=REPLAYED_OTP'
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
sudo tail /var/log/syslog
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Success 3"
|
|
|
|
fi
|
2013-11-11 10:40:37 +01:00
|
|
|
|
2013-11-11 11:03:22 +01:00
|
|
|
num=`php ykval-export | wc -l`
|
2013-11-11 10:40:37 +01:00
|
|
|
if [ $num != 1 ]; then
|
|
|
|
echo "failed exporting"
|
2013-11-11 11:14:41 +01:00
|
|
|
php ykval-export
|
2013-11-11 10:40:37 +01:00
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Success export"
|
|
|
|
fi
|
|
|
|
|
2013-11-11 11:03:22 +01:00
|
|
|
num=`php ykval-gen-clients | wc -l`
|
2013-11-11 10:40:37 +01:00
|
|
|
if [ $num != 1 ]; then
|
2013-11-11 10:48:23 +01:00
|
|
|
echo "failed generating new client"
|
2013-11-11 11:14:41 +01:00
|
|
|
php ykval-gen-clients
|
2013-11-11 10:48:23 +01:00
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Success generating new client"
|
|
|
|
fi
|
|
|
|
|
2013-11-11 11:03:22 +01:00
|
|
|
num=`php ykval-export-clients | wc -l`
|
2013-11-11 10:48:23 +01:00
|
|
|
if [ $num != 2 ]; then
|
2013-11-11 10:40:37 +01:00
|
|
|
echo "failed exporting clients"
|
2013-11-11 11:14:41 +01:00
|
|
|
php ykval-export-clients
|
2013-11-11 10:40:37 +01:00
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Success export-clients"
|
|
|
|
fi
|