Skip to content

Commit

Permalink
[Fleet] Remove in memory repository (#50431)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored Nov 13, 2019
1 parent 3612b98 commit d3b1941
Show file tree
Hide file tree
Showing 28 changed files with 3,978 additions and 2,121 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

exports['AgentsEventsRepository Api Keys allow to create and delete an api key - createApiKey (1)'] = {
"results": {
"id": "xnomHW4BOCe18YaxW5t6",
"id": "tLNEZW4B4KwD6w8oPuUl",
"name": "test api key",
"api_key": "HSIY-8YbQCuVOy1lTUSJsg"
"api_key": "RXqjPJhUQ8O7LWLMH4Wuvw"
}
}

exports['AgentsEventsRepository Api Keys allow to create and delete an api key - deleteApiKey (2)'] = {
"results": {
"invalidated_api_keys": [
"xnomHW4BOCe18YaxW5t6"
"tLNEZW4B4KwD6w8oPuUl"
],
"previously_invalidated_api_keys": [],
"error_count": 0
Expand Down
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;
* you may not use this file except in compliance with the Elastic License.
*/

import { SavedObjectsBaseOptions, SavedObjectAttributes, SavedObject } from 'src/core/server';

export interface EncryptedSavedObjects {
getDecryptedAsInternalUser<T extends SavedObjectAttributes = any>(
type: string,
id: string,
options?: SavedObjectsBaseOptions
): Promise<SavedObject<T>>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

import { SavedObjectsBaseOptions, SavedObjectAttributes, SavedObject } from 'src/core/server';
import { PluginStartContract } from '../../../../../../plugins/encrypted_saved_objects/server';
import { EncryptedSavedObjects as EncryptedSavedObjectsType } from './adapter_types';

export class EncryptedSavedObjects {
export class EncryptedSavedObjects implements EncryptedSavedObjectsType {
constructor(private readonly plugin: PluginStartContract) {}

public async getDecryptedAsInternalUser<T extends SavedObjectAttributes = any>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

import { memorize } from '@mattapperson/slapshot/lib/memorize';
import { SavedObjectsBaseOptions, SavedObjectAttributes, SavedObject } from 'src/core/server';
import { EncryptedSavedObjects } from './default';
import { EncryptedSavedObjects } from './adapter_types';

/**
* Memorize adpater for test purpose only
*/
export class MemorizeEncryptedSavedObjects {
export class MemorizeEncryptedSavedObjects implements EncryptedSavedObjects {
constructor(private readonly adapter?: EncryptedSavedObjects) {}

public async getDecryptedAsInternalUser<T extends SavedObjectAttributes = any>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class MemorizeSODatabaseAdapter implements SODatabaseAdapterType {
options?: SavedObjectsCreateOptions
) {
return Slapshot.memorize(
`bulkCreate:${JSON.stringify(objects)}:${JSON.stringify(options || {})}`,
`bulkCreate`,
() => {
if (!this.soAdadpter) {
throw new Error('An adapter must be provided when running tests online');
Expand All @@ -67,7 +67,7 @@ export class MemorizeSODatabaseAdapter implements SODatabaseAdapterType {
options: SavedObjectsBaseOptions = {}
) {
return Slapshot.memorize(
`delete:${type}:${id}:${JSON.stringify(options)}`,
`delete`,
() => {
if (!this.soAdadpter) {
throw new Error('An adapter must be provided when running tests online');
Expand Down Expand Up @@ -100,7 +100,7 @@ export class MemorizeSODatabaseAdapter implements SODatabaseAdapterType {
options: SavedObjectsBaseOptions = {}
): Promise<SavedObjectsBulkResponse<T>> {
return Slapshot.memorize(
`bulkCreate:${JSON.stringify(objects)}:${JSON.stringify(options || {})}`,
`bulkGet`,
() => {
if (!this.soAdadpter) {
throw new Error('An adapter must be provided when running tests online');
Expand All @@ -118,7 +118,7 @@ export class MemorizeSODatabaseAdapter implements SODatabaseAdapterType {
options: SavedObjectsBaseOptions = {}
): Promise<SavedObject<T> | null> {
return Slapshot.memorize(
`get:${type}:${id}:${JSON.stringify(options)}`,
`get:${type}`,
() => {
if (!this.soAdadpter) {
throw new Error('An adapter must be provided when running tests online');
Expand All @@ -137,7 +137,7 @@ export class MemorizeSODatabaseAdapter implements SODatabaseAdapterType {
options: SavedObjectsUpdateOptions = {}
): Promise<SavedObjectsUpdateResponse<T>> {
return Slapshot.memorize(
`get:${type}:${id}:${JSON.stringify(attributes)}:${JSON.stringify(options)}`,
`update:${type}`,
() => {
if (!this.soAdadpter) {
throw new Error('An adapter must be provided when running tests online');
Expand Down
Loading

0 comments on commit d3b1941

Please sign in to comment.