services/sync/tests/unit/test_status_checkSetup.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/services/sync/tests/unit/test_status_checkSetup.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,45 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +Cu.import("resource://services-sync/constants.js");
     1.8 +Cu.import("resource://services-sync/status.js");
     1.9 +Cu.import("resource://services-sync/util.js");
    1.10 +Cu.import("resource://testing-common/services/sync/utils.js");
    1.11 +
    1.12 +function run_test() {
    1.13 +  initTestLogging("Trace");
    1.14 +  ensureLegacyIdentityManager();
    1.15 +
    1.16 +  try {
    1.17 +    _("Ensure fresh config.");
    1.18 +    Status._authManager.deleteSyncCredentials();
    1.19 +
    1.20 +    _("Fresh setup, we're not configured.");
    1.21 +    do_check_eq(Status.checkSetup(), CLIENT_NOT_CONFIGURED);
    1.22 +    do_check_eq(Status.login, LOGIN_FAILED_NO_USERNAME);
    1.23 +    Status.resetSync();
    1.24 +
    1.25 +    _("Let's provide a username.");
    1.26 +    Status._authManager.username = "johndoe";
    1.27 +    do_check_eq(Status.checkSetup(), CLIENT_NOT_CONFIGURED);
    1.28 +    do_check_eq(Status.login, LOGIN_FAILED_NO_PASSWORD);
    1.29 +    Status.resetSync();
    1.30 +
    1.31 +    do_check_neq(Status._authManager.username, null);
    1.32 +
    1.33 +    _("Let's provide a password.");
    1.34 +    Status._authManager.basicPassword = "carotsalad";
    1.35 +    do_check_eq(Status.checkSetup(), CLIENT_NOT_CONFIGURED);
    1.36 +    do_check_eq(Status.login, LOGIN_FAILED_NO_PASSPHRASE);
    1.37 +    Status.resetSync();
    1.38 +
    1.39 +    _("Let's provide a passphrase");
    1.40 +    Status._authManager.syncKey = "a-bcdef-abcde-acbde-acbde-acbde";
    1.41 +    _("checkSetup()");
    1.42 +    do_check_eq(Status.checkSetup(), STATUS_OK);
    1.43 +    Status.resetSync();
    1.44 +
    1.45 +  } finally {
    1.46 +    Svc.Prefs.resetBranch("");
    1.47 +  }
    1.48 +}

mercurial