Skip to content

Commit

Permalink
[CLOUD] Instant deployment (elastic#201688)
Browse files Browse the repository at this point in the history
## Summary

We are having the same issue as here
elastic#197667 for instant deployment. We
need to allow the solution_type `search`.


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
XavierM authored Nov 27, 2024
1 parent 5ecfdf6 commit 54d4698
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,60 @@ describe('PUT /internal/spaces/space/{id}/solution', () => {
});
});

it('should update the solution_type when it is search', async () => {
const payload = {
solution_type: 'search',
};

const { routeHandler, savedObjectsRepositoryMock } = await setup();

const request = httpServerMock.createKibanaRequest({
params: {
id: 'a-space',
},
body: payload,
method: 'post',
});

const response = await routeHandler(mockRouteContext, request, kibanaResponseFactory);

const { status } = response;

expect(status).toEqual(200);
expect(savedObjectsRepositoryMock.update).toHaveBeenCalledTimes(1);
expect(savedObjectsRepositoryMock.update).toHaveBeenCalledWith('space', 'a-space', {
solution: 'es',
name: 'a space',
color: undefined,
description: undefined,
disabledFeatures: [],
imageUrl: undefined,
initials: undefined,
});
});

it('should failed when the solution_type is not the expected one', async () => {
const payload = {
solution_type: 'searchXoXo',
};

const { routeHandler } = await setup();

const request = httpServerMock.createKibanaRequest({
params: {
id: 'a-space',
},
body: payload,
method: 'post',
});

const response = await routeHandler(mockRouteContext, request, kibanaResponseFactory);

const { status } = response;

expect(status).toEqual(500);
});

it('should not allow a new space to be created', async () => {
const payload = {
solution: 'oblt',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const spaceSolutionSchema = schema.oneOf([
schema.literal('security'),
schema.literal('observability'),
schema.literal('elasticsearch'),
schema.literal('search'),
]),
}),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default function ({ getService }: FtrProviderContext) {
.expect(400);

expect(body.message).to.eql(
'[request body]: types that failed validation:\n- [request body.0.solution]: expected at least one defined value but got [undefined]\n- [request body.1.solution_type]: types that failed validation:\n - [request body.solution_type.0]: expected value to equal [security]\n - [request body.solution_type.1]: expected value to equal [observability]\n - [request body.solution_type.2]: expected value to equal [elasticsearch]'
'[request body]: types that failed validation:\n- [request body.0.solution]: expected at least one defined value but got [undefined]\n- [request body.1.solution_type]: types that failed validation:\n - [request body.solution_type.0]: expected value to equal [security]\n - [request body.solution_type.1]: expected value to equal [observability]\n - [request body.solution_type.2]: expected value to equal [elasticsearch]\n - [request body.solution_type.3]: expected value to equal [search]'
);
});

Expand Down

0 comments on commit 54d4698

Please sign in to comment.