Refactor REST API tests to use aspnet test server#706
Conversation
|
There are Rest api tests which have dependency on this fix which is yet to be merged : #690. And hence there are some temporary changes in this PR which I have included so that the test pass for the time being. I will revert back those once the above mentioned PR is merged. |
seantleonard
left a comment
There was a problem hiding this comment.
Thanks for addressing this big refactor! Few questions to clarify before merging this in + additional details and examples requested in PR description/comments.
aaronburtle
left a comment
There was a problem hiding this comment.
LGMT! This might have some conflicts if this PR merges first: #690 so if you have any issues with that please let me know. Big refactor which should really help our test functionality, thanks for taking charge of this.
seantleonard
left a comment
There was a problem hiding this comment.
Few more changes requested and then will be in a good state.
seantleonard
left a comment
There was a problem hiding this comment.
last little nit. thanks for addressing comments!
Why is this change required?
Currently we create objects for classes like RestController,RestService etc. to execute the RestApiTests. This is not a good approach because as our codebase gets complex, we would need to mimic the behaviour of runtime which will get complex as well. Hence this PR replaces the the use of such mocked up objects and use HttpClient to execute the tests. GraphQL already uses HttpClient for its tests. Moreover, previously the tests did not use to go through all the middlewares which are there in the runtime pipeline(like AuthorizationMiddleware). Switching to HttpClient would include those middlewares in the test pipeline as well.
What is the change?
Instead of creating objects for RestController and RestService we now use HttpClient to send requests as specified in the test to the engine. And then consequently, there are some differences as to how HttpClient deals with sending requests to the engine as compared to the previous approach we have. This PR does all those changes.
How was this validated?
All the tests like the
PUT,PATCH,FIND,INSERT,DELETEwhich are already present in the {OperationName}ApiTestBase.cs classes, are passing after making the changes which validates the code change.IMPORTANT NOTE
There are Rest api tests which have dependency on this fix which is yet to be merged : #690. And hence there are some temporary changes in this PR which I have included so that the test pass for the time being. I will revert back those once the above mentioned PR is merged. Please ignore the changes in the SqlQueryStructure.cs, RequestParser.cs and ODataAstVistor.cs classes for the above reason.