From 38774849a4ddc08d519bca3f191dbf6912c48e9f Mon Sep 17 00:00:00 2001 From: Charles Overbeck Date: Thu, 17 Aug 2023 13:36:42 -0700 Subject: [PATCH] Revert, try setting LD_LIBRARY_PATH --- checkUrlExists/lambda/index.js | 40 +++++++++---------- checkUrlExists/lambda/package.json | 1 + .../lambda/tests/unit/test-handler.js | 8 ++-- checkUrlExists/template.yaml | 2 + 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/checkUrlExists/lambda/index.js b/checkUrlExists/lambda/index.js index 3cf1d37f..504b65da 100644 --- a/checkUrlExists/lambda/index.js +++ b/checkUrlExists/lambda/index.js @@ -1,8 +1,7 @@ const fs = require("fs"); const tls = require("tls"); -const process = require("process"); -// const { curly } = require("node-libcurl"); +const { curly } = require("node-libcurl"); // important steps to get validation of https (as opposed to http) urls // Get root certificates so https will work @@ -35,30 +34,27 @@ fs.writeFileSync(certFilePath, tlsData); * */ exports.lambdaHandler = async function (event) { - console.log(process.env.PATH); - console.log(process.env.LD_LIBRARY_PATH); const url = event.queryStringParameters.url; - console.log(url); - return returnResponse(false); + return checkUrl(url); }; -// async function checkUrl(url) { -// return run(url) -// .then(() => { -// return returnResponse(true); -// }) -// .catch((error) => { -// console.error(`Something went wrong`, { error }); -// return returnResponse(false); -// }); -// } +async function checkUrl(url) { + return run(url) + .then(() => { + return returnResponse(true); + }) + .catch((error) => { + console.error(`Something went wrong`, { error }); + return returnResponse(false); + }); +} -// async function run(url) { -// const curlOpts = { -// caInfo: certFilePath, -// }; -// return curly.head(url, curlOpts); -// } +async function run(url) { + const curlOpts = { + caInfo: certFilePath, + }; + return curly.head(url, curlOpts); +} function returnResponse(fileFound) { const response = { diff --git a/checkUrlExists/lambda/package.json b/checkUrlExists/lambda/package.json index e7980af0..9d5c2499 100644 --- a/checkUrlExists/lambda/package.json +++ b/checkUrlExists/lambda/package.json @@ -7,6 +7,7 @@ "author": "Dockstore", "license": "MIT", "dependencies": { + "node-libcurl": "^3.0.0" }, "scripts": { "test": "jasmine" diff --git a/checkUrlExists/lambda/tests/unit/test-handler.js b/checkUrlExists/lambda/tests/unit/test-handler.js index 580331c9..467ae212 100644 --- a/checkUrlExists/lambda/tests/unit/test-handler.js +++ b/checkUrlExists/lambda/tests/unit/test-handler.js @@ -9,11 +9,11 @@ describe("Tests index", function () { }); it("verifies successful response from http", async () => { const url = "http://docs.aws.amazon.com/lambda/latest/dg/welcome.html"; - await setupTest(url, false); + await setupTest(url, true); }); it("verifies successful response from https", async () => { const url = "https://www.google.ca"; - await setupTest(url, false); + await setupTest(url, true); }); it("verifies unsuccessful response", async () => { const url = @@ -23,12 +23,12 @@ describe("Tests index", function () { it("verifies successful response for large file", async () => { const url = "https://dcc.icgc.org/api/v1/download?fn=/PCAWG/reference_data/data_for_testing/HCC1143_ds/HCC1143.bam"; - await setupTest(url, false); + await setupTest(url, true); }); it("verifies successful response from ftp file", async () => { const url = "ftp://ftp.ensembl.org/pub/release-100/tsv/homo_sapiens/Homo_sapiens.GRCh38.100.entrez.tsv.gz"; - await setupTest(url, false); + await setupTest(url, true); }); it("verifies unsuccessful response from ftp file", async () => { const url = diff --git a/checkUrlExists/template.yaml b/checkUrlExists/template.yaml index 3b70b7c1..82caa0b7 100644 --- a/checkUrlExists/template.yaml +++ b/checkUrlExists/template.yaml @@ -25,6 +25,8 @@ Resources: CodeUri: lambda/ Handler: index.lambdaHandler Runtime: nodejs18.x + Environment: + LD_LIBRARY_PATH: /opt/lib64:/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib Layers: !Ref LayerVersion Events: Lambda: