Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update JsThemis tests #620

Merged
merged 13 commits into from
Apr 9, 2020
Merged

Update JsThemis tests #620

merged 13 commits into from
Apr 9, 2020

Commits on Apr 8, 2020

  1. Secure Cell: reuse WasmThemis tests

    Update Secure Cell test suite with the tests used in WasmThemis. There
    are some minor tweaks here and there to make them compatible, but it's
    all the same tests otherwise.
    ilammy committed Apr 8, 2020
    Configuration menu
    Copy the full SHA
    239f8ed View commit details
    Browse the repository at this point in the history
  2. Secure Cell: report TypeError correctly

    Instead of throwing a generic error with INVALID_PARAMETER status code,
    throw a proper TypeError when we notice an issue with input types.
    
    This commit updates all cryptosystems, not only Secure Cell.
    ilammy committed Apr 8, 2020
    Configuration menu
    Copy the full SHA
    47f1ca2 View commit details
    Browse the repository at this point in the history
  3. Secure Cell: allow "null" for context values

    In addition to allowing empty buffers and omitted arguments, accept
    explicit "null" values when the context is not used. This improves
    API compatibility with WasmThemis.
    ilammy committed Apr 8, 2020
    Configuration menu
    Copy the full SHA
    39a910e View commit details
    Browse the repository at this point in the history
  4. Secure Message: reuse WasmThemis tests

    In JsThemis there is no SecureMessageSign and SecureMessageVerify
    objects, empty keys should be used instead.
    ilammy committed Apr 8, 2020
    Configuration menu
    Copy the full SHA
    ac3bb87 View commit details
    Browse the repository at this point in the history
  5. Secure Message: allow "null" keys for sign/verify

    Allow omitted keys to be specified with "null" values in addition to
    empty buffers. This improves compatibility with WasmThemis API and is
    consistent with other places where we allow optional values.
    ilammy committed Apr 8, 2020
    Configuration menu
    Copy the full SHA
    ef25982 View commit details
    Browse the repository at this point in the history
  6. Secure Message: disallow both empty keys

    Check that the user has provided either public or private key, do not
    allow both keys to be omitted.
    ilammy committed Apr 8, 2020
    Configuration menu
    Copy the full SHA
    37a9cc9 View commit details
    Browse the repository at this point in the history
  7. Secure Comparator: reuse WasmThemis tests

    Note that JsThemis uses a bit different naming and does not have a
    "destroy()" method. The Secure Comparator object is freed when Node.js
    runtime collects the garbage.
    ilammy committed Apr 8, 2020
    Configuration menu
    Copy the full SHA
    c9359a0 View commit details
    Browse the repository at this point in the history
  8. Secure Session: reuse WasmThemis tests

    API is slightly different in JsThemis and WasmThemis, the names are not
    the same and JsThemis does not have a dedicated negotiation method,
    using just unwrap() for that.
    ilammy committed Apr 8, 2020
    Configuration menu
    Copy the full SHA
    b316e55 View commit details
    Browse the repository at this point in the history
  9. Secure Session: check private key validity

    WasmThemis verifies the private key during Secure Session construction.
    Don't defer this to usage in JsThemis either.
    ilammy committed Apr 8, 2020
    Configuration menu
    Copy the full SHA
    86d5696 View commit details
    Browse the repository at this point in the history
  10. Secure Session: handle exceptions in callback

    We should check the call result as it may be empty if the callback
    throws an exception. Failure to check for this leads to process abort:
    
        FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal.
         1: 0x8fa090 node::Abort() [node]
         2: 0x8fa0dc  [node]
         3: 0xb0030a v8::Utils::ReportApiFailure(char const*, char const*) [node]
         4: 0x7ff9182b1785 jsthemis::SecureSession::get_public_key_for_id_callback(void const*, unsigned long, void*, unsigned long, void*)
         [...]
         9: 0xb8e96f  [node]
        10: 0xb8f4d9 v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node]
        11: 0x1762fd45be1d
        Aborted (core dumped)
    
    We don't want this to happen.
    ilammy committed Apr 8, 2020
    Configuration menu
    Copy the full SHA
    983edd6 View commit details
    Browse the repository at this point in the history
  11. Retroactively apply copyright to tests

    Since we're publishing test code on npm now, we should properly
    attribute this file. The tests were added in 944b9e0 ("Add JSTHEMIS
    test", 2016-01-17).
    ilammy committed Apr 8, 2020
    Configuration menu
    Copy the full SHA
    6d8f4af View commit details
    Browse the repository at this point in the history

Commits on Apr 9, 2020

  1. Simplify sign/verify test case

    We know that JsThemis returns results as instances of Node.js Buffer so
    we can verify that signed message includes the plaintext by using the
    "includes" method. We don't need to write it ourselves.
    ilammy committed Apr 9, 2020
    Configuration menu
    Copy the full SHA
    10d26da View commit details
    Browse the repository at this point in the history
  2. Reformat code with "make fmt"

    ilammy committed Apr 9, 2020
    Configuration menu
    Copy the full SHA
    c618c01 View commit details
    Browse the repository at this point in the history