Slackbot
03/12/2024, 5:23 PMLee Turner
03/12/2024, 5:51 PMŽiga sternad
03/12/2024, 7:27 PMBas Dijkstra
03/13/2024, 6:51 AMjerrymon albert
03/18/2024, 3:15 PMjerrymon albert
03/18/2024, 3:16 PMjerrymon albert
03/18/2024, 3:16 PMBas Dijkstra
03/18/2024, 3:26 PMusingFilesUnderDirectory
allows you to use a non-default root folder (i.e., something other than src/test/resources
) for your mapping files and response body files. In other words, it'll look for auth_api_v1_authentication_login.json.json
(is that filename correct, with the double extension?) under /iQ-automation/src/test/java/Wiremock/__files
. Is it there?jerrymon albert
03/18/2024, 3:30 PM{
"id" : "1850cfe7-8e96-4c24-877f-40de1e5d6c32",
"name" : "auth_api_v1_authentication_login",
"request" : {
"url" : "/auth/api/v1/Authentication/login",
"method" : "POST",
"bodyPatterns" : [ {
"equalToJson" : "{ \"email\": \"emily_foulkes+d3@hotmail.com\", \"password\": \"Password1\"}",
"ignoreArrayOrder" : *true*,
"ignoreExtraElements" : true
} ]
},
"response" : {
"status" : 400,
"body" : "Incorrect username or password.",
"headers" : {
"Server" : "Kestrel",
"api-supported-versions" : "1",
"Date" : "Mon, 18 Mar 2024 14:36:35 GMT",
"Content-Type" : "text/plain; charset=utf-8"
}
},
"uuid" : "1850cfe7-8e96-4c24-877f-40de1e5d6c32",
"persistent" : *true*,
"insertionIndex" : 6
}jerrymon albert
03/18/2024, 3:31 PMjerrymon albert
03/18/2024, 3:33 PMjerrymon albert
03/18/2024, 3:33 PMBas Dijkstra
03/18/2024, 3:34 PMmappings
.jerrymon albert
03/18/2024, 3:35 PMBas Dijkstra
03/18/2024, 3:35 PMjerrymon albert
03/18/2024, 3:36 PMjerrymon albert
03/18/2024, 3:36 PMBas Dijkstra
03/18/2024, 3:37 PMstubFor(post(urlMatching("/auth/api/v1/Authentication/login"))
.willReturn(aResponse()
.withBodyFile("auth_api_v1_authentication_login.json.json")
.withStatus(400)));
That's another stub definition, pointing to your stub definition file. What happens if you remove that from the code?Bas Dijkstra
03/18/2024, 3:37 PMjerrymon albert
03/18/2024, 3:37 PMjerrymon albert
03/18/2024, 3:38 PMjerrymon albert
03/18/2024, 3:38 PMBas Dijkstra
03/18/2024, 3:39 PMBas Dijkstra
03/18/2024, 3:46 PMstubFor(post(urlMatching("/auth/api/v1/Authentication/login"))
.willReturn(aResponse()
.withBodyFile("auth_api_v1_authentication_login.json.json")
.withStatus(400)));
You don't need it. Everything is in the JSON mapping file.jerrymon albert
03/18/2024, 3:48 PMjerrymon albert
03/18/2024, 3:48 PMjerrymon albert
03/18/2024, 3:48 PMBas Dijkstra
03/18/2024, 3:51 PM__files
and mappings
) under src/test/resources
(the default location) and try again? I don't think it's a good idea to put them in src/test/java
. It's not source code.jerrymon albert
03/18/2024, 3:52 PMjerrymon albert
03/18/2024, 4:10 PMjerrymon albert
03/18/2024, 4:11 PMjerrymon albert
03/18/2024, 4:11 PMjerrymon albert
03/18/2024, 4:11 PMjerrymon albert
03/18/2024, 4:13 PMBas Dijkstra
03/18/2024, 4:14 PMjerrymon albert
03/18/2024, 4:19 PMBas Dijkstra
03/18/2024, 4:21 PM<https://something.xyz:2424/auth/api/v1/Authentication/login>
?
If that's the case then yes, your WireMock server should be running on port 2424, of course. And you should enable HTTPS: https://wiremock.org/docs/https/jerrymon albert
03/18/2024, 4:30 PMjerrymon albert
03/18/2024, 4:31 PMjerrymon albert
03/18/2024, 4:31 PMBas Dijkstra
03/18/2024, 4:32 PMBas Dijkstra
03/18/2024, 4:32 PMBas Dijkstra
03/18/2024, 4:33 PMjerrymon albert
03/18/2024, 4:33 PMjerrymon albert
03/18/2024, 4:33 PMjerrymon albert
03/18/2024, 4:33 PM