Bug 1640765 - only build the rust fxa-client crate on Nightly. r=lina

Differential Revision: https://phabricator.services.mozilla.com/D76771
This commit is contained in:
Ryan Kelly 2020-05-27 05:51:39 +00:00
parent 15858ad28e
commit bc3600def8
9 changed files with 80 additions and 44 deletions

View File

@ -7,8 +7,6 @@
with Files('**'):
BUG_COMPONENT = ('Firefox', 'Firefox Accounts')
DIRS += ['rust-bridge']
MOCHITEST_CHROME_MANIFESTS += ['tests/mochitest/chrome.ini']
BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
@ -36,6 +34,9 @@ EXTRA_JS_MODULES += [
'RustFxAccount.js',
]
if CONFIG['MOZ_RUST_FXA_CLIENT']:
DIRS += ['rust-bridge']
XPCOM_MANIFESTS += [
'components.conf',
]

View File

@ -9,49 +9,57 @@
// We are simply assessing that the Rust XPCOM
// and the Viaduct plumbing work!
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
const { RustFxAccount } = ChromeUtils.import(
"resource://gre/modules/RustFxAccount.js"
);
add_task(async function test_authenticated_get_request() {
let serverCalls = 0;
const server = httpd_setup({
"/.well-known/openid-configuration": function(request, response) {
response.setStatusLine(request.httpVersion, 200, "OK");
const body = JSON.stringify({
authorization_endpoint: "https://foo.bar/authorization",
introspection_endpoint: "https://oauth.foo.bar/v1/introspect",
issuer: "https://foo.bar",
jwks_uri: "https://oauth.foo.bar/v1/jwks",
revocation_endpoint: "https://oauth.foo.bar/v1/destroy",
token_endpoint: "https://oauth.foo.bar/v1/token",
userinfo_endpoint: "https://profile.foo.bar/v1/profile",
});
response.bodyOutputStream.write(body, body.length);
serverCalls++;
},
"/.well-known/fxa-client-configuration": function(request, response) {
response.setStatusLine(request.httpVersion, 200, "OK");
const body = JSON.stringify({
auth_server_base_url: "https://api.foo.bar",
oauth_server_base_url: "https://oauth.foo.bar",
pairing_server_base_uri: "wss://channelserver.services.mozilla.com",
profile_server_base_url: "https://profile.foo.bar",
sync_tokenserver_base_url: "https://token.services.mozilla.com",
});
response.bodyOutputStream.write(body, body.length);
serverCalls++;
},
});
add_task(
{
skip_if: () => !AppConstants.MOZ_RUST_FXA_CLIENT,
},
async function test_authenticated_get_request() {
let serverCalls = 0;
const server = httpd_setup({
"/.well-known/openid-configuration": function(request, response) {
response.setStatusLine(request.httpVersion, 200, "OK");
const body = JSON.stringify({
authorization_endpoint: "https://foo.bar/authorization",
introspection_endpoint: "https://oauth.foo.bar/v1/introspect",
issuer: "https://foo.bar",
jwks_uri: "https://oauth.foo.bar/v1/jwks",
revocation_endpoint: "https://oauth.foo.bar/v1/destroy",
token_endpoint: "https://oauth.foo.bar/v1/token",
userinfo_endpoint: "https://profile.foo.bar/v1/profile",
});
response.bodyOutputStream.write(body, body.length);
serverCalls++;
},
"/.well-known/fxa-client-configuration": function(request, response) {
response.setStatusLine(request.httpVersion, 200, "OK");
const body = JSON.stringify({
auth_server_base_url: "https://api.foo.bar",
oauth_server_base_url: "https://oauth.foo.bar",
pairing_server_base_uri: "wss://channelserver.services.mozilla.com",
profile_server_base_url: "https://profile.foo.bar",
sync_tokenserver_base_url: "https://token.services.mozilla.com",
});
response.bodyOutputStream.write(body, body.length);
serverCalls++;
},
});
const fxa = new RustFxAccount({
fxaServer: server.baseURI,
clientId: "abcd",
redirectUri: "https://foo.bar/1234",
});
const oauthFlowUrl = await fxa.beginOAuthFlow(["profile"]);
Assert.equal(2, serverCalls);
Assert.ok(oauthFlowUrl.startsWith("https://foo.bar/authorization"));
const fxa = new RustFxAccount({
fxaServer: server.baseURI,
clientId: "abcd",
redirectUri: "https://foo.bar/1234",
});
const oauthFlowUrl = await fxa.beginOAuthFlow(["profile"]);
Assert.equal(2, serverCalls);
Assert.ok(oauthFlowUrl.startsWith("https://foo.bar/authorization"));
await promiseStopServer(server);
});
await promiseStopServer(server);
}
);

View File

@ -32,6 +32,7 @@ wasm_library_sandboxing = ["gkrust-shared/wasm_library_sandboxing"]
webgpu = ["gkrust-shared/webgpu"]
remote_agent = ["gkrust-shared/remote"]
glean = ["gkrust-shared/glean"]
rust_fxa_client = ["gkrust-shared/rust_fxa_client"]
[dependencies]
bench-collections-gtest = { path = "../../../../xpcom/rust/gtest/bench-collections" }

View File

@ -33,6 +33,7 @@ wasm_library_sandboxing = ["gkrust-shared/wasm_library_sandboxing"]
webgpu = ["gkrust-shared/webgpu"]
remote_agent = ["gkrust-shared/remote"]
glean = ["gkrust-shared/glean"]
rust_fxa_client = ["gkrust-shared/rust_fxa_client"]
[dependencies]
gkrust-shared = { path = "shared" }

View File

@ -77,5 +77,8 @@ if CONFIG['ENABLE_REMOTE_AGENT']:
if CONFIG['MOZ_GLEAN']:
gkrust_features += ['glean']
if CONFIG['MOZ_RUST_FXA_CLIENT']:
gkrust_features += ['rust_fxa_client']
if CONFIG['MOZ_USING_WASM_SANDBOXING']:
gkrust_features += ['wasm_library_sandboxing']

View File

@ -65,9 +65,9 @@ rusqlite = { version = "0.23.1", features = ["modern_sqlite", "in_gecko"] }
fluent = { version = "0.11" , features = ["fluent-pseudo"] }
fluent-ffi = { path = "../../../../intl/l10n/rust/fluent-ffi" }
firefox-accounts-bridge = { path = "../../../../services/fxaccounts/rust-bridge/firefox-accounts-bridge", optional=true }
[target.'cfg(not(target_os = "android"))'.dependencies]
firefox-accounts-bridge = { path = "../../../../services/fxaccounts/rust-bridge/firefox-accounts-bridge" }
viaduct = { git = "https://github.com/mozilla/application-services", rev = "77a7f5eb12a8d93f2bd71bd4d844405e06743365"}
webext_storage_bridge = { path = "../../../components/extensions/storage/webext_storage_bridge" }
@ -102,6 +102,7 @@ wasm_library_sandboxing = ["rlbox_lucet_sandbox"]
webgpu = ["wgpu_bindings"]
remote_agent = ["remote"]
glean = ["fog"]
rust_fxa_client = ["firefox-accounts-bridge"]
[lib]
path = "lib.rs"

View File

@ -26,7 +26,7 @@ extern crate cubeb_coreaudio;
extern crate cubeb_pulse;
extern crate encoding_glue;
extern crate env_logger;
#[cfg(not(target_os = "android"))]
#[cfg(feature = "rust_fxa_client")]
extern crate firefox_accounts_bridge;
#[cfg(feature = "glean")]
extern crate fog;

View File

@ -411,4 +411,11 @@ this.AppConstants = Object.freeze({
#else
false,
#endif
MOZ_RUST_FXA_CLIENT:
#ifdef MOZ_RUST_FXA_CLIENT
true,
#else
false,
#endif
});

View File

@ -1985,6 +1985,20 @@ set_config('MOZ_GLEAN', True, when=glean)
set_define('MOZ_GLEAN', True, when=glean)
# New Firefox Accounts client implemented in Rust
# ===============================================
@depends(milestone, target)
def rust_fxa_client(milestone, target):
if milestone.is_nightly and target.os != 'Android':
return True
set_config('MOZ_RUST_FXA_CLIENT', True, when=rust_fxa_client)
set_define('MOZ_RUST_FXA_CLIENT', True, when=rust_fxa_client)
# dump_syms
# ==============================================================