Remote Debug API entrypoint with Codeception on PhpStorm - docker-compose

I'm trying to debug an application that is using docker [docker-compose], PhpStorm and Codeception. Xdebug's setup seems correct because if I add some breakpoint on the code then use the browser I'm able to stop on the breakpoint and debug the code with no issues. Also, Codeception setup seems correct because I'm able to debug the scenario placing some breakpoint in the ControllerCest file.
The issue here is when I'm trying to debug a breakpoint that is on the application controller from the Codeception ControllerCest file through $I->sendGet(self::SERVICE_URL), it doesn't stop on the selected breakpoint.
This is my api.suite.yml
modules:
enabled:
- REST:
url: 'http://app.local/api/v1/'
depends: PhpBrowser
part: Json
timeout: 1000
- PhpBrowser:
url: 'http://app.local/api/v1/'
headers:
Accept: application/json
Content-Type: application/json
Cookie: XDEBUG_SESSION=PHPSTORM
curl:
CURLOPT_RETURNTRANSFER: true
CURLOPT_TIMEOUT: 10000
- Symfony:
app_path: 'src'
environment: 'test'
- Doctrine2:
depends: Symfony
cleanup: true
- \App\Tests\Helper\Api
- Asserts

Related

"DedupeResponseHeader" not working with Greenwich.SR3

DedupeResponseHeader is not working for me in Spring Cloud Greenwich.SR3, I have added CORS configuration in application.yml, and downstream application is also sending Access-Control-Allow-Origin in response header, which in ending up with:
The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost:4200, http://localhost:4200', but only one is allowed.
I have used DedupeResponseHeader but that is not working for me still seeing same error in browser console. Following is the config for CORS and DedupeResponseHeader:
spring:
cloud:
gateway:
default-filters:
- DedupeResponseHeader=Access-Control-Allow-Origin, RETAIN_UNIQUE
globalcors:
add-to-simple-url-handler-mapping: true
corsConfigurations:
'[/**]':
allowedOrigins: "http://localhost:4200"
allowedMethods: "*"
allowedHeaders: "*"
Tried in filters also, but also didn't work
spring:
cloud:
gateway:
routes:
- id: dedupe_response_header_route
uri: http://localhost:4200
predicates:
- Method=OPTIONS
- Method=GET
filters:
- DedupeResponseHeader=Access-Control-Allow-Origin
Couldn't figure out the reason why its not working, double checked the spring cloud version. I appreciate, if someone could help to understand why DedupeResponseHeader not working.
You can use the latest version of the spring cloud i.e. 2020.0.2 --- it is working perfectly there.

Keycloak is stripping the port from my redirect_uri in the Location header. Why?

I have the following allowed redirect uri set for my client: exp://192.168.2.212:19000
After a code exchange using the following URL:
GET /auth/realms/xxxxx/protocol/openid-connect/auth?code_challenge=m71Cl...D4hw&redirect_uri=exp%3A%2F%2F192.168.2.212%3A19000&client_id=3B03...
X-Forwarded-For: 178.84.x.x
X-Forwarded-Host: oidc.production.my.domain.com
X-Forwarded-Port: 443
X-Forwarded-Proto: https
X-Forwarded-Server: 09918a799a23
X-Real-Ip: 178.84.x.x
I get a HTTP/1.1 302 Found with the following Location field:
Location: exp://192.168.2.212?state=T0pvzPyHF6&session_state=b1cf16ad-b.....
The port is missing. My (Expo) client in android emulator then barfs about not being able to connect to 192.168.2.212 port 80. Naturally.
I am using the docker hub images 11.0.0
How can I prevent this? Is it a bug?
(The iOS version of my app uses a different redirect_uri (exp://127.0.0.1:19000), but although Keycloak strips the port there as well and it receives a Location: exp://127.0.0.1?state=T0p... it does connect to port 19000 and works fine for some reason.)
EDIT: Note that authentication works fine on iOS, and I run exactly the same Keycloak settings in iOS as Android (It's a React Native application).
Keycloak logs no error, and the following debug message:
13:24:33,365 DEBUG [org.keycloak.events] (default task-47) type=LOGIN, realmId=neemop, clientId=3B03FD35, userId=28619cd3-c51d-4756-9d06-fb47********, ipAddress=178.84.x.x, auth_method=openid-connect, auth_type=code, response_type=code, redirect_uri=exp://192.168.2.212:19000, consent=no_consent_required, code_id=a0faa4d4-6826-4c2f-9243-*******, response_mode=query, username=ron.arts#mydomain.com, authSessionParentId=a0faa4d4-6826-4c2f-9243-*******, authSessionTabId=-Pn******
shows the redirect_uri is parsed correctly. It's just that in the actual HTTP response the Location: header omits the port. Which imho should not happen.
Seems like a bug: https://issues.redhat.com/browse/KEYCLOAK-9405?_sscc=t
Tested on 12.0.4 and it still occurs. It appears to be an issue with any non-http(s) protocol
another bug has been submitted to keycloak team:
https://issues.redhat.com/browse/KEYCLOAK-17141
a fix is available in keycloak version >= 13.0.0

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

Dredd seems to hang with api calls to asp.net kestrel server

When I run dredd, it seems to just hang after the first api call. I'm not sure how to debug or diagnose. I'm running an asp.net 5 mvc 6 api service with the dnx web command. How can I see what's going on or what the issue might be?
I tried adding hooks for debugging and see that it calls the first api and then just never triggers the after event. I tested the api with postman and curl with correct results. Dredd also works with the same blueprint if I'm using an express node.js server.
The only combination that fails is Dredd with the asp.net kestrel server response. The server logs that the request is made and a response is sent so it does trigger the test, but just never finishes.
Is Dredd looking for some sort of after processing hook, because I see the server receiving the request with dredd regardless of .net or node.js. Even if I spin up the .net api process in another process it doesn't work, why would that matter? It should just be http requests for dredd in any case right?
Does it care that it's coming back from a kestrel server?
kestrel response
Content-Type → application/json; charset=utf-8
Date → Wed, 06 Jan 2016 17:14:10 GMT
Server → Kestrel
Transfer-Encoding → chunked
Body {"foo":"bar"}
dredd.yml
dry-run: null
hookfiles: null
language: nodejs
sandbox: false
server: dnx web
server-wait: 3
init: false
names: false
only: []
output: []
header: []
sorted: false
user: null
inline-errors: false
details: false
method: []
color: true
level: verbose
timestamp: false
silent: false
path: []
blueprint: test.apib
endpoint: 'http://localhost:5000'
console output of dredd command
Starting server with command: dnx web
Waiting 3 seconds for server command to start...
Hosting environment: Production
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
info: Beginning Dredd testing...
info: Found Hookfiles: hooks.js
hook: before all
hook: before each
info: Microsoft.AspNet.Hosting.Internal.HostingEngine[1]
Request starting HTTP/1.1 GET http://localhost:5000/message
info: Microsoft.AspNet.Mvc.Controllers.ControllerActionInvoker[1]
Executing action method Foo.Controllers.HelloController.Get with arguments () - ModelState is Valid'
info: Microsoft.AspNet.Mvc.Infrastructure.ObjectResultExecutor[1]
Executing ObjectResult, writing value Microsoft.AspNet.Mvc.ActionContext.
info: Microsoft.AspNet.Mvc.Infrastructure.MvcRouteHandler[2]
Executed action Foo.Controllers.HelloController.Get in 0.0165ms
info: Microsoft.AspNet.Hosting.Internal.HostingEngine[2]
Request finished in 0.041ms 200 application/json; charset=utf-8
test.apib
# GET /message
+ Response 200 (application/json; charset=utf-8)
{"foo":"bar"}
It is correctly passing on my machine (MacOSX with coreclr mono rc2)
The same goes with the nodejs version you provided in the repo.
The only thing I had to change in my application was the startup command:
dnx run --server Microsoft.AspNet.Server.Kestrel
but I do not really think that is the problem here.

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

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