MCPcopy Create free account
hub / github.com/pydio/cells / TestHandler_GetObject

Function TestHandler_GetObject

common/nodes/encryption/handler-encryption_test.go:54–103  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52var testcases = test.TemplateSQL(srv_dao.NewKeyDAO)
53
54func TestHandler_GetObject(t *testing.T) {
55
56 handler := &Handler{
57 // UserTools: &EncryptionClientMock{},
58 }
59 mock := nodes.NewHandlerMock()
60 mock.Nodes["test"] = &tree.Node{Path: "test"}
61 handler.SetNextHandler(mock)
62
63 ctx := context.Background()
64 branchInfo := nodes.BranchInfo{}
65 branchInfo.DataSource = &object.DataSource{}
66 // branchInfo.Encrypted = true
67 ctx = nodes.WithBranchInfo(ctx, "in", branchInfo)
68
69 Convey("Test Get Object without enc", t, func() {
70
71 reqData := &models.GetRequestData{}
72 reader, e := handler.GetObject(ctx, &tree.Node{Path: "test"}, reqData)
73 So(reader, ShouldNotBeNil)
74 So(e, ShouldBeNil)
75
76 })
77
78 Convey("Test Put Object without enc", t, func() {
79
80 reqData := &models.PutRequestData{}
81 _, e := handler.PutObject(ctx, &tree.Node{Path: "test2"}, strings.NewReader(""), reqData)
82 // Wait for the stub to finish - TODO we should use actual service instead of stubs
83 <-time.After(time.Second * 1)
84
85 So(e, ShouldBeNil)
86 So(mock.Nodes["in"], ShouldNotBeNil)
87 So(mock.Nodes["in"].Path, ShouldEqual, "test2")
88
89 })
90
91 Convey("Test Copy Object without Enc", t, func() {
92
93 ctx = nodes.WithBranchInfo(ctx, "from", branchInfo)
94 ctx = nodes.WithBranchInfo(ctx, "to", branchInfo)
95 reqData := &models.CopyRequestData{}
96 _, e := handler.CopyObject(ctx, &tree.Node{Path: "test2"}, &tree.Node{Path: "test2"}, reqData)
97 So(e, ShouldBeNil)
98 So(mock.Nodes["from"], ShouldNotBeNil)
99 So(mock.Nodes["to"], ShouldNotBeNil)
100
101 })
102
103}
104
105func TestHandler_GetPut_Encrypted(t *testing.T) {
106 sql.TestPrintQueries = false

Callers

nothing calls this directly

Calls 6

SetNextHandlerMethod · 0.95
GetObjectMethod · 0.95
PutObjectMethod · 0.95
CopyObjectMethod · 0.95
NewHandlerMockFunction · 0.92
WithBranchInfoFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…