From 82d26d425ecb035521e18e3f692279b15918025c Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Wed, 16 Nov 2022 09:41:48 +0100 Subject: [PATCH] fix: send POST body to indicators/expression/description as text plain (#1286) --- .../textPlainMatchers.test.ts | 18 ++++++++++++++++++ .../queryToRequestOptions/textPlainMatchers.ts | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.ts b/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.ts index 042b5bc1..a01f2918 100644 --- a/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.ts +++ b/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.ts @@ -8,6 +8,7 @@ import { isAddOrUpdateSystemOrUserSetting, addOrUpdateConfigurationProperty, isMetadataPackageInstallation, + isExpressionDescriptionValidation, } from './textPlainMatchers' describe('isReplyToMessageConversation', () => { @@ -241,3 +242,20 @@ describe('isMetadataPackageInstallation', () => { ).toBe(false) }) }) + +describe('isExpressionDescriptionValidation', () => { + it('returns true for a POST to "indicators/expression/description"', () => { + expect( + isExpressionDescriptionValidation('create', { + resource: 'indicators/expression/description', + }) + ).toBe(true) + }) + it('retuns false for a POST to a different resource', () => { + expect( + isMetadataPackageInstallation('create', { + resource: 'indicators/expression/somethingelse', + }) + ).toBe(false) + }) +}) diff --git a/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.ts b/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.ts index 36b69bc5..d6bde09b 100644 --- a/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.ts +++ b/services/data/src/links/RestAPILink/queryToRequestOptions/textPlainMatchers.ts @@ -121,3 +121,10 @@ export const isMetadataPackageInstallation = ( type: FetchType, { resource }: ResolvedResourceQuery ): boolean => type === 'create' && resource === 'synchronization/metadataPull' + +// POST to 'indicaators/expression/description' (validate an expression) +export const isExpressionDescriptionValidation = ( + type: FetchType, + { resource }: ResolvedResourceQuery +): boolean => + type === 'create' && resource === 'indicators/expression/description'