fix(tests): Disable unused tests and fix failing ones.

This commit is contained in:
Lewin Bormann
2019-06-12 00:02:47 +02:00
parent 7c1731cac9
commit f3774e4b74
5 changed files with 10 additions and 42 deletions

View File

@@ -22,7 +22,6 @@ rust:
stages:
- name: test
- name: examples
- name: lint
- name: coverage
@@ -45,13 +44,6 @@ jobs:
- cargo fmt --all -- --check
- cargo clippy --all-targets --all-features -- -D warnings || true
- stage: examples
if: os = linux
rust: stable
script:
- cargo build --manifest-path examples/drive_example/Cargo.toml
- cargo build --manifest-path examples/service_account/Cargo.toml
- stage: coverage
if: os = linux
sudo: true

View File

@@ -307,16 +307,16 @@ impl InstalledFlowServer {
let addr = format!("127.0.0.1:{}", port);
let builder = hyper::server::Server::try_bind(&addr.parse().unwrap())?;
let server = builder
.http1_only(true)
.serve(service_maker)
let server = builder.http1_only(true).serve(service_maker);
let port = server.local_addr().port();
let server_future = server
.with_graceful_shutdown(shutdown_rx)
.map_err(|err| panic!("Failed badly: {}", err));
threadpool.spawn(server);
threadpool.spawn(server_future);
Result::Ok(InstalledFlowServer {
port,
port: port,
shutdown_tx: Some(shutdown_tx),
auth_code_rx: Some(auth_code_rx),
threadpool: Some(threadpool),
@@ -497,7 +497,7 @@ mod tests {
fn test_request_url_builder() {
assert_eq!(
"https://accounts.google.\
com/o/oauth2/auth?scope=email%20profile&redirect_uri=urn:ietf:wg:oauth:2.0:\
com/o/oauth2/auth?scope=email%20profile&access_type=offline&redirect_uri=urn:ietf:wg:oauth:2.0:\
oob&response_type=code&client_id=812741506391-h38jh0j4fv0ce1krdkiq0hfvt6n5amr\
f.apps.googleusercontent.com",
build_authentication_request_url(

View File

@@ -35,31 +35,7 @@
//! authorize future API requests to the same scopes.
//!
//! ```test_harness,no_run
//! #[macro_use]
//! extern crate serde_derive;
//!
//! use yup_oauth2::{Authenticator, DefaultAuthenticatorDelegate, PollInformation, ConsoleApplicationSecret, MemoryStorage, GetToken};
//! use serde_json as json;
//! use std::default::Default;
//! use hyper::Client;
//! use hyper_tls::HttpsConnector;
//! # const SECRET: &'static str = "{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"UqkDJd5RFwnHoiG5x5Rub8SI\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"14070749909-vgip2f1okm7bkvajhi9jugan6126io9v.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}";
//!
//! # #[test] fn device() {
//! let secret = json::from_str::<ConsoleApplicationSecret>(SECRET).unwrap().installed.unwrap();
//! let res = Authenticator::new(&secret, DefaultAuthenticatorDelegate,
//! Client::builder().build(HttpsConnector::new(4).unwrap()),
//! <MemoryStorage as Default>::default(), None)
//! .token(&["https://www.googleapis.com/auth/youtube.upload"]);
//! match res {
//! Ok(t) => {
//! // now you can use t.access_token to authenticate API calls within your
//! // given scopes. It will not be valid forever, but Authenticator will automatically
//! // refresh the token for you.
//! },
//! Err(err) => println!("Failed to acquire token: {}", err),
//! }
//! # }
//! // TODO: Rewrite example here once new authenticator works.
//! ```
//!
#[macro_use]
@@ -88,5 +64,5 @@ pub use crate::refresh::{RefreshFlow, RefreshResult};
pub use crate::service_account::*;
pub use crate::storage::{DiskTokenStorage, MemoryStorage, NullStorage, TokenStorage};
pub use crate::types::{
ApplicationSecret, ConsoleApplicationSecret, FlowType, Scheme, Token, TokenType,
ApplicationSecret, ConsoleApplicationSecret, FlowType, GetToken, Scheme, Token, TokenType,
};

View File

@@ -347,8 +347,8 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crate::authenticator::GetToken;
use crate::helper::service_account_key_from_file;
use crate::types::GetToken;
use hyper;
use hyper_tls::HttpsConnector;
@@ -369,7 +369,7 @@ mod tests {
println!(
"{:?}",
acc.token(vec![&"https://www.googleapis.com/auth/pubsub"])
.unwrap()
.wait()
);
}