Merge pull request #10112 from owncloud/collaboration_info_notfound_error_code

fix: return 404 code if file isn't found on CheckFileInfo request
This commit is contained in:
Juan Pablo Villafañez
2024-09-20 11:10:08 +02:00
committed by GitHub
3 changed files with 22 additions and 0 deletions
@@ -1058,6 +1058,10 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (*ConnectorResponse,
Str("StatusCode", statRes.GetStatus().GetCode().String()).
Str("StatusMsg", statRes.GetStatus().GetMessage()).
Msg("CheckFileInfo: stat failed with unexpected status")
if statRes.GetStatus().GetCode() == rpcv1beta1.Code_CODE_NOT_FOUND {
return NewResponse(404), nil
}
return NewResponse(500), nil
}
@@ -1634,6 +1634,19 @@ var _ = Describe("FileConnector", func() {
Expect(response.Body).To(BeNil())
})
It("Stat fails status not found", func() {
ctx := middleware.WopiContextToCtx(context.Background(), wopiCtx)
gatewayClient.On("Stat", mock.Anything, mock.Anything).Times(1).Return(&providerv1beta1.StatResponse{
Status: status.NewNotFound(ctx, "something not found"),
}, nil)
response, err := fc.CheckFileInfo(ctx)
Expect(err).ToNot(HaveOccurred())
Expect(response.Status).To(Equal(404))
Expect(response.Body).To(BeNil())
})
It("Stat success", func() {
ctx := middleware.WopiContextToCtx(context.Background(), wopiCtx)
u := &userv1beta1.User{