js: remove non-browser tests

--

* The majority of tests needs to be run in a nativeMessaging context.
  Offering the few tests that don't need this context at two places
  introduces issues with maintainability. All tests now removed can be
  found in ./unittests.js
This commit is contained in:
Maximilian Krambach 2018-05-14 16:36:05 +02:00
parent 987b317468
commit d1ca90ef75
6 changed files with 0 additions and 264 deletions

View File

@ -4,9 +4,6 @@
"description": "javascript part of a nativeMessaging gnupg integration", "description": "javascript part of a nativeMessaging gnupg integration",
"main": "src/index.js", "main": "src/index.js",
"private": true, "private": true,
"scripts": {
"test": "mocha"
},
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "", "license": "",

View File

@ -1,97 +0,0 @@
/* gpgme.js - Javascript integration for gpgme
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
*
* This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
* SPDX-License-Identifier: LGPL-2.1+
*/
import { expect } from "../node_modules/chai/chai";
import { gpgme_error} from "../src/Errors";
import { GPGME_Key } from "../src/Key";
import { isLongId, isFingerprint, toKeyIdArray } from "../src/Helpers"
import { helper_params } from "./inputvalues";
export function Helpertest(){
describe('Error Object handling', function(){
it('check the Timeout error', function(){
let test0 = gpgme_error('CONN_TIMEOUT');
expect(test0).to.be.an.instanceof(Error);
expect(test0.code).to.equal('CONN_TIMEOUT');
});
it('Error Object returns generic code if code is not listed', function(){
let test0 = gpgme_error(helper_params.invalidErrorCode);
expect(test0).to.be.an.instanceof(Error);
expect(test0.code).to.equal('GENERIC_ERROR');
});
it('Warnings like PARAM_IGNORED should not return errors', function(){
let test0 = gpgme_error('PARAM_IGNORED');
expect(test0).to.be.null;
});
});
describe('Fingerprint checking', function(){
it('isFingerprint(): valid Fingerprint', function(){
let test0 = isFingerprint(helper_params.validFingerprint);
expect(test0).to.be.true;
});
it('isFingerprint(): invalid Fingerprint', function(){
let test0 = isFingerprint(helper_params.invalidFingerprint);
expect(test0).to.be.false;
});
});
describe('Converting to Fingerprint', function(){
it('Correct Inputs', function(){
it('Fingerprint string', function(){
let test0 = toKeyIdArray(helper_params.validFingerprint);
expect(test0).to.be.an('array');
expect(test0).to.include(helper_params.validFingerprint);
});
it('GPGME_Key', function(){
expect(helper_params.validGPGME_Key).to.be.an.instanceof(GPGME_Key);
let test0 = toKeyIdArray(helper_params.validGPGME_Key);
expect(test0).to.be.an('array');
expect(test0).to.include(helper_params.validGPGME_Key.fingerprint);
});
it('Array of valid inputs', function(){
let test0 = toKeyIdArray(helper_params.validKeys);
expect(test0).to.be.an('array');
expect(test0).to.have.lengthOf(helper_params.validKeys.length);
});
});
describe('Incorrect inputs', function(){
it('valid Long ID', function(){
let test0 = toKeyIdArray(helper_params.validLongId);
expect(test0).to.be.empty;
});
it('invalidFingerprint', function(){
let test0 = toKeyIdArray(helper_params.invalidFingerprint);
expect(test0).to.be.empty;
});
it('invalidKeyArray', function(){
let test0 = toKeyIdArray(helper_params.invalidKeyArray);
expect(test0).to.be.empty;
});
it('Partially invalid array', function(){
let test0 = toKeyIdArray(helper_params.invalidKeyArray_OneBad);
expect(test0).to.be.an('array');
expect(test0).to.have.lengthOf(
helper_params.invalidKeyArray_OneBad.length - 1);
});
});
});
};
export default Helpertest;

View File

@ -1,93 +0,0 @@
/* gpgme.js - Javascript integration for gpgme
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
*
* This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
* SPDX-License-Identifier: LGPL-2.1+
*/
import { expect } from "../node_modules/chai/chai";
import { GPGME_Message, createMessage } from "../src/Message";
import { message_params as mp, helper_params as hp} from "./inputvalues";
export function Messagetest(){
describe('Message Object', function(){
describe('correct initialization of an encrypt Message', function(){
it('creating Message', function(){
let test0 = createMessage('encrypt');
expect(test0).to.be.an.instanceof(GPGME_Message);
expect(test0.isComplete).to.be.false;
});
it('Message is complete after setting mandatoy data', function(){
let test0 = createMessage('encrypt');
test0.setParameter('data', mp.valid_encrypt_data);
test0.setParameter('keys', hp.validFingerprints);
expect(test0.isComplete).to.be.true;
});
it('Complete Message contains the data that was set', function(){
let test0 = createMessage('encrypt');
test0.setParameter('data', mp.valid_encrypt_data);
test0.setParameter('keys', hp.validFingerprints);
expect(test0.message).to.not.be.null;
expect(test0.message).to.have.keys('op', 'data', 'keys');
expect(test0.message.op).to.equal('encrypt');
expect(test0.message.data).to.equal(
mp.valid_encrypt_data);
});
});
describe('Incorrect initialization', function(){
it('non-allowed operation', function(){
let test0 = createMessage(mp.invalid_op_action);
expect(test0).to.be.an.instanceof(Error);
expect(test0.code).to.equal('MSG_WRONG_OP');
});
it('wrong parameter type in constructor', function(){
let test0 = createMessage(mp.invalid_op_type);
expect(test0).to.be.an.instanceof(Error);
expect(test0.code).to.equal('PARAM_WRONG');
});
});
describe('Setting wrong parameters', function(){
it('Wrong parameter name', function(){
let test0 = createMessage(mp.invalid_param_test.valid_op);
for (let i=0; i < mp.invalid_param_test.invalid_param_names.length; i++){
let ret = test0.setParameter(
mp.invalid_param_test.invalid_param_names[i],
'Somevalue');
expect(ret).to.be.an.instanceof(Error);
expect(ret.code).to.equal('PARAM_WRONG');
}
});
it('Wrong parameter value', function(){
let test0 = createMessage(mp.invalid_param_test.valid_op);
for (let j=0;
j < mp.invalid_param_test.invalid_values_0.length;
j++){
let ret = test0.setParameter(
mp.invalid_param_test.validparam_name_0,
mp.invalid_param_test.invalid_values_0[j]);
expect(ret).to.be.an.instanceof(Error);
expect(ret.code).to.equal('PARAM_WRONG');
}
});
});
});
}
export default Messagetest;

View File

@ -1,28 +0,0 @@
/* gpgme.js - Javascript integration for gpgme
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
*
* This file is part of GPGME.
*
* GPGME is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* GPGME is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses/>.
* SPDX-License-Identifier: LGPL-2.1+
*/
import { Helpertest } from "./Helpers";
import { Messagetest } from "./Message";
/**
* Unit tests.
*/
Helpertest();
Messagetest();

View File

@ -1,39 +0,0 @@
import { gpgme_error } from "../src/Errors";
export const helper_params = {
validLongId: '0A0A0A0A0A0A0A0A',
validKeys: ['A1E3BC45BDC8E87B74F4392D53B151A1368E50F3',
'ADDBC303B6D31026F5EB4591A27EABDF283121BB',
'EE17AEE730F88F1DE7713C54BBE0A4FF7851650A'],
validFingerprint: '9A9A7A7A8A9A9A7A7A8A9A9A7A7A8A9A9A7A7A8A',
validFingerprints: ['9A9A7A7A8A9A9A7A7A8A9A9A7A7A8A9A9A7A7A8A',
'9AAE7A338A9A9A7A7A8A9A9A7A7A8A9A9A7A7DDA'],
invalidLongId: '9A9A7A7A8A9A9A7A7A8A',
invalidFingerprint: [{hello:'World'}],
invalidKeyArray: {curiosity:'uncat'},
invalidKeyArray_OneBad: [
'12AE9F3E41B33BF77DF52B6BE8EE1992D7909B08',
'E1D18E6E994FA9FE9360Bx0E687B940FEFEB095A',
'3AEA7FE4F5F416ED18CEC63DD519450D9C0FAEE5'],
invalidErrorCode: 'Please type in all your passwords.',
}
export const message_params = {
invalid_op_action : 'dance',
invalid_op_type : [234, 34, '<>'],
valid_encrypt_data: "مرحبا بالعالم",
invalid_param_test: {
valid_op: 'encrypt',
invalid_param_names: [22,'dance', {}],
validparam_name_0: 'mime',
invalid_values_0: [2134, 'All your passwords', gpgme_error('12AE9F3E41B33BF77DF52B6BE8EE1992D7909B08'), null]
}
}
export const whatever_params = {
four_invalid_params: ['<(((-<', '>°;==;~~', '^^', '{{{{o}}}}']
}
export default {
helper_params: helper_params,
message_params: message_params
}

View File

@ -1,4 +0,0 @@
--require babel-register
--reporter spec
--ui bdd
--colors