mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2026-01-01 00:50:04 +01:00
refactor(cleanup): Remove obsolete tests.
DeviceFlow now works in a different way, so remove old test.
This commit is contained in:
@@ -290,69 +290,3 @@ where
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
mock_connector_in_order!(MockGoogleAuth {
|
||||
"HTTP/1.1 200 OK\r\n\
|
||||
Server: BOGUS\r\n\
|
||||
\r\n\
|
||||
{\r\n\
|
||||
\"device_code\" : \"4/L9fTtLrhY96442SEuf1Rl3KLFg3y\",\r\n\
|
||||
\"user_code\" : \"a9xfwk9c\",\r\n\
|
||||
\"verification_url\" : \"http://www.google.com/device\",\r\n\
|
||||
\"expires_in\" : 1800,\r\n\
|
||||
\"interval\" : 0\r\n\
|
||||
}"
|
||||
"HTTP/1.1 200 OK\r\n\
|
||||
Server: BOGUS\r\n\
|
||||
\r\n\
|
||||
{\r\n\
|
||||
\"error\" : \"authorization_pending\"\r\n\
|
||||
}"
|
||||
"HTTP/1.1 200 OK\r\nServer: \
|
||||
BOGUS\r\n\r\n{\r\n\"access_token\":\"1/fFAGRNJru1FTz70BzhT3Zg\",\
|
||||
\r\n\"expires_in\":3920,\r\n\"token_type\":\"Bearer\",\
|
||||
\r\n\"refresh_token\":\
|
||||
\"1/6BMfW9j53gdGImsixUH6kU5RsR4zwI9lUVX-tqf8JXQ\"\r\n}"
|
||||
});
|
||||
|
||||
const TEST_APP_SECRET: &'static str = r#"{"installed":{"client_id":"384278056379-tr5pbot1mil66749n639jo54i4840u77.apps.googleusercontent.com","project_id":"sanguine-rhythm-105020","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"QeQUnhzsiO4t--ZGmj9muUAu","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}"#;
|
||||
|
||||
#[test]
|
||||
fn working_flow() {
|
||||
use crate::helper::parse_application_secret;
|
||||
|
||||
let runtime = tokio::runtime::Runtime::new().unwrap();
|
||||
let appsecret = parse_application_secret(&TEST_APP_SECRET.to_string()).unwrap();
|
||||
let client = hyper::Client::builder()
|
||||
.executor(runtime.executor())
|
||||
.build(MockGoogleAuth::default());
|
||||
|
||||
let mut flow = DeviceFlow::new(client, &appsecret, GOOGLE_DEVICE_CODE_URL);
|
||||
|
||||
match flow.request_code(&["https://www.googleapis.com/auth/youtube.upload"]) {
|
||||
Ok(pi) => assert_eq!(pi.interval, Duration::from_secs(0)),
|
||||
Err(err) => assert!(false, "request_code failed: {}", err),
|
||||
}
|
||||
|
||||
match flow.poll_token() {
|
||||
Ok(None) => {}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let t = match flow.poll_token() {
|
||||
Ok(Some(t)) => {
|
||||
assert_eq!(t.access_token, "1/fFAGRNJru1FTz70BzhT3Zg");
|
||||
t
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
// from now on, all calls will yield the same result
|
||||
// As our mock has only 3 items, we would panic on this call
|
||||
assert_eq!(flow.poll_token().unwrap(), Some(t));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user