services/sync/tests/unit/test_status_checkSetup.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 Cu.import("resource://services-sync/constants.js");
michael@0 5 Cu.import("resource://services-sync/status.js");
michael@0 6 Cu.import("resource://services-sync/util.js");
michael@0 7 Cu.import("resource://testing-common/services/sync/utils.js");
michael@0 8
michael@0 9 function run_test() {
michael@0 10 initTestLogging("Trace");
michael@0 11 ensureLegacyIdentityManager();
michael@0 12
michael@0 13 try {
michael@0 14 _("Ensure fresh config.");
michael@0 15 Status._authManager.deleteSyncCredentials();
michael@0 16
michael@0 17 _("Fresh setup, we're not configured.");
michael@0 18 do_check_eq(Status.checkSetup(), CLIENT_NOT_CONFIGURED);
michael@0 19 do_check_eq(Status.login, LOGIN_FAILED_NO_USERNAME);
michael@0 20 Status.resetSync();
michael@0 21
michael@0 22 _("Let's provide a username.");
michael@0 23 Status._authManager.username = "johndoe";
michael@0 24 do_check_eq(Status.checkSetup(), CLIENT_NOT_CONFIGURED);
michael@0 25 do_check_eq(Status.login, LOGIN_FAILED_NO_PASSWORD);
michael@0 26 Status.resetSync();
michael@0 27
michael@0 28 do_check_neq(Status._authManager.username, null);
michael@0 29
michael@0 30 _("Let's provide a password.");
michael@0 31 Status._authManager.basicPassword = "carotsalad";
michael@0 32 do_check_eq(Status.checkSetup(), CLIENT_NOT_CONFIGURED);
michael@0 33 do_check_eq(Status.login, LOGIN_FAILED_NO_PASSPHRASE);
michael@0 34 Status.resetSync();
michael@0 35
michael@0 36 _("Let's provide a passphrase");
michael@0 37 Status._authManager.syncKey = "a-bcdef-abcde-acbde-acbde-acbde";
michael@0 38 _("checkSetup()");
michael@0 39 do_check_eq(Status.checkSetup(), STATUS_OK);
michael@0 40 Status.resetSync();
michael@0 41
michael@0 42 } finally {
michael@0 43 Svc.Prefs.resetBranch("");
michael@0 44 }
michael@0 45 }

mercurial