-
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.
[7.x] Migrate Security and EncryptedSavedObjects test plugins to the …
…Kibana Platform (#61864)
- Loading branch information
Showing
20 changed files
with
249 additions
and
220 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
30 changes: 30 additions & 0 deletions
30
x-pack/test/encrypted_saved_objects_api_integration/config.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,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { resolve } from 'path'; | ||
import { FtrConfigProviderContext } from '@kbn/test/types/ftr'; | ||
import { services } from './services'; | ||
|
||
export default async function({ readConfigFile }: FtrConfigProviderContext) { | ||
const xPackAPITestsConfig = await readConfigFile(require.resolve('../api_integration/config.js')); | ||
|
||
return { | ||
testFiles: [require.resolve('./tests')], | ||
servers: xPackAPITestsConfig.get('servers'), | ||
services, | ||
junit: { | ||
reportName: 'X-Pack Encrypted Saved Objects API Integration Tests', | ||
}, | ||
esTestCluster: xPackAPITestsConfig.get('esTestCluster'), | ||
kbnTestServer: { | ||
...xPackAPITestsConfig.get('kbnTestServer'), | ||
serverArgs: [ | ||
...xPackAPITestsConfig.get('kbnTestServer.serverArgs'), | ||
`--plugin-path=${resolve(__dirname, './fixtures/api_consumer_plugin')}`, | ||
], | ||
}, | ||
}; | ||
} |
8 changes: 8 additions & 0 deletions
8
x-pack/test/encrypted_saved_objects_api_integration/fixtures/api_consumer_plugin/kibana.json
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,8 @@ | ||
{ | ||
"id": "eso", | ||
"version": "8.0.0", | ||
"kibanaVersion": "kibana", | ||
"requiredPlugins": ["encryptedSavedObjects", "spaces"], | ||
"server": true, | ||
"ui": false | ||
} |
78 changes: 78 additions & 0 deletions
78
...test/encrypted_saved_objects_api_integration/fixtures/api_consumer_plugin/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,78 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { CoreSetup, PluginInitializer } from '../../../../../../src/core/server'; | ||
import { deepFreeze } from '../../../../../../src/core/utils'; | ||
import { | ||
EncryptedSavedObjectsPluginSetup, | ||
EncryptedSavedObjectsPluginStart, | ||
} from '../../../../../plugins/encrypted_saved_objects/server'; | ||
import { SpacesPluginSetup } from '../../../../../plugins/spaces/server'; | ||
|
||
const SAVED_OBJECT_WITH_SECRET_TYPE = 'saved-object-with-secret'; | ||
|
||
interface PluginsSetup { | ||
encryptedSavedObjects: EncryptedSavedObjectsPluginSetup; | ||
spaces: SpacesPluginSetup; | ||
} | ||
|
||
interface PluginsStart { | ||
encryptedSavedObjects: EncryptedSavedObjectsPluginStart; | ||
spaces: never; | ||
} | ||
|
||
export const plugin: PluginInitializer<void, void, PluginsSetup, PluginsStart> = () => ({ | ||
setup(core: CoreSetup<PluginsStart>, deps) { | ||
core.savedObjects.registerType({ | ||
name: SAVED_OBJECT_WITH_SECRET_TYPE, | ||
hidden: false, | ||
namespaceAgnostic: false, | ||
mappings: deepFreeze({ | ||
properties: { | ||
publicProperty: { type: 'keyword' }, | ||
publicPropertyExcludedFromAAD: { type: 'keyword' }, | ||
privateProperty: { type: 'binary' }, | ||
}, | ||
}), | ||
}); | ||
|
||
deps.encryptedSavedObjects.registerType({ | ||
type: SAVED_OBJECT_WITH_SECRET_TYPE, | ||
attributesToEncrypt: new Set(['privateProperty']), | ||
attributesToExcludeFromAAD: new Set(['publicPropertyExcludedFromAAD']), | ||
}); | ||
|
||
core.http.createRouter().get( | ||
{ | ||
path: '/api/saved_objects/get-decrypted-as-internal-user/{id}', | ||
validate: { params: value => ({ value }) }, | ||
}, | ||
async (context, request, response) => { | ||
const [, { encryptedSavedObjects }] = await core.getStartServices(); | ||
const spaceId = deps.spaces.spacesService.getSpaceId(request); | ||
const namespace = deps.spaces.spacesService.spaceIdToNamespace(spaceId); | ||
|
||
try { | ||
return response.ok({ | ||
body: await encryptedSavedObjects.getDecryptedAsInternalUser( | ||
SAVED_OBJECT_WITH_SECRET_TYPE, | ||
request.params.id, | ||
{ namespace } | ||
), | ||
}); | ||
} catch (err) { | ||
if (encryptedSavedObjects.isEncryptionError(err)) { | ||
return response.badRequest({ body: 'Failed to encrypt attributes' }); | ||
} | ||
|
||
return response.customError({ body: err, statusCode: 500 }); | ||
} | ||
} | ||
); | ||
}, | ||
start() {}, | ||
stop() {}, | ||
}); |
11 changes: 11 additions & 0 deletions
11
x-pack/test/encrypted_saved_objects_api_integration/ftr_provider_context.d.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,11 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { GenericFtrProviderContext } from '@kbn/test/types/ftr'; | ||
|
||
import { services } from './services'; | ||
|
||
export type FtrProviderContext = GenericFtrProviderContext<typeof services, {}>; |
7 changes: 7 additions & 0 deletions
7
x-pack/test/encrypted_saved_objects_api_integration/services.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,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export { services } from '../api_integration/services'; |
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
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
104 changes: 0 additions & 104 deletions
104
x-pack/test/oidc_api_integration/fixtures/oidc_provider/init_routes.js
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
x-pack/test/oidc_api_integration/fixtures/oidc_provider/kibana.json
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,7 @@ | ||
{ | ||
"id": "oidc_provider_plugin", | ||
"version": "8.0.0", | ||
"kibanaVersion": "kibana", | ||
"server": true, | ||
"ui": false | ||
} |
13 changes: 0 additions & 13 deletions
13
x-pack/test/oidc_api_integration/fixtures/oidc_provider/package.json
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.