1

While writing karate feature test for websockets i am getting Invalid handshake response while the same endpoint is working when executed with postman.Here is karate feature test

Background:
* def accessTokenKey = call read('PostmanRequest.feature')
* def AuthToken = accessTokenKey.response.access_token
 
Scenario: getAccounts using txt
* def socket = karate.webSocket('wss://api-ws-priv.eem.sit.bank.ikano/csp-v1 
  action=searchCounterParty&authtoken=' + AuthToken)
* def requestdata = read('classpath:testData/getAccountsRequest.txt')
* socket.send(requestdata)
* def result = socket.listen(5000)
* json jsonResult = result
* print jsonResult.event.payload.operation
* match jsonResult.event.payload.operation.operationCode == '200'

The error response we are getting is this:

14:26:39.336 websocket client init failed: Invalid handshake response getStatus: 403 Forbidden
14:26:39.361 src/test/java/Features/getAccounts.feature:16
* def socket = karate.webSocket('wss://api-ws-priv.eem.sit.bank.ikano/csp-v1? 
action=searchCounterParty&authtoken=' + AuthToken)
js failed:
01: karate.webSocket('wss://api-ws-priv.eem.sit.bank.ikano/csp-v1? 
action=searchCounterParty&authtoken=' + AuthToken)
org.graalvm.polyglot.PolyglotException: 
io.netty.handler.codec.http.websocketx.WebSocketClientHandshakeException: Invalid handshake 
response getStatus: 403 Forbidden
- com.intuit.karate.http.WebSocketClient.<init>(WebSocketClient.java:148)
- com.intuit.karate.core.ScenarioEngine.webSocket(ScenarioEngine.java:750)
- com.intuit.karate.core.ScenarioBridge.webSocket(ScenarioBridge.java:988)
- com.intuit.karate.core.ScenarioBridge.webSocket(ScenarioBridge.java:970)
- <js>.:program(Unnamed:1)

Is this something karate is not able to connect to server due to which we are getting this exception as this is working fine with postman.

abdul khan
  • 173
  • 5
  • karate may very well have bugs. if you replicate the problem, we can fix it: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue - and you would understand how important this is for an open-source (or any) product – Peter Thomas Aug 26 '22 at 13:35
  • @PeterThomas Actually this is test we can running in our SIT environment, so even I share the code with you..it would not be possible to replicate in your env. I can share if you still need the code – abdul khan Aug 26 '22 at 14:01
  • we don't need your code. we need a simulation of the problem. yes, this may need a little research from your side, to find out what special kind of websocket type your server is doing. that said, this problem has never been reported before, so maybe you are not sending a header or something. try to take the help of the server side team etc. and read the docs. only you can figure out what your server is expecting – Peter Thomas Aug 26 '22 at 15:39
  • While more debugging this issue I got this information though cloud logs: Source IP54.171.56.213Rule inside rule groupAWS#AWSManagedRulesCommonRuleSet#NoUserAgent_HEADERActionBLOCKTimeMon Aug 29 2022 11:25:51 GMT+0200 (Central European Summer Time)GET /csp-v1?action=searchCounterParty&authtoken=uct62UHzO1qC5ujlhB5 host: api-ws-priv.eem.sit.bank.ikano upgrade: websocket connection: upgrade sec-websocket-key: YaPVyRwO6sEXwj0NZwHvCw== origin: https://api-ws-priv.eem.sit.bank.ikano sec-websocket-extensions: permessage-deflate;client_max_window_bits,deflate-frame,x-webkit-deflate-frame – abdul khan Aug 29 '22 at 10:11
  • @peter: How can I pass header information in karate.Websocket request – abdul khan Aug 29 '22 at 10:16
  • read the docs: https://github.com/karatelabs/karate#websocket – Peter Thomas Aug 29 '22 at 17:14

0 Answers0