From 27b116798ee7d14279b5bf3969d8ab0d33688742 Mon Sep 17 00:00:00 2001 From: antelle Date: Wed, 14 Apr 2021 20:41:45 +0200 Subject: [PATCH] tests fix --- .../src/native-messaging-host.cpp | 5 ++++- .../test/native-messaging-host-test.mjs | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/extension/native-messaging-host/src/native-messaging-host.cpp b/extension/native-messaging-host/src/native-messaging-host.cpp index 17ce20c4..a00d4d0a 100644 --- a/extension/native-messaging-host/src/native-messaging-host.cpp +++ b/extension/native-messaging-host/src/native-messaging-host.cpp @@ -56,7 +56,6 @@ std::string keeweb_pipe_name() { #endif uv_os_free_passwd(&user_info); } - std::cout << pipe_name; return pipe_name; } @@ -103,6 +102,8 @@ void stdin_read_cb(uv_stream_t *, ssize_t nread, const uv_buf_t *buf) { state.pending_to_keeweb.emplace( uv_buf_init(buf->base, static_cast(nread))); process_keeweb_queue(); + } else if (nread == UV_EOF) { + quit_on_error(); } else if (nread < 0) { std::cerr << "STDIN read error: " << uv_err_name(static_cast(nread)) << std::endl; quit_on_error(); @@ -191,6 +192,8 @@ void keeweb_pipe_read_cb(uv_stream_t *, ssize_t nread, const uv_buf_t *buf) { state.pending_to_stdout.emplace( uv_buf_init(buf->base, static_cast(nread))); process_stdout_queue(); + } else if (nread == UV_EOF) { + close_keeweb_pipe(); } else if (nread < 0) { std::cerr << "KeeWeb read error: " << uv_err_name(static_cast(nread)) << std::endl; close_keeweb_pipe(); diff --git a/extension/native-messaging-host/test/native-messaging-host-test.mjs b/extension/native-messaging-host/test/native-messaging-host-test.mjs index dc23ad27..0e58d9ba 100644 --- a/extension/native-messaging-host/test/native-messaging-host-test.mjs +++ b/extension/native-messaging-host/test/native-messaging-host-test.mjs @@ -6,12 +6,19 @@ import childProcess from 'child_process'; import { expect } from 'chai'; describe('KeeWeb extension native module host', function () { - const sockPath = path.join(os.tmpdir(), 'keeweb-browser.sock'); const hostPath = 'build/keeweb-native-messaging-host'; - const extensionOrigin = 'chrome-extension://enjifmdnhaddmajefhfaoglcfdobkcpj'; + const extensionOrigin = 'keeweb-connect@keeweb.info'; + + const userInfo = os.userInfo(); + let sockPath; + if (process.platform === 'win32') { + sockPath = `\\\\.pipe\\keeweb-browser-${userInfo.username}`; + } else { + sockPath = path.join(os.tmpdir(), `keeweb-browser-${userInfo.uid}.sock`); + } let server; - let serverConnection = undefined; + let serverConnection; this.timeout(5000);