mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Help with implementing tracking http session in WireMock.NET #381
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @AndresGMD on GitHub (Oct 27, 2021).
Hi Stef,
is there anyway to implement following task, using static mappings.
Narrative: Session tracking requires that a session ID is maintained across multiple request to the server. This means that each time a given client makes a request to the server it passes the same session ID. The server can use this ID to lookup the session information it maintains. How works
In my reviews I know the following
How Implemented Lifetime session #652
How to associate Scenarios and States
Kind regards!
@StefH commented on GitHub (Oct 28, 2021):
Hello @andresendava ,
You scenario is as follows (I think...)
This is what I think you request.
Is this correct ?
@AndresGMD commented on GitHub (Oct 28, 2021):
Good Morning @StefH !
That's correct!
Additional:
The servlet retrieves the session-related information that is stored on the server-side. There are 2 alternatives:
a. Cookies by Default
b. Url rewriting in case that the client browser doesn't support cookies.
After the session is completed (or timed out due to inactivity) the session object is removed from the server.
I don't know if there is a way to view cookies. For example generating logs.
King regards!
@AndresGMD commented on GitHub (Nov 2, 2021):
Hi @StefH Stef
I would like to use __admin/requests/find to use Session tracking
I have created a cookie:
I would like to filter theses requests by session id to try the cookie associate with these requests. Ex:
_POST http://localhost:8080/_admin/requests/find
To filter the next request
But the result was
I try the next filter
But the result was
I don't sure if the filter was implemented correctly.
Kind regards
@StefH commented on GitHub (Nov 3, 2021):
https://github.com/WireMock-Net/WireMock.Net/issues/665
@AndresGMD commented on GitHub (Nov 4, 2021):
Hi @StefH
Because filtering by body does not work correctly for parameters other than path. I was thinking in another option could be to implement a capability that allows me to filter cookies using the URL Rewriting method:
In general can looks like the following:
__admin/requests/cookie/(Name)/(Value)
or
__admin/requests/find/cookie/(Name)/(Value)
i.e. Given:
__admin/requests/cookie/session_id/456
or
__admin/requests/find/cookie/session_id/456
Thanks in advace
@AndresGMD commented on GitHub (Nov 4, 2021):
@StefH ,
I have found the solution by filtering with Body
I Found that Cookie is a collection. I make a prove sending a request with session_id=123 And 2 request with session_id = 456
I check the requests _http://localhost:8080/_admin/requests
###Filter
And I apply the filter inn the following way (I check in detail de CookieModel):
And the result was:
[
{
"Guid": "ecca4c0e-116c-426a-a04c-5466451fed14",
"Request": {
"ClientIP": "::1",
"DateTime": "2021-11-04T14:50:35.713853Z",
"Path": "/states/1",
"AbsolutePath": "/states/1",
"Url": "http://localhost:8080/states/1",
"AbsoluteUrl": "http://localhost:8080/states/1",
"Query": {},
"Method": "GET",
"Headers": {
"Connection": [
"keep-alive"
],
"Content-Type": [
"application/json"
],
"Accept": [
"/"
],
"Accept-Encoding": [
"gzip, deflate, br"
],
"Cookie": [
"session_id=123"
],
"Host": [
"localhost:8080"
],
"User-Agent": [
"PostmanRuntime/7.28.4"
],
"Content-Length": [
"392"
],
"x-api-key": [
"123"
],
"Postman-Token": [
"489e4408-90a0-41a1-8e61-d9acc2f6b9a9"
]
},
"Cookies": {
"session_id": "123"
}
},
"Response": {
"StatusCode": 200,
"Headers": {
"Content-Type": [
"application/json; charset=UTF-8"
],
"Content-Length": [
"105"
],
"Date": [
"Tue, 26 Oct 2021 15:41:14 GMT"
]
},
"BodyAsJson": {
"state": "Scenario 2",
"Data": {
"person": [
{
"id": 1,
"name": "Eva Charpman",
"age": "33",
"Height": "1.63",
"gender": "female"
}
]
}
},
"DetectedBodyType": 2,
"DetectedBodyTypeFromContentType": 0
},
"MappingGuid": "ed18595b-6fe5-4c27-b04b-8ee2f8d4be10",
"MappingTitle": "States & Scenarios",
"RequestMatchResult": {
"TotalScore": 3.0,
"TotalNumber": 3,
"IsPerfectMatch": true,
"AverageTotalScore": 1.0,
"MatchDetails": [
{
"Name": "PathMatcher",
"Score": 1.0
},
{
"Name": "MethodMatcher",
"Score": 1.0
},
{
"Name": "ScenarioAndStateMatcher",
"Score": 1.0
}
]
},
"PartialMappingGuid": "ed18595b-6fe5-4c27-b04b-8ee2f8d4be10",
"PartialMappingTitle": "States & Scenarios",
"PartialRequestMatchResult": {
"TotalScore": 3.0,
"TotalNumber": 3,
"IsPerfectMatch": true,
"AverageTotalScore": 1.0,
"MatchDetails": [
{
"Name": "PathMatcher",
"Score": 1.0
},
{
"Name": "MethodMatcher",
"Score": 1.0
},
{
"Name": "ScenarioAndStateMatcher",
"Score": 1.0
}
]
}
}
]
I change de cookie filter
And I get
Thanks a lot!