comparison mail_imap.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 imap http rewrite/)->plan(9) 30 ->has(qw/mail imap http rewrite/)->plan(9)
31 ->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon, port(2)) 31 ->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon, port(8144))
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:8143;
47 protocol imap; 47 protocol imap;
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_8144%%;
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::IMAP->new(PeerAddr => '127.0.0.1:' . port(1)); 83 my $s = Test::Nginx::IMAP->new();
84 $s->ok('greeting'); 84 $s->ok('greeting');
85 85
86 # bad auth 86 # bad auth
87 87
88 $s->send('1 AUTHENTICATE'); 88 $s->send('1 AUTHENTICATE');
96 $s->send('1 AUTHENTICATE PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); 96 $s->send('1 AUTHENTICATE PLAIN ' . encode_base64("\0test\@example.com\0secret", ''));
97 $s->ok('auth plain'); 97 $s->ok('auth plain');
98 98
99 # auth login simple 99 # auth login simple
100 100
101 $s = Test::Nginx::IMAP->new(PeerAddr => '127.0.0.1:' . port(1)); 101 $s = Test::Nginx::IMAP->new();
102 $s->read(); 102 $s->read();
103 103
104 $s->send('1 AUTHENTICATE LOGIN'); 104 $s->send('1 AUTHENTICATE LOGIN');
105 $s->check(qr/\+ VXNlcm5hbWU6/, 'auth login username challenge'); 105 $s->check(qr/\+ VXNlcm5hbWU6/, 'auth login username challenge');
106 106
110 $s->send(encode_base64('secret', '')); 110 $s->send(encode_base64('secret', ''));
111 $s->ok('auth login simple'); 111 $s->ok('auth login simple');
112 112
113 # auth login with username 113 # auth login with username
114 114
115 $s = Test::Nginx::IMAP->new(PeerAddr => '127.0.0.1:' . port(1)); 115 $s = Test::Nginx::IMAP->new();
116 $s->read(); 116 $s->read();
117 117
118 $s->send('1 AUTHENTICATE LOGIN ' . encode_base64('test@example.com', '')); 118 $s->send('1 AUTHENTICATE LOGIN ' . encode_base64('test@example.com', ''));
119 $s->check(qr/\+ UGFzc3dvcmQ6/, 'auth login with username password challenge'); 119 $s->check(qr/\+ UGFzc3dvcmQ6/, 'auth login with username password challenge');
120 120