26 test failures to go :D

pull/21833/head
Michael Telatynski 2019-12-16 11:55:01 +00:00
parent 6ad31fe023
commit 0041dae664
7 changed files with 70 additions and 10 deletions

View File

@ -154,6 +154,7 @@
"matrix-mock-request": "^1.2.3",
"matrix-react-test-utils": "^0.2.2",
"mocha": "^5.0.5",
"node-webcrypto-shim": "^0.0.1",
"react-test-renderer": "^16.9.0",
"require-json": "0.0.1",
"rimraf": "^2.4.3",
@ -163,6 +164,7 @@
"stylelint-scss": "^3.9.0",
"subtle": "^0.1.8",
"walk": "^2.3.9",
"webcrypto": "^0.1.1",
"webpack": "^4.20.2",
"webpack-cli": "^3.1.1"
}

View File

@ -78,8 +78,9 @@ describe('MessagePanel', function() {
client.credentials = {userId: '@me:here'};
// HACK: We assume all settings want to be disabled
SettingsStore.getValue = jest.fn().returns(false);
SettingsStore.getValue.withArgs('showDisplaynameChanges').returns(true);
SettingsStore.getValue = jest.fn((arg) => {
return arg === "showDisplaynameChanges";
});
// This option clobbers the duration of all animations to be 1ms
// which makes unit testing a lot simpler (the animation doesn't

View File

@ -69,7 +69,7 @@ describe('Login', function() {
});
it('should show form without change server link when custom URLs disabled', function() {
jest.spyOn(SdkConfig, "get").returns({
jest.spyOn(SdkConfig, "get").mockReturnValue({
disable_custom_urls: true,
});

View File

@ -58,7 +58,7 @@ describe('Registration', function() {
});
it('should show form when custom URLs disabled', function() {
jest.spyOn(SdkConfig, "get").returns({
jest.spyOn(SdkConfig, "get").mockReturnValue({
disable_custom_urls: true,
});

View File

@ -27,7 +27,7 @@ describe('RoomViewStore', function() {
});
it('can be used to view a room by alias and join', function(done) {
peg.get().getRoomIdForAlias.returns(Promise.resolve({room_id: "!randomcharacters:aser.ver"}));
peg.get().getRoomIdForAlias.mockResolvedValue({room_id: "!randomcharacters:aser.ver"});
peg.get().joinRoom = (roomAddress) => {
expect(roomAddress).toBe("#somealias2:aser.ver");
done();

View File

@ -16,7 +16,27 @@ limitations under the License.
"use strict";
import SubtleCrypto from 'subtle';
import webcrypto from "node-webcrypto-shim";
import {TextEncoder} from "util";
import crypto from "crypto";
function getRandomValues(buf) {
if (!(buf instanceof Uint8Array)) {
throw new TypeError('expected Uint8Array');
}
if (buf.length > 65536) {
const e = new Error();
e.code = 22;
e.message = 'Failed to execute \'getRandomValues\' on \'Crypto\': The ' +
'ArrayBufferView\'s byte length (' + buf.length + ') exceeds the ' +
'number of bytes of entropy available via this API (65536).';
e.name = 'QuotaExceededError';
throw e;
}
const bytes = crypto.randomBytes(buf.length);
buf.set(bytes);
return buf;
}
const TEST_VECTORS=[
[
@ -66,7 +86,7 @@ describe('MegolmExportEncryption', function() {
let MegolmExportEncryption;
beforeAll(() => {
window.crypto = { subtle: SubtleCrypto };
window.crypto = { ...webcrypto, getRandomValues };
MegolmExportEncryption = require("../../src/utils/MegolmExportEncryption");
});

View File

@ -2343,7 +2343,7 @@ cross-spawn@6.0.5, cross-spawn@^6.0.0, cross-spawn@^6.0.5:
shebang-command "^1.2.0"
which "^1.2.9"
crypto-browserify@^3.11.0:
crypto-browserify@^3.10.0, crypto-browserify@^3.11.0:
version "3.12.0"
resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec"
integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==
@ -2562,6 +2562,11 @@ detect-newline@^2.1.0:
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2"
integrity sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I=
detect-node@^2.0.3:
version "2.0.4"
resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.0.4.tgz#014ee8f8f669c5c58023da64b8179c083a28c46c"
integrity sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw==
di@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c"
@ -6200,7 +6205,7 @@ nan@^1.6.2:
resolved "https://registry.yarnpkg.com/nan/-/nan-1.9.0.tgz#1a9cd2755609766f5c291e4194fce39fde286515"
integrity sha1-GpzSdVYJdm9cKR5BlPzjn94oZRU=
nan@^2.12.1:
nan@^2.12.1, nan@^2.13.2:
version "2.14.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==
@ -6341,6 +6346,23 @@ node-releases@^1.1.41:
dependencies:
semver "^6.3.0"
node-webcrypto-ossl@^1.0.31:
version "1.0.48"
resolved "https://registry.yarnpkg.com/node-webcrypto-ossl/-/node-webcrypto-ossl-1.0.48.tgz#640e9547f8ae1d0becc8374a65e1d0e11ab385ea"
integrity sha512-MWUkQ/5wrs7lpAr+fhsLMfjdxKGd3dQFVqWbNMkyYyCMRW8E7ScailqtCZYDLTnJtU6B+91rXxCJNyZvbYaSOg==
dependencies:
mkdirp "^0.5.1"
nan "^2.13.2"
tslib "^1.9.3"
webcrypto-core "^0.1.26"
node-webcrypto-shim@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/node-webcrypto-shim/-/node-webcrypto-shim-0.0.1.tgz#674167cfb688c3a9cc5b1650b89b11395080f31a"
integrity sha512-8MBE1nDPpJ5IMM48K98EZ6UZavN/Y3P2SKkmux9Pr8RkQNCy3ahVOayjSE8g6/EGpN5w6nT+Vj9RvZ8iXY6HxQ==
dependencies:
node-webcrypto-ossl "^1.0.31"
nopt@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d"
@ -8995,7 +9017,7 @@ trough@^1.0.0:
resolved "https://registry.yarnpkg.com/trough/-/trough-1.0.4.tgz#3b52b1f13924f460c3fbfd0df69b587dbcbc762e"
integrity sha512-tdzBRDGWcI1OpPVmChbdSKhvSVurznZ8X36AYURAcl+0o2ldlCY2XPzyXNNxwJwwyIU+rIglTCG4kxtNKBQH7Q==
tslib@^1.8.1, tslib@^1.9.0:
tslib@^1.7.1, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
version "1.10.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==
@ -9401,6 +9423,21 @@ watchpack@^1.6.0:
graceful-fs "^4.1.2"
neo-async "^2.5.0"
webcrypto-core@^0.1.26:
version "0.1.26"
resolved "https://registry.yarnpkg.com/webcrypto-core/-/webcrypto-core-0.1.26.tgz#977e5cdd9173db6ac8b18414d66ee3759a8b1024"
integrity sha512-BZVgJZkkHyuz8loKvsaOKiBDXDpmMZf5xG4QAOlSeYdXlFUl9c1FRrVnAXcOdb4fTHMG+TRu81odJwwSfKnWTA==
dependencies:
tslib "^1.7.1"
webcrypto@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/webcrypto/-/webcrypto-0.1.1.tgz#63316e5ecbce6ce965ab5f259c2faa62c3e782b4"
integrity sha512-BAvoatS38TbHdyt42ECLroi27NmDh5iea5l5rHC6nZTZjlbJlndrT0FoIiEq7fmPHpmNtP0lMFKVMEKZQFIrGA==
dependencies:
crypto-browserify "^3.10.0"
detect-node "^2.0.3"
webidl-conversions@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"