mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 20:29:54 -06:00
fix: return 404 code if file isn't found on CheckFileInfo request
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user