-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added the watermark text for the Secure View mode
- Loading branch information
Showing
3 changed files
with
107 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Enhancement: Add watermark text | ||
|
||
We've added the watermark text for the Secure View mode. | ||
|
||
https://github.com/owncloud/ocis/pull/9144 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import ( | |
cs3mocks "github.com/cs3org/reva/v2/tests/cs3mocks/mocks" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/owncloud/ocis/v2/ocis-pkg/shared" | ||
"github.com/owncloud/ocis/v2/services/collaboration/pkg/config" | ||
"github.com/owncloud/ocis/v2/services/collaboration/pkg/connector" | ||
"github.com/owncloud/ocis/v2/services/collaboration/pkg/middleware" | ||
|
@@ -25,16 +26,19 @@ var _ = Describe("FileConnector", func() { | |
gatewayClient *cs3mocks.GatewayAPIClient | ||
cfg *config.Config | ||
wopiCtx middleware.WopiContext | ||
testCtx context.Context | ||
) | ||
|
||
BeforeEach(func() { | ||
cfg = &config.Config{ | ||
App: config.App{ | ||
LockName: "testName_for_unittests", // Only the LockName is used | ||
}, | ||
Commons: &shared.Commons{OcisURL: "https://ocis.com"}, | ||
} | ||
gatewayClient = &cs3mocks.GatewayAPIClient{} | ||
fc = connector.NewFileConnector(gatewayClient, cfg) | ||
testCtx = context.WithValue(context.Background(), "randomID", "zzz000") | ||
|
||
wopiCtx = middleware.WopiContext{ | ||
AccessToken: "abcdef123456", | ||
|
@@ -52,7 +56,9 @@ var _ = Describe("FileConnector", func() { | |
OpaqueId: "opaqueId", | ||
Type: userv1beta1.UserType_USER_TYPE_PRIMARY, | ||
}, | ||
Username: "Pet Shaft", | ||
Username: "Shaft", | ||
DisplayName: "Pet Shaft", | ||
Mail: "[email protected]", | ||
// Opaque is here for reference, not used by default but might be needed for some tests | ||
//Opaque: &typesv1beta1.Opaque{ | ||
// Map: map[string]*typesv1beta1.OpaqueEntry{ | ||
|
@@ -856,6 +862,7 @@ var _ = Describe("FileConnector", func() { | |
IsAnonymousUser: true, | ||
UserId: "guest-zzz000", | ||
UserFriendlyName: "guest zzz000", | ||
WatermarkText: "guest zzz000", | ||
} | ||
|
||
newFileInfo, err := fc.CheckFileInfo(ctx) | ||
|
@@ -864,9 +871,72 @@ var _ = Describe("FileConnector", func() { | |
// Check both separately | ||
Expect(newFileInfo.UserId).To(HavePrefix(hex.EncodeToString([]byte("guest-")))) | ||
Expect(newFileInfo.UserFriendlyName).To(HavePrefix("Guest ")) | ||
// overwrite UserId and UserFriendlyName here for easier matching | ||
Expect(newFileInfo.WatermarkText).To(HavePrefix("Guest ")) | ||
// overwrite UserId, UserFriendlyName and WatermarkText here for easier matching | ||
newFileInfo.UserId = "guest-zzz000" | ||
newFileInfo.UserFriendlyName = "guest zzz000" | ||
newFileInfo.WatermarkText = "guest zzz000" | ||
|
||
Expect(err).To(Succeed()) | ||
Expect(newFileInfo).To(Equal(expectedFileInfo)) | ||
}) | ||
|
||
It("Stat success authenticated user", func() { | ||
// change view mode to view only | ||
wopiCtx.ViewMode = appproviderv1beta1.ViewMode_VIEW_MODE_VIEW_ONLY | ||
|
||
ctx := middleware.WopiContextToCtx(testCtx, wopiCtx) | ||
|
||
gatewayClient.On("Stat", mock.Anything, mock.Anything).Times(1).Return(&providerv1beta1.StatResponse{ | ||
Status: status.NewOK(ctx), | ||
Info: &providerv1beta1.ResourceInfo{ | ||
Owner: &userv1beta1.UserId{ | ||
Idp: "customIdp", | ||
OpaqueId: "aabbcc", | ||
Type: userv1beta1.UserType_USER_TYPE_PRIMARY, | ||
}, | ||
Size: uint64(998877), | ||
Mtime: &typesv1beta1.Timestamp{ | ||
Seconds: uint64(16273849), | ||
}, | ||
Path: "/path/to/test.txt", | ||
// Other properties aren't used for now. | ||
}, | ||
}, nil) | ||
|
||
expectedFileInfo := connector.FileInfo{ | ||
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", | ||
EnableOwnerTermination: false, | ||
SupportsExtendedLockLength: true, | ||
SupportsGetLock: true, | ||
SupportsLocks: true, | ||
DisableExport: true, | ||
DisableCopy: true, | ||
DisablePrint: true, | ||
IsAnonymousUser: false, | ||
UserId: "guest-zzz000", | ||
UserFriendlyName: "guest zzz000", | ||
WatermarkText: "guest zzz000", | ||
} | ||
|
||
newFileInfo, err := fc.CheckFileInfo(ctx) | ||
|
||
// UserId and UserFriendlyName have random Ids generated which are impossible to guess | ||
// Check both separately | ||
Expect(newFileInfo.UserId).To(HavePrefix(hex.EncodeToString([]byte("opaqueId@inmemory")))) | ||
Expect(newFileInfo.UserFriendlyName).To(HavePrefix("Pet Shaft")) | ||
Expect(newFileInfo.WatermarkText).To(HavePrefix("Pet Shaft")) | ||
// overwrite UserId, UserFriendlyName and WatermarkText here for easier matching | ||
newFileInfo.UserId = "guest-zzz000" | ||
newFileInfo.UserFriendlyName = "guest zzz000" | ||
newFileInfo.WatermarkText = "guest zzz000" | ||
|
||
Expect(err).To(Succeed()) | ||
Expect(newFileInfo).To(Equal(expectedFileInfo)) | ||
|