2018-08-16 09:25:50 +00:00
|
|
|
/* 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+
|
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Maximilian Krambach <mkrambach@intevation.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* global describe, it, expect, before, Gpgmejs */
|
2018-08-17 17:20:35 +00:00
|
|
|
/* global inputvalues*/
|
2018-08-16 09:25:50 +00:00
|
|
|
|
|
|
|
describe('Key information', function () {
|
|
|
|
let context = null;
|
2018-08-20 13:12:01 +00:00
|
|
|
before(function (done){
|
2018-09-19 08:56:36 +00:00
|
|
|
const prm = Gpgmejs.init({ timeout: 2000 });
|
2018-08-20 13:12:01 +00:00
|
|
|
prm.then(function (gpgmejs){
|
2018-08-16 09:25:50 +00:00
|
|
|
context = gpgmejs;
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-08-20 13:12:01 +00:00
|
|
|
it('A fingerprint is consistently returned upper case hex', function (done){
|
2018-08-16 09:25:50 +00:00
|
|
|
const mixedCase = inputvalues.encrypt.good.fingerprint_mixedcase;
|
2018-08-22 16:37:46 +00:00
|
|
|
context.Keyring.getKeys({ pattern: mixedCase }).then(function (result){
|
2018-08-16 09:25:50 +00:00
|
|
|
expect(result).to.be.an('array');
|
|
|
|
expect(result.length).to.equal(1);
|
|
|
|
expect(result[0].fingerprint).to.equal(mixedCase.toUpperCase());
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2018-08-17 17:20:35 +00:00
|
|
|
|
2018-08-20 13:12:01 +00:00
|
|
|
it('A userId keeps their encoding', function (done){
|
2018-08-17 17:20:35 +00:00
|
|
|
context.Keyring.importKey(inputvalues.publicKeyNonAscii.key, true)
|
2018-08-20 13:12:01 +00:00
|
|
|
.then(function (result){
|
2018-08-17 17:20:35 +00:00
|
|
|
expect(result.Keys[0]).to.be.an('object');
|
|
|
|
const user = result.Keys[0].key.get('userids')[0];
|
|
|
|
expect(user.get('name')).to.equal(
|
|
|
|
inputvalues.publicKeyNonAscii.userid);
|
2018-08-31 13:24:38 +00:00
|
|
|
result.Keys[0].key.delete().then(function (){
|
2018-08-31 08:35:35 +00:00
|
|
|
done();
|
|
|
|
});
|
2018-08-17 17:20:35 +00:00
|
|
|
});
|
|
|
|
});
|
2018-08-31 13:24:38 +00:00
|
|
|
});
|