mail_smtp_greeting_delay.t 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/usr/bin/perl
  2. # (C) Maxim Dounin
  3. ###############################################################################
  4. use warnings;
  5. use strict;
  6. use Test::More;
  7. BEGIN { use FindBin; chdir($FindBin::Bin); }
  8. use lib 'lib';
  9. use Test::Nginx;
  10. use Test::Nginx::SMTP;
  11. ###############################################################################
  12. select STDERR; $| = 1;
  13. select STDOUT; $| = 1;
  14. local $SIG{PIPE} = 'IGNORE';
  15. my $t = Test::Nginx->new()->has(qw/mail smtp http/)->plan(2)
  16. ->write_file_expand('nginx.conf', <<'EOF')->run();
  17. %%TEST_GLOBALS%%
  18. master_process off;
  19. daemon off;
  20. events {
  21. }
  22. mail {
  23. proxy_pass_error_message on;
  24. auth_http http://127.0.0.1:8080/mail/auth;
  25. xclient off;
  26. server {
  27. listen 127.0.0.1:8025;
  28. protocol smtp;
  29. smtp_greeting_delay 100ms;
  30. }
  31. }
  32. http {
  33. # stub to avoid SIGSEGV when perl module compiled in, <= 0.7.30
  34. }
  35. EOF
  36. ###############################################################################
  37. # With smtp_greeting_delay session expected to be closed after first error
  38. # message if client sent something before greeting.
  39. my $s = Test::Nginx::SMTP->new();
  40. $s->send('HELO example.com');
  41. $s->check(qr/^5.. /, "command before greeting - session must be rejected");
  42. TODO: {
  43. local $TODO = 'not in official nginx yet';
  44. ok($s->eof(), "session have to be closed");
  45. }
  46. ###############################################################################