Ejemplo n.º 1
0
exports["test site authentication credentials"] = function(assert) {
  let options = {
    url: "http://test.authentication.com",
    username: "******",
    password: "******",
    realm: "r"
  };

  store(options);
  assert.ok(search().length, "credential was stored");
  assert.ok(search(options).length, "stored credential found");
  assert.ok(search({ username: options.username }).length, "found by username");
  assert.ok(search({ password: options.password }).length, "found by password");
  assert.ok(search({ realm: options.realm }).length, "found by realm");
  assert.ok(search({ url: options.url }).length, "found by url");

  let credential = search(options)[0];
  assert.equal(credential.url, options.url, "url matches");
  assert.equal(credential.username, options.username, "username matches");
  assert.equal(credential.password, options.password, "password matches");
  assert.equal(credential.realm, options.realm, "realm matches");
  assert.equal(credential.formSubmitURL, null,
               "`formSubmitURL` is `null` for site authentication credentials");
  assert.equal(credential.usernameField, "", "usernameField is empty");
  assert.equal(credential.passwordField, "", "passwordField is empty");

  remove(search(options)[0]);
  assert.ok(!search(options).length, "remove worked");
};
Ejemplo n.º 2
0
exports["test can't store same login twice"] = function(assert) {
  let options = { username: "******", password: "******", realm: "realm" };
  store(options);
  assert.throws(function() {
    store(options);
  }, "can't store same pass twice");
  remove(options);
};
Ejemplo n.º 3
0
exports["test web page associated credentials"] = function(assert) {
  let options = {
    url: "http://www.example.com",
    formSubmitURL: "http://login.example.com",
    username: "******",
    password: "******",
    usernameField: "user-f",
    passwordField: "pass-f"
  };
  store({
    url: "http://www.example.com/login",
    formSubmitURL: "http://login.example.com/foo/authenticate.cgi",
    username: options.username,
    password: options.password,
    usernameField: options.usernameField,
    passwordField: options.passwordField
  });

  assert.ok(search().length, "credential was stored");
  assert.ok(search(options).length, "stored credential found");
  assert.ok(search({ username: options.username }).length, "found by username");
  assert.ok(search({ password: options.password }).length, "found by password");
  assert.ok(search({ formSubmitURL: options.formSubmitURL }).length,
            "found by formSubmitURL");
  assert.ok(search({ usernameField: options.usernameField }).length,
            "found by usernameField");
  assert.ok(search({ passwordField: options.passwordField }).length,
            "found by passwordField");

  let credential = search(options)[0];
  assert.equal(credential.url, options.url, "url matches");
  assert.equal(credential.username, options.username, "username matches");
  assert.equal(credential.password, options.password, "password matches");
  assert.equal(credential.realm, null, "realm is ");
  assert.equal(credential.formSubmitURL, options.formSubmitURL,
               "`formSubmitURL` matches");
  assert.equal(credential.usernameField, options.usernameField,
               "usernameField matches");
  assert.equal(credential.passwordField, options.passwordField,
               "passwordField matches");

  remove(search(options)[0]);
  assert.ok(!search(options).length, "remove worked");
};
Ejemplo n.º 4
0
exports["test addon associated credentials"] = function(assert) {
  let options = { username: "******", password: "******", realm: "baz" };
  store(options);

  assert.ok(search().length, "credential was stored");
  assert.ok(search(options).length, "stored credential found");
  assert.ok(search({ username: options.username }).length, "found by username");
  assert.ok(search({ password: options.password }).length, "found by password");
  assert.ok(search({ realm: options.realm }).length, "found by realm");

  let credential = search(options)[0];
  assert.equal(credential.url.indexOf("addon:"), 0,
               "`addon:` uri is used for add-on associated credentials");
  assert.equal(credential.username, options.username, "username matches");
  assert.equal(credential.password, options.password, "password matches");
  assert.equal(credential.realm, options.realm, "realm matches");
  assert.equal(credential.formSubmitURL, null,
               "`formSubmitURL` is `null` for add-on associated credentials");
  assert.equal(credential.usernameField, "", "usernameField is empty");
  assert.equal(credential.passwordField, "", "passwordField is empty");

  remove(search(options)[0]);
  assert.ok(!search(options).length, "remove worked");
};
Ejemplo n.º 5
0
 assert.throws(function() {
   store({ username: "******", realm: "bar" });
 }, "`password` is required");
Ejemplo n.º 6
0
 assert.throws(function() {
   store(options);
 }, "can't store same pass twice");