From e69fa03de53ed2a8bf5c2f694210897a71dd5136 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 25 Dec 2015 21:35:21 -0500 Subject: [PATCH] Add auth_uri integration tests --- tests/client.rs | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/client.rs diff --git a/tests/client.rs b/tests/client.rs new file mode 100644 index 0000000..c9719b5 --- /dev/null +++ b/tests/client.rs @@ -0,0 +1,50 @@ +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::::new( + Default::default(), + "143225766783-ip2d9qv6sdr37276t77luk6f7bhd6bj5.apps.googleusercontent.com", + "", + Some("urn:ietf:wg:oauth:2.0:oob") + ); + 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::::new( + Default::default(), + "01774654cd9a6051e478", + "", + Some("https://cmcenroe.me/oauth2-paste/") + ); + 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::::new( + Default::default(), + "505c8ca804230e0", + "", + Some("https://cmcenroe.me/oauth2-paste/") + ); + let auth_uri = client.auth_uri(None, Some("state")).unwrap(); + assert_get_uri_ok(&auth_uri); +}