diff options
author | David Blajda <blajda@hotmail.com> | 2019-05-08 15:38:37 +0000 |
---|---|---|
committer | David Blajda <blajda@hotmail.com> | 2019-05-08 15:38:37 +0000 |
commit | 98fb79b85e3cfbb547e5340b30623511daf09ef5 (patch) | |
tree | a03bd7a95c86a92eb7510409429f50433056d7ab /tests/kraken.rs | |
parent | 0e09c2c06fc0b81f11d12985a4172c815233db17 (diff) |
:WIP: Move types to a different crate
Diffstat (limited to 'tests/kraken.rs')
-rw-r--r-- | tests/kraken.rs | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/tests/kraken.rs b/tests/kraken.rs deleted file mode 100644 index 8300b69..0000000 --- a/tests/kraken.rs +++ /dev/null @@ -1,76 +0,0 @@ -extern crate twitch_api; -extern crate tokio; -extern crate hyper; -extern crate futures; -extern crate url; -extern crate http; - -pub mod common; - -use twitch_api::KrakenClient; -use twitch_api::{ClientConfig, TestConfig}; -use twitch_api::client::ClientTrait; -use twitch_api::error::Error; -use twitch_api::client::KrakenScope; - -use tokio::runtime::current_thread::Runtime; -use reqwest::r#async::Response; -use http::response::Builder; - -use crate::common::*; - -const AUTH_RESPONSE: &str = r#" -{ - "access_token": "prau3ol6mg5glgek8m89ec2s9q5i3i", - "refresh_token": "", - "expires_in": 3600, - "scope": ["user_read", "channel_commercial"], - "token_type": "bearer" -}"#; - -const USER_RESPONSE: &str = r#"{ - "_id": "44322889", - "bio": "Just a gamer playing games and chatting. :)", - "created_at": "2013-06-03T19:12:02.580593Z", - "display_name": "dallas", - "logo": "https://static-cdn.jtvnw.net/jtv_user_pictures/dallas-profile_image-1a2c906ee2c35f12-300x300.png", - "name": "dallas", - "type": "staff", - "updated_at": "2016-12-13T16:31:55.958584Z" -}"#; - -#[test] -fn test_auth_header() { - - let (config, test_config) = test_config(); - test_config.push_response(okay_response(USER_RESPONSE)); - test_config.push_response(okay_response(AUTH_RESPONSE)); - let mut runtime = Runtime::new().unwrap(); - - let client = KrakenClient::new_with_config(CLIENT_ID, config) - .authenticate(CLIENT_SECRET).build(); - - /*Authentication is lazy*/ - assert!(!client.authenticated()); - - let user_future = client.users().by_id(&"44322889"); - let result = runtime.block_on(user_future); - assert!(result.is_ok()); - - let request = { - let config = &mut test_config.inner.lock().unwrap(); - config.requests.pop().unwrap().unwrap() - }; - - let headers = request.headers(); - let client_id = headers.get("Client-Id"); - let secret = headers.get("Authorization"); - - let scopes = client.scopes(); - - assert!(client.authenticated()); - assert_eq!(Some(CLIENT_ID), client_id.and_then(|s| Some(s.to_str().unwrap()))); - assert_eq!(Some("OAuth ".to_owned() + "prau3ol6mg5glgek8m89ec2s9q5i3i"), secret.and_then(|s| Some(s.to_str().unwrap().to_owned()))); - assert!(scopes.contains(&KrakenScope::UserRead)); - assert!(scopes.contains(&KrakenScope::ChannelCommercial)); -}
\ No newline at end of file |