feat(Magento 2 Node): Add credential tests (#3086)

* Implements Magento Auth API Test

* Deletes unit tests

* Fixed lint issues and changed the URI for the credential test

*  Move credential verification to the credential file

*  Simplify code

Co-authored-by: paolo-rechia <paolo@e-bot7.com>
Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Jonathan Bennetts
2022-04-08 11:01:21 +01:00
committed by GitHub
parent c7a037e9fe
commit a11b00a037
3 changed files with 22 additions and 5 deletions

View File

@@ -28,10 +28,6 @@ export async function magentoApiRequest(this: IWebhookFunctions | IHookFunctions
const credentials = await this.getCredentials('magento2Api') as IDataObject;
let options: OptionsWithUri = {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${credentials.accessToken}`,
},
method,
body,
qs,
@@ -45,7 +41,7 @@ export async function magentoApiRequest(this: IWebhookFunctions | IHookFunctions
delete options.body;
}
//@ts-ignore
return await this.helpers.request.call(this, options);
return await this.helpers.requestWithAuthentication.call(this, 'magento2Api', options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}