You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2026-01-03 23:22:30 +03:00
Run the crypto tests under travis (#467)
The crypto tests haven't been running since things got rearranged to expect
Olm in a global (41864d4). Reinstate them.
This commit is contained in:
committed by
GitHub
parent
d7e1910076
commit
e6b35a9237
@@ -2,5 +2,4 @@ language: node_js
|
||||
node_js:
|
||||
- node # Latest stable version of nodejs.
|
||||
script:
|
||||
- npm run lint
|
||||
- npm run test
|
||||
- ./travis.sh
|
||||
|
||||
@@ -17,6 +17,9 @@ limitations under the License.
|
||||
|
||||
"use strict";
|
||||
|
||||
// load olm before the sdk if possible
|
||||
import './olm-loader';
|
||||
|
||||
import sdk from '..';
|
||||
import testUtils from './test-utils';
|
||||
import MockHttpBackend from './mock-request';
|
||||
|
||||
@@ -16,18 +16,10 @@ limitations under the License.
|
||||
|
||||
"use strict";
|
||||
|
||||
import 'source-map-support/register';
|
||||
|
||||
let Olm = null;
|
||||
try {
|
||||
Olm = require('olm');
|
||||
} catch (e) {}
|
||||
|
||||
const anotherjson = require('another-json');
|
||||
const q = require('q');
|
||||
import expect from 'expect';
|
||||
|
||||
const sdk = require('../..');
|
||||
const utils = require('../../lib/utils');
|
||||
const testUtils = require('../test-utils');
|
||||
const TestClient = require('../TestClient').default;
|
||||
@@ -46,7 +38,7 @@ function createOlmSession(olmAccount, recipientTestClient) {
|
||||
const otkId = utils.keys(keys)[0];
|
||||
const otk = keys[otkId];
|
||||
|
||||
const session = new Olm.Session();
|
||||
const session = new global.Olm.Session();
|
||||
session.create_outbound(
|
||||
olmAccount, recipientTestClient.getDeviceKey(), otk.key,
|
||||
);
|
||||
@@ -209,9 +201,11 @@ function getSyncResponse(roomMembers) {
|
||||
|
||||
|
||||
describe("megolm", function() {
|
||||
if (!sdk.CRYPTO_ENABLED) {
|
||||
if (!global.Olm) {
|
||||
console.warn('not running megolm tests: Olm not present');
|
||||
return;
|
||||
}
|
||||
const Olm = global.Olm;
|
||||
|
||||
let testOlmAccount;
|
||||
let testSenderKey;
|
||||
|
||||
24
spec/olm-loader.js
Normal file
24
spec/olm-loader.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright 2017 Vector creations Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// try to load the olm library.
|
||||
|
||||
try {
|
||||
global.Olm = require('olm');
|
||||
console.log('loaded libolm');
|
||||
} catch (e) {
|
||||
console.warn("unable to run crypto tests: libolm not available");
|
||||
}
|
||||
@@ -2,7 +2,10 @@
|
||||
import expect from 'expect';
|
||||
import q from 'q';
|
||||
|
||||
const sdk = require("..");
|
||||
// load olm before the sdk if possible
|
||||
import './olm-loader';
|
||||
|
||||
import sdk from '..';
|
||||
const MatrixEvent = sdk.MatrixEvent;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user