Skip to content

Commit

Permalink
Review#1: make sure null values are not allowed for the encryption …
Browse files Browse the repository at this point in the history
…key, document `canEncrypt`.
  • Loading branch information
azasypkin committed Feb 10, 2021
1 parent 0a12c30 commit e6cbf58
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions x-pack/plugins/encrypted_saved_objects/server/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ describe('config schema', () => {
);
});

it('should not allow `null` value for the encryption key', () => {
expect(() => ConfigSchema.validate({ encryptionKey: null })).toThrowErrorMatchingInlineSnapshot(
`"[encryptionKey]: expected value of type [string] but got [null]"`
);

expect(() =>
ConfigSchema.validate({ encryptionKey: null }, { dist: true })
).toThrowErrorMatchingInlineSnapshot(
`"[encryptionKey]: expected value of type [string] but got [null]"`
);
});

it('should throw error if any of the xpack.encryptedSavedObjects.keyRotation.decryptionOnlyKeys is less than 32 characters', () => {
expect(() =>
ConfigSchema.validate({
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/encrypted_saved_objects/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export interface PluginsSetup {
}

export interface EncryptedSavedObjectsPluginSetup {
/**
* Indicates if Saved Object encryption is possible. Requires an encryption key to be explicitly set via `xpack.encryptedSavedObjects.encryptionKey`.
*/
canEncrypt: boolean;
registerType: (typeRegistration: EncryptedSavedObjectTypeRegistration) => void;
createMigration: CreateEncryptedSavedObjectsMigrationFn;
Expand Down

0 comments on commit e6cbf58

Please sign in to comment.