This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: stub out ipfs interactions in http injection tests (#2990)
* test: stub out ipfs interactions in http injection tests This makes running the tests faster as we do no network operations, nor do we wait for ports to open, etc. Functionality covered by the tests is also covered by the interface tests so there is no testing gap.
- Loading branch information
1 parent
fbb5ef9
commit 553a65b
Showing
39 changed files
with
3,443 additions
and
2,959 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,37 @@ | ||
'use strict' | ||
|
||
const Boom = require('@hapi/boom') | ||
const Joi = require('@hapi/joi') | ||
|
||
module.exports = async (request, h) => { | ||
const domain = request.query.arg | ||
module.exports = { | ||
validate: { | ||
options: { | ||
allowUnknown: true, | ||
stripUnknown: true | ||
}, | ||
query: Joi.object().keys({ | ||
arg: Joi.string().required(), | ||
format: Joi.string(), | ||
recursive: Joi.boolean().default(false) | ||
}) | ||
.rename('r', 'recursive', { | ||
override: true, | ||
ignoreUndefined: true | ||
}) | ||
}, | ||
async handler (request, h) { | ||
const { | ||
arg, | ||
format, | ||
recursive | ||
} = request.query | ||
|
||
if (!domain) { | ||
throw Boom.badRequest("Argument 'domain' is required") | ||
} | ||
|
||
const format = request.query.format | ||
const path = await request.server.app.ipfs.dns(arg, { | ||
recursive, | ||
format | ||
}) | ||
|
||
// query parameters are passed as strings and need to be parsed to expected type | ||
let recursive = request.query.recursive || request.query.r | ||
recursive = !(recursive && recursive === 'false') | ||
|
||
const path = await request.server.app.ipfs.dns(domain, { recursive, format }) | ||
return h.response({ | ||
Path: path | ||
}) | ||
return h.response({ | ||
Path: path | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.