From f2d7ea663658bb0446332dcb2ce88fa45db2ffb0 Mon Sep 17 00:00:00 2001 From: denihs Date: Thu, 16 Mar 2023 16:02:23 -0400 Subject: [PATCH] Revert "fixing tests for packages:" This reverts commit e94fdfd0042d1323ded3bb8029ec3d40676fdd91. --- packages/oauth/oauth_server.js | 2 +- .../oauth1/oauth1_pending_request_tokens.js | 6 +-- packages/oauth1/oauth1_server.js | 2 +- packages/oauth1/oauth1_tests.js | 2 +- packages/oauth2/oauth2_tests.js | 2 +- tools/static-assets/server/boot.js | 42 +++++++++---------- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/packages/oauth/oauth_server.js b/packages/oauth/oauth_server.js index 2fd9f57606..272ec551d2 100644 --- a/packages/oauth/oauth_server.js +++ b/packages/oauth/oauth_server.js @@ -239,7 +239,7 @@ const oauthServiceName = req => { const ensureConfigured = async serviceName => { const config = - await ServiceConfiguration.configurations.findOneAsync({ service: serviceName }); + await ServiceConfiguration.configurations.findOne({ service: serviceName }) if (!config) { throw new ServiceConfiguration.ConfigError(); } diff --git a/packages/oauth1/oauth1_pending_request_tokens.js b/packages/oauth1/oauth1_pending_request_tokens.js index 31a78e2a59..5a3c78aa9a 100644 --- a/packages/oauth1/oauth1_pending_request_tokens.js +++ b/packages/oauth1/oauth1_pending_request_tokens.js @@ -53,7 +53,7 @@ OAuth._storeRequestToken = async (key, requestToken, requestTokenSecret) => { // We do an upsert here instead of an insert in case the user happens // to somehow send the same `state` parameter twice during an OAuth // login; we don't want a duplicate key error. - await OAuth._pendingRequestTokens.upsertAsync({ + await OAuth._pendingRequestTokens.upsert({ key, }, { key, @@ -72,9 +72,9 @@ OAuth._storeRequestToken = async (key, requestToken, requestTokenSecret) => { OAuth._retrieveRequestToken = async key => { check(key, String); - const pendingRequestToken = await OAuth._pendingRequestTokens.findOneAsync({ key: key }); + const pendingRequestToken = await OAuth._pendingRequestTokens.findOne({ key: key }); if (pendingRequestToken) { - await OAuth._pendingRequestTokens.removeAsync({ _id: pendingRequestToken._id }); + await OAuth._pendingRequestTokens.remove({ _id: pendingRequestToken._id }); return { requestToken: OAuth.openSecret(pendingRequestToken.requestToken), requestTokenSecret: OAuth.openSecret( diff --git a/packages/oauth1/oauth1_server.js b/packages/oauth1/oauth1_server.js index f025a3c197..a8ffb501ef 100644 --- a/packages/oauth1/oauth1_server.js +++ b/packages/oauth1/oauth1_server.js @@ -26,7 +26,7 @@ OAuth._queryParamsWithAuthTokenUrl = (authUrl, oauthBinding, params = {}, whitel // connect middleware OAuth._requestHandlers['1'] = async (service, query, res) => { - const config = await ServiceConfiguration.configurations.findOneAsync({service: service.serviceName}); + const config = await ServiceConfiguration.configurations.findOne({service: service.serviceName}); if (! config) { throw new ServiceConfiguration.ConfigError(service.serviceName); } diff --git a/packages/oauth1/oauth1_tests.js b/packages/oauth1/oauth1_tests.js index 7ad8419015..bc87f6a2af 100644 --- a/packages/oauth1/oauth1_tests.js +++ b/packages/oauth1/oauth1_tests.js @@ -23,7 +23,7 @@ const testPendingCredential = async (test, method) => { this.accessTokenSecret = twitterfooAccessTokenSecret; }; - await ServiceConfiguration.configurations.insertAsync({service: serviceName}); + await ServiceConfiguration.configurations.insert({service: serviceName}); try { // register a fake login service diff --git a/packages/oauth2/oauth2_tests.js b/packages/oauth2/oauth2_tests.js index e4394a50ed..53d25a5c6a 100644 --- a/packages/oauth2/oauth2_tests.js +++ b/packages/oauth2/oauth2_tests.js @@ -6,7 +6,7 @@ const testPendingCredential = async function (test, method) { const credentialToken = Random.id(); const serviceName = Random.id(); - await ServiceConfiguration.configurations.insertAsync({service: serviceName}); + await ServiceConfiguration.configurations.insert({service: serviceName}); try { // register a fake login service diff --git a/tools/static-assets/server/boot.js b/tools/static-assets/server/boot.js index fb573bca9f..a62bfd592d 100644 --- a/tools/static-assets/server/boot.js +++ b/tools/static-assets/server/boot.js @@ -221,11 +221,11 @@ var specialArgPaths = { } }; -const loadServerBundles = Profile("Load server bundles", async function () { - const infos = []; - const nonLocalNodeModulesPaths = new Set(); +var loadServerBundles = Profile("Load server bundles", async function () { + var infos = []; + var nonLocalNodeModulesPaths = new Set(); for (const fileInfo of serverJson.load) { - const code = fs.readFileSync(path.resolve(serverDir, fileInfo.path)); + var code = fs.readFileSync(path.resolve(serverDir, fileInfo.path)); function addNodeModulesPath(path) { nonLocalNodeModulesPaths.add( @@ -255,7 +255,7 @@ const loadServerBundles = Profile("Load server bundles", async function () { } } - const Npm = { + var Npm = { /** * @summary Require a package that was specified using * `Npm.depends()`. @@ -267,7 +267,7 @@ const loadServerBundles = Profile("Load server bundles", async function () { return "Npm.require(" + JSON.stringify(name) + ")"; }, function (name, error) { if (fileInfo.node_modules || nonLocalNodeModulesPaths.size > 0) { - let fullPath; + var fullPath; // Replace all backslashes with forward slashes, just in case // someone passes a Windows-y module identifier. @@ -282,7 +282,7 @@ const loadServerBundles = Profile("Load server bundles", async function () { } } else { for (const nodeModuleBase of nonLocalNodeModulesPaths) { - const packageBase = files.convertToOSPath(files.pathResolve( + var packageBase = files.convertToOSPath(files.pathResolve( nodeModuleBase, name.split("/", 1)[0] )); @@ -301,7 +301,7 @@ const loadServerBundles = Profile("Load server bundles", async function () { } } - const resolved = require.resolve(name); + var resolved = require.resolve(name); if (resolved === name && ! path.isAbsolute(resolved)) { // If require.resolve(id) === id and id is not an absolute // identifier, it must be a built-in module like fs or http. @@ -314,7 +314,7 @@ const loadServerBundles = Profile("Load server bundles", async function () { }) }; - const getAsset = function (assetPath, encoding, callback) { + var getAsset = function (assetPath, encoding, callback) { let promiseResolver, promise; if (! callback) { promise = new Promise(r => promiseResolver = r); @@ -324,7 +324,7 @@ const loadServerBundles = Profile("Load server bundles", async function () { // itself can't call Assets.get*. (We could change this function so that // it doesn't call bindEnvironment if you don't pass a callback if we need // to.) - const _callback = Package.meteor.Meteor.bindEnvironment(function (err, result) { + var _callback = Package.meteor.Meteor.bindEnvironment(function (err, result) { if (result && ! encoding) // Sadly, this copies in Node 0.10. result = new Uint8Array(result); @@ -344,14 +344,14 @@ const loadServerBundles = Profile("Load server bundles", async function () { if (! fileInfo.assets || ! hasOwn.call(fileInfo.assets, assetPath)) { _callback(new Error("Unknown asset: " + assetPath)); } else { - const filePath = path.join(serverDir, fileInfo.assets[assetPath]); + var filePath = path.join(serverDir, fileInfo.assets[assetPath]); fs.readFile(files.convertToOSPath(filePath), encoding, _callback); } if (promise) return promise; }; - const Assets = { + var Assets = { getText: function (assetPath, callback) { return getAsset(assetPath, "utf8", callback); }, @@ -382,20 +382,20 @@ const loadServerBundles = Profile("Load server bundles", async function () { } }; - const wrapParts = ["(function(Npm,Assets"]; + var wrapParts = ["(function(Npm,Assets"]; - const specialArgs = + var specialArgs = hasOwn.call(specialArgPaths, fileInfo.path) && specialArgPaths[fileInfo.path](fileInfo); - const specialKeys = Object.keys(specialArgs || {}); + var specialKeys = Object.keys(specialArgs || {}); specialKeys.forEach(function (key) { wrapParts.push("," + key); }); // \n is necessary in case final line is a //-comment wrapParts.push("){", code, "\n})"); - const wrapped = wrapParts.join(""); + var wrapped = wrapParts.join(""); // It is safer to use the absolute path when source map is present as // different tooling, such as node-inspector, can get confused on relative @@ -403,18 +403,18 @@ const loadServerBundles = Profile("Load server bundles", async function () { // fileInfo.path is a standard path, convert it to OS path to join with // __dirname - const fileInfoOSPath = files.convertToOSPath(fileInfo.path); - const absoluteFilePath = path.resolve(__dirname, fileInfoOSPath); + var fileInfoOSPath = files.convertToOSPath(fileInfo.path); + var absoluteFilePath = path.resolve(__dirname, fileInfoOSPath); - const scriptPath = + var scriptPath = parsedSourceMaps[absoluteFilePath] ? absoluteFilePath : fileInfoOSPath; - const func = await require('vm').runInThisContext(wrapped, { + var func = await require('vm').runInThisContext(wrapped, { filename: scriptPath, displayErrors: true }); - const args = [Npm, Assets]; + var args = [Npm, Assets]; specialKeys.forEach(function (key) { args.push(specialArgs[key]);