diff --git a/src/client/mod.rs b/src/client/mod.rs index 69013d1..fc60864 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -76,7 +76,7 @@ impl Client

{ /// None /// ); /// ``` - pub fn auth_uri(&self, scope: Option<&str>, state: Option<&str>) -> Result + pub fn auth_uri(&self, scope: Option<&str>, state: Option<&str>) -> Result { let mut uri = try!(Url::parse(P::auth_uri())); @@ -96,7 +96,7 @@ impl Client

{ uri.set_query_from_pairs(query_pairs.iter()); - Ok(uri.serialize()) + Ok(uri) } fn post_token<'a>( @@ -209,7 +209,7 @@ mod tests { let client = Client::::new(String::from("foo"), String::from("bar"), None); assert_eq!( "http://example.com/oauth2/auth?response_type=code&client_id=foo", - client.auth_uri(None, None).unwrap() + client.auth_uri(None, None).unwrap().serialize() ); } @@ -222,7 +222,7 @@ mod tests { ); assert_eq!( "http://example.com/oauth2/auth?response_type=code&client_id=foo&redirect_uri=http%3A%2F%2Fexample.com%2Foauth2%2Fcallback", - client.auth_uri(None, None).unwrap() + client.auth_uri(None, None).unwrap().serialize() ); } @@ -231,7 +231,7 @@ mod tests { let client = Client::::new(String::from("foo"), String::from("bar"), None); assert_eq!( "http://example.com/oauth2/auth?response_type=code&client_id=foo&scope=baz", - client.auth_uri(Some("baz"), None).unwrap() + client.auth_uri(Some("baz"), None).unwrap().serialize() ); } @@ -240,7 +240,7 @@ mod tests { let client = Client::::new(String::from("foo"), String::from("bar"), None); assert_eq!( "http://example.com/oauth2/auth?response_type=code&client_id=foo&state=baz", - client.auth_uri(None, Some("baz")).unwrap() + client.auth_uri(None, Some("baz")).unwrap().serialize() ); } } diff --git a/tests/auth_uri.rs b/tests/auth_uri.rs index c31ff32..7ffd9bc 100644 --- a/tests/auth_uri.rs +++ b/tests/auth_uri.rs @@ -1,10 +1,12 @@ extern crate hyper; extern crate inth_oauth2; +extern crate url; use inth_oauth2::Client; use inth_oauth2::provider::*; +use url::Url; -fn assert_get_uri_ok(uri: &str) { +fn assert_get_uri_ok(uri: Url) { let client = hyper::Client::new(); let response = client.get(uri).send().unwrap(); assert_eq!(hyper::Ok, response.status); @@ -21,7 +23,7 @@ fn google_web_auth_uri_ok() { Some("https://www.googleapis.com/auth/userinfo.email"), Some("state"), ).unwrap(); - assert_get_uri_ok(&auth_uri); + assert_get_uri_ok(auth_uri); } #[test] @@ -35,7 +37,7 @@ fn google_installed_auth_uri_ok() { Some("https://www.googleapis.com/auth/userinfo.email"), Some("state") ).unwrap(); - assert_get_uri_ok(&auth_uri); + assert_get_uri_ok(auth_uri); } #[test] @@ -46,7 +48,7 @@ fn github_auth_uri_ok() { Some(String::from("https://cmcenroe.me/oauth2-paste/")) ); let auth_uri = client.auth_uri(Some("user"), Some("state")).unwrap(); - assert_get_uri_ok(&auth_uri); + assert_get_uri_ok(auth_uri); } #[test] @@ -57,5 +59,5 @@ fn imgur_auth_uri_ok() { Some(String::from("https://cmcenroe.me/oauth2-paste/")) ); let auth_uri = client.auth_uri(None, Some("state")).unwrap(); - assert_get_uri_ok(&auth_uri); + assert_get_uri_ok(auth_uri); }