-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interpreter functional tests on the server.
- Loading branch information
1 parent
1e086ee
commit 18f62e0
Showing
5 changed files
with
167 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
test/interpreter_functional/plugins/kbn_tp_run_pipeline/server/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { PluginInitializer } from '../../../../../src/core/server'; | ||
import { TestPlugin, TestPluginSetup, TestPluginStart } from './plugin'; | ||
|
||
export const plugin: PluginInitializer<TestPluginSetup, TestPluginStart> = () => new TestPlugin(); |
63 changes: 63 additions & 0 deletions
63
test/interpreter_functional/plugins/kbn_tp_run_pipeline/server/plugin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { schema } from '@kbn/config-schema'; | ||
import { CoreSetup, Plugin, HttpResponsePayload } from '../../../../../src/core/server'; | ||
import { PluginStart as DataPluginStart } from '../../../../../src/plugins/data/server'; | ||
import { ExpressionsServerStart } from '../../../../../src/plugins/expressions/server'; | ||
|
||
export interface TestStartDeps { | ||
data: DataPluginStart; | ||
expressions: ExpressionsServerStart; | ||
} | ||
|
||
export class TestPlugin implements Plugin<TestPluginSetup, TestPluginStart, {}, TestStartDeps> { | ||
public setup(core: CoreSetup<TestStartDeps>) { | ||
const router = core.http.createRouter(); | ||
|
||
router.post( | ||
{ | ||
path: '/api/interpreter_functional/run_expression', | ||
validate: { | ||
body: schema.object({ | ||
input: schema.maybe(schema.nullable(schema.object({}, { unknowns: 'allow' }))), | ||
expression: schema.string(), | ||
}), | ||
}, | ||
}, | ||
async (context, req, res) => { | ||
const [, { expressions }] = await core.getStartServices(); | ||
const output = await expressions.run<unknown, HttpResponsePayload>( | ||
req.body.expression, | ||
req.body.input, | ||
{ | ||
kibanaRequest: req, | ||
} | ||
); | ||
return res.ok({ body: output }); | ||
} | ||
); | ||
} | ||
|
||
public start() {} | ||
public stop() {} | ||
} | ||
|
||
export type TestPluginSetup = ReturnType<TestPlugin['setup']>; | ||
export type TestPluginStart = ReturnType<TestPlugin['start']>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters