forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Automatic Import] Add more FTR tests (elastic#203772)
- Loading branch information
1 parent
807511f
commit c9787fd
Showing
16 changed files
with
285 additions
and
11 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
15 changes: 15 additions & 0 deletions
15
x-pack/test/automatic_import_api_integration/apis/config_graphs.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,15 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { createTestConfig } from '../common/config'; | ||
|
||
export default createTestConfig('apis', { | ||
license: 'trial', | ||
ssl: true, | ||
testFiles: [require.resolve('./tests/graphs')], | ||
publicBaseUrl: true, | ||
}); |
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
67 changes: 67 additions & 0 deletions
67
x-pack/test/automatic_import_api_integration/apis/tests/graphs/categorization.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,67 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../../../common/ftr_provider_context'; | ||
import { postCategorization } from '../../../common/lib/api/categorization'; | ||
import { User } from '../../../common/lib/authentication/types'; | ||
import { BadRequestError } from '../../../common/lib/error/error'; | ||
|
||
export default function (providerContext: FtrProviderContext) { | ||
const { getService } = providerContext; | ||
const supertest = getService('supertest'); | ||
describe('Run categorization', () => { | ||
it('should get 400 when trying to run categorization with invalid json', async () => { | ||
const response = await postCategorization({ | ||
supertest, | ||
req: { | ||
packageName: 'some-package', | ||
dataStreamName: 'some-data-stream', | ||
rawSamples: ['{test:json}'], | ||
samplesFormat: { | ||
name: 'json', | ||
}, | ||
connectorId: 'preconfigured-bedrock', | ||
currentPipeline: { processors: [] }, | ||
}, | ||
expectedHttpCode: 400, | ||
auth: { | ||
user: { username: 'elastic', password: 'elastic' } as User, | ||
}, | ||
}); | ||
if (response instanceof BadRequestError) { | ||
expect(response.message).to.be("Expected property name or '}' in JSON at position 1"); | ||
} else { | ||
expect().fail('Expected BadRequestError'); | ||
} | ||
}); | ||
it('should get 400 when trying to run categorization without connector action', async () => { | ||
const response = await postCategorization({ | ||
supertest, | ||
req: { | ||
packageName: 'some-package', | ||
dataStreamName: 'some-data-stream', | ||
rawSamples: ['{test:json}'], | ||
samplesFormat: { | ||
name: 'json', | ||
}, | ||
connectorId: 'preconfigured-dummy', | ||
currentPipeline: { processors: [] }, | ||
}, | ||
expectedHttpCode: 400, | ||
auth: { | ||
user: { username: 'elastic', password: 'elastic' } as User, | ||
}, | ||
}); | ||
if (response instanceof BadRequestError) { | ||
expect(response.message).to.be('Saved object [action/preconfigured-dummy] not found'); | ||
} else { | ||
expect().fail('Expected BadRequestError'); | ||
} | ||
}); | ||
}); | ||
} |
65 changes: 65 additions & 0 deletions
65
x-pack/test/automatic_import_api_integration/apis/tests/graphs/ecs_mapping.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,65 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../../../common/ftr_provider_context'; | ||
import { postEcsMapping } from '../../../common/lib/api/ecs'; | ||
import { User } from '../../../common/lib/authentication/types'; | ||
import { BadRequestError } from '../../../common/lib/error/error'; | ||
|
||
export default function (providerContext: FtrProviderContext) { | ||
const { getService } = providerContext; | ||
const supertest = getService('supertest'); | ||
describe('Run ecs_mapping', () => { | ||
it('should get 400 when trying to run ecs_mapping with invalid json', async () => { | ||
const response = await postEcsMapping({ | ||
supertest, | ||
req: { | ||
packageName: 'some-package', | ||
dataStreamName: 'some-data-stream', | ||
rawSamples: ['{test:json}'], | ||
samplesFormat: { | ||
name: 'json', | ||
}, | ||
connectorId: 'preconfigured-bedrock', | ||
}, | ||
expectedHttpCode: 400, | ||
auth: { | ||
user: { username: 'elastic', password: 'elastic' } as User, | ||
}, | ||
}); | ||
if (response instanceof BadRequestError) { | ||
expect(response.message).to.be("Expected property name or '}' in JSON at position 1"); | ||
} else { | ||
expect().fail('Expected BadRequestError'); | ||
} | ||
}); | ||
it('should get 400 when trying to run ecs_mapping without connector action', async () => { | ||
const response = await postEcsMapping({ | ||
supertest, | ||
req: { | ||
packageName: 'some-package', | ||
dataStreamName: 'some-data-stream', | ||
rawSamples: ['{test:json}'], | ||
samplesFormat: { | ||
name: 'json', | ||
}, | ||
connectorId: 'preconfigured-dummy', | ||
}, | ||
expectedHttpCode: 400, | ||
auth: { | ||
user: { username: 'elastic', password: 'elastic' } as User, | ||
}, | ||
}); | ||
if (response instanceof BadRequestError) { | ||
expect(response.message).to.be('Saved object [action/preconfigured-dummy] not found'); | ||
} else { | ||
expect().fail('Expected BadRequestError'); | ||
} | ||
}); | ||
}); | ||
} |
33 changes: 33 additions & 0 deletions
33
x-pack/test/automatic_import_api_integration/apis/tests/graphs/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,33 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FtrProviderContext } from '../../../common/ftr_provider_context'; | ||
import { | ||
createUsersAndRoles, | ||
deleteUsersAndRoles, | ||
activateUserProfiles, | ||
} from '../../../common/lib/authentication'; | ||
|
||
export default ({ loadTestFile, getService }: FtrProviderContext): void => { | ||
describe('Automatic Import enabled: basic', function () { | ||
before(async () => { | ||
await createUsersAndRoles(getService); | ||
// once a user profile is created the only way to remove it is to delete the user and roles, so best to activate | ||
// before all the tests | ||
await activateUserProfiles(getService); | ||
}); | ||
|
||
after(async () => { | ||
await deleteUsersAndRoles(getService); | ||
}); | ||
|
||
// Basic | ||
loadTestFile(require.resolve('./ecs_mapping')); | ||
loadTestFile(require.resolve('./categorization')); | ||
loadTestFile(require.resolve('./related')); | ||
}); | ||
}; |
67 changes: 67 additions & 0 deletions
67
x-pack/test/automatic_import_api_integration/apis/tests/graphs/related.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,67 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../../../common/ftr_provider_context'; | ||
import { postRelated } from '../../../common/lib/api/related'; | ||
import { User } from '../../../common/lib/authentication/types'; | ||
import { BadRequestError } from '../../../common/lib/error/error'; | ||
|
||
export default function (providerContext: FtrProviderContext) { | ||
const { getService } = providerContext; | ||
const supertest = getService('supertest'); | ||
describe('Run related', () => { | ||
it('should get 400 when trying to run related with invalid json', async () => { | ||
const response = await postRelated({ | ||
supertest, | ||
req: { | ||
packageName: 'some-package', | ||
dataStreamName: 'some-data-stream', | ||
rawSamples: ['{test:json}'], | ||
samplesFormat: { | ||
name: 'json', | ||
}, | ||
connectorId: 'preconfigured-bedrock', | ||
currentPipeline: { processors: [] }, | ||
}, | ||
expectedHttpCode: 400, | ||
auth: { | ||
user: { username: 'elastic', password: 'elastic' } as User, | ||
}, | ||
}); | ||
if (response instanceof BadRequestError) { | ||
expect(response.message).to.be("Expected property name or '}' in JSON at position 1"); | ||
} else { | ||
expect().fail('Expected BadRequestError'); | ||
} | ||
}); | ||
it('should get 400 when trying to run related without connector action', async () => { | ||
const response = await postRelated({ | ||
supertest, | ||
req: { | ||
packageName: 'some-package', | ||
dataStreamName: 'some-data-stream', | ||
rawSamples: ['{test:json}'], | ||
samplesFormat: { | ||
name: 'json', | ||
}, | ||
connectorId: 'preconfigured-dummy', | ||
currentPipeline: { processors: [] }, | ||
}, | ||
expectedHttpCode: 400, | ||
auth: { | ||
user: { username: 'elastic', password: 'elastic' } as User, | ||
}, | ||
}); | ||
if (response instanceof BadRequestError) { | ||
expect(response.message).to.be('Saved object [action/preconfigured-dummy] not found'); | ||
} else { | ||
expect().fail('Expected BadRequestError'); | ||
} | ||
}); | ||
}); | ||
} |
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
Oops, something went wrong.