summaryrefslogtreecommitdiffstats
path: root/services/fxaccounts/tests/xpcshell/test_oauth_client.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /services/fxaccounts/tests/xpcshell/test_oauth_client.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'services/fxaccounts/tests/xpcshell/test_oauth_client.js')
-rw-r--r--services/fxaccounts/tests/xpcshell/test_oauth_client.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/services/fxaccounts/tests/xpcshell/test_oauth_client.js b/services/fxaccounts/tests/xpcshell/test_oauth_client.js
new file mode 100644
index 000000000..9bcb1b1ab
--- /dev/null
+++ b/services/fxaccounts/tests/xpcshell/test_oauth_client.js
@@ -0,0 +1,55 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+Cu.import("resource://gre/modules/FxAccountsOAuthClient.jsm");
+
+function run_test() {
+ validationHelper(undefined,
+ "Error: Missing 'parameters' configuration option");
+
+ validationHelper({},
+ "Error: Missing 'parameters' configuration option");
+
+ validationHelper({ parameters: {} },
+ "Error: Missing 'parameters.oauth_uri' parameter");
+
+ validationHelper({ parameters: {
+ oauth_uri: "http://oauth.test/v1"
+ }},
+ "Error: Missing 'parameters.client_id' parameter");
+
+ validationHelper({ parameters: {
+ oauth_uri: "http://oauth.test/v1",
+ client_id: "client_id"
+ }},
+ "Error: Missing 'parameters.content_uri' parameter");
+
+ validationHelper({ parameters: {
+ oauth_uri: "http://oauth.test/v1",
+ client_id: "client_id",
+ content_uri: "http://content.test"
+ }},
+ "Error: Missing 'parameters.state' parameter");
+
+ validationHelper({ parameters: {
+ oauth_uri: "http://oauth.test/v1",
+ client_id: "client_id",
+ content_uri: "http://content.test",
+ state: "complete",
+ action: "force_auth"
+ }},
+ "Error: parameters.email is required for action 'force_auth'");
+
+ run_next_test();
+}
+
+function validationHelper(params, expected) {
+ try {
+ new FxAccountsOAuthClient(params);
+ } catch (e) {
+ return do_check_eq(e.toString(), expected);
+ }
+ throw new Error("Validation helper error");
+}