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

N8N-3272 magento credential tests #3086

Merged
merged 7 commits into from
Apr 8, 2022
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
13 changes: 13 additions & 0 deletions packages/nodes-base/credentials/Magento2Api.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
IAuthenticateBearer,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
Expand All @@ -21,4 +23,15 @@ export class Magento2Api implements ICredentialType {
default: '',
},
];
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.host}}',
url: '/rest/default/V1/modules',
},
};

authenticate = {
type: 'bearer',
properties: {},
} as IAuthenticateBearer;
}
6 changes: 1 addition & 5 deletions packages/nodes-base/nodes/Magento/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/nodes-base/nodes/Magento/Magento2.node.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import {
OptionsWithUri,
} from 'request';


import {
IExecuteFunctions,
} from 'n8n-core';

import {
ICredentialsDecrypted,
ICredentialTestFunctions,
IDataObject,
ILoadOptionsFunctions,
INodeCredentialTestResult,
INodeExecutionData,
INodePropertyOptions,
INodeType,
Expand Down