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.