Mercurial > hg > nginx-tests
annotate mail_oauth.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | b5e2609d34a3 |
children | 099c972fb42b |
rev | line source |
---|---|
1985
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for mail module, XOAUTH2 and OAUTHBEARER authentication. |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 ############################################################################### |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 use warnings; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 use strict; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
12 use Test::More; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 use MIME::Base64; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 use Socket qw/ CRLF /; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 use lib 'lib'; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 use Test::Nginx; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 use Test::Nginx::IMAP; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 use Test::Nginx::POP3; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 use Test::Nginx::SMTP; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 ############################################################################### |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
27 select STDERR; $| = 1; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 select STDOUT; $| = 1; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 local $SIG{PIPE} = 'IGNORE'; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 my $t = Test::Nginx->new()->has(qw/mail imap pop3 smtp http map rewrite/) |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 ->write_file_expand('nginx.conf', <<'EOF'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
34 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
35 %%TEST_GLOBALS%% |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
36 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 daemon off; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 events { |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 } |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 mail { |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 proxy_pass_error_message on; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 proxy_timeout 15s; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 timeout 2s; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 auth_http http://127.0.0.1:8080/mail/auth; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 server { |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 listen 127.0.0.1:8143; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 protocol imap; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 imap_auth plain oauthbearer xoauth2; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
52 } |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 server { |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 listen 127.0.0.1:8110; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 protocol pop3; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 pop3_auth plain oauthbearer xoauth2; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 } |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
58 server { |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 listen 127.0.0.1:8025; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 protocol smtp; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
61 smtp_auth plain oauthbearer xoauth2; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
62 } |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
63 } |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
64 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
65 http { |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
66 %%TEST_GLOBALS_HTTP%% |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
67 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 map $http_auth_protocol $proxy_port { |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
69 imap %%PORT_8144%%; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 pop3 %%PORT_8111%%; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
71 smtp %%PORT_8026%%; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
72 } |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
73 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
74 map $http_auth_user:$http_auth_pass $reply { |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
75 test@example.com:secretok OK; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
76 test=,@example.com:secretok OK; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
77 default auth-failed; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
78 } |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
79 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
80 map $http_auth_pass $passw { |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
81 secretok secret; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
82 } |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
83 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 map $http_auth_pass $sasl { |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 saslfail "eyJzY2hlbWVzIjoiQmVhcmVyIiwic3RhdHVzIjoiNDAwIn0="; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 } |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 server { |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 listen 127.0.0.1:8080; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
90 server_name localhost; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
91 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 location = /mail/auth { |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
93 add_header Auth-Status $reply; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 add_header Auth-Server 127.0.0.1; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 add_header Auth-Port $proxy_port; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 add_header Auth-Pass $passw; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
97 add_header Auth-Wait 1; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
98 add_header Auth-Error-SASL $sasl; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 return 204; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 } |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 } |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 } |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
103 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
104 EOF |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
106 $t->run_daemon(\&Test::Nginx::IMAP::imap_test_daemon); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 $t->run_daemon(\&Test::Nginx::POP3::pop3_test_daemon); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
108 $t->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 $t->try_run('no oauth support')->plan(48); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
110 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 $t->waitforsocket('127.0.0.1:' . port(8144)); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 $t->waitforsocket('127.0.0.1:' . port(8111)); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
113 $t->waitforsocket('127.0.0.1:' . port(8026)); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
114 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
115 ############################################################################### |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
116 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
117 # AUTHBEARER SASL mechanism |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
118 # https://datatracker.ietf.org/doc/html/rfc7628 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
119 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
120 # XOAUTH2 SASL mechanism |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
121 # https://developers.google.com/gmail/imap/xoauth2-protocol |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
122 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
123 my $s; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
124 my $token = encode_base64( |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
125 "n,a=test\@example.com,\001auth=Bearer secretok\001\001", ''); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
126 my $token_escaped = encode_base64( |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
127 "n,a=test=3D=2C\@example.com,\001auth=Bearer secretok\001\001", ''); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
128 my $token_saslfail = encode_base64( |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
129 "n,a=test\@example.com,\001auth=Bearer saslfail\001\001", ''); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
130 my $token_bad = encode_base64( |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
131 "n,a=test\@example.com,\001auth=Bearer bad\001\001", ''); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
132 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
133 my $token_xoauth2 = encode_base64( |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
134 "user=test\@example.com\001auth=Bearer secretok\001\001", ''); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
135 my $token_xoauth2_saslfail = encode_base64( |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
136 "user=test\@example.com\001auth=Bearer saslfail\001\001", ''); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
137 my $token_xoauth2_bad = encode_base64( |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
138 "user=test\@example.com\001auth=Bearer bad\001\001", ''); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
139 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
140 # IMAP |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
141 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
142 $s = Test::Nginx::IMAP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
143 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
144 $s->send('1 AUTHENTICATE OAUTHBEARER ' . $token); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
145 $s->ok('imap oauthbearer success'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
146 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
147 $s = Test::Nginx::IMAP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
148 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
149 $s->send('1 AUTHENTICATE OAUTHBEARER ' . $token_escaped); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
150 $s->ok('imap oauthbearer escaped login'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
151 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
152 $s = Test::Nginx::IMAP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
153 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
154 $s->send('1 AUTHENTICATE OAUTHBEARER'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 $s->check(qr/\+ /, 'imap oauthbearer challenge'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 $s->send($token); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 $s->ok('imap oauthbearer success after challenge'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
158 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
159 $s = Test::Nginx::IMAP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
160 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
161 $s->send('1 AUTHENTICATE OAUTHBEARER ' . $token_bad); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
162 $s->check(qr/^1 NO auth-failed/, 'imap oauthbearer non-sasl error'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
163 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
164 sleep(3); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
165 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
166 my @ready = $s->can_read(0); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
167 is(scalar @ready, 1, "imap ready for reading"); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
168 ok($s->eof(), "imap session closed"); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
169 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
170 # fail, sasl failure method |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
171 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
172 $s = Test::Nginx::IMAP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
173 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
174 my $start = time; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 $s->send('1 AUTHENTICATE OAUTHBEARER ' . $token_saslfail); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
176 $s->check(qr/^\+ eyJz/, 'imap oauthbearer sasl failure'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
177 my $wait_time = time - $start; |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
178 ok($wait_time >= 1, 'imap oauthbearer error delayed'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
179 $s->send('AQ=='); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
180 $s->check(qr/^1 NO auth-failed/, |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
181 'imap oauthbearer auth failure after dummy response'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
182 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
183 # fail, sasl failure method, invalid client response |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
184 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
185 $s = Test::Nginx::IMAP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
186 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
187 $s->send('1 AUTHENTICATE OAUTHBEARER ' . $token_saslfail); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
188 $s->check(qr/^\+ eyJz/, 'imap oauthbearer sasl failure'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
189 $s->send('foo'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
190 $s->check(qr/^1 BAD /, 'imap oauthbearer invalid command after invalid line'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
191 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
192 # fail, sasl failure method, multiple attempts, then success |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
193 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
194 $s = Test::Nginx::IMAP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
195 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
196 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
197 $s->send('1 AUTHENTICATE OAUTHBEARER ' . $token_saslfail); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
198 $s->check(qr/^\+ eyJz/, 'imap oauthbearer sasl failure'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
199 $s->send('AQ=='); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
200 $s->check(qr/^1 NO auth-failed/, |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
201 'imap oauthbearer auth failure after dummy response'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
202 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
203 $s->send('1 AUTHENTICATE OAUTHBEARER ' . $token_saslfail); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
204 $s->check(qr/^\+ eyJz/, 'imap oauthbearer sasl failure next'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
205 $s->send('foo'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
206 $s->check(qr/^1 BAD/, 'imap oauthbearer invalid command after invalid line'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
207 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
208 $s->send('1 AUTHENTICATE OAUTHBEARER'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
209 $s->check(qr/\+ /, 'imap oauthbearer challenge after fail'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
210 $s->send($token); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
211 $s->ok('imap oauthbearer success after fail'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
212 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
213 # IMAP XOAUTH2 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
214 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
215 $s = Test::Nginx::IMAP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
216 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
217 $s->send('1 AUTHENTICATE XOAUTH2 ' . $token_xoauth2); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
218 $s->ok('imap xoauth2 success'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
219 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
220 $s = Test::Nginx::IMAP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
221 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
222 $s->send('1 AUTHENTICATE XOAUTH2'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
223 $s->check(qr/^\+ /, 'imap xoauth2 challenge'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
224 $s->send($token_xoauth2); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
225 $s->ok('imap xoauth2 success after challenge'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
226 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
227 $s = Test::Nginx::IMAP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
228 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
229 $s->send('1 AUTHENTICATE XOAUTH2 ' . $token_xoauth2_saslfail); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
230 $s->check(qr/^\+ eyJz/, 'imap xoauth2 with bad token'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
231 $s->send(''); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
232 $s->check(qr/^1 NO auth-failed/, 'imap xoauth2 auth failure after empty line'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
233 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
234 $s->send('1 AUTHENTICATE XOAUTH2 ' . $token_xoauth2_saslfail); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
235 $s->check(qr/^\+ eyJz/, 'imap xoauth2 with bad token next'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
236 $s->send('foo'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
237 $s->check(qr/^1 BAD/, 'imap xoauth2 invalid command after invalid line'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
238 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
239 $s->send('1 AUTHENTICATE XOAUTH2 ' . $token_xoauth2); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
240 $s->ok('imap xoauth2 success after fail'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
241 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
242 # POP3 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
243 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
244 $s = Test::Nginx::POP3->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
245 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
246 $s->send('AUTH OAUTHBEARER ' . $token); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
247 $s->ok('pop3 oauthbearer success'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
248 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
249 $s = Test::Nginx::POP3->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
250 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
251 $s->send('AUTH OAUTHBEARER'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
252 $s->check(qr/^\+ /, 'pop3 oauthbearer challenge'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
253 $s->send($token); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
254 $s->ok('pop3 oauthbearer success after challenge'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
255 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
256 $s = Test::Nginx::POP3->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
257 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
258 $s->send('AUTH OAUTHBEARER ' . $token_saslfail); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
259 $s->check(qr/^\+ eyJz/, 'pop3 oauthbearer sasl failure'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
260 $s->send('AQ=='); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
261 $s->check(qr/^-ERR /, 'pop3 oauthbearer auth failure after dummy response'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
262 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
263 $s->send('AUTH OAUTHBEARER ' . $token_saslfail); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
264 $s->check(qr/^\+ eyJz/, 'pop3 oauthbearer sasl failure next'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
265 $s->send(''); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
266 $s->check(qr/^-ERR /, 'pop3 oauthbearer invalid command after invalid line'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
267 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
268 $s->send('AUTH OAUTHBEARER ' . $token); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
269 $s->ok('pop3 oauthbearer success after fail'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
270 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
271 # POP3 XOAUTH2 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
272 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
273 $s = Test::Nginx::POP3->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
274 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
275 $s->send('AUTH XOAUTH2 ' . $token_xoauth2); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
276 $s->ok('pop3 xoauth2 success'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
277 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
278 $s = Test::Nginx::POP3->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
279 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
280 $s->send('AUTH XOAUTH2'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
281 $s->check(qr/^\+ /, 'pop3 xoauth2 challenge'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
282 $s->send($token_xoauth2); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
283 $s->ok('pop3 xoauth2 success after challenge'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
284 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
285 # SMTP |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
286 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
287 $s = Test::Nginx::SMTP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
288 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
289 $s->send('EHLO example.com'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
290 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
291 $s->send('AUTH OAUTHBEARER ' . $token); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
292 $s->authok('smtp oauthbearer success'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
293 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
294 $s = Test::Nginx::SMTP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
295 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
296 $s->send('EHLO example.com'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
297 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
298 $s->send('AUTH OAUTHBEARER'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
299 $s->check(qr/^334 /, 'smtp oauthbearer challenge'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
300 $s->send($token); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
301 $s->authok('smtp oauthbearer success after challenge'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
302 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
303 $s = Test::Nginx::SMTP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
304 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
305 $s->send('EHLO example.com'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
306 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
307 $s->send('AUTH OAUTHBEARER ' . $token_saslfail); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
308 $s->check(qr/^334 eyJz/, 'smtp oauthbearer sasl failure'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
309 $s->send('AQ=='); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
310 $s->check(qr/^535 /, 'smtp oauthbearer auth failure after dummy response'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
311 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
312 $s->send('AUTH OAUTHBEARER ' . $token_saslfail); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
313 $s->check(qr/^334 eyJz/, 'smtp oauthbearer sasl failure next'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
314 $s->send('foo'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
315 $s->check(qr/^500 /, 'smtp oauthbearer invalid command after invalid line'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
316 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
317 $s->send('AUTH OAUTHBEARER ' . $token); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
318 $s->authok('smtp oauthbearer success after fail'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
319 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
320 # SMTP XOAUTH2 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
321 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
322 $s = Test::Nginx::SMTP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
323 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
324 $s->send('EHLO example.com'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
325 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
326 $s->send('AUTH XOAUTH2 ' . $token_xoauth2); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
327 $s->authok('smtp xoauth2 success'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
328 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
329 $s = Test::Nginx::SMTP->new(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
330 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
331 $s->send('EHLO example.com'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
332 $s->read(); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
333 $s->send('AUTH XOAUTH2'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
334 $s->check(qr/^334 /, 'smtp xoauth2 challenge'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
335 $s->send($token_xoauth2); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
336 $s->authok('smtp xoauth2 success after challenge'); |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
337 |
b5e2609d34a3
Tests: added tests for OAUTHBEARER and XOAUTH2 auth methods.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
338 ############################################################################### |