Skip to content

Commit

Permalink
Fix panic due to variant_name()
Browse files Browse the repository at this point in the history
Fixes #43.
  • Loading branch information
ramosbugs committed May 28, 2021
1 parent a093012 commit a6879e3
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,6 @@ extern crate pretty_assertions;
#[macro_use]
extern crate serde_derive;

use oauth2::helpers::variant_name;
use oauth2::ResponseType as OAuth2ResponseType;
use url::Url;

Expand Down Expand Up @@ -1337,7 +1336,7 @@ where
core::CoreResponseType::Token,
]
.iter()
.map(variant_name)
.map(|response_type| response_type.as_ref())
.collect::<Vec<_>>()
.join(" "),
)
Expand All @@ -1348,7 +1347,7 @@ where
AuthenticationFlow::Hybrid(ref response_types) => OAuth2ResponseType::new(
response_types
.iter()
.map(variant_name)
.map(|response_type| response_type.as_ref())
.collect::<Vec<_>>()
.join(" "),
),
Expand Down Expand Up @@ -1484,6 +1483,47 @@ mod tests {
);
}

#[test]
fn test_authorize_url_implicit_with_access_token() {
let client = new_client();

let (authorize_url, _, _) = client
.authorize_url(
AuthenticationFlow::<CoreResponseType>::Implicit(true),
|| CsrfToken::new("CSRF123".to_string()),
|| Nonce::new("NONCE456".to_string()),
)
.url();

assert_eq!(
"https://example/authorize?response_type=id_token+token&client_id=aaa&\
state=CSRF123&scope=openid&nonce=NONCE456",
authorize_url.to_string()
);
}

#[test]
fn test_authorize_url_hybrid() {
let client = new_client();

let (authorize_url, _, _) = client
.authorize_url(
AuthenticationFlow::Hybrid(vec![
CoreResponseType::Code,
CoreResponseType::Extension("other".to_string()),
]),
|| CsrfToken::new("CSRF123".to_string()),
|| Nonce::new("NONCE456".to_string()),
)
.url();

assert_eq!(
"https://example/authorize?response_type=code+other&client_id=aaa&\
state=CSRF123&scope=openid&nonce=NONCE456",
authorize_url.to_string()
);
}

#[test]
fn test_authorize_url_full() {
let client = new_client()
Expand Down

0 comments on commit a6879e3

Please sign in to comment.