From 1f1b818056861c48a6716b5b052e84a2eb5e20e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Pablo=20Villaf=C3=A1=C3=B1ez?= Date: Mon, 27 May 2024 14:30:01 +0200 Subject: [PATCH] fix: change var naming for CI --- .../pkg/connector/fileconnector.go | 8 +-- .../pkg/connector/fileconnector_test.go | 24 +++---- .../pkg/connector/fileinfo/collabora.go | 10 +-- .../pkg/connector/fileinfo/microsoft.go | 62 ++++++++++--------- .../pkg/connector/fileinfo/onlyoffice.go | 30 ++++----- 5 files changed, 70 insertions(+), 64 deletions(-) diff --git a/services/collaboration/pkg/connector/fileconnector.go b/services/collaboration/pkg/connector/fileconnector.go index cb7fcba3e..b08718bc4 100644 --- a/services/collaboration/pkg/connector/fileconnector.go +++ b/services/collaboration/pkg/connector/fileconnector.go @@ -535,7 +535,7 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (fileinfo.FileInfo, e // fileinfo map infoMap := map[string]interface{}{ - "OwnerId": hexEncodedOwnerId, + "OwnerID": hexEncodedOwnerId, "Size": int64(statRes.GetInfo().GetSize()), "Version": version, "BaseFileName": path.Base(statRes.GetInfo().GetPath()), @@ -543,8 +543,8 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (fileinfo.FileInfo, e // to get the folder we actually need to do a GetPath() request //BreadcrumbFolderName: path.Dir(statRes.Info.Path), - "HostViewUrl": wopiContext.ViewAppUrl, - "HostEditUrl": wopiContext.EditAppUrl, + "HostViewURL": wopiContext.ViewAppUrl, + "HostEditURL": wopiContext.EditAppUrl, "EnableOwnerTermination": true, // only for collabora "SupportsExtendedLockLength": true, @@ -555,7 +555,7 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (fileinfo.FileInfo, e "UserCanNotWriteRelative": true, "IsAnonymousUser": isAnonymousUser, "UserFriendlyName": userFriendlyName, - "UserId": userId, + "UserID": userId, } switch wopiContext.ViewMode { diff --git a/services/collaboration/pkg/connector/fileconnector_test.go b/services/collaboration/pkg/connector/fileconnector_test.go index a70c9302a..538da4972 100644 --- a/services/collaboration/pkg/connector/fileconnector_test.go +++ b/services/collaboration/pkg/connector/fileconnector_test.go @@ -785,20 +785,20 @@ var _ = Describe("FileConnector", func() { }, nil) expectedFileInfo := &fileinfo.Microsoft{ - OwnerId: "61616262636340637573746f6d496470", // hex of aabbcc@customIdp + OwnerID: "61616262636340637573746f6d496470", // hex of aabbcc@customIdp Size: int64(998877), Version: "16273849.0", BaseFileName: "test.txt", BreadcrumbDocName: "test.txt", UserCanNotWriteRelative: true, - HostViewUrl: "http://test.ex.prv/view", - HostEditUrl: "http://test.ex.prv/edit", + HostViewURL: "http://test.ex.prv/view", + HostEditURL: "http://test.ex.prv/edit", SupportsExtendedLockLength: true, SupportsGetLock: true, SupportsLocks: true, SupportsUpdate: true, UserCanWrite: true, - UserId: "6f7061717565496440696e6d656d6f7279", // hex of opaqueId@inmemory + UserID: "6f7061717565496440696e6d656d6f7279", // hex of opaqueId@inmemory UserFriendlyName: "Pet Shaft", } @@ -843,26 +843,26 @@ var _ = Describe("FileConnector", func() { cfg.WopiApp.Provider = "Collabora" expectedFileInfo := &fileinfo.Collabora{ - OwnerId: "61616262636340637573746f6d496470", // hex of aabbcc@customIdp + OwnerID: "61616262636340637573746f6d496470", // hex of aabbcc@customIdp Size: int64(998877), BaseFileName: "test.txt", UserCanNotWriteRelative: true, DisableExport: true, DisableCopy: true, DisablePrint: true, - UserId: "guest-zzz000", + UserID: "guest-zzz000", UserFriendlyName: "guest zzz000", EnableOwnerTermination: true, } newFileInfo, err := fc.CheckFileInfo(ctx) - // UserId and UserFriendlyName have random Ids generated which are impossible to guess + // UserID and UserFriendlyName have random Ids generated which are impossible to guess // Check both separately - Expect(newFileInfo.(*fileinfo.Collabora).UserId).To(HavePrefix(hex.EncodeToString([]byte("guest-")))) + Expect(newFileInfo.(*fileinfo.Collabora).UserID).To(HavePrefix(hex.EncodeToString([]byte("guest-")))) Expect(newFileInfo.(*fileinfo.Collabora).UserFriendlyName).To(HavePrefix("Guest ")) - // overwrite UserId and UserFriendlyName here for easier matching - newFileInfo.(*fileinfo.Collabora).UserId = "guest-zzz000" + // overwrite UserID and UserFriendlyName here for easier matching + newFileInfo.(*fileinfo.Collabora).UserID = "guest-zzz000" newFileInfo.(*fileinfo.Collabora).UserFriendlyName = "guest zzz000" Expect(err).To(Succeed()) @@ -896,14 +896,14 @@ var _ = Describe("FileConnector", func() { cfg.WopiApp.Provider = "Collabora" expectedFileInfo := &fileinfo.Collabora{ - OwnerId: "61616262636340637573746f6d496470", // hex of aabbcc@customIdp + OwnerID: "61616262636340637573746f6d496470", // hex of aabbcc@customIdp Size: int64(998877), BaseFileName: "test.txt", UserCanNotWriteRelative: true, DisableExport: true, DisableCopy: true, DisablePrint: true, - UserId: hex.EncodeToString([]byte("opaqueId@inmemory")), + UserID: hex.EncodeToString([]byte("opaqueId@inmemory")), UserFriendlyName: "Pet Shaft", EnableOwnerTermination: true, WatermarkText: "Pet Shaft shaft@example.com", diff --git a/services/collaboration/pkg/connector/fileinfo/collabora.go b/services/collaboration/pkg/connector/fileinfo/collabora.go index c53ca305f..01c23b4a4 100644 --- a/services/collaboration/pkg/connector/fileinfo/collabora.go +++ b/services/collaboration/pkg/connector/fileinfo/collabora.go @@ -14,7 +14,7 @@ type Collabora struct { // Copied from MS WOPI DisablePrint bool `json:"DisablePrint"` // Copied from MS WOPI - OwnerId string `json:"OwnerId,omitempty"` + OwnerID string `json:"OwnerId,omitempty"` // A string for the domain the host page sends/receives PostMessages from, we only listen to messages from this domain. PostMessageOrigin string `json:"PostMessageOrigin,omitempty"` // copied from MS WOPI @@ -26,7 +26,7 @@ type Collabora struct { // copied from MS WOPI UserCanNotWriteRelative bool `json:"UserCanNotWriteRelative"` // copied from MS WOPI - UserId string `json:"UserId,omitempty"` + UserID string `json:"UserId,omitempty"` // copied from MS WOPI UserFriendlyName string `json:"UserFriendlyName,omitempty"` @@ -66,17 +66,18 @@ type Collabora struct { WatermarkText string `json:"WatermarkText,omitempty"` } +// SetProperties will set the file properties for the Collabora implementation. func (cinfo *Collabora) SetProperties(props map[string]interface{}) { setters := map[string]func(value interface{}){ "BaseFileName": assignStringTo(&cinfo.BaseFileName), "DisablePrint": assignBoolTo(&cinfo.DisablePrint), - "OwnerId": assignStringTo(&cinfo.OwnerId), + "OwnerID": assignStringTo(&cinfo.OwnerID), "PostMessageOrigin": assignStringTo(&cinfo.PostMessageOrigin), "Size": assignInt64To(&cinfo.Size), "TemplateSource": assignStringTo(&cinfo.TemplateSource), "UserCanWrite": assignBoolTo(&cinfo.UserCanWrite), "UserCanNotWriteRelative": assignBoolTo(&cinfo.UserCanNotWriteRelative), - "UserId": assignStringTo(&cinfo.UserId), + "UserID": assignStringTo(&cinfo.UserID), "UserFriendlyName": assignStringTo(&cinfo.UserFriendlyName), "EnableInsertRemoteImage": assignBoolTo(&cinfo.EnableInsertRemoteImage), @@ -103,6 +104,7 @@ func (cinfo *Collabora) SetProperties(props map[string]interface{}) { } } +// GetTarget will always return "Collabora" func (cinfo *Collabora) GetTarget() string { return "Collabora" } diff --git a/services/collaboration/pkg/connector/fileinfo/microsoft.go b/services/collaboration/pkg/connector/fileinfo/microsoft.go index f65b2576c..204e803fb 100644 --- a/services/collaboration/pkg/connector/fileinfo/microsoft.go +++ b/services/collaboration/pkg/connector/fileinfo/microsoft.go @@ -12,11 +12,11 @@ type Microsoft struct { // The string name of the file, including extension, without a path. Used for display in user interface (UI), and determining the extension of the file. BaseFileName string `json:"BaseFileName,omitempty"` //A string that uniquely identifies the owner of the file. In most cases, the user who uploaded or created the file should be considered the owner. - OwnerId string `json:"OwnerId,omitempty"` + OwnerID string `json:"OwnerId,omitempty"` // The size of the file in bytes, expressed as a long, a 64-bit signed integer. Size int64 `json:"Size"` // A string value uniquely identifying the user currently accessing the file. - UserId string `json:"UserId,omitempty"` + UserID string `json:"UserId,omitempty"` // The current version of the file based on the server’s file version schema, as a string. This value must change when the file changes, and version values must never repeat for a given file. Version string `json:"Version,omitempty"` @@ -25,7 +25,7 @@ type Microsoft struct { // // An array of strings containing the Share URL types supported by the host. - SupportedShareUrlTypes []string `json:"SupportedShareUrlTypes,omitempty"` + SupportedShareURLTypes []string `json:"SupportedShareUrlTypes,omitempty"` // A Boolean value that indicates that the host supports the following WOPI operations: ExecuteCellStorageRequest, ExecuteCellStorageRelativeRequest SupportsCobalt bool `json:"SupportsCobalt"` // A Boolean value that indicates that the host supports the following WOPI operations: CheckContainerInfo, CreateChildContainer, CreateChildFile, DeleteContainer, DeleteFile, EnumerateAncestors (containers), EnumerateAncestors (files), EnumerateChildren (containers), GetEcosystem (containers), RenameContainer @@ -90,25 +90,25 @@ type Microsoft struct { // // A URI to a web page that the WOPI client should navigate to when the application closes, or in the event of an unrecoverable error. - CloseUrl string `json:"CloseUrl,omitempty"` + CloseURL string `json:"CloseUrl,omitempty"` // A user-accessible URI to the file intended to allow the user to download a copy of the file. - DownloadUrl string `json:"DownloadUrl,omitempty"` + DownloadURL string `json:"DownloadUrl,omitempty"` // A URI to a location that allows the user to create an embeddable URI to the file. - FileEmbedCommandUrl string `json:"FileEmbedCommandUrl,omitempty"` + FileEmbedCommandURL string `json:"FileEmbedCommandUrl,omitempty"` // A URI to a location that allows the user to share the file. - FileSharingUrl string `json:"FileSharingUrl,omitempty"` + FileSharingURL string `json:"FileSharingUrl,omitempty"` // A URI to the file location that the WOPI client uses to get the file. If this is provided, the WOPI client may use this URI to get the file instead of a GetFile request. A host might set this property if it is easier or provides better performance to serve files from a different domain than the one handling standard WOPI requests. WOPI clients must not add or remove parameters from the URL; no other parameters, including the access token, should be appended to the FileUrl before it is used. - FileUrl string `json:"FileUrl,omitempty"` + FileURL string `json:"FileUrl,omitempty"` // A URI to a location that allows the user to view the version history for the file. - FileVersionUrl string `json:"FileVersionUrl,omitempty"` + FileVersionURL string `json:"FileVersionUrl,omitempty"` // A URI to a host page that loads the edit WOPI action. - HostEditUrl string `json:"HostEditUrl,omitempty"` + HostEditURL string `json:"HostEditUrl,omitempty"` // A URI to a web page that provides access to a viewing experience for the file that can be embedded in another HTML page. This is typically a URI to a host page that loads the embedview WOPI action. - HostEmbeddedViewUrl string `json:"HostEmbeddedViewUrl,omitempty"` + HostEmbeddedViewURL string `json:"HostEmbeddedViewUrl,omitempty"` // A URI to a host page that loads the view WOPI action. This URL is used by Office Online to navigate between view and edit mode. - HostViewUrl string `json:"HostViewUrl,omitempty"` + HostViewURL string `json:"HostViewUrl,omitempty"` // A URI that will sign the current user out of the host’s authentication system. - SignoutUrl string `json:"SignoutUrl,omitempty"` + SignoutURL string `json:"SignoutUrl,omitempty"` // // Miscellaneous properties @@ -154,24 +154,25 @@ type Microsoft struct { // A string that indicates the brand name of the host. BreadcrumbBrandName string `json:"BreadcrumbBrandName,omitempty"` // A URI to a web page that the WOPI client should navigate to when the user clicks on UI that displays BreadcrumbBrandName. - BreadcrumbBrandUrl string `json:"BreadcrumbBrandUrl,omitempty"` + BreadcrumbBrandURL string `json:"BreadcrumbBrandUrl,omitempty"` // A string that indicates the name of the file. If this is not provided, WOPI clients may use the BaseFileName value. BreadcrumbDocName string `json:"BreadcrumbDocName,omitempty"` // A string that indicates the name of the container that contains the file. BreadcrumbFolderName string `json:"BreadcrumbFolderName,omitempty"` // A URI to a web page that the WOPI client should navigate to when the user clicks on UI that displays BreadcrumbFolderName. - BreadcrumbFolderUrl string `json:"BreadcrumbFolderUrl,omitempty"` + BreadcrumbFolderURL string `json:"BreadcrumbFolderUrl,omitempty"` } +// SetProperties will set the file properties for the Microsoft implementation. func (minfo *Microsoft) SetProperties(props map[string]interface{}) { setters := map[string]func(value interface{}){ "BaseFileName": assignStringTo(&minfo.BaseFileName), - "OwnerId": assignStringTo(&minfo.OwnerId), + "OwnerID": assignStringTo(&minfo.OwnerID), "Size": assignInt64To(&minfo.Size), - "UserId": assignStringTo(&minfo.UserId), + "UserID": assignStringTo(&minfo.UserID), "Version": assignStringTo(&minfo.Version), - "SupportedShareUrlTypes": assignStringListTo(&minfo.SupportedShareUrlTypes), + "SupportedShareURLTypes": assignStringListTo(&minfo.SupportedShareURLTypes), "SupportsCobalt": assignBoolTo(&minfo.SupportsCobalt), "SupportsContainers": assignBoolTo(&minfo.SupportsContainers), "SupportsDeleteFile": assignBoolTo(&minfo.SupportsDeleteFile), @@ -199,16 +200,16 @@ func (minfo *Microsoft) SetProperties(props map[string]interface{}) { "UserCanRename": assignBoolTo(&minfo.UserCanRename), "UserCanWrite": assignBoolTo(&minfo.UserCanWrite), - "CloseUrl": assignStringTo(&minfo.CloseUrl), - "DownloadUrl": assignStringTo(&minfo.DownloadUrl), - "FileEmbedCommandUrl": assignStringTo(&minfo.FileEmbedCommandUrl), - "FileSharingUrl": assignStringTo(&minfo.FileSharingUrl), - "FileUrl": assignStringTo(&minfo.FileUrl), - "FileVersionUrl": assignStringTo(&minfo.FileVersionUrl), - "HostEditUrl": assignStringTo(&minfo.HostEditUrl), - "HostEmbeddedViewUrl": assignStringTo(&minfo.HostEmbeddedViewUrl), - "HostViewUrl": assignStringTo(&minfo.HostViewUrl), - "SignoutUrl": assignStringTo(&minfo.SignoutUrl), + "CloseURL": assignStringTo(&minfo.CloseURL), + "DownloadURL": assignStringTo(&minfo.DownloadURL), + "FileEmbedCommandURL": assignStringTo(&minfo.FileEmbedCommandURL), + "FileSharingURL": assignStringTo(&minfo.FileSharingURL), + "FileURL": assignStringTo(&minfo.FileURL), + "FileVersionURL": assignStringTo(&minfo.FileVersionURL), + "HostEditURL": assignStringTo(&minfo.HostEditURL), + "HostEmbeddedViewURL": assignStringTo(&minfo.HostEmbeddedViewURL), + "HostViewURL": assignStringTo(&minfo.HostViewURL), + "SignoutURL": assignStringTo(&minfo.SignoutURL), "AllowAdditionalMicrosoftServices": assignBoolTo(&minfo.AllowAdditionalMicrosoftServices), "AllowErrorReportPrompt": assignBoolTo(&minfo.AllowErrorReportPrompt), @@ -227,10 +228,10 @@ func (minfo *Microsoft) SetProperties(props map[string]interface{}) { "TemporarilyNotWritable": assignBoolTo(&minfo.TemporarilyNotWritable), "BreadcrumbBrandName": assignStringTo(&minfo.BreadcrumbBrandName), - "BreadcrumbBrandUrl": assignStringTo(&minfo.BreadcrumbBrandUrl), + "BreadcrumbBrandURL": assignStringTo(&minfo.BreadcrumbBrandURL), "BreadcrumbDocName": assignStringTo(&minfo.BreadcrumbDocName), "BreadcrumbFolderName": assignStringTo(&minfo.BreadcrumbFolderName), - "BreadcrumbFolderUrl": assignStringTo(&minfo.BreadcrumbFolderUrl), + "BreadcrumbFolderURL": assignStringTo(&minfo.BreadcrumbFolderURL), } for key, value := range props { @@ -241,6 +242,7 @@ func (minfo *Microsoft) SetProperties(props map[string]interface{}) { } } +// GetTarget will always return "Microsoft" func (minfo *Microsoft) GetTarget() string { return "Microsoft" } diff --git a/services/collaboration/pkg/connector/fileinfo/onlyoffice.go b/services/collaboration/pkg/connector/fileinfo/onlyoffice.go index f10eaeb34..d2315e669 100644 --- a/services/collaboration/pkg/connector/fileinfo/onlyoffice.go +++ b/services/collaboration/pkg/connector/fileinfo/onlyoffice.go @@ -21,13 +21,13 @@ type OnlyOffice struct { // copied from MS WOPI BreadcrumbBrandName string `json:"BreadcrumbBrandName,omitempty"` // copied from MS WOPI - BreadcrumbBrandUrl string `json:"BreadcrumbBrandUrl,omitempty"` + BreadcrumbBrandURL string `json:"BreadcrumbBrandUrl,omitempty"` // copied from MS WOPI BreadcrumbDocName string `json:"BreadcrumbDocName,omitempty"` // copied from MS WOPI BreadcrumbFolderName string `json:"BreadcrumbFolderName,omitempty"` // copied from MS WOPI - BreadcrumbFolderUrl string `json:"BreadcrumbFolderUrl,omitempty"` + BreadcrumbFolderURL string `json:"BreadcrumbFolderUrl,omitempty"` // // PostMessage properties @@ -52,13 +52,13 @@ type OnlyOffice struct { // // copied from MS WOPI - CloseUrl string `json:"CloseUrl,omitempty"` + CloseURL string `json:"CloseUrl,omitempty"` // copied from MS WOPI - FileSharingUrl string `json:"FileSharingUrl,omitempty"` + FileSharingURL string `json:"FileSharingUrl,omitempty"` // copied from MS WOPI - FileVersionUrl string `json:"FileVersionUrl,omitempty"` + FileVersionURL string `json:"FileVersionUrl,omitempty"` // copied from MS WOPI - HostEditUrl string `json:"HostEditUrl,omitempty"` + HostEditURL string `json:"HostEditUrl,omitempty"` // // Miscellaneous properties @@ -87,7 +87,7 @@ type OnlyOffice struct { // copied from MS WOPI UserFriendlyName string `json:"UserFriendlyName,omitempty"` // copied from MS WOPI - UserId string `json:"UserId,omitempty"` + UserID string `json:"UserId,omitempty"` // // User permissions properties @@ -127,16 +127,17 @@ type OnlyOffice struct { HidePrintOption bool `json:"HidePrintOption,omitempty"` } +// SetProperties will set the file properties for the OnlyOffice implementation. func (oinfo *OnlyOffice) SetProperties(props map[string]interface{}) { setters := map[string]func(value interface{}){ "BaseFileName": assignStringTo(&oinfo.BaseFileName), "Version": assignStringTo(&oinfo.Version), "BreadcrumbBrandName": assignStringTo(&oinfo.BreadcrumbBrandName), - "BreadcrumbBrandUrl": assignStringTo(&oinfo.BreadcrumbBrandUrl), + "BreadcrumbBrandURL": assignStringTo(&oinfo.BreadcrumbBrandURL), "BreadcrumbDocName": assignStringTo(&oinfo.BreadcrumbDocName), "BreadcrumbFolderName": assignStringTo(&oinfo.BreadcrumbFolderName), - "BreadcrumbFolderUrl": assignStringTo(&oinfo.BreadcrumbFolderUrl), + "BreadcrumbFolderURL": assignStringTo(&oinfo.BreadcrumbFolderURL), "ClosePostMessage": assignBoolTo(&oinfo.ClosePostMessage), "EditModePostMessage": assignBoolTo(&oinfo.EditModePostMessage), @@ -145,10 +146,10 @@ func (oinfo *OnlyOffice) SetProperties(props map[string]interface{}) { "FileVersionPostMessage": assignBoolTo(&oinfo.FileVersionPostMessage), "PostMessageOrigin": assignStringTo(&oinfo.PostMessageOrigin), - "CloseUrl": assignStringTo(&oinfo.CloseUrl), - "FileSharingUrl": assignStringTo(&oinfo.FileSharingUrl), - "FileVersionUrl": assignStringTo(&oinfo.FileVersionUrl), - "HostEditUrl": assignStringTo(&oinfo.HostEditUrl), + "CloseURL": assignStringTo(&oinfo.CloseURL), + "FileSharingURL": assignStringTo(&oinfo.FileSharingURL), + "FileVersionURL": assignStringTo(&oinfo.FileVersionURL), + "HostEditURL": assignStringTo(&oinfo.HostEditURL), "CopyPasteRestrictions": assignStringTo(&oinfo.CopyPasteRestrictions), "DisablePrint": assignBoolTo(&oinfo.DisablePrint), @@ -158,7 +159,7 @@ func (oinfo *OnlyOffice) SetProperties(props map[string]interface{}) { "IsAnonymousUser": assignBoolTo(&oinfo.IsAnonymousUser), "UserFriendlyName": assignStringTo(&oinfo.UserFriendlyName), - "UserId": assignStringTo(&oinfo.UserId), + "UserID": assignStringTo(&oinfo.UserID), "ReadOnly": assignBoolTo(&oinfo.ReadOnly), "UserCanNotWriteRelative": assignBoolTo(&oinfo.UserCanNotWriteRelative), @@ -183,6 +184,7 @@ func (oinfo *OnlyOffice) SetProperties(props map[string]interface{}) { } } +// GetTarget will always return "OnlyOffice" func (oinfo *OnlyOffice) GetTarget() string { return "OnlyOffice" }