空手道:签署AWS HTTP请求和将生成的标头添加到“请求标头" [英] Karate: Signing AWS HTTP requests & add the generated headers to the 'request headers'

查看:71
本文介绍了空手道:签署AWS HTTP请求和将生成的标头添加到“请求标头"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们测试的内部API需要经历对其进行签名(即获取AWS Signature)和在执行任何CRUD操作之前,请将签名的标头添加到请求标头"中.

The internal API's we test need to go through the process of signing them (i.e., get AWS Signature) & add the signed headers to 'request headers' before we do any CRUD operation.

可以通过AWS-SDK或使用类似 https:/的方式对请求进行签名/github.com/lucasweb78/aws-v4-signer-java (如果我们的测试完全用Java编写)

Signing the requests can happen through AWS-SDK or using something like this https://github.com/lucasweb78/aws-v4-signer-java (if our tests are written completely in Java)

在空手道DSL中实现此目标的最佳方法是什么.请提出建议.

What would be the optimum way of achieving this in Karate DSL. Please suggest.

推荐答案

阅读文档:例如,这是您进行基本身份验证的方式:

For example this is how you do basic auth:

function fn(creds) {
  var temp = creds.username + ':' + creds.password;
  var Base64 = Java.type('java.util.Base64');
  var encoded = Base64.getEncoder().encodeToString(temp.bytes);
  return 'Basic ' + encoded;
}

这里的要点是您可以插入任何Java代码.您也可以查看OAuth示例以获取更多想法:

The point here is you can plug in any Java code. You can also look at the OAuth examples for more ideas: https://github.com/intuit/karate/tree/master/karate-demo/src/test/java/demo/oauth

这篇关于空手道:签署AWS HTTP请求和将生成的标头添加到“请求标头"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆