@@ -294,6 +294,111 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
294294 } ) ;
295295 } ) ;
296296
297+ it ( 'Redirect and save deployment at creation time' , async ( ) => {
298+ const resourceDataString = '{"deployment":{"id":"deployment-id","name":"deployment-name"}}' ;
299+
300+ await browser . get (
301+ deployment . getHostPort ( ) +
302+ `/app/cloud/onboarding?onboarding_token=vector&resource_data=${ resourceDataString } &next=${ encodeURIComponent (
303+ '/app/security/get_started'
304+ ) } #some=hash-value`
305+ ) ;
306+ await find . byCssSelector ( '[data-test-subj="userMenuButton"]' , 20000 ) ;
307+
308+ // We need to make sure that both path and hash are respected.
309+ const currentURL = parse ( await browser . getCurrentUrl ( ) ) ;
310+ expect ( currentURL . pathname ) . to . eql ( '/app/security/get_started' ) ;
311+ expect ( currentURL . hash ) . to . eql ( '#some=hash-value' ) ;
312+
313+ const {
314+ body : { onboardingData, resourceData } ,
315+ } = await supertest
316+ . get ( '/internal/cloud/solution' )
317+ . set ( 'kbn-xsrf' , 'xxx' )
318+ . set ( 'x-elastic-internal-origin' , 'cloud' )
319+ . set ( 'elastic-api-version' , '1' )
320+ . expect ( 200 ) ;
321+ expect ( onboardingData ) . to . eql ( {
322+ token : 'vector' ,
323+ } ) ;
324+
325+ expect ( resourceData ) . to . eql ( {
326+ deployment : {
327+ id : 'deployment-id' ,
328+ name : 'deployment-name' ,
329+ } ,
330+ } ) ;
331+ } ) ;
332+
333+ it ( 'Redirect and update deployment' , async ( ) => {
334+ const resourceDataString = '{"deployment":{"id":"deployment-id","name":"deployment-name"}}' ;
335+
336+ await browser . get (
337+ deployment . getHostPort ( ) +
338+ `/app/cloud/onboarding?onboarding_token=token&resource_data=${ resourceDataString } &next=${ encodeURIComponent (
339+ '/app/security/get_started'
340+ ) } #some=hash-value`
341+ ) ;
342+ await find . byCssSelector ( '[data-test-subj="userMenuButton"]' , 20000 ) ;
343+
344+ // We need to make sure that both path and hash are respected.
345+ const currentURL = parse ( await browser . getCurrentUrl ( ) ) ;
346+ expect ( currentURL . pathname ) . to . eql ( '/app/security/get_started' ) ;
347+ expect ( currentURL . hash ) . to . eql ( '#some=hash-value' ) ;
348+
349+ const {
350+ body : { onboardingData, resourceData } ,
351+ } = await supertest
352+ . get ( '/internal/cloud/solution' )
353+ . set ( 'kbn-xsrf' , 'xxx' )
354+ . set ( 'x-elastic-internal-origin' , 'cloud' )
355+ . set ( 'elastic-api-version' , '1' )
356+ . expect ( 200 ) ;
357+
358+ expect ( onboardingData ) . to . eql ( {
359+ token : 'token' ,
360+ } ) ;
361+
362+ expect ( resourceData ) . to . eql ( {
363+ deployment : {
364+ id : 'deployment-id' ,
365+ name : 'deployment-name' ,
366+ } ,
367+ } ) ;
368+
369+ const resourceDataStringUpdated =
370+ '{"deployment":{"id":"new-deployment-id","name":"new-deployment-name"}}' ;
371+
372+ await browser . get (
373+ deployment . getHostPort ( ) +
374+ `/app/cloud/onboarding?resource_data=${ resourceDataStringUpdated } &next=${ encodeURIComponent (
375+ '/app/security/get_started'
376+ ) } #some=hash-value`
377+ ) ;
378+
379+ await find . byCssSelector ( '[data-test-subj="userMenuButton"]' , 20000 ) ;
380+
381+ const {
382+ body : { onboardingData : onboardingDataUpdated , resourceData : resourceDataUpdated } ,
383+ } = await supertest
384+ . get ( '/internal/cloud/solution' )
385+ . set ( 'kbn-xsrf' , 'xxx' )
386+ . set ( 'x-elastic-internal-origin' , 'cloud' )
387+ . set ( 'elastic-api-version' , '1' )
388+ . expect ( 200 ) ;
389+
390+ expect ( onboardingDataUpdated ) . to . eql ( {
391+ token : 'token' ,
392+ } ) ;
393+
394+ expect ( resourceDataUpdated ) . to . eql ( {
395+ deployment : {
396+ id : 'new-deployment-id' ,
397+ name : 'new-deployment-name' ,
398+ } ,
399+ } ) ;
400+ } ) ;
401+
297402 it ( `Redirect and keep initial onboarding token when it's not provided on update` , async ( ) => {
298403 const securityDetails = '{"use_case":"siem","migration":{"value":true,"type":"splunk"}}' ;
299404
0 commit comments