Skip to content

Commit

Permalink
Revert, try setting LD_LIBRARY_PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
coverbeck committed Aug 17, 2023
1 parent 314478e commit 3877484
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
40 changes: 18 additions & 22 deletions checkUrlExists/lambda/index.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = {
Expand Down
1 change: 1 addition & 0 deletions checkUrlExists/lambda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"author": "Dockstore",
"license": "MIT",
"dependencies": {
"node-libcurl": "^3.0.0"
},
"scripts": {
"test": "jasmine"
Expand Down
8 changes: 4 additions & 4 deletions checkUrlExists/lambda/tests/unit/test-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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 =
Expand Down
2 changes: 2 additions & 0 deletions checkUrlExists/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3877484

Please sign in to comment.