Merge branch 'master' of https://github.com/lyonbeckers/yup-oauth2 into option_hyper_tls

This commit is contained in:
Lyon Beckers
2021-02-01 07:18:48 -07:00
2 changed files with 29 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
[package]
name = "yup-oauth2"
version = "5.0.1"
version = "5.0.2"
authors = ["Sebastian Thiel <byronimo@gmail.com>", "Lewin Bormann <lbo@spheniscida.de>"]
repository = "https://github.com/dermesser/yup-oauth2"
description = "An oauth2 implementation, providing the 'device', 'service account' and 'installed' authorization flows"

View File

@@ -36,8 +36,18 @@ where
let scopes_string = crate::helper::join(scopes, " ");
url.push_str(auth_uri);
if !url.contains('?') {
url.push('?');
} else {
match url.chars().last() {
Some('?') | None => {}
Some(_) => url.push('&'),
}
}
vec![
format!("?scope={}", scopes_string),
format!("scope={}", scopes_string),
"&access_type=offline".to_string(),
format!("&redirect_uri={}", redirect_uri.unwrap_or(OOB_REDIRECT_URI)),
"&response_type=code".to_string(),
@@ -371,6 +381,23 @@ mod tests {
);
}
#[test]
fn test_request_url_builder_appends_queries() {
assert_eq!(
"https://accounts.google.\
com/o/oauth2/auth?unknown=testing&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(
"https://accounts.google.com/o/oauth2/auth?unknown=testing",
"812741506391-h38jh0j4fv0ce1krdkiq0hfvt6n5am\
rf.apps.googleusercontent.com",
&["email", "profile"],
None
)
);
}
#[tokio::test]
async fn test_server_random_local_port() {
let addr1 = InstalledFlowServer::run().unwrap().local_addr();