Test missing/bad password
This commit is contained in:
parent
9227a0c316
commit
dc08fc6423
@ -1,6 +1,7 @@
|
|||||||
use tokio_core::reactor::Core;
|
use tokio_core::reactor::Core;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use error::{ConnectError, SqlState};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic() {
|
fn basic() {
|
||||||
@ -19,6 +20,30 @@ fn md5_user() {
|
|||||||
l.run(done).unwrap();
|
l.run(done).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn md5_user_no_pass() {
|
||||||
|
let mut l = Core::new().unwrap();
|
||||||
|
let handle = l.handle();
|
||||||
|
let done = Connection::connect("postgres://md5_user@localhost/postgres", &handle);
|
||||||
|
match l.run(done) {
|
||||||
|
Err(ConnectError::ConnectParams(_)) => {}
|
||||||
|
Err(e) => panic!("unexpected error {}", e),
|
||||||
|
Ok(_) => panic!("unexpected success"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn md5_user_wrong_pass() {
|
||||||
|
let mut l = Core::new().unwrap();
|
||||||
|
let handle = l.handle();
|
||||||
|
let done = Connection::connect("postgres://md5_user:foobar@localhost/postgres", &handle);
|
||||||
|
match l.run(done) {
|
||||||
|
Err(ConnectError::Db(ref e)) if e.code == SqlState::InvalidPassword => {}
|
||||||
|
Err(e) => panic!("unexpected error {}", e),
|
||||||
|
Ok(_) => panic!("unexpected success"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pass_user() {
|
fn pass_user() {
|
||||||
let mut l = Core::new().unwrap();
|
let mut l = Core::new().unwrap();
|
||||||
@ -26,3 +51,27 @@ fn pass_user() {
|
|||||||
let done = Connection::connect("postgres://pass_user:password@localhost/postgres", &handle);
|
let done = Connection::connect("postgres://pass_user:password@localhost/postgres", &handle);
|
||||||
l.run(done).unwrap();
|
l.run(done).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn pass_user_no_pass() {
|
||||||
|
let mut l = Core::new().unwrap();
|
||||||
|
let handle = l.handle();
|
||||||
|
let done = Connection::connect("postgres://pass_user@localhost/postgres", &handle);
|
||||||
|
match l.run(done) {
|
||||||
|
Err(ConnectError::ConnectParams(_)) => {}
|
||||||
|
Err(e) => panic!("unexpected error {}", e),
|
||||||
|
Ok(_) => panic!("unexpected success"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn pass_user_wrong_pass() {
|
||||||
|
let mut l = Core::new().unwrap();
|
||||||
|
let handle = l.handle();
|
||||||
|
let done = Connection::connect("postgres://pass_user:foobar@localhost/postgres", &handle);
|
||||||
|
match l.run(done) {
|
||||||
|
Err(ConnectError::Db(ref e)) if e.code == SqlState::InvalidPassword => {}
|
||||||
|
Err(e) => panic!("unexpected error {}", e),
|
||||||
|
Ok(_) => panic!("unexpected success"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user