@@ -10,12 +10,6 @@ import {
1010 setupSynchronizerApi ,
1111} from './util/synchronization' ;
1212
13- import {
14- StepResultStatus ,
15- SynchronizationJobStatus ,
16- } from '@jupiterone/integration-sdk-core' ;
17-
18- import * as log from '../log' ;
1913import { createTestPolly } from './util/recording' ;
2014
2115jest . mock ( '../log' ) ;
@@ -80,92 +74,19 @@ test('disables graph object schema validation', async () => {
8074 expect ( process . env . ENABLE_GRAPH_OBJECT_SCHEMA_VALIDATION ) . toBeUndefined ( ) ;
8175} ) ;
8276
83- test ( 'step should fail if enableSchemaValidation = true' , async ( ) => {
84- loadProjectStructure ( 'instanceWithNonValidatingSteps' ) ;
85- const job = generateSynchronizationJob ( ) ;
86-
87- setupSynchronizerApi ( {
88- polly,
89- job,
90- baseUrl : 'https://api.us.jupiterone.io' ,
91- } ) ;
92-
93- await createCli ( ) . parseAsync ( [
94- 'node' ,
95- 'j1-integration' ,
96- 'run' ,
97- '--integrationInstanceId' ,
98- 'test' ,
99- ] ) ;
100-
101- expect ( log . displaySynchronizationResults ) . toHaveBeenCalledTimes ( 1 ) ;
102-
103- expect ( log . displayExecutionResults ) . toHaveBeenCalledTimes ( 1 ) ;
104- expect ( log . displayExecutionResults ) . toHaveBeenCalledWith ( {
105- integrationStepResults : [
106- {
107- id : 'fetch-users' ,
108- name : 'Fetch Users' ,
109- declaredTypes : [ 'my_user' ] ,
110- partialTypes : [ ] ,
111- encounteredTypes : [ ] ,
112- status : StepResultStatus . FAILURE ,
113- } ,
114- ] ,
115- metadata : {
116- partialDatasets : {
117- types : [ 'my_user' ] ,
118- } ,
119- } ,
120- } ) ;
121- } ) ;
122-
123- test ( 'step should pass if enableSchemaValidation = false' , async ( ) => {
124- loadProjectStructure ( 'instanceWithNonValidatingSteps' ) ;
125- const job = generateSynchronizationJob ( ) ;
126-
127- setupSynchronizerApi ( {
128- polly,
129- job,
130- baseUrl : 'https://api.us.jupiterone.io' ,
131- } ) ;
132-
133- await createCli ( ) . parseAsync ( [
134- 'node' ,
135- 'j1-integration' ,
136- 'run' ,
137- '--integrationInstanceId' ,
138- 'test' ,
139- '--disable-schema-validation' ,
140- ] ) ;
141-
142- expect ( log . displaySynchronizationResults ) . toHaveBeenCalledTimes ( 1 ) ;
143-
144- expect ( log . displayExecutionResults ) . toHaveBeenCalledTimes ( 1 ) ;
145- expect ( log . displayExecutionResults ) . toHaveBeenCalledWith ( {
146- integrationStepResults : [
147- {
148- id : 'fetch-users' ,
149- name : 'Fetch Users' ,
150- declaredTypes : [ 'my_user' ] ,
151- partialTypes : [ ] ,
152- encounteredTypes : [ 'my_user' ] ,
153- status : StepResultStatus . SUCCESS ,
154- } ,
155- ] ,
156- metadata : {
157- partialDatasets : {
158- types : [ ] ,
159- } ,
160- } ,
161- } ) ;
162- } ) ;
163-
16477test ( 'executes integration and performs upload' , async ( ) => {
16578 const job = generateSynchronizationJob ( ) ;
16679
16780 setupSynchronizerApi ( { polly, job, baseUrl : 'https://api.us.jupiterone.io' } ) ;
16881
82+ let calledFinalize = false ;
83+ polly . server
84+ . post (
85+ `https://api.us.jupiterone.io/persister/synchronization/jobs/${ job . id } /finalize` ,
86+ )
87+ . intercept ( ( req , res ) => {
88+ calledFinalize = true ;
89+ } ) ;
16990 await createCli ( ) . parseAsync ( [
17091 'node' ,
17192 'j1-integration' ,
@@ -174,43 +95,7 @@ test('executes integration and performs upload', async () => {
17495 'test' ,
17596 ] ) ;
17697
177- expect ( log . displayExecutionResults ) . toHaveBeenCalledTimes ( 1 ) ;
178- expect ( log . displayExecutionResults ) . toHaveBeenCalledWith ( {
179- integrationStepResults : [
180- {
181- id : 'fetch-accounts' ,
182- name : 'Fetch Accounts' ,
183- declaredTypes : [ 'my_account' ] ,
184- partialTypes : [ ] ,
185- encounteredTypes : [ 'my_account' ] ,
186- status : StepResultStatus . SUCCESS ,
187- } ,
188- {
189- id : 'fetch-users' ,
190- name : 'Fetch Users' ,
191- declaredTypes : [ 'my_user' , 'my_account_has_user' ] ,
192- partialTypes : [ ] ,
193- encounteredTypes : [ 'my_user' , 'my_account_has_user' ] ,
194- status : StepResultStatus . SUCCESS ,
195- } ,
196- ] ,
197- metadata : {
198- partialDatasets : {
199- types : [ ] ,
200- } ,
201- } ,
202- } ) ;
203-
204- expect ( log . displaySynchronizationResults ) . toHaveBeenCalledTimes ( 1 ) ;
205- expect ( log . displaySynchronizationResults ) . toHaveBeenCalledWith ( {
206- ...job ,
207- status : SynchronizationJobStatus . FINALIZE_PENDING ,
208- // These are the expected number of entities and relationships
209- // collected when executing the
210- // 'typeScriptIntegrationProject' fixture
211- numEntitiesUploaded : 2 ,
212- numRelationshipsUploaded : 1 ,
213- } ) ;
98+ expect ( calledFinalize ) . toBe ( true ) ;
21499} ) ;
215100
216101test ( 'executes integration and skips finalization with skip-finalize' , async ( ) => {
@@ -222,6 +107,15 @@ test('executes integration and skips finalization with skip-finalize', async ()
222107 baseUrl : 'https://api.us.jupiterone.io' ,
223108 } ) ;
224109
110+ let calledFinalize = false ;
111+ polly . server
112+ . post (
113+ `https://api.us.jupiterone.io/persister/synchronization/jobs/${ job . id } /finalize` ,
114+ )
115+ . intercept ( ( req , res ) => {
116+ calledFinalize = true ;
117+ } ) ;
118+
225119 await createCli ( ) . parseAsync ( [
226120 'node' ,
227121 'j1-integration' ,
@@ -230,19 +124,7 @@ test('executes integration and skips finalization with skip-finalize', async ()
230124 'test' ,
231125 '--skip-finalize' ,
232126 ] ) ;
233-
234- expect ( log . displayExecutionResults ) . toHaveBeenCalledTimes ( 1 ) ;
235-
236- expect ( log . displaySynchronizationResults ) . toHaveBeenCalledTimes ( 1 ) ;
237- expect ( log . displaySynchronizationResults ) . toHaveBeenCalledWith ( {
238- ...job ,
239- status : SynchronizationJobStatus . AWAITING_UPLOADS ,
240- // These are the expected number of entities and relationships
241- // collected when executing the
242- // 'typeScriptIntegrationProject' fixture
243- numEntitiesUploaded : 2 ,
244- numRelationshipsUploaded : 1 ,
245- } ) ;
127+ expect ( calledFinalize ) . toBe ( false ) ;
246128} ) ;
247129
248130test ( 'does not publish events for source "api" since there is no integrationJobId' , async ( ) => {
@@ -256,7 +138,9 @@ test('does not publish events for source "api" since there is no integrationJobI
256138
257139 let eventsPublished = false ;
258140 polly . server
259- . post ( `https://example.com/persister/synchronization/jobs/${ job . id } /events` )
141+ . post (
142+ `https://api.us.jupiterone.io/persister/synchronization/jobs/${ job . id } /events` ,
143+ )
260144 . intercept ( ( req , res ) => {
261145 eventsPublished = true ;
262146 } ) ;
@@ -272,8 +156,6 @@ test('does not publish events for source "api" since there is no integrationJobI
272156 ] ) ;
273157
274158 expect ( eventsPublished ) . toBe ( false ) ;
275- expect ( log . displayExecutionResults ) . toHaveBeenCalledTimes ( 1 ) ;
276- expect ( log . displaySynchronizationResults ) . toHaveBeenCalledTimes ( 1 ) ;
277159} ) ;
278160
279161test ( 'should use JUPITERONE_API_KEY value in Authorization request header' , async ( ) => {
0 commit comments