1
0
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:
Richard van der Hoff
2017-06-20 10:44:03 +01:00
committed by GitHub
parent d7e1910076
commit e6b35a9237
6 changed files with 46 additions and 13 deletions

View File

@@ -2,5 +2,4 @@ language: node_js
node_js:
- node # Latest stable version of nodejs.
script:
- npm run lint
- npm run test
- ./travis.sh

View File

@@ -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';

View File

@@ -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
View 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");
}

View File

@@ -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;
/**

10
travis.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
set -ex
npm run lint
# install Olm so that we can run the crypto tests.
npm install https://matrix.org/packages/npm/olm/olm-2.2.2.tgz
npm run test