简体   繁体   English

请求 API 密钥命中空手道模拟服务器 - 禁止返回 403

[英]Request with API Keys hitting Karate Mock Server - Returning 403 Forbidden

I could not find a similar question, but I might have missed.我找不到类似的问题,但我可能错过了。

Anyways, I have an application, were one of the downstream calls builds the request with API keys (recent update).无论如何,我有一个应用程序,其中一个下游调用使用 API 密钥(最近更新)构建请求。

We have this specific downstream call pointed to the karate mock server and the karate mock server is just set up to listen for the path and confirm that it is a 'POST' being called to return a response.我们有这个特定的下游调用指向空手道模拟服务器,空手道模拟服务器只是设置为侦听路径并确认它是一个被调用以返回响应的“POST”。

We have confirmed in POSTMAN that when we do not have the API keys and call the karate mock server (with the same downstream request that is created in the application), the karate mock server returns the response correctly, but when we add the API keys to the header of the request, the karate mock server returns a 403 forbidden.我们已经在 POSTMAN 中确认,当我们没有 API 密钥并调用空手道模拟服务器(使用在应用程序中创建的相同下游请求)时,空手道模拟服务器正确返回响应,但是当我们添加 API 密钥时对于请求的头部,空手道模拟服务器返回一个 403 forbidden。

I was thinking that the mock server would just ignore the api keys being sent in the request since we do not have it set up in the mockServerPath.feature to listen or care for these keys but only check for the path and that it is a POST, but it does not seem to like the API keys...我在想模拟服务器只会忽略请求中发送的 api 密钥,因为我们没有在 mockServerPath.feature 中设置它来监听或关心这些密钥,但只检查路径并且它是一个 POST ,但它似乎不喜欢 API 密钥...

This must be a simple misconfiguration, Karate mocks just take the incoming request and applies the Scenario expressions from top to bottom and stops when it finds the first one that returns true .这一定是一个简单的错误配置,空手道模拟只是接受传入的请求并从上到下应用Scenario表达式,并在找到第一个返回true时停止。

Maybe all the expressions you have are too "strict" and none of them "matched" when the extra header appeared.也许您拥有的所有表达式都太“严格”,并且在出现额外标题时没有一个“匹配”。 Or maybe the shape of the URL changed, just look carefully and you should figure this out.或者,也许 URL 的形状发生了变化,只要仔细查看,您就应该弄清楚这一点。

If still stuck, follow this process: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue如果仍然卡住,请按照以下流程操作: https : //github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM