@@ -53,6 +53,10 @@ func (s *dispatcherTestSuite) TestLoadInputsEnvelope() {
53
53
envelope , err := testEnvelope ("testdata/attestation.json" )
54
54
require .NoError (s .T (), err )
55
55
56
+ s .ociIntegrationBackend .(* mockedSDK.FanOut ).On ("IsSubscribedTo" , "CONTAINER_IMAGE" ).Return (true )
57
+ s .ociIntegrationBackend .(* mockedSDK.FanOut ).On ("IsSubscribedTo" , "SBOM_CYCLONEDX_JSON" ).Return (false )
58
+ s .ociIntegrationBackend .(* mockedSDK.FanOut ).On ("String" ).Return ("mocked-integration" )
59
+
56
60
err = s .dispatcher .loadInputs (context .TODO (), queue , envelope , "backend-type" , "secret-name" )
57
61
assert .NoError (s .T (), err )
58
62
@@ -84,6 +88,15 @@ func (s *dispatcherTestSuite) TestLoadInputsMaterials() {
84
88
integrationInfoBuilder (s .cdxIntegrationBackend ),
85
89
}
86
90
91
+ s .ociIntegrationBackend .(* mockedSDK.FanOut ).On ("IsSubscribedTo" , "CONTAINER_IMAGE" ).Return (false )
92
+ s .ociIntegrationBackend .(* mockedSDK.FanOut ).On ("IsSubscribedTo" , "SBOM_CYCLONEDX_JSON" ).Return (false )
93
+ s .containerIntegrationBackend .(* mockedSDK.FanOut ).On ("IsSubscribedTo" , "CONTAINER_IMAGE" ).Return (true )
94
+ s .containerIntegrationBackend .(* mockedSDK.FanOut ).On ("IsSubscribedTo" , "SBOM_CYCLONEDX_JSON" ).Return (false )
95
+ s .containerIntegrationBackend .(* mockedSDK.FanOut ).On ("String" ).Return ("mocked-integration" )
96
+ s .cdxIntegrationBackend .(* mockedSDK.FanOut ).On ("IsSubscribedTo" , "CONTAINER_IMAGE" ).Return (false )
97
+ s .cdxIntegrationBackend .(* mockedSDK.FanOut ).On ("IsSubscribedTo" , "SBOM_CYCLONEDX_JSON" ).Return (true )
98
+ s .cdxIntegrationBackend .(* mockedSDK.FanOut ).On ("String" ).Return ("mocked-integration" )
99
+
87
100
envelope , err := testEnvelope ("testdata/attestation.json" )
88
101
require .NoError (s .T (), err )
89
102
@@ -178,12 +191,18 @@ func (s *dispatcherTestSuite) TestInitDispatchQueue() {
178
191
integrationInfoBuilder (s .cdxIntegrationBackend ), integrationInfoBuilder (s .cdxIntegrationBackend ),
179
192
}
180
193
194
+ s .containerIntegrationBackend .(* mockedSDK.FanOut ).On ("String" , mock .Anything ).Return ("mocked-integration" )
195
+ s .cdxIntegrationBackend .(* mockedSDK.FanOut ).On ("String" , mock .Anything ).Return ("mocked-integration" )
196
+ s .ociIntegrationBackend .(* mockedSDK.FanOut ).On ("String" , mock .Anything ).Return ("mocked-integration" )
181
197
q , err := s .dispatcher .initDispatchQueue (context .TODO (), s .org .ID , s .workflow .ID .String ())
182
198
require .NoError (t , err )
183
199
184
200
// There are 4 integrations attached
185
201
require .Len (t , q , 4 )
186
202
203
+ s .containerIntegrationBackend .(* mockedSDK.FanOut ).On ("IsSubscribedTo" , mock .Anything ).Return (true )
204
+ s .cdxIntegrationBackend .(* mockedSDK.FanOut ).On ("IsSubscribedTo" , mock .Anything ).Return (true )
205
+
187
206
for i , tc := range []struct { id , subscribedMaterial string }{
188
207
{"OCI_INTEGRATION" , "" },
189
208
{"CONTAINER_INTEGRATION" , "CONTAINER_IMAGE" },
@@ -228,9 +247,6 @@ func (s *dispatcherTestSuite) SetupTest() {
228
247
s .emptyWorkflow , err = s .Workflow .Create (ctx , & biz.WorkflowCreateOpts {Name : "empty-workflow" , OrgID : s .org .ID , Project : "test-project" })
229
248
assert .NoError (s .T (), err )
230
249
231
- customImplementation := mockedSDK .NewFanOutPlugin (s .T ())
232
- customImplementation .On ("Register" , ctx , mock .Anything ).Return (& sdk.RegistrationResponse {Configuration : []byte ("deadbeef" )}, nil )
233
- customImplementation .On ("Attach" , ctx , mock .Anything ).Return (& sdk.AttachmentResponse {Configuration : []byte ("deadbeef" )}, nil )
234
250
type schema struct {
235
251
TestProperty string
236
252
}
@@ -246,11 +262,13 @@ func (s *dispatcherTestSuite) SetupTest() {
246
262
sdk .WithInputMaterial (v1 .CraftingSchema_Material_SBOM_CYCLONEDX_JSON ),
247
263
)
248
264
require .NoError (s .T (), err )
265
+ customImplementation := s .newMock (ctx )
266
+ customImplementation .On ("Describe" ).Return (b .Describe ())
249
267
250
268
// Registration configuration
251
269
config , _ := structpb .NewStruct (map [string ]interface {}{"TestProperty" : "testValue" })
252
270
253
- s .cdxIntegrationBackend = & mockedIntegration { FanOutPlugin : customImplementation , FanOutIntegration : b }
271
+ s .cdxIntegrationBackend = customImplementation
254
272
s .cdxIntegration , err = s .Integration .RegisterAndSave (ctx , s .org .ID , "sbom-integration" , "" , s .cdxIntegrationBackend , config )
255
273
require .NoError (s .T (), err )
256
274
@@ -263,8 +281,10 @@ func (s *dispatcherTestSuite) SetupTest() {
263
281
sdk .WithInputMaterial (v1 .CraftingSchema_Material_CONTAINER_IMAGE ),
264
282
)
265
283
require .NoError (s .T (), err )
284
+ customImplementation = s .newMock (ctx )
285
+ customImplementation .On ("Describe" ).Return (b .Describe ())
266
286
267
- s .containerIntegrationBackend = & mockedIntegration { FanOutPlugin : customImplementation , FanOutIntegration : b }
287
+ s .containerIntegrationBackend = customImplementation
268
288
s .containerIntegration , err = s .Integration .RegisterAndSave (ctx , s .org .ID , "container-integration" , "" , s .containerIntegrationBackend , config )
269
289
require .NoError (s .T (), err )
270
290
@@ -277,8 +297,10 @@ func (s *dispatcherTestSuite) SetupTest() {
277
297
},
278
298
)
279
299
require .NoError (s .T (), err )
300
+ customImplementation = s .newMock (ctx )
301
+ customImplementation .On ("Describe" ).Return (b .Describe ())
280
302
281
- s .ociIntegrationBackend = & mockedIntegration { FanOutPlugin : customImplementation , FanOutIntegration : b }
303
+ s .ociIntegrationBackend = customImplementation
282
304
s .ociIntegration , err = s .Integration .RegisterAndSave (ctx , s .org .ID , "oci-integration" , "" , s .ociIntegrationBackend , config )
283
305
require .NoError (s .T (), err )
284
306
@@ -316,9 +338,12 @@ func (s *dispatcherTestSuite) SetupTest() {
316
338
s .dispatcher = New (s .Integration , nil , nil , nil , s .casClient , registeredIntegrations , l )
317
339
}
318
340
319
- type mockedIntegration struct {
320
- * sdk.FanOutIntegration
321
- * mockedSDK.FanOutPlugin
341
+ func (s * dispatcherTestSuite ) newMock (ctx context.Context ) * mockedSDK.FanOut {
342
+ customImplementation := mockedSDK .NewFanOut (s .T ())
343
+ customImplementation .On ("Register" , ctx , mock .Anything ).Return (& sdk.RegistrationResponse {Configuration : []byte ("deadbeef" )}, nil )
344
+ customImplementation .On ("Attach" , ctx , mock .Anything ).Return (& sdk.AttachmentResponse {Configuration : []byte ("deadbeef" )}, nil )
345
+
346
+ return customImplementation
322
347
}
323
348
324
349
// Utility struct to hold the test suite
0 commit comments