Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions x-pack/platform/plugins/shared/cloud/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export interface ResourceData {
type: 'general' | 'vector' | 'timeseries';
};
};
deployment?: {
id?: string;
name?: string;
};
}
export interface CloudSecurityAnswer {
useCase: 'siem' | 'cloud' | 'edr' | 'other';
Expand Down
8 changes: 6 additions & 2 deletions x-pack/platform/plugins/shared/cloud/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,12 @@ export class CloudPlugin implements Plugin<CloudSetup, CloudStart> {
),
})
),
// Can be added in the future if needed:
// deployment: schema.maybe(schema.object({})),
deployment: schema.maybe(
schema.object({
id: schema.maybe(schema.string()),
name: schema.maybe(schema.string()),
})
),
})
),
},
Expand Down
104 changes: 104 additions & 0 deletions x-pack/platform/test/functional_cloud/tests/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,110 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});

it('Redirect and save deployment at creation time', async () => {
const resourceDataString = '{"deployment":{"id":"deployment-id","name":"deployment-name"}}';

await browser.get(
deployment.getHostPort() +
`/app/cloud/onboarding?onboarding_token=vector&resource_data=${resourceDataString}&next=${encodeURIComponent(
'/app/security/get_started'
)}#some=hash-value`
);
await find.byCssSelector('[data-test-subj="userMenuButton"]', 20000);

// We need to make sure that both path and hash are respected.
const currentURL = parse(await browser.getCurrentUrl());
expect(currentURL.pathname).to.eql('/app/security/get_started');
expect(currentURL.hash).to.eql('#some=hash-value');

const {
body: { onboardingData, resourceData },
} = await supertest
.get('/internal/cloud/solution')
.set('kbn-xsrf', 'xxx')
.set('x-elastic-internal-origin', 'cloud')
.set('elastic-api-version', '1')
.expect(200);
expect(onboardingData).to.eql({
token: 'vector',
});

expect(resourceData).to.eql({
deployment: {
id: 'deployment-id',
name: 'deployment-name',
},
});
});
it('Redirect and update deployment', async () => {
const resourceDataString = '{"deployment":{"id":"deployment-id","name":"deployment-name"}}';

await browser.get(
deployment.getHostPort() +
`/app/cloud/onboarding?onboarding_token=token&resource_data=${resourceDataString}&next=${encodeURIComponent(
'/app/security/get_started'
)}#some=hash-value`
);
await find.byCssSelector('[data-test-subj="userMenuButton"]', 20000);

// We need to make sure that both path and hash are respected.
const currentURL = parse(await browser.getCurrentUrl());
expect(currentURL.pathname).to.eql('/app/security/get_started');
expect(currentURL.hash).to.eql('#some=hash-value');

const {
body: { onboardingData, resourceData },
} = await supertest
.get('/internal/cloud/solution')
.set('kbn-xsrf', 'xxx')
.set('x-elastic-internal-origin', 'cloud')
.set('elastic-api-version', '1')
.expect(200);

expect(onboardingData).to.eql({
token: 'token',
});

expect(resourceData).to.eql({
deployment: {
id: 'deployment-id',
name: 'deployment-name',
},
});

const resourceDataStringUpdated =
'{"deployment":{"id":"new-deployment-id","name":"new-deployment-name"}';

await browser.get(
deployment.getHostPort() +
`/app/cloud/onboarding?resource_data=${resourceDataStringUpdated}&next=${encodeURIComponent(
'/app/security/get_started'
)}#some=hash-value`
);

await find.byCssSelector('[data-test-subj="userMenuButton"]', 20000);

const {
body: { onboardingData: onboardingDataUpdated, resourceData: resourceDataUpdated },
} = await supertest
.get('/internal/cloud/solution')
.set('kbn-xsrf', 'xxx')
.set('x-elastic-internal-origin', 'cloud')
.set('elastic-api-version', '1')
.expect(200);

expect(onboardingDataUpdated).to.eql({
token: 'token',
});

expect(resourceDataUpdated).to.eql({
deployment: {
id: 'new-deployment-id',
name: 'new-deployment-name',
},
});
});

it(`Redirect and keep initial onboarding token when it's not provided on update`, async () => {
const securityDetails = '{"use_case":"siem","migration":{"value":true,"type":"splunk"}}';

Expand Down