aboutsummaryrefslogtreecommitdiffstats
path: root/lang/js/unittests.js (unfollow)
Commit message (Collapse)AuthorFilesLines
2019-06-19js: Error handling for browser errorsMaximilian Krambach1-0/+32
-- * Connection.js - Add some meaningful nativeMessaging feedback for failing communication due to misconfiguration or other browser-originated fails - add an "isDisconnected" property - "isNativeHostUnknown" tries to match browser's feedback string if the browser does not find gpgme-json * init.js - initialization will now reject with a more meaningful error if the configuration is not set up or other browser-based errors (chrome.runtime.lastError) are present. This should speed up the normal initialization (not having to waiting for a timeout any more in case of improper setup) * errors.js - CONN_NATIVEMESSAGE: New error that passes the browser's nativeMessaging error - CONN_NO_CONFIG: native messaging error indicating that the nativeMessaging host was not set up properly * unittests.js: - added the "isDisconnected" property to the startup tests - added tests for proper behavior of connection checks
2018-10-18doc: use https:// for www.gnu.orgDaniel Kahn Gillmor1-1/+1
-- Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2018-09-19js: add configuration option on startupMaximilian Krambach1-16/+20
-- * src/index.js: Added an optional configuration object for the startup. * configuration: timeout - the initial check for a connection ran into timeouts on slower testing machines. 500ms for initial startup is not sufficient everywhere. The default timeout was raised to 1000ms, and as an option this timeout can be increased even further. * BrowsertestExtension: Set the initial connection timeouts to 2 seconds, to be able to test on slower machines.
2018-08-27js: typecheck destructured parametersMaximilian Krambach1-7/+8
-- * destructuring just takes the input argument and treats it as object. In cases like in src/Keyring/generateKey, where I forgot to change the old syntax, the fingerprint as string was destructured into an object without "pattern", which caused all Keys to be retrieved. So, methods with a destructuring now check if the first argument is an object and get a default empty object if no parameter is submitted. This allows the further use of destructured parameters, while still ensuring nothing vastly incorrect is used. * src/Kering.js, unittsets.js: fixed old syntax in method usage
2018-08-23js: use destructured option parametersMaximilian Krambach1-2/+4
-- * Adds to f0409bbdafcbd4f8b0be099a6b3ce0d5352c9bcd and makes use of destructuring, allowing for defaults, and cleaning up the validation.
2018-08-22js: throw errors in sync functionsMaximilian Krambach1-25/+29
-- * synchronous functions should throw errors if something goes wrong, Promises should reject. This commit changes some error cases that returned Error objects instead of throwing them - src/Key.js: createKey() and sync Key.get() throw errors - src/Error.js: Exporting the list of errors to be able to test and compare against these strings - src/Keyring.js: Setting a null value in pattern is not useful, and now caused an error with the new changes. - src/Message.js: createMessage and Message.setParameter now throw errors
2018-08-20js: add and apply eslint rulesMaximilian Krambach1-54/+54
-- * mainly spacing, see .eslintrc.json for details
2018-08-20js: revert changes to class read/write restrictionMaximilian Krambach1-46/+16
-- * undoes 94ee0988d4eaac27785de6efb7c19ca9976e1e9c and e16a87e83910ebb6bfdc4148369165f121f0997e. I do not fully understand why my approach was bad, but I am not in a position to argue. This revert was requested to me after a review, and I'm doing it in the assumption that more experienced people know better than me. * unittests: Also changed some outdated tests that stopped working since 754e799d35fd62d7a979452f44342934659908c7 (as GPGME_Key is not exported, one cannot check for instanceof in the tests anymore)
2018-08-17js: removed Key.armor property in synchronous useMaximilian Krambach1-4/+0
-- * src/Key.js The synchronous mode for a Key does not offer an armor/ armored property anymore. This frees up a lot of performance issues, also the armored expoort is expected to change quite often, so a cached version is not advisable. * hasSecret/getHasSecret is now refactored, to reflect their uses. With get('hasSecret') there is a method that fetches the result. * src/Key.js also some refactoring
2018-07-30js: Making objects inmutableMaximilian Krambach1-0/+16
-- * An Object.freeze should stop any malicious third party from changing objects' methods once the objects are instantiated (see unittest for an approach that would have worked before) - An initialized gpgmejs- object doesn't have a '_Keyring' property anymore (it still has its 'Keyring') - The internal expect='base64' needed to be turned into a method.
2018-07-27js: change the write access for js class methodsMaximilian Krambach1-11/+11
-- * src/ [Connection, Error, Key, Keyring, MEssage, Signature, gpgmejs]: Functions and values that are not meant to be overwritten are now moved into their constructors, thus eliminating the possibility of overwrites after initialization. * Key: The mode of use (synchronous cached, or async promises) ivs now determined at initialization of that Key. The property Key.isAsync reflects this state. * unittests: fixed old Key syntax for testing. * Message.js isComplete is now a method and not a getter anymore. * Added some startup tests.
2018-07-09js: reduce request spam at getKeys()Maximilian Krambach1-6/+8
-- * Don't make a secret-Key request for each Key retrieved, use one request for all of them instead, and assemble the info later. This should reduce the traffic with large Keyrings. The bulk retrieval for the public armored Keys for each of these Keys is still up to discussion * unittests: disabled assertion for the armored key (as it currently doesn't work) * encryptTest: clarified the mechanism/reason of rejection for Messages >64 MB. This is still a TODO, as this error comes from a different place (the browser itself) and behaves different from the other errors.
2018-06-08js: change chunksize handling and decodingMaximilian Krambach1-1/+2
-- * the nativeApp now sends all data in one base64-encoded string, which needs reassembly, but in a much easier way now. * there are some new performance problems now, especially with decrypting data
2018-06-06js: code cleanup (eslint)Maximilian Krambach1-67/+37
-- * trying to stick to eslint from now on for readability * As some attribution was lost in previous git confusions, I added my name into some of the licence headers
2018-06-06js: implement import/delete Key, some fixesMaximilian Krambach1-32/+94
-- * Keyring.js - implemented importKey: importing one or more armored public key blocks. - implemented deleteKey: deleting a public Key from gpg. * Key.js renamed property Key.armor to Key.armored * Helpers.js: toKeyIDArray does not complain anymore if there are no keys. Not having Keys in e.g. signing keys in encrypt is legitimate and common, the complaints were getting spammy * Errors.js: gpgme_errors now always pass an optional additional message, for easier debugging in minified code * Connection.js: Fix in gpgme-json responses containing objects * eslintrc.json: Start using eslint. A cleanup to conform to it is not done yet * Added further tests for the new functionality
2018-05-28js: Keyring listing keysMaximilian Krambach1-11/+37
-- * 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.
2018-05-28js: Treat a connection as a gpgme ContextMaximilian Krambach1-57/+11
-- * After an operation a connection should be disconnected again. The "end of operation" is now assumed to be either an error as answer, or a message not including a "more" * GPGME, GPGME_Key, GPGME_Keyring don't require a connection anymore * Message.js: The Message.post() method will open a connection as required
2018-05-25js: implement Key handling (1)Maximilian Krambach1-8/+59
-- * Keys can now be queried for information. Onne version queries gnug directly (asynchronous Promise in javascript terms), the cached version refreshes on demand. * Small fixes: src/Connection.js joins answers that stay json properly now
2018-05-25js: use version operation for connection checksMaximilian Krambach1-28/+29
-- * src/Connection.js: isConnected was renamed to checkConnection, that returns a promise with either version information or Boolean * Connection checks have been adapted to reflect that checkConnection returns a Promise * BrowsertestExtension: tests/signTest.js was missing from my last commit
2018-05-07js: fixing errors found by testing: encrypt/decryptMaximilian Krambach1-3/+8
-- * Key.js: Error code for wrong parameter in createKey should be "PARAM_WRONG" * Helpers.js: The property openpgpjs-like Objects were checked for in toKeyIdArray was not defined. * src/permittedOperations.js: updated more expectations and assumptions for the native API * new Problems: - There seems to be a message size limit of about 21 MB for nativeMessaging, much lower than the documented 4GB. - Some bytes are lost with random data in an encrypt-decrypt roundtrip. The culprit is unclear.
2018-05-04js: fixing errors found by testingMaximilian Krambach1-1/+1
-- * Key.js: Error code for wrong parameter in createKey should be "PARAM_WRONG" * Helpers.js: The property openpgpjs-like Objects were checked for in toKeyIdArray was not defined. * src/permittedOperations.js: updated more expectations and assumptions for the native API
2018-05-03js: Added browser testing for unit testsMaximilian Krambach1-0/+321
-- * Added unittests to be run inside a Browser. To be able to access the non-exposed functions and classes, a testing bundle will be created, containing the tests (unittests.js) and the items to be tested. * src/Helpelpers, src/Key, src/Keyring: fixed some errors found during testing.