mirror of
https://github.com/Yubico/yubico-pam.git
synced 2024-12-03 03:24:12 +01:00
add a test for wrong otp and small fixup to mock server
This commit is contained in:
parent
9038130e88
commit
086bfbb3f7
@ -51,20 +51,21 @@ my $socket = new IO::Socket::INET (
|
||||
while(1) {
|
||||
my $clientsocket = $socket->accept();
|
||||
my $clientdata = <$clientsocket>;
|
||||
my $ret = "status=MISSING_PARAMETER";
|
||||
my $ret = "h=ZrU7UfjwazJVf5ay1P/oC3XCQlI=\n";
|
||||
|
||||
if($clientdata =~ m/nonce=([a-zA-Z0-9]+).*otp=([cbdefghijklnrtuv]+)/) {
|
||||
my $nonce = $1;
|
||||
my $otp = $2;
|
||||
if($otps{$otp}) {
|
||||
my $status = $otps{$otp};
|
||||
$ret = "h=ZrU7UfjwazJVf5ay1P/oC3XCQlI=\n";
|
||||
$ret .= "nonce=$nonce\n";
|
||||
$ret .= "otp=$otp\n";
|
||||
$ret .= "status=$status";
|
||||
} else {
|
||||
$ret = "status=BAD_OTP";
|
||||
$ret .= "status=BAD_OTP";
|
||||
}
|
||||
} else {
|
||||
$ret .= "status=MISSING_PARAMETER";
|
||||
}
|
||||
print $clientsocket "\n$ret\n";
|
||||
close $clientsocket;
|
||||
|
@ -46,6 +46,7 @@ static struct data {
|
||||
{"foo", "vvincredibletrerdegkkrkkneieultcjdghrejjbckh"},
|
||||
{"bar", "vvincredibletrerdegkkrkkneieultcjdghrejjbckh"},
|
||||
{"foo", "vvincrediblltrerdegkkrkkneieultcjdghrejjbckh"},
|
||||
{"foo", "vvincredibletrerdegkkrkkneieultcjdghrejjbckl"},
|
||||
};
|
||||
|
||||
static const char *err = "error";
|
||||
@ -154,6 +155,16 @@ static int test_fail_authenticate2(void) {
|
||||
return pam_sm_authenticate(2, 0, sizeof(cfg) / sizeof(char*), cfg);
|
||||
}
|
||||
|
||||
static int test_fail_authenticate3(void) {
|
||||
char *cfg[] = {
|
||||
"id=1",
|
||||
"urllist=http://localhost:8889/wsapi/2/verify",
|
||||
"authfile=aux/authfile",
|
||||
"debug"
|
||||
};
|
||||
return pam_sm_authenticate(3, 0, sizeof(cfg) / sizeof(char*), cfg);
|
||||
}
|
||||
|
||||
static pid_t run_mock(const char *port) {
|
||||
pid_t pid = fork();
|
||||
if(pid == 0) {
|
||||
@ -186,6 +197,10 @@ int main () {
|
||||
ret = 4;
|
||||
goto out;
|
||||
}
|
||||
if(test_fail_authenticate3() != PAM_AUTH_ERR) {
|
||||
ret = 5;
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
kill(child, 9);
|
||||
|
Loading…
Reference in New Issue
Block a user