Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Refactor connector to homogenize the responses. This means that almost all the connector methods will return a
ConnectorResponse
which will include the HTTP status, headers and body. Note that the body is expected to be JSON-encoded before sending it to the client.There are new
NewResponse*
methods to simplify the creation of common responses. These include a response with just the HTTP status and a response with status and lock id. For more complex responses, you'll need to create the response yourself.Code of the httpAdapter is greatly simplified with these changes, the code of the connector is mostly homogenized (only some exceptions), and the behavior is barely touched (only in the
PutRelativeFile
)In addition, mockery has been updated to 2.43.2 because mocks were already created with that version.
Exceptions:
NewResponse*
method to simplify the call.GetLock
method returns a lock id with a 200 status. This is why we opted to supply a status in theNewResponseWithLock
method even though the rest of the cases the lock would be sent with a 409 status.PutRelativeFile
methods has been adjusted because the underlyingPutFile
call also returns aConnectorResponse
. The behavior of both methods should still be the same.GetFile
method remains unchanged with the refactor. The main problem is that we'd need a switch of responsibilities: the connector method would need to return a reader for the httpAdapter to copy the contents, however this will cause problems with the "bodycloser" linter because the connector would need to send a request but can't close the body of the response.Related Issue
No open issue
Motivation and Context
With the only exception of the
GetFile
method in the httpAdapter, the rest of the methods are straightforward.Having the same response for most of the connector methods (with the exception of the
GetFile
) is easier to understand the code.How Has This Been Tested?
unit tests and wopi validator
Screenshots (if appropriate):
Types of changes
Checklist: