mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
dovecot: Add tests for more error cases
This patch adds more tests for the dovecot library, in particular: - Protocol errors (invalid versions, etc.). - Invalid command (cli-specific test). - Connection breakups.
This commit is contained in:
37
cmd/dovecot-auth-cli/test_auth_bad_proto.cmy
Normal file
37
cmd/dovecot-auth-cli/test_auth_bad_proto.cmy
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
# Break the handhake early.
|
||||
client unix_listen .dovecot-client
|
||||
c = ./dovecot-auth-cli .dovecot auth username password
|
||||
|
||||
client <- VERSION 1 1
|
||||
client <~ CPID
|
||||
|
||||
# We are supposed to send the handshake here.
|
||||
client close
|
||||
|
||||
c <- no: error receiving handshake: EOF
|
||||
c wait 0
|
||||
|
||||
|
||||
# Break before sending the final response.
|
||||
client unix_listen .dovecot-client
|
||||
c = ./dovecot-auth-cli .dovecot auth username password
|
||||
|
||||
client -> VERSION 1 1
|
||||
client -> SPID 12345
|
||||
client -> CUID 12345
|
||||
client -> COOKIE lovelycookie
|
||||
client -> MECH PLAIN
|
||||
client -> MECH LOGIN
|
||||
client -> DONE
|
||||
|
||||
client <- VERSION 1 1
|
||||
client <~ CPID
|
||||
|
||||
client <- AUTH 1 PLAIN service=smtp secured no-penalty nologin resp=dXNlcm5hbWUAdXNlcm5hbWUAcGFzc3dvcmQ=
|
||||
|
||||
# We're supposed to send the OK/FAIL here.
|
||||
client close
|
||||
|
||||
c <- no: error receiving response: EOF
|
||||
c wait 0
|
||||
32
cmd/dovecot-auth-cli/test_exists_bad_proto.cmy
Normal file
32
cmd/dovecot-auth-cli/test_exists_bad_proto.cmy
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
# Invalid version
|
||||
userdb unix_listen .dovecot-userdb
|
||||
c = ./dovecot-auth-cli .dovecot exists username
|
||||
|
||||
userdb -> VERSION 0
|
||||
c <~ no: error receiving version
|
||||
c wait 0
|
||||
|
||||
|
||||
# No SPID (send "NOSPID" instead
|
||||
userdb unix_listen .dovecot-userdb
|
||||
c = ./dovecot-auth-cli .dovecot exists username
|
||||
|
||||
userdb -> VERSION 1 1
|
||||
userdb -> NOSPID
|
||||
c <~ no: error receiving SPID:
|
||||
c wait 0
|
||||
|
||||
# Break before sending the final response.
|
||||
userdb unix_listen .dovecot-userdb
|
||||
c = ./dovecot-auth-cli .dovecot exists username
|
||||
|
||||
userdb -> VERSION 1 1
|
||||
userdb -> SPID 12345
|
||||
userdb <- VERSION 1 1
|
||||
userdb <- USER 1 username service=smtp
|
||||
|
||||
userdb close
|
||||
|
||||
c <- no: error receiving response: EOF
|
||||
c wait 0
|
||||
15
cmd/dovecot-auth-cli/test_exists_error.cmy
Normal file
15
cmd/dovecot-auth-cli/test_exists_error.cmy
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
userdb unix_listen .dovecot-userdb
|
||||
|
||||
c = ./dovecot-auth-cli .dovecot exists username
|
||||
|
||||
userdb -> VERSION 1 1
|
||||
userdb -> SPID 12345
|
||||
|
||||
userdb <- VERSION 1 1
|
||||
userdb <- USER 1 username service=smtp
|
||||
|
||||
userdb -> OTHER
|
||||
|
||||
c <~ no: invalid response:
|
||||
c wait 0
|
||||
4
cmd/dovecot-auth-cli/test_wrong_command.cmy
Normal file
4
cmd/dovecot-auth-cli/test_wrong_command.cmy
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
c = ./dovecot-auth-cli .missingsocket something
|
||||
c <- unknown subcommand
|
||||
c wait 0
|
||||
Reference in New Issue
Block a user