-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Description
For some reason, I am unable to hit a localhost address. To replicate this I am hosting http://jsonplaceholder.typicode.com/ locally on port 3000 and I can confirm that accessing this url through a web browser brings up the same information as using the site. For this example I'll be using the path /todos/1/.
int type = 2;
string uhost = (type == 1)
? "https://jsonplaceholder.typicode.com"
: "http://localhost";
new RestAssured()
.Given()
.Name("Localhost Test")
.Port((type == 1) ? 80 : 3000)
.When()
.Get(uhost+"/todos/1")
.Then()
.TestStatus("test a", x => x == 200)
.Assert("test a")
.WriteAssertions();When type is 1 this runs as expected, however, when I change it to 2 (localhost) it gets back a HTML page and a 404 (Thus it fails to parse as Content-Type is html, but I set a custom parser to just print the _content to the console for this content-type).
Localhost does work if I change this to;
new RestAssured()
.Given()
.Name("Localhost Test")
.Port((type == 1) ? 80 : 3000)
.Host(uhost)
.When()
.Get("/todos/1")
.Then()
.TestStatus("test a", x => x == 200)
.Assert("test a")
.WriteAssertions();```
However, needing a workaround isn't elegant.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels