Mercurial > hg > nginx-tests
comparison mail_pop3.t @ 952:e9064d691790
Tests: converted tests to run in parallel.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Tue, 21 Jun 2016 16:39:13 +0300 |
parents | b70df6924290 |
children | c227348453db |
comparison
equal
deleted
inserted
replaced
951:9361c7eddfc1 | 952:e9064d691790 |
---|---|
26 | 26 |
27 local $SIG{PIPE} = 'IGNORE'; | 27 local $SIG{PIPE} = 'IGNORE'; |
28 | 28 |
29 my $t = Test::Nginx->new() | 29 my $t = Test::Nginx->new() |
30 ->has(qw/mail pop3 http rewrite/)->plan(8) | 30 ->has(qw/mail pop3 http rewrite/)->plan(8) |
31 ->run_daemon(\&Test::Nginx::POP3::pop3_test_daemon) | 31 ->run_daemon(\&Test::Nginx::POP3::pop3_test_daemon, port(2)) |
32 ->write_file_expand('nginx.conf', <<'EOF')->run(); | 32 ->write_file_expand('nginx.conf', <<'EOF')->run(); |
33 | 33 |
34 %%TEST_GLOBALS%% | 34 %%TEST_GLOBALS%% |
35 | 35 |
36 daemon off; | 36 daemon off; |
38 events { | 38 events { |
39 } | 39 } |
40 | 40 |
41 mail { | 41 mail { |
42 proxy_pass_error_message on; | 42 proxy_pass_error_message on; |
43 auth_http http://127.0.0.1:8080/mail/auth; | 43 auth_http http://127.0.0.1:%%PORT_0%%/mail/auth; |
44 | 44 |
45 server { | 45 server { |
46 listen 127.0.0.1:8110; | 46 listen 127.0.0.1:%%PORT_1%%; |
47 protocol pop3; | 47 protocol pop3; |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 http { | 51 http { |
52 %%TEST_GLOBALS_HTTP%% | 52 %%TEST_GLOBALS_HTTP%% |
53 | 53 |
54 server { | 54 server { |
55 listen 127.0.0.1:8080; | 55 listen 127.0.0.1:%%PORT_0%%; |
56 server_name localhost; | 56 server_name localhost; |
57 | 57 |
58 location = /mail/auth { | 58 location = /mail/auth { |
59 set $reply ERROR; | 59 set $reply ERROR; |
60 | 60 |
67 set $reply OK; | 67 set $reply OK; |
68 } | 68 } |
69 | 69 |
70 add_header Auth-Status $reply; | 70 add_header Auth-Status $reply; |
71 add_header Auth-Server 127.0.0.1; | 71 add_header Auth-Server 127.0.0.1; |
72 add_header Auth-Port 8111; | 72 add_header Auth-Port %%PORT_2%%; |
73 add_header Auth-Wait 1; | 73 add_header Auth-Wait 1; |
74 return 204; | 74 return 204; |
75 } | 75 } |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 EOF | 79 EOF |
80 | 80 |
81 ############################################################################### | 81 ############################################################################### |
82 | 82 |
83 my $s = Test::Nginx::POP3->new(); | 83 my $s = Test::Nginx::POP3->new(PeerAddr => '127.0.0.1:' . port(1)); |
84 $s->ok('greeting'); | 84 $s->ok('greeting'); |
85 | 85 |
86 # auth plain | 86 # auth plain |
87 | 87 |
88 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0bad", '')); | 88 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0bad", '')); |
91 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); | 91 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); |
92 $s->ok('auth plain'); | 92 $s->ok('auth plain'); |
93 | 93 |
94 # auth login simple | 94 # auth login simple |
95 | 95 |
96 $s = Test::Nginx::POP3->new(); | 96 $s = Test::Nginx::POP3->new(PeerAddr => '127.0.0.1:' . port(1)); |
97 $s->read(); | 97 $s->read(); |
98 | 98 |
99 $s->send('AUTH LOGIN'); | 99 $s->send('AUTH LOGIN'); |
100 $s->check(qr/\+ VXNlcm5hbWU6/, 'auth login username challenge'); | 100 $s->check(qr/\+ VXNlcm5hbWU6/, 'auth login username challenge'); |
101 | 101 |
105 $s->send(encode_base64('secret', '')); | 105 $s->send(encode_base64('secret', '')); |
106 $s->ok('auth login simple'); | 106 $s->ok('auth login simple'); |
107 | 107 |
108 # auth login with username | 108 # auth login with username |
109 | 109 |
110 $s = Test::Nginx::POP3->new(); | 110 $s = Test::Nginx::POP3->new(PeerAddr => '127.0.0.1:' . port(1)); |
111 $s->read(); | 111 $s->read(); |
112 | 112 |
113 $s->send('AUTH LOGIN ' . encode_base64('test@example.com', '')); | 113 $s->send('AUTH LOGIN ' . encode_base64('test@example.com', '')); |
114 $s->check(qr/\+ UGFzc3dvcmQ6/, 'auth login with username password challenge'); | 114 $s->check(qr/\+ UGFzc3dvcmQ6/, 'auth login with username password challenge'); |
115 | 115 |