@@ -26,7 +26,7 @@ describe('#generateIngestionSourcesConfig', () => {
2626 } ,
2727 } ;
2828
29- it ( 'should include the matched step itself in childIngestionSources even when no dependents exist ' , ( ) => {
29+ it ( 'should not include matched steps without authorization in childIngestionSources' , ( ) => {
3030 const integrationSteps : IntegrationStep < IntegrationInstanceConfig > [ ] = [
3131 {
3232 id : 'fetch-vulnerability-alerts' ,
@@ -51,16 +51,11 @@ describe('#generateIngestionSourcesConfig', () => {
5151 expect (
5252 ingestionSourcesConfig [ INGESTION_SOURCE_IDS . FINDING_ALERTS ] ,
5353 ) . toMatchObject ( ingestionConfig [ INGESTION_SOURCE_IDS . FINDING_ALERTS ] ) ;
54- // childIngestionSources includes the matched step itself
54+ // childIngestionSources is empty because the matched step has no authorization
5555 expect (
5656 ingestionSourcesConfig [ INGESTION_SOURCE_IDS . FINDING_ALERTS ]
5757 . childIngestionSources ,
58- ) . toEqual ( [
59- expect . objectContaining ( {
60- id : 'fetch-vulnerability-alerts' ,
61- name : 'Fetch Vulnerability Alerts' ,
62- } ) ,
63- ] ) ;
58+ ) . toBeEmpty ( ) ;
6459 // ingestionSourcesConfig[INGESTION_SOURCE_IDS.FETCH_REPOS] is undefined because there are no steps using that ingestionSourceId
6560 expect (
6661 ingestionSourcesConfig [ INGESTION_SOURCE_IDS . FETCH_REPOS ] ,
@@ -142,16 +137,12 @@ describe('#generateIngestionSourcesConfig', () => {
142137 expect (
143138 ingestionSourcesConfig [ INGESTION_SOURCE_IDS . FETCH_REPOS ] ,
144139 ) . toMatchObject ( ingestionConfig [ INGESTION_SOURCE_IDS . FETCH_REPOS ] ) ;
145- // New property added — includes the matched root step and its dependents
146- const childSources =
140+ // Only includes dependents (fetch-repos has no authorization so it's excluded)
141+ expect (
147142 ingestionSourcesConfig [ INGESTION_SOURCE_IDS . FETCH_REPOS ]
148- . childIngestionSources ;
149- expect ( childSources ) . toEqual (
150- expect . arrayContaining ( [
151- expect . objectContaining ( { id : 'fetch-repos' , name : 'Fetch Repos' } ) ,
152- stepFetchVulnerabilityAlerts ,
153- stepFetchIssues ,
154- ] ) ,
143+ . childIngestionSources ,
144+ ) . toEqual (
145+ expect . arrayContaining ( [ stepFetchVulnerabilityAlerts , stepFetchIssues ] ) ,
155146 ) ;
156147 // For FINDING_ALERTS the ingestionConfig keep exactly the same
157148 expect (
@@ -199,4 +190,62 @@ describe('#generateIngestionSourcesConfig', () => {
199190 ingestionSourcesConfig [ INGESTION_SOURCE_IDS . TEST_SOURCE ] ,
200191 ) . toBeUndefined ( ) ;
201192 } ) ;
193+
194+ it ( 'should include matched root steps that have authorization' , ( ) => {
195+ const integrationSteps : IntegrationStep < IntegrationInstanceConfig > [ ] = [
196+ {
197+ id : 'fetch-repos' ,
198+ name : 'Fetch Repos' ,
199+ entities : [
200+ {
201+ resourceName : 'Github Repo' ,
202+ _type : 'github_repo' ,
203+ _class : [ 'CodeRepo' ] ,
204+ } ,
205+ ] ,
206+ relationships : [ ] ,
207+ dependsOn : [ 'fetch-account' ] ,
208+ ingestionSourceId : INGESTION_SOURCE_IDS . FETCH_REPOS ,
209+ authorization : {
210+ permissions : [ 'repo:read' ] ,
211+ endpoints : [ 'https://api.example.com/repos' ] ,
212+ } ,
213+ executionHandler : jest . fn ( ) ,
214+ } ,
215+ {
216+ id : 'fetch-issues' ,
217+ name : 'Fetch Issues' ,
218+ entities : [
219+ {
220+ resourceName : 'GitHub Issue' ,
221+ _type : 'github_issue' ,
222+ _class : [ 'Issue' ] ,
223+ } ,
224+ ] ,
225+ relationships : [ ] ,
226+ dependsOn : [ 'fetch-repos' ] ,
227+ executionHandler : jest . fn ( ) ,
228+ } ,
229+ ] ;
230+ const ingestionSourcesConfig = generateIngestionSourcesConfig (
231+ ingestionConfig ,
232+ integrationSteps ,
233+ ) ;
234+ const children =
235+ ingestionSourcesConfig [ INGESTION_SOURCE_IDS . FETCH_REPOS ]
236+ . childIngestionSources ;
237+ // Root step with authorization is included
238+ expect ( children ) . toEqual (
239+ expect . arrayContaining ( [
240+ expect . objectContaining ( {
241+ id : 'fetch-repos' ,
242+ authorization : {
243+ permissions : [ 'repo:read' ] ,
244+ endpoints : [ 'https://api.example.com/repos' ] ,
245+ } ,
246+ } ) ,
247+ expect . objectContaining ( { id : 'fetch-issues' } ) ,
248+ ] ) ,
249+ ) ;
250+ } ) ;
202251} ) ;
0 commit comments