inth-oauth2/tests/auth_uri.rs

48 lines
1.3 KiB
Rust
Raw Normal View History

2015-12-26 02:35:21 +00:00
extern crate hyper;
extern crate inth_oauth2;
use inth_oauth2::Client;
use inth_oauth2::provider::*;
fn assert_get_uri_ok(uri: &str) {
let client = hyper::Client::new();
let response = client.get(uri).send().unwrap();
assert_eq!(hyper::Ok, response.status);
}
#[test]
fn google_auth_uri_ok() {
let client = Client::<Google>::new(
2016-01-29 02:54:14 +00:00
String::from("143225766783-ip2d9qv6sdr37276t77luk6f7bhd6bj5.apps.googleusercontent.com"),
String::new(),
Some(String::from("urn:ietf:wg:oauth:2.0:oob"))
2015-12-26 02:35:21 +00:00
);
let auth_uri = client.auth_uri(
Some("https://www.googleapis.com/auth/userinfo.email"),
Some("state")
).unwrap();
assert_get_uri_ok(&auth_uri);
}
#[test]
fn github_auth_uri_ok() {
let client = Client::<GitHub>::new(
2016-01-29 02:54:14 +00:00
String::from("01774654cd9a6051e478"),
String::new(),
Some(String::from("https://cmcenroe.me/oauth2-paste/"))
2015-12-26 02:35:21 +00:00
);
let auth_uri = client.auth_uri(Some("user"), Some("state")).unwrap();
assert_get_uri_ok(&auth_uri);
}
#[test]
fn imgur_auth_uri_ok() {
let client = Client::<Imgur>::new(
2016-01-29 02:54:14 +00:00
String::from("505c8ca804230e0"),
String::new(),
Some(String::from("https://cmcenroe.me/oauth2-paste/"))
2015-12-26 02:35:21 +00:00
);
let auth_uri = client.auth_uri(None, Some("state")).unwrap();
assert_get_uri_ok(&auth_uri);
}