-
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.
- Loading branch information
Showing
3 changed files
with
204 additions
and
10 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
200 changes: 200 additions & 0 deletions
200
x-pack/plugins/fleet/server/saved_objects/migrations/security_solution/to_v7_14_0.test.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,200 @@ | ||
/* | ||
* 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 type { SavedObjectMigrationContext, SavedObjectUnsanitizedDoc } from 'kibana/server'; | ||
|
||
import type { PackagePolicy } from '../../../../common'; | ||
|
||
import { migrateEndpointPackagePolicyToV7140 } from './to_v7_14_0'; | ||
|
||
describe('7.14.0 Endpoint Package Policy migration', () => { | ||
const migration = migrateEndpointPackagePolicyToV7140; | ||
it('adds supported option for ransomware on migrations', () => { | ||
const doc = { | ||
id: 'mock-saved-object-id', | ||
attributes: { | ||
name: 'Some Policy Name', | ||
package: { | ||
name: 'endpoint', | ||
title: '', | ||
version: '', | ||
}, | ||
id: 'endpoint', | ||
policy_id: '', | ||
enabled: true, | ||
namespace: '', | ||
output_id: '', | ||
revision: 0, | ||
updated_at: '', | ||
updated_by: '', | ||
created_at: '', | ||
created_by: '', | ||
inputs: [ | ||
{ | ||
type: 'endpoint', | ||
enabled: true, | ||
streams: [], | ||
config: { | ||
policy: { | ||
value: { | ||
windows: { | ||
ransomware: { | ||
mode: 'off', | ||
}, | ||
malware: { | ||
mode: 'off', | ||
}, | ||
popup: { | ||
malware: { | ||
message: '', | ||
enabled: false, | ||
}, | ||
ransomware: { | ||
message: '', | ||
enabled: false, | ||
}, | ||
}, | ||
}, | ||
linux: { | ||
events: { process: true, file: true, network: true }, | ||
logging: { file: 'info' }, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
type: ' nested', | ||
}; | ||
|
||
expect(migration(doc, {} as SavedObjectMigrationContext)).toEqual({ | ||
attributes: { | ||
name: 'Some Policy Name', | ||
package: { | ||
name: 'endpoint', | ||
title: '', | ||
version: '', | ||
}, | ||
id: 'endpoint', | ||
policy_id: '', | ||
enabled: true, | ||
namespace: '', | ||
output_id: '', | ||
revision: 0, | ||
updated_at: '', | ||
updated_by: '', | ||
created_at: '', | ||
created_by: '', | ||
inputs: [ | ||
{ | ||
type: 'endpoint', | ||
enabled: true, | ||
streams: [], | ||
config: { | ||
policy: { | ||
value: { | ||
windows: { | ||
ransomware: { | ||
mode: 'off', | ||
supported: true, | ||
}, | ||
malware: { | ||
mode: 'off', | ||
}, | ||
popup: { | ||
malware: { | ||
message: '', | ||
enabled: false, | ||
}, | ||
ransomware: { | ||
message: '', | ||
enabled: false, | ||
}, | ||
}, | ||
}, | ||
linux: { | ||
events: { process: true, file: true, network: true }, | ||
logging: { file: 'info' }, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
type: ' nested', | ||
id: 'mock-saved-object-id', | ||
}); | ||
}); | ||
|
||
it('does not modify non-endpoint package policies', () => { | ||
const doc: SavedObjectUnsanitizedDoc<PackagePolicy> = { | ||
id: 'mock-saved-object-id', | ||
attributes: { | ||
name: 'Some Policy Name', | ||
package: { | ||
name: 'notEndpoint', | ||
title: '', | ||
version: '', | ||
}, | ||
id: 'notEndpoint', | ||
policy_id: '', | ||
enabled: true, | ||
namespace: '', | ||
output_id: '', | ||
revision: 0, | ||
updated_at: '', | ||
updated_by: '', | ||
created_at: '', | ||
created_by: '', | ||
inputs: [ | ||
{ | ||
type: 'notEndpoint', | ||
enabled: true, | ||
streams: [], | ||
config: {}, | ||
}, | ||
], | ||
}, | ||
type: ' nested', | ||
}; | ||
|
||
expect( | ||
migration(doc, {} as SavedObjectMigrationContext) as SavedObjectUnsanitizedDoc<PackagePolicy> | ||
).toEqual({ | ||
attributes: { | ||
name: 'Some Policy Name', | ||
package: { | ||
name: 'notEndpoint', | ||
title: '', | ||
version: '', | ||
}, | ||
id: 'notEndpoint', | ||
policy_id: '', | ||
enabled: true, | ||
namespace: '', | ||
output_id: '', | ||
revision: 0, | ||
updated_at: '', | ||
updated_by: '', | ||
created_at: '', | ||
created_by: '', | ||
inputs: [ | ||
{ | ||
type: 'notEndpoint', | ||
enabled: true, | ||
streams: [], | ||
config: {}, | ||
}, | ||
], | ||
}, | ||
type: ' nested', | ||
id: 'mock-saved-object-id', | ||
}); | ||
}); | ||
}); |
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