fix: change var naming for CI

This commit is contained in:
Juan Pablo Villafáñez
2024-06-21 10:48:30 +02:00
parent 573f3a25bc
commit 1f1b818056
5 changed files with 70 additions and 64 deletions
@@ -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 {
@@ -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",
@@ -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"
}
@@ -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 servers 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 hosts 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"
}
@@ -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"
}