aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/unittests.js
diff options
context:
space:
mode:
authorMaximilian Krambach <[email protected]>2018-05-28 15:26:56 +0000
committerMaximilian Krambach <[email protected]>2018-05-28 15:26:56 +0000
commit53ce2b94bc35243710dec9b7972c7aaaa79dbc75 (patch)
tree3cf99970812a21d5e4c57afcb39a2b0c67212269 /lang/js/unittests.js
parentjs: Treat a connection as a gpgme Context (diff)
downloadgpgme-53ce2b94bc35243710dec9b7972c7aaaa79dbc75.tar.gz
gpgme-53ce2b94bc35243710dec9b7972c7aaaa79dbc75.zip
js: Keyring listing keys
-- * implementing Keyring methods: - Keyring.getKeys: has an additional option that retrieves the armor and secret state once at the beginning. This is power hungry, but allows for Keys to be used directly (without querying gpgme-json each call) * permittedOperations.js: reflect recent changes in the native counterpart, adding more options * Key: adding two methods for retrieving the armored Key block and for finding out if the Key includes a secret subkey.
Diffstat (limited to 'lang/js/unittests.js')
-rw-r--r--lang/js/unittests.js48
1 files changed, 37 insertions, 11 deletions
diff --git a/lang/js/unittests.js b/lang/js/unittests.js
index 9830a2c5..443aa685 100644
--- a/lang/js/unittests.js
+++ b/lang/js/unittests.js
@@ -197,7 +197,34 @@ function unittests (){
expect(result).to.be.a('boolean');
done();
});
- })
+ });
+
+ it('Non-cached key async armored Key', function (done){
+ let key = createKey(kp.validKeyFingerprint);
+ key.get('armor', false).then(function(result){
+ expect(result).to.be.a('string');
+ expect(result).to.include('KEY BLOCK-----');
+ done();
+ });
+ });
+
+ it('Non-cached key async hasSecret', function (done){
+ let key = createKey(kp.validKeyFingerprint);
+ key.get('hasSecret', false).then(function(result){
+ expect(result).to.be.a('boolean');
+ done();
+ });
+ });
+
+ it('Non-cached key async hasSecret (no secret in Key)', function (done){
+ let key = createKey(kp.validFingerprintNoSecret);
+ expect(key).to.be.an.instanceof(GPGME_Key);
+ key.get('hasSecret', false).then(function(result){
+ expect(result).to.be.a('boolean');
+ expect(result).to.equal(false);
+ done();
+ });
+ });
it('Querying non-existing Key returns an error', function(done) {
let key = createKey(kp.invalidKeyFingerprint);
@@ -224,7 +251,6 @@ function unittests (){
expect(key.fingerprint.code).to.equal('KEY_INVALID');
}
});
-
// TODO: tests for subkeys
// TODO: tests for userids
// TODO: some invalid tests for key/keyring
@@ -236,19 +262,19 @@ function unittests (){
let keyring = new GPGME_Keyring;
expect(keyring).to.be.an.instanceof(GPGME_Keyring);
expect(keyring.getKeys).to.be.a('function');
- expect(keyring.getSubset).to.be.a('function');
});
- it('correct initialization', function(){
+ it('Loading Keys from Keyring, to be used synchronously', function(done){
let keyring = new GPGME_Keyring;
- expect(keyring).to.be.an.instanceof(GPGME_Keyring);
- expect(keyring.getKeys).to.be.a('function');
- expect(keyring.getSubset).to.be.a('function');
+ keyring.getKeys(null, true).then(function(result){
+ expect(result).to.be.an('array');
+ expect(result[0]).to.be.an.instanceof(GPGME_Key);
+ expect(result[0].get('armor')).to.be.a('string');
+ expect(result[0].get('armor')).to.include(
+ '-----END PGP PUBLIC KEY BLOCK-----');
+ done();
+ });
});
- //TODO not yet implemented:
- // getKeys(pattern, include_secret) //note: pattern can be null
- // getSubset(flags, pattern)
- // available Boolean flags: secret revoked expired
});
describe('GPGME_Message', function(){