aws-sdk-nodejs - 如何为 aws4 签名请求存根 sinon
问题描述
我是 sinon 和 aws 的新手。我需要为以下代码片段编写一个测试用例。我无法找到如何为 aws4.sign 存根。请帮忙
function signRequest(Parameter, creds, body) {
console.log("*********** signRequest *********************");
var hostname = Parameter.Value.split('//', 2)[1].split('/', 2)[0];
let request = {
service: 'execute-api',
region: REGION,
host: hostname,
method: 'POST',
url: `${Parameter.Value}/api`,
path: '/api',
data: body, // object describing the mappedbody
body: body,
headers: {
'content-type': 'application/json'
}
};
var signedRequest = aws4.sign(request, creds);
console.log("signRequest-->signedRequest: " + signedRequest)
return signedRequest;
}
解决方案
推荐阅读
- amazon-web-services - 如何将安全组附加到 terraform 中的 aws 实例
- clang - 启用 LLVM 的 MemorySanitizer 是否会改变库的 ABI
- godot - Timer.start() 未按预期调用
- javascript - 如何使用 JavaScript 使所有表和数据表具有焦点?
- sql - 如何在表格中模拟 SQL 分组依据?
- gitlab - Gitlab LFS repo 更改为 NFS
- vim - Vim:处理函数 vundle#config#bundle[2] 时检测到错误。
33_check_bundle_name: - c# - 如何以编程方式停止 HostedService?
- ios - SwiftUI:如何获取设备的宽度?
- spring - 大摇大摆地从属性文件中读取文档