-
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.
[xpack/ftr/common] follow service provider conventions (#52236)
* [xpack/ftr/common] follow conventions, expose a config file In order to make xpack/test/common ftr config easier to work with, this updates it to follow the conventions established by most other configs of exposing all services from the services module as an object that can be easily merges into local services modules. * common config file and FtrProviderConfig are unused and unnecessary * turns out FtrProviderContext was used...
- Loading branch information
Spencer
authored
Dec 5, 2019
1 parent
05fd394
commit b66415e
Showing
53 changed files
with
157 additions
and
180 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
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
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
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
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, {}>; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* 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 { format as formatUrl } from 'url'; | ||
|
||
import { Role } from './role'; | ||
import { User } from './user'; | ||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export function SecurityServiceProvider({ getService }: FtrProviderContext) { | ||
const log = getService('log'); | ||
const config = getService('config'); | ||
const url = formatUrl(config.get('servers.kibana')); | ||
|
||
return new (class SecurityService { | ||
role = new Role(url, log); | ||
user = new User(url, log); | ||
})(); | ||
} |
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,48 @@ | ||
/* | ||
* 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 Axios from 'axios'; | ||
import { format as formatUrl } from 'url'; | ||
import util from 'util'; | ||
import { FtrProviderContext } from '../ftr_provider_context'; | ||
|
||
export function SpacesServiceProvider({ getService }: FtrProviderContext) { | ||
const log = getService('log'); | ||
const config = getService('config'); | ||
const url = formatUrl(config.get('servers.kibana')); | ||
|
||
const axios = Axios.create({ | ||
headers: { 'kbn-xsrf': 'x-pack/ftr/services/spaces/space' }, | ||
baseURL: url, | ||
maxRedirects: 0, | ||
validateStatus: () => true, // we do our own validation below and throw better error messages | ||
}); | ||
|
||
return new (class SpacesService { | ||
public async create(space: any) { | ||
log.debug('creating space'); | ||
const { data, status, statusText } = await axios.post('/api/spaces/space', space); | ||
|
||
if (status !== 200) { | ||
throw new Error( | ||
`Expected status code of 200, received ${status} ${statusText}: ${util.inspect(data)}` | ||
); | ||
} | ||
log.debug('created space'); | ||
} | ||
|
||
public async delete(spaceId: string) { | ||
log.debug(`deleting space: ${spaceId}`); | ||
const { data, status, statusText } = await axios.delete(`/api/spaces/space/${spaceId}`); | ||
|
||
if (status !== 204) { | ||
throw new Error( | ||
`Expected status code of 204, received ${status} ${statusText}: ${util.inspect(data)}` | ||
); | ||
} | ||
log.debug(`deleted space: ${spaceId}`); | ||
} | ||
})(); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.