1
0
mirror of https://github.com/Yubico/yubikey-val.git synced 2024-12-03 03:24:15 +01:00

add travis ci for yubikey-val

This commit is contained in:
Klas Lindfors 2013-11-08 10:32:12 +01:00
parent 24b948e7d4
commit 7ea58ed9da
3 changed files with 116 additions and 0 deletions

9
.travis.yml Normal file
View File

@ -0,0 +1,9 @@
language: php
php:
- 5.5
env:
- DB=mysql
- DB=pgsql
- DB=sqlite
script:
- travis/selftest.sh

74
travis/selftest.sh Executable file
View File

@ -0,0 +1,74 @@
#!/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/
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
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

33
travis/server.pl Normal file
View File

@ -0,0 +1,33 @@
#!/usr/bin/perl
use IO::Socket::INET;
use strict;
use warnings;
my %otps = (
'idkfefrdhtrutjduvtcjbfeuvhehdvjjlbchtlenfgku' => 'OK counter=0001 low=8d40 high=0f use=00',
'idkfefrdhtrutjduvtcjbfeuvhehdvjjlbchtlenfgkv' => 'ERR Corrupt OTP',
);
my $socket = new IO::Socket::INET (
LocalHost => '127.0.0.1',
LocalPort => '80',
Proto => 'tcp',
Listen => 10,
Reuse => 1
) or die "Oops: $! \n";
while (1) {
my $clientsocket = $socket->accept();
my $clientdata = <$clientsocket>;
my $ret = "ERR Unknown yubikey";
if($clientdata =~ m/otp=([cbdefghijklnrtuv]+)/) {
my $otp = $1;
if($otps{$otp}) {
$ret = $otps{$otp};
}
}
print $clientsocket "\n$ret\n";
close $clientsocket;
}