fix: return 404 code if file isn't found on CheckFileInfo request

This commit is contained in:
Juan Pablo Villafáñez
2024-09-19 10:51:28 +02:00
parent fddad3780d
commit 153502189d
2 changed files with 17 additions and 0 deletions

View File

@@ -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
}

View File

@@ -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{