Browse Source

Get test suite going again, all tests still fail: Remove irrelevant tests, fix paths.

1.1.101
Jorg Knobloch 1 year ago
parent
commit
6a1ea9e40a
10 changed files with 13 additions and 785 deletions
  1. +4
    -4
      tests/boilerplate.js
  2. +1
    -1
      tests/features/decrypt_feature_spec.js
  3. +1
    -1
      tests/features/encrypt_feature_spec.js
  4. +1
    -1
      tests/features/identity_rating_feature_spec.js
  5. +1
    -1
      tests/features/is_pEp_user_feature_spec.js
  6. +3
    -2
      tests/messages.js
  7. +2
    -2
      tests/mock.js
  8. +0
    -50
      tests/unit/accountOptions.js
  9. +0
    -668
      tests/unit/message.js
  10. +0
    -55
      tests/unit/mimeEmitter.js

+ 4
- 4
tests/boilerplate.js View File

@ -5,10 +5,10 @@
const os = require('os');
const fs = require('fs');
const pEp = require('../chrome/content/modules/pEp');
const pEpAdapter = require('../chrome/content/modules/pEpAdapter');
const pEpServer = require('../chrome/content/modules/pEpServer');
const pEpLogger = require('../chrome/content/pEpLogger');
const pEp = require('../addon/content/modules/pEp');
const pEpAdapter = require('../addon/content/modules/pEpAdapter');
const pEpServer = require('../addon/content/modules/pEpServer');
const pEpLogger = require('../addon/content/pEpLogger');
/* eslint new-cap: ["error", { "newIsCap": false }] */


+ 1
- 1
tests/features/decrypt_feature_spec.js View File

@ -6,7 +6,7 @@ const chai = require('chai').use(require('chai-as-promised'));
const btoa = require('btoa');
chai.should();
const pEp = require('../../chrome/content/modules/pEp');
const pEp = require('../../addon/content/modules/pEp');
describe('pEp Decrypt Feature', () => {
const {getQueue} = require('../mock');


+ 1
- 1
tests/features/encrypt_feature_spec.js View File

@ -5,7 +5,7 @@ const {
const chai = require('chai').use(require('chai-as-promised'));
chai.should();
const pEp = require('../../chrome/content/modules/pEp');
const pEp = require('../../addon/content/modules/pEp');
const {getQueue} = require('../mock');
const {getController} = require('../boilerplate');


+ 1
- 1
tests/features/identity_rating_feature_spec.js View File

@ -2,7 +2,7 @@
let {describe, it, before, beforeEach} = require('mocha');
let chai = require('chai').use(require('chai-as-promised'));
chai.should();
let pEp = require('../../chrome/content/modules/pEp');
let pEp = require('../../addon/content/modules/pEp');
describe('pEp Identity Rating Feature', () => {


+ 1
- 1
tests/features/is_pEp_user_feature_spec.js View File

@ -2,7 +2,7 @@
let {describe, it, before, beforeEach} = require('mocha');
let chai = require('chai').use(require('chai-as-promised'));
chai.should();
let pEp = require('../../chrome/content/modules/pEp');
let pEp = require('../../addon/content/modules/pEp');
describe('pEp Is pEp User Feature', () => {


+ 3
- 2
tests/messages.js View File

@ -1,6 +1,7 @@
let btoa = require('btoa');
let pEp = require('../chrome/content/modules/pEp');
let c = pEp.cloneMessage;
function c(msg) {
JSON.parse(JSON.stringify(msg));
}
module.exports = {
encrypted: c({


+ 2
- 2
tests/mock.js View File

@ -6,8 +6,8 @@ const {expect} = require('chai');
const sinon = require('sinon');
// unset to use the actual server
const mocked = true;
const XhrQueue = require('../chrome/content/modules/xhrQueue');
const pEpLogger = require('../chrome/content/pEpLogger');
const XhrQueue = require('../addon/content/modules/xhrQueue');
const pEpLogger = require('../addon/content/pEpLogger');
function getQueue() {


+ 0
- 50
tests/unit/accountOptions.js View File

@ -1,50 +0,0 @@
let {describe, it, before, beforeEach} = require('mocha');
let chai = require('chai').use(require('chai-as-promised'));
let expect = require('chai').expect
let AccountOptions = require('../../chrome/content/modules/AccountOptions');
describe("account preferences", () => {
let options;
before(() => {
options = AccountOptions.fromDefaults(["account1", "account2"]);
});
it("serialises, parses, compares", () => {
let o2 = AccountOptions.parse(options.serialise());
expect(AccountOptions.equals(o2, options));
});
it("generates updaters", () => {
let accountsMock = {
"account1": { defaultIdentity: { fullName: "name <address>" } },
"account2": { defaultIdentity: { fullName: "name <address>" } }
};
let updates = options.getUpdates(options, accountsMock);
expect(updates.length).to.equal(2);
});
it("generates readers", () => {
let readers = options.getReaders();
expect(readers["#account1-disabled"](true)).to.deep.equal(["account1", "disabled"]);
let identifiers = [
"#account1-disabled",
"#account1-decrypt",
"#account1-trusted",
"#account2-disabled",
"#account2-decrypt",
"#account2-trusted"
];
expect(Object.keys(readers)).to.deep.equal(identifiers);
});
it("generates option getters by account", () => {
expect(options.forAccount({ key: "account2" }).disabled()).to.be.false;
});
it("reacts to new or deleted accounts", () => {
let deleted = "a1";
let added = "a3";
let initial = [deleted, "a2"];
let eventual = {};
eventual["a2"] = {}; // we omit the account object
eventual[added] = {}; // we omit the account object
let options = AccountOptions.fromDefaults(initial);
options.updateAccounts(eventual);
expect(options.forAccount({ key: deleted })).to.be.null;
expect(options.forAccount({ key: added }).decrypt()).to.be.true;
});
});

+ 0
- 668
tests/unit/message.js
File diff suppressed because it is too large
View File


+ 0
- 55
tests/unit/mimeEmitter.js View File

@ -1,55 +0,0 @@
/* eslint-disable no-console */
let {describe, it, before, beforeEach} = require('mocha');
let chai = require('chai').use(require('chai-as-promised'));
let expect = require('chai').expect
let messages = require('../messages.js');
let jsmimeMock = {
headeremitter: {
emitStructuredHeader: (name, value, empty) => {
return name + ": " + value + "\r\n";
}
}
};
let MimeEmitter = require('../../chrome/content/modules/MimeEmitter');
let controller = require('../../chrome/content/modules/pEp');
let emitter = new MimeEmitter(jsmimeMock, require('atob'), 'boundary');
let expectations = {
encrypted: 'Message-ID: pEp....@pep.security\r\nSubject: p≡p\r\nX-pEp-Version: 2.1\r\nContent-Type: multipart/encrypted; protocol="application/pgp-encrypted"; boundary="boundary"\r\n\r\nthis message was encrypted with p≡p https://pEp-project.org\r\n\r\n--boundary\r\nContent-Type: application/pgp-encrypted\r\nContent-Description: PGP/MIME version identification\r\n\r\nVersion: 1\r\n\r\n--boundary\r\nContent-Type: application/octet-stream; name="msg.asc"\r\nContent-Description: OpenPGP encrypted message\r\nContent-Disposition: inline; filename="msg.asc"\r\n\r\n1337\r\n--boundary--\r\n\r\n',
unencrypted: {
simple: 'Message-ID: No-message-ID\r\nSubject: pep test\r\nContent-Type: text/plain; charset=utf-8\r\nContent-Transfer-Encoding: 7bit\r\n\r\nbody\r\n\r\n',
withAttachments: 'Message-ID: No-message-ID\r\nSubject: pep attach\r\nContent-Type: multipart/mixed; boundary="boundary"\r\n\r\nThis is a multi-part message in MIME format.\r\n\r\n--boundary\r\nContent-Type: text/plain; charset=utf-8;\r\nContent-Transfer-Encoding: 7bit\r\n\r\nbody\r\n\r\n--boundary\r\nContent-Type: image/x-icon\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment; filename="favicon.ico"\r\n\r\n1337\r\n--boundary--\r\n\r\n',
pgpMime: ''
}
};
describe('the MIME emitter', () => {
describe('multipart encoding', () => {
it('emits MIME from raw data', () => {
let parts = [{
headers: [['a', 'b']],
body: 'body 1'
}, {
headers: [['c', 'd'], ['e', 'f']],
body: 'body 2'
}];
let expected = 'a: b\r\n\r\nbody 1\r\n\r\n--boundary\r\nc: d\r\ne: f\r\n\r\nbody 2\r\n--boundary--\r\n\r\n';
expect(emitter.emit(parts))
.to.equal(expected);
});
});
describe('message serialisation', () => {
it('ducktypes encrypted messages', () => {
expect(emitter.fromMessage(controller.cloneMessage(messages.encrypted)))
.to.equal(expectations.encrypted);
});
it('ducktypes unencrypted messages', () => {
expect(emitter.fromMessage(controller.cloneMessage(messages.unencrypted.simple)))
.to.equal(expectations.unencrypted.simple);
});
it('ducktypes multipart unencrypted messages', () => {
expect(emitter.fromMessage(controller.cloneMessage(messages.unencrypted.withAttachments)))
.to.equal(expectations.unencrypted.withAttachments);
});
});
});

Loading…
Cancel
Save