Add wrong lifetime mocked tests

This commit is contained in:
Curtis McEnroe 2015-12-29 23:15:43 -05:00
parent 53ac5f8e05
commit d05cbad012
1 changed files with 15 additions and 1 deletions

View File

@ -5,7 +5,7 @@ extern crate inth_oauth2;
extern crate yup_hyper_mock;
use chrono::{UTC, Duration};
use inth_oauth2::{Client, Token, Lifetime};
use inth_oauth2::{Client, ClientError, Token, Lifetime};
mod provider {
use inth_oauth2::token::{Bearer, Static, Expiring};
@ -103,3 +103,17 @@ fn refresh_token_bearer_partial() {
assert!(token.lifetime().expires() > &UTC::now());
assert!(token.lifetime().expires() <= &(UTC::now() + Duration::seconds(3600)));
}
#[test]
fn request_token_bearer_static_wrong_lifetime() {
let client = mock_client!(provider::BearerStatic, connector::BearerExpiringSuccess);
let err = client.request_token("code").unwrap_err();
assert!(match err { ClientError::Parse(..) => true, _ => false });
}
#[test]
fn request_token_bearer_expiring_wrong_lifetime() {
let client = mock_client!(provider::BearerExpiring, connector::BearerStaticSuccess);
let err = client.request_token("code").unwrap_err();
assert!(match err { ClientError::Parse(..) => true, _ => false });
}