~ubuntu-branches/ubuntu/trusty/libauthen-sasl-cyrus-perl/trusty-proposed

« back to all changes in this revision

Viewing changes to .pc/test-warnings/t/plain.t

  • Committer: Bazaar Package Importer
  • Author(s): Russ Allbery
  • Date: 2011-03-05 22:56:44 UTC
  • mfrom: (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110305225644-76yxl95fd1ek5c8t
Tags: 0.13-server-8
Explicitly set USER when running the test suite, since it may not be
set in a buildd environment.  This fix was accidentally dropped in
0.13-server-6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
use strict;
 
3
use Authen::SASL;
 
4
use Test::Simple tests => 5;
 
5
 
 
6
our $me;
 
7
require "t/common.pl";
 
8
 
 
9
pipe (FROM_CLIENT,TO_PARENT) or die "pipe failed.";
 
10
pipe (FROM_PARENT,TO_CLIENT) or die "pipe failed.";
 
11
 
 
12
my $pid = fork();
 
13
my $mech = "PLAIN";
 
14
my $service = "arc";
 
15
my $host = "hyade11.ifh.de";
 
16
 
 
17
if ($pid) { # parent
 
18
sleep(1);
 
19
        close FROM_PARENT;
 
20
        close TO_PARENT;
 
21
        $me = "server";
 
22
 
 
23
 
 
24
        my $sasl = Authen::SASL->new (
 
25
                mechanism => $mech,
 
26
                callback => {
 
27
                        canonuser => \&canonuser,               
 
28
                        authorize => \&authorize,
 
29
                        getsecret => \&getsecret,
 
30
                        checkpass => \&checkpass,
 
31
                }
 
32
        ) or ok(0);
 
33
        ok(1);
 
34
        
 
35
        my $conn = $sasl->server_new($service) or die "Authen::SASL::Cyrus failed." or
 
36
                ok(0);
 
37
        ok(1);
 
38
 
 
39
        print $conn->listmech("","|",""),"\n";
 
40
 
 
41
        sendreply( $conn->server_start( getreply(\*FROM_CLIENT)  ),\*TO_CLIENT );
 
42
        ok(1);
 
43
        
 
44
        while ($conn->need_step) {
 
45
                sendreply( $conn->server_step( &getreply(\*FROM_CLIENT) ) ,\*TO_CLIENT );
 
46
        }
 
47
 
 
48
        if ($conn->code == 0) {
 
49
                ok(1);
 
50
                print "Server: Test successful Negotiation succeeded.\n";
 
51
        } else {
 
52
                ok(0);
 
53
                print "Server: Negotiation failed.\n",$conn->error(),"\n";
 
54
        }
 
55
 
 
56
        close FROM_CLIENT;
 
57
        close TO_CLIENT;
 
58
        wait();
 
59
} elsif ($pid == 0) {
 
60
        close FROM_CLIENT;
 
61
        close TO_CLIENT;
 
62
        $me = "client";
 
63
 
 
64
        my $sasl = Authen::SASL->new (
 
65
                mechanism => $mech,
 
66
                callback => {
 
67
                        user => \&getusername,
 
68
                        pass => \&getpassword,
 
69
                        auth => \&getauthname,
 
70
                }
 
71
        ) or die "Authen::SASL failed.";
 
72
 
 
73
        my $conn = $sasl->client_new($service, $host)
 
74
                or die "Authen::SASL::Cyrus failed.";
 
75
 
 
76
        sendreply($conn->client_start(),*TO_PARENT);
 
77
 
 
78
        while ($conn->need_step) {
 
79
                sendreply($conn->client_step( &getreply(*FROM_PARENT) ),*TO_PARENT );
 
80
        }
 
81
                                           
 
82
        if ($conn->code == 0) {
 
83
                print "Client: Negotiation succeeded.\n";
 
84
        } else { 
 
85
                print "Client: Negotiation failed.\n",$conn->error,"\n";
 
86
        }
 
87
        
 
88
        close FROM_PARENT;
 
89
        close TO_PARENT;
 
90
        exit 0;
 
91
} else {
 
92
        exit 1;
 
93
}
 
94
 
 
95
ok(1);
 
96
 
 
97
exit 0;