comparison mail_pop3.t @ 970:c227348453db

Tests: simplified parallel modifications in mail tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 08 Jul 2016 02:21:16 +0300
parents e9064d691790
children a8b8dd6e8ae1
comparison
equal deleted inserted replaced
969:1edb092149e2 970:c227348453db
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, port(2)) 31 ->run_daemon(\&Test::Nginx::POP3::pop3_test_daemon, port(8111))
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:%%PORT_0%%/mail/auth; 43 auth_http http://127.0.0.1:8080/mail/auth;
44 44
45 server { 45 server {
46 listen 127.0.0.1:%%PORT_1%%; 46 listen 127.0.0.1:8110;
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:%%PORT_0%%; 55 listen 127.0.0.1:8080;
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 %%PORT_2%%; 72 add_header Auth-Port %%PORT_8111%%;
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(PeerAddr => '127.0.0.1:' . port(1)); 83 my $s = Test::Nginx::POP3->new();
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(PeerAddr => '127.0.0.1:' . port(1)); 96 $s = Test::Nginx::POP3->new();
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(PeerAddr => '127.0.0.1:' . port(1)); 110 $s = Test::Nginx::POP3->new();
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