|
Packit Service |
30b792 |
/* gpgme.js - Javascript integration for gpgme
|
|
Packit Service |
30b792 |
* Copyright (C) 2018 Bundesamt für Sicherheit in der Informationstechnik
|
|
Packit Service |
30b792 |
*
|
|
Packit Service |
30b792 |
* This file is part of GPGME.
|
|
Packit Service |
30b792 |
*
|
|
Packit Service |
30b792 |
* GPGME is free software; you can redistribute it and/or modify it
|
|
Packit Service |
30b792 |
* under the terms of the GNU Lesser General Public License as
|
|
Packit Service |
30b792 |
* published by the Free Software Foundation; either version 2.1 of
|
|
Packit Service |
30b792 |
* the License, or (at your option) any later version.
|
|
Packit Service |
30b792 |
*
|
|
Packit Service |
30b792 |
* GPGME is distributed in the hope that it will be useful, but
|
|
Packit Service |
30b792 |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
30b792 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
30b792 |
* Lesser General Public License for more details.
|
|
Packit Service |
30b792 |
*
|
|
Packit Service |
30b792 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
30b792 |
* License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
|
Packit Service |
30b792 |
* SPDX-License-Identifier: LGPL-2.1+
|
|
Packit Service |
30b792 |
*
|
|
Packit Service |
30b792 |
* Author(s):
|
|
Packit Service |
30b792 |
* Maximilian Krambach <mkrambach@intevation.de>
|
|
Packit Service |
30b792 |
*/
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
/* global describe, it, expect, before, Gpgmejs */
|
|
Packit Service |
30b792 |
/* global bigString, inputvalues */
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
describe('Signing', function () {
|
|
Packit Service |
30b792 |
let context = null;
|
|
Packit Service |
30b792 |
const good_fpr = inputvalues.encrypt.good.fingerprint;
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
before(function (done){
|
|
Packit Service |
30b792 |
const prm = Gpgmejs.init({ timeout: 2000 });
|
|
Packit Service |
30b792 |
prm.then(function (gpgmejs){
|
|
Packit Service |
30b792 |
context = gpgmejs;
|
|
Packit Service |
30b792 |
done();
|
|
Packit Service |
30b792 |
});
|
|
Packit Service |
30b792 |
});
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
it('Sign a message', function (done) {
|
|
Packit Service |
30b792 |
const data = bigString(100);
|
|
Packit Service |
30b792 |
context.sign({ data: data, keys: good_fpr }).then(function (answer) {
|
|
Packit Service |
30b792 |
expect(answer).to.not.be.empty;
|
|
Packit Service |
30b792 |
expect(answer.data).to.be.a('string');
|
|
Packit Service |
30b792 |
expect(answer.data).to.include('BEGIN PGP SIGNATURE');
|
|
Packit Service |
30b792 |
expect(answer.data).to.include('END PGP SIGNATURE');
|
|
Packit Service |
30b792 |
expect(answer.data).to.include(data);
|
|
Packit Service |
30b792 |
done();
|
|
Packit Service |
30b792 |
});
|
|
Packit Service |
30b792 |
});
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
it('Detached sign a message', function (done) {
|
|
Packit Service |
30b792 |
const data = bigString(100);
|
|
Packit Service |
30b792 |
context.sign({ data: data, keys: good_fpr, mode: 'detached' })
|
|
Packit Service |
30b792 |
.then(function (answer) {
|
|
Packit Service |
30b792 |
expect(answer).to.not.be.empty;
|
|
Packit Service |
30b792 |
expect(answer.data).to.be.a('string');
|
|
Packit Service |
30b792 |
expect(answer.data).to.include(data);
|
|
Packit Service |
30b792 |
expect(answer.signature).to.be.a('string');
|
|
Packit Service |
30b792 |
expect(answer.signature).to.be.a('string');
|
|
Packit Service |
30b792 |
done();
|
|
Packit Service |
30b792 |
});
|
|
Packit Service |
30b792 |
});
|
|
Packit Service |
30b792 |
|
|
Packit Service |
30b792 |
});
|