snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
This commit is contained in:
84
web/tests/password.test.cjs
Normal file
84
web/tests/password.test.cjs
Normal file
@@ -0,0 +1,84 @@
|
||||
"use strict";
|
||||
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const {zrequire} = require("./lib/namespace.cjs");
|
||||
const {run_test} = require("./lib/test.cjs");
|
||||
|
||||
const {password_quality, password_warning} = zrequire("password_quality");
|
||||
|
||||
function password_field(min_length, max_length, min_guesses) {
|
||||
return {
|
||||
attr(name) {
|
||||
switch (name) {
|
||||
case "data-min-length":
|
||||
return min_length;
|
||||
case "data-min-guesses":
|
||||
return min_guesses;
|
||||
case "data-max-length":
|
||||
return max_length;
|
||||
/* istanbul ignore next */
|
||||
default:
|
||||
throw new Error(`Unknown attribute ${name}`);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
run_test("basics w/progress bar", () => {
|
||||
let accepted;
|
||||
let password;
|
||||
let warning;
|
||||
|
||||
const $bar = (function () {
|
||||
const $self = {};
|
||||
|
||||
$self.width = (width) => {
|
||||
$self.w = width;
|
||||
return $self;
|
||||
};
|
||||
|
||||
$self.removeClass = (arg) => {
|
||||
assert.equal(arg, "bar-success bar-danger");
|
||||
return $self;
|
||||
};
|
||||
|
||||
$self.addClass = (arg) => {
|
||||
$self.added_class = arg;
|
||||
return $self;
|
||||
};
|
||||
|
||||
return $self;
|
||||
})();
|
||||
|
||||
password = "z!X4@S_&";
|
||||
accepted = password_quality(password, $bar, password_field(10, 80000));
|
||||
assert.ok(!accepted);
|
||||
assert.equal($bar.w, "39.7%");
|
||||
assert.equal($bar.added_class, "bar-danger");
|
||||
warning = password_warning(password, password_field(10));
|
||||
assert.equal(warning, "translated: Password should be at least 10 characters long.");
|
||||
|
||||
password = "foo";
|
||||
accepted = password_quality(password, $bar, password_field(2, 200, 10));
|
||||
assert.ok(accepted);
|
||||
assert.equal($bar.w, "10.390277164940581%");
|
||||
assert.equal($bar.added_class, "bar-success");
|
||||
warning = password_warning(password, password_field(2));
|
||||
assert.equal(warning, "translated: Password is too weak.");
|
||||
|
||||
password = "aaaaaaaa";
|
||||
accepted = password_quality(password, $bar, password_field(6, 1e100));
|
||||
assert.ok(!accepted);
|
||||
assert.equal($bar.added_class, "bar-danger");
|
||||
warning = password_warning(password, password_field(6));
|
||||
assert.equal(warning, 'Repeated characters like "aaa" are easy to guess.');
|
||||
|
||||
// Test a password that's longer than the configured limit.
|
||||
password = "hfHeo34FksdBChjeruShJ@sidfgusd";
|
||||
accepted = password_quality(password, $bar, password_field(6, 20, 1e20));
|
||||
assert.ok(!accepted);
|
||||
assert.equal($bar.added_class, "bar-danger");
|
||||
warning = password_warning(password, password_field(6, 20, 1e20));
|
||||
assert.equal(warning, `translated: Maximum password length: 20 characters.`);
|
||||
});
|
||||
Reference in New Issue
Block a user