Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Remove in memory repository #50431

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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