-
Notifications
You must be signed in to change notification settings - Fork 250
Bug 1925091 - [ci full] Make Android FxaAccountManager supply comma-separate list of values for service=sync #6877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AadityaDhingra
wants to merge
4
commits into
mozilla:main
Choose a base branch
from
AadityaDhingra:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fef6a02
Bug 1925091 - Make Android FxaAccountManager supply comma-separate li…
AadityaDhingra 10c04bc
Bug 1925091 - Make Android FxaAccountManager supply comma-separate li…
AadityaDhingra c7ff0d0
Bug 1925091 - Make Android FxaAccountManager supply comma-separate li…
AadityaDhingra 6a72e7f
Bug 1925091 - Make Android FxaAccountManager supply comma-separate li…
AadityaDhingra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,15 +128,20 @@ impl FirefoxAccount { | |
| /// the pairing authority. | ||
| /// * `scopes` - Space-separated list of requested scopes by the pairing supplicant. | ||
| /// * `entrypoint` - The entrypoint to be used for data collection | ||
| /// * `service` - Space-separated list of requested services. | ||
| /// * `metrics` - Optional parameters for metrics | ||
| pub fn begin_pairing_flow( | ||
| &mut self, | ||
| pairing_url: &str, | ||
| scopes: &[&str], | ||
| entrypoint: &str, | ||
| service: &[&str], | ||
| ) -> Result<String> { | ||
| let mut url = self.state.config().pair_supp_url()?; | ||
| url.query_pairs_mut().append_pair("entrypoint", entrypoint); | ||
| let service_param = service.join(","); | ||
| url.query_pairs_mut() | ||
| .append_pair("entrypoint", entrypoint) | ||
| .append_pair("service", &service_param); | ||
| let pairing_url = Url::parse(pairing_url)?; | ||
| if url.host_str() != pairing_url.host_str() { | ||
| let fxa_server = FxaServer::from(&url); | ||
|
|
@@ -153,19 +158,26 @@ impl FirefoxAccount { | |
| /// | ||
| /// * `scopes` - Space-separated list of requested scopes. | ||
| /// * `entrypoint` - The entrypoint to be used for metrics | ||
| /// * `service` - Space-separated list of requested services. | ||
| /// * `metrics` - Optional metrics parameters | ||
| pub fn begin_oauth_flow(&mut self, scopes: &[&str], entrypoint: &str) -> Result<String> { | ||
| pub fn begin_oauth_flow( | ||
| &mut self, | ||
| scopes: &[&str], | ||
| entrypoint: &str, | ||
| service: &[&str], | ||
| ) -> Result<String> { | ||
| self.state.on_begin_oauth(); | ||
| let mut url = if self.state.last_seen_profile().is_some() { | ||
| self.state.config().oauth_force_auth_url()? | ||
| } else { | ||
| self.state.config().authorization_endpoint()? | ||
| }; | ||
|
|
||
| let service_param = service.join(","); | ||
| url.query_pairs_mut() | ||
| .append_pair("action", "email") | ||
| .append_pair("response_type", "code") | ||
| .append_pair("entrypoint", entrypoint); | ||
| .append_pair("entrypoint", entrypoint) | ||
| .append_pair("service", &service_param); | ||
|
|
||
| if let Some(cached_profile) = self.state.last_seen_profile() { | ||
| url.query_pairs_mut() | ||
|
|
@@ -621,15 +633,15 @@ mod tests { | |
| ); | ||
| let mut fxa = FirefoxAccount::with_config(config); | ||
| let url = fxa | ||
| .begin_oauth_flow(&["profile"], "test_oauth_flow_url") | ||
| .begin_oauth_flow(&["profile"], "test_oauth_flow_url", &["sync"]) | ||
| .unwrap(); | ||
| let flow_url = Url::parse(&url).unwrap(); | ||
|
|
||
| assert_eq!(flow_url.host_str(), Some("accounts.firefox.com")); | ||
| assert_eq!(flow_url.path(), "/authorization"); | ||
|
|
||
| let mut pairs = flow_url.query_pairs(); | ||
| assert_eq!(pairs.count(), 11); | ||
| assert_eq!(pairs.count(), 12); | ||
| assert_eq!( | ||
| pairs.next(), | ||
| Some((Cow::Borrowed("action"), Cow::Borrowed("email"))) | ||
|
|
@@ -645,6 +657,10 @@ mod tests { | |
| Cow::Borrowed("test_oauth_flow_url") | ||
| )) | ||
| ); | ||
| assert_eq!( | ||
| pairs.next(), | ||
| Some((Cow::Borrowed("service"), Cow::Borrowed("sync"))) | ||
| ); | ||
| assert_eq!( | ||
| pairs.next(), | ||
| Some((Cow::Borrowed("client_id"), Cow::Borrowed("12345678"))) | ||
|
|
@@ -692,7 +708,7 @@ mod tests { | |
| let email = "[email protected]"; | ||
| fxa.add_cached_profile("123", email); | ||
| let url = fxa | ||
| .begin_oauth_flow(&["profile"], "test_force_auth_url") | ||
| .begin_oauth_flow(&["profile"], "test_force_auth_url", &["sync"]) | ||
| .unwrap(); | ||
| let url = Url::parse(&url).unwrap(); | ||
| assert_eq!(url.path(), "/oauth/force_auth"); | ||
|
|
@@ -716,7 +732,7 @@ mod tests { | |
| ); | ||
| let mut fxa = FirefoxAccount::with_config(config); | ||
| let url = fxa | ||
| .begin_oauth_flow(SCOPES, "test_webchannel_context_url") | ||
| .begin_oauth_flow(SCOPES, "test_webchannel_context_url", &["sync"]) | ||
| .unwrap(); | ||
| let url = Url::parse(&url).unwrap(); | ||
| let query_params: HashMap<_, _> = url.query_pairs().into_owned().collect(); | ||
|
|
@@ -738,7 +754,12 @@ mod tests { | |
| ); | ||
| let mut fxa = FirefoxAccount::with_config(config); | ||
| let url = fxa | ||
| .begin_pairing_flow(PAIRING_URL, SCOPES, "test_webchannel_pairing_context_url") | ||
| .begin_pairing_flow( | ||
| PAIRING_URL, | ||
| SCOPES, | ||
| "test_webchannel_pairing_context_url", | ||
| &["sync"], | ||
| ) | ||
| .unwrap(); | ||
| let url = Url::parse(&url).unwrap(); | ||
| let query_params: HashMap<_, _> = url.query_pairs().into_owned().collect(); | ||
|
|
@@ -762,7 +783,7 @@ mod tests { | |
|
|
||
| let mut fxa = FirefoxAccount::with_config(config); | ||
| let url = fxa | ||
| .begin_pairing_flow(PAIRING_URL, SCOPES, "test_pairing_flow_url") | ||
| .begin_pairing_flow(PAIRING_URL, SCOPES, "test_pairing_flow_url", &["sync"]) | ||
| .unwrap(); | ||
| let flow_url = Url::parse(&url).unwrap(); | ||
| let expected_parsed_url = Url::parse(EXPECTED_URL).unwrap(); | ||
|
|
@@ -772,14 +793,18 @@ mod tests { | |
| assert_eq!(flow_url.fragment(), expected_parsed_url.fragment()); | ||
|
|
||
| let mut pairs = flow_url.query_pairs(); | ||
| assert_eq!(pairs.count(), 9); | ||
| assert_eq!(pairs.count(), 10); | ||
| assert_eq!( | ||
| pairs.next(), | ||
| Some(( | ||
| Cow::Borrowed("entrypoint"), | ||
| Cow::Borrowed("test_pairing_flow_url") | ||
| )) | ||
| ); | ||
| assert_eq!( | ||
| pairs.next(), | ||
| Some((Cow::Borrowed("service"), Cow::Borrowed("sync"))) | ||
| ); | ||
| assert_eq!( | ||
| pairs.next(), | ||
| Some((Cow::Borrowed("client_id"), Cow::Borrowed("12345678"))) | ||
|
|
@@ -832,6 +857,7 @@ mod tests { | |
| PAIRING_URL, | ||
| &["https://identity.mozilla.com/apps/oldsync"], | ||
| "test_pairiong_flow_origin_mismatch", | ||
| &["sync"], | ||
| ); | ||
|
|
||
| assert!(url.is_err()); | ||
|
|
@@ -1099,7 +1125,7 @@ mod tests { | |
| ); | ||
| let mut fxa = FirefoxAccount::with_config(config); | ||
| let url = fxa | ||
| .begin_oauth_flow(&[OLD_SYNC, "profile"], "test_entrypoint") | ||
| .begin_oauth_flow(&[OLD_SYNC, "profile"], "test_entrypoint", &["sync"]) | ||
| .unwrap(); | ||
| let url = Url::parse(&url).unwrap(); | ||
| let state = url.query_pairs().find(|(name, _)| name == "state").unwrap(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should expose the service param here and use the default value from here since there is this thin wrapper around the rust generated FFI code.