summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-12-16 03:13:12 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-12-19 02:44:03 +0800
commit321e296371383fd63131d21c1121e22163ddeb86 (patch)
tree71113f7b4f3300f706ee1a3f988bae117fc2c8c8 /test
parent74a1dfb56e413373064475290a1fd6a9cf8cd9ae (diff)
downloadandroid-node-v8-321e296371383fd63131d21c1121e22163ddeb86.tar.gz
android-node-v8-321e296371383fd63131d21c1121e22163ddeb86.tar.bz2
android-node-v8-321e296371383fd63131d21c1121e22163ddeb86.zip
process: move POSIX credential accessors into node_credentials.cc
Expose the POSIX credential accessors through `internalBinding('credentials')` instead of setting them on the process or bootstrapper object from C++ directly. Also moves `SafeGetEnv` from `internalBinding('util')` to `internalBinding('credentials')` since it's closely related to the credentials. In the JS land, instead of wrapping the bindings then writing to the process object directly in main_thread_only.js, return the wrapped functions back to bootstrap/node.js where they get written to the process object conditionally for clarity. Refs: https://github.com/nodejs/node/issues/24961 PR-URL: https://github.com/nodejs/node/pull/25066 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-bootstrap-modules.js2
-rw-r--r--test/parallel/test-safe-get-env.js19
-rw-r--r--test/parallel/test-util-internal.js10
3 files changed, 21 insertions, 10 deletions
diff --git a/test/parallel/test-bootstrap-modules.js b/test/parallel/test-bootstrap-modules.js
index 8f1592084c..5c1693ca89 100644
--- a/test/parallel/test-bootstrap-modules.js
+++ b/test/parallel/test-bootstrap-modules.js
@@ -9,7 +9,7 @@ const common = require('../common');
const assert = require('assert');
const isMainThread = common.isMainThread;
-const kMaxModuleCount = isMainThread ? 59 : 82;
+const kMaxModuleCount = isMainThread ? 60 : 82;
assert(list.length <= kMaxModuleCount,
`Total length: ${list.length}\n` + list.join('\n')
diff --git a/test/parallel/test-safe-get-env.js b/test/parallel/test-safe-get-env.js
new file mode 100644
index 0000000000..0bee9971db
--- /dev/null
+++ b/test/parallel/test-safe-get-env.js
@@ -0,0 +1,19 @@
+'use strict';
+// Flags: --expose_internals
+
+require('../common');
+const assert = require('assert');
+const { internalBinding } = require('internal/test/binding');
+const { safeGetenv } = internalBinding('credentials');
+
+// FIXME(joyeecheung): this test is not entirely useful. To properly
+// test this we could create a mismatch between the effective/real
+// group/user id of a Node.js process and see if the environment variables
+// are no longer available - but that might be tricky to set up reliably.
+
+for (const oneEnv in process.env) {
+ assert.strictEqual(
+ safeGetenv(oneEnv),
+ process.env[oneEnv]
+ );
+}
diff --git a/test/parallel/test-util-internal.js b/test/parallel/test-util-internal.js
index 4b78cefc6e..f16ccfdbdc 100644
--- a/test/parallel/test-util-internal.js
+++ b/test/parallel/test-util-internal.js
@@ -9,17 +9,9 @@ const { internalBinding } = require('internal/test/binding');
const {
getHiddenValue,
setHiddenValue,
- arrow_message_private_symbol: kArrowMessagePrivateSymbolIndex,
- safeGetenv
+ arrow_message_private_symbol: kArrowMessagePrivateSymbolIndex
} = internalBinding('util');
-for (const oneEnv in process.env) {
- assert.strictEqual(
- safeGetenv(oneEnv),
- process.env[oneEnv]
- );
-}
-
assert.strictEqual(
getHiddenValue({}, kArrowMessagePrivateSymbolIndex),
undefined);