Codeception acceptance tests fail with LogicException: The page history is empty - soap

I am preparing acceptance tests for my SOAP API methods. I've already made two of them and if I launch each of them separately, they pass without any problems. But if I call them together using codecept run acceptance, second always fails with [LogicException] The page history is empty on $I->see(); method. Why is it so?
I'm using codeception v2.0.11 and my suit is:
class_name: AcceptanceSOAPTester
modules:
enabled:
- PhpBrowser
- SOAP
- ApiHelper
config:
PhpBrowser:
url: http://localhost/
SOAP:
endpoint: http://localhost/soap/
schema: http://www.w3.org/2001/XMLSchema-instance

Related

Why does SwaggerHub return error 403 when I test my OpenAPI definition?

I have the following OpenAPI definition hosted on SwaggerHub:
https://app.swaggerhub.com/apis/MyFirstAPI/1.0.1-oas3
openapi: 3.0.0
servers:
- url: http://api.myfirstapi.com/
info:
version: 1.0.1-oas3
title: Equ API
paths:
/query:
get:
tags:
- developers
parameters:
- in: query
name: searchString
schema:
type: string
responses:
'200':
description: search results matching criteria
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Equity'
'400':
description: There is 400
components:
schemas:
Equity:
...
When I test the GET /query request, it returns a 403 error:
content-length: 0
date: Fri,10 Sep 2021 14:32:54 GMT
server: nginx/1.18.0 + Phusion Passenger(R) 6.0.8
status: 403 Forbidden
via: 1.1 b5d86079363e9709b4c4051d3c94ac3d.cloudfront.net (CloudFront)
x-amz-cf-id: pYbLwlrEHg5DXkGe5FkysAjSjbSDqUg7Rrhbv-Dt8Xwt8JuPRMAW3Q==
x-amz-cf-pop: DEL54-C1
x-cache: Error from cloudfront
x-powered-by: Express,Phusion Passenger(R) 6.0.8
Why does this error happen and how to fix it?
This 403 error is somewhat misleading. The actual problem here is that the target server for requests - api.myfirstapi.com - does not actually exist. The servers list is supposed to specify your real server(s).
If you are designing a new API and don't have a live server yet, you can use SwaggerHub's mock server to similate responses and test API calls.
To add a mock to your API definition:
Click the API name on the editor toolbar.
Switch to the Integrations tab and click Add New Integrations.
Select API Auto Mocking from the list and click Add.
Enter any value for Name (e.g. mock), leave other options as is, and click Create and Execute.
Close the remaining dialogs.
This creates a mock server for your API and adds it to the servers list in your API definition:
servers:
- description: SwaggerHub API Auto Mocking
url: https://virtserver.swaggerhub.com/OWNER_NAME/API_NAME/VERSION
Make sure to select this server in the API docs before you test API calls.

All Tags not replicating from SOAP Endpoint while creating REST Service in WSO2 API-Manager

I am trying to create a REST Endpoint from a SOAP Endpoint using WSO2 API Manager(v3.2.0).
Steps are
Launch API Manager
Create API > I have a SOAP Endpoint
Implementation Type : Generate REST APIs, Input Type : WSDL URL
I enter the WSDL URL and system validates it.
I enter the Name of the API, context, version, endpoint URL and select the Business Plan and click on CREATE.
API is created. Now I click on Resources and a specific post method e.g., createContract. In the in-mediation file, all xml tags present in the SOAP endpoint is not reflected properly.
I have tried to add these tags manually as well but it does not reflect in the REST API.
Kindly help!
TID: [-1234] [] [2021-07-29 09:28:14,972] INFO {org.wso2.carbon.apimgt.keymgt.handlers.DefaultKeyValidationHandler} - org.wso2.carbon.apimgt.keymgt.handlers.DefaultKeyValidationHandler Initialised
TID: [-1234] [] [2021-07-29 09:28:15,120] ERROR {org.apache.synapse.mediators.bsf.ScriptMediator} - {api:admin--FCUBSDEService:v1} The script engine returned an error executing the inlined js script function mediate com.sun.phobos.script.util.ExtendedScriptException: org.mozilla.javascript.EcmaError: ReferenceError: "Jrnl" is not defined. (<Unknown Source>#3) in <Unknown Source> at line number 3
at com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:68)
at java.scripting/javax.script.CompiledScript.eval(CompiledScript.java:89)

"Can't GET /XXX" error while using swagger-express

I'm using swagger-express for making RESTful API. Base /hello route works fine, but I tried to add some more sophisticated one, with database connection etc. Whenever I tried to send GET request on that route, I would get "Cannot GET /xxx". I triple-checked everything and it looked fine, so I decided to make an exact copy of /hello route called /test, just changed some variables - doesn't work too, same error. Here is my /test route in swagger.yaml
/test:
# binds a127 app logic to a route
x-swagger-route-controller: test-route
get:
description: route for testing
# used as the method name of the controller
operationId: test
responses:
"200":
description: Success
schema:
# a pointer to a definition
$ref: "#/definitions/TestResponse"
# responses may fall trough to errors
default:
description: Error
schema:
$ref: "#/definitions/ErrorResponse"
and here is my test-route.js controller
'use strict';
module.exports = {
test
};
function test(req, res) {
res.json("Test Route");
}
As I said, it's almost exact copy of /hello default route, all other files in swagger project were untouched.

Rest API Token Based Authentication Mechanism with Swagger Not Working

I am trying to make an API call with rest token based authentication from swagger. But at server side, I don't find token in the request. I tried the same API call with poster and swagger. In Poster it works fine but in swagger it doesn't.
Below is my JSON file which I am using to make API call with token:
swagger: '2.0'
info:
title: City
description: City Information
version: 1.0.0
host: '127.0.0.1:8090'
schemes:
- http
basePath: /App
produces:
- application/json
paths:
/city/list:
get:
summary: city
description:
Show cities name and its attributes.
security:
- APIAuthKey: []
responses:
'200':
description: An array of city
default:
description: Unexpected error
securityDefinitions:
APIAuthKey:
type: apiKey
in: header
name: X-AUTH-TOKEN
And this is how swagger sends request with X-AUTH-TOKEN:
But, when I use the same API call wit same parameters and X-AUTH-TOKEN in Poster, It works fine. Below, I have highlighted that how I send request with Poster:
Can anyone please suggest if I'm doing anything wrong or missing something? Why am I unable to send token with request correctly to fetch at server side in request header?

Codeception REST API call for HTTPS url

I'm looking for a codeception configuration to use the Codeception REST Module to make calls against a secured https url.
For example I want to check the online status of our slack bot:
$slackApiUrl = 'https://slack.com/api/users.getPresence';
$params = [
'token' => $apiToken,
'user' => $botUserId,
];
$I->sendPOST($slackApiUrl, $params);
When I execute the test, I'll get a guzzle error like
[GuzzleHttp\Exception\ConnectException] cURL error 35: SSL: CA certificate set, but certificate verification is disabled (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
I knew, that the default of codeception switch off https secured urls but how can I activate https, when I need it?
My suite.yml:
class_name: AcceptanceTester
modules:
enabled:
- REST:
url: *****
depends: PhpBrowser
- PhpBrowser
- Asserts
- \Helper\Acceptance
I could answer myself. It`s the codeception version. After updating to Codeception v2.2, the same test works like expected.
Codeception PHP Testing Framework v2.2.8
Powered by PHPUnit 5.7.15 by Sebastian Bergmann and contributors.
[Groups] slack
Acceptance (live) Tests (1) --------------------------------------------------------------------------
Modules: REST, PhpBrowser, Asserts, \Helper\Acceptance
------------------------------------------------------------------------------------------------------
slackCest: Check slack bot online status
I send post "https://slack.com/api/users.getPresence"
[...]
[Response] {"ok":true,"presence":"active"}
I am going to Check SlackBot online status
I see response contains json {"ok":true,"presence":"active"}
PASSED