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 3949 add cred test to popular nodes #3668

Merged
merged 36 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ffa2e63
✨ Add injection to notion,
agobrech Jun 27, 2022
b3b1a00
🔥 Remove unuse method
agobrech Jun 27, 2022
e714d66
🎨 Move testing from node file to cred file
agobrech Jun 27, 2022
8dd3bc1
✨ Add injection and testing in facebook graph
agobrech Jun 27, 2022
efe1a38
Add cred injec with testing
agobrech Jul 1, 2022
4538e0b
Add Cred injection and cred test
agobrech Jul 1, 2022
da6ddd3
Add cred injection, and cred testing for typeform, fix issue in clickup
agobrech Jul 1, 2022
9f55f87
Add cred injection, move testing inside creds
agobrech Jul 1, 2022
d7a4df9
Add cred injection and cred testing to SendGrid
agobrech Jul 3, 2022
78d7e5f
Add cred injection and cred testing to woocommerce
agobrech Jul 3, 2022
bf72a6b
Add cred injection, add cred test to gitlab
agobrech Jul 5, 2022
0e9bbd5
🔥 Fix duplicated imports in Mautic cred
agobrech Jul 5, 2022
0bbe8e7
🔥 removed unused credentials testing in node
agobrech Jul 5, 2022
fadb6d0
Add cred injection, cred testing, handles slash trailing for Grafana …
agobrech Jul 5, 2022
5c873f5
Add cred injection, cred testing to shopify
agobrech Jul 5, 2022
bc12eca
Add cred injection , add cred testing to stripe
agobrech Jul 6, 2022
85a658f
changed cred injection, add testing to cred for mattermost
agobrech Jul 6, 2022
382f460
add cred injection and testing for dropbox
agobrech Jul 7, 2022
2f88719
Add cred injection, cred testing to webflow
agobrech Jul 7, 2022
d8587ef
✨ Add cred injection and cred test to nocodb
agobrech Jul 11, 2022
ac9826e
✨ Add cred injection, cred testing to mailchimp
agobrech Jul 11, 2022
560bb87
🐛 fix a bug In credentials testing
agobrech Jul 11, 2022
33aefee
✨ Add cred injection, cred testing to sms77
agobrech Jul 11, 2022
c736037
✨ Add cred injection, cred testing to ActiveCampaign
agobrech Jul 11, 2022
e60ffe2
Add cred injection, cred testing to TheHive
agobrech Jul 11, 2022
256ebf7
✨ Add cred injection, add cred testing to ApiTemplateio
agobrech Jul 11, 2022
203684c
✨ Add cred injection, add cred testing for zoom
agobrech Jul 11, 2022
be9b3ea
✨ Add cred injection, cred testing to rocketchat
agobrech Jul 11, 2022
f00a8d0
✨ Add cred injection, add cred test to getResponse
agobrech Jul 11, 2022
e9b3ddd
Merge branch 'master' into n8n-3949-add-cred-test-to-popular-nodes
agobrech Jul 12, 2022
5e94506
🔥 Remove useless authentcate creds and testing from facebookGraphApp
agobrech Jul 12, 2022
89721d5
🔥 Remove useless imports in FacebookGrappApp credentials file
agobrech Jul 12, 2022
7a41aed
🔥 Removed useless imports and if statement
agobrech Jul 12, 2022
b0ee874
🐛 Add version to header when testing cred
agobrech Jul 12, 2022
bfde7bb
Merge branch 'master' into n8n-3949-add-cred-test-to-popular-nodes
krynble Jul 13, 2022
0b35b2f
Merge branch 'master' into n8n-3949-add-cred-test-to-popular-nodes
janober Jul 15, 2022
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
16 changes: 16 additions & 0 deletions packages/nodes-base/credentials/ActiveCampaignApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
Expand All @@ -22,4 +24,18 @@ export class ActiveCampaignApi implements ICredentialType {
default: '',
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
'Api-Token': '={{$credentials.apiKey}}',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.apiUrl}}',
url: '/api/3/fields',
},
};
}
16 changes: 16 additions & 0 deletions packages/nodes-base/credentials/ApiTemplateIoApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
Expand All @@ -15,4 +17,18 @@ export class ApiTemplateIoApi implements ICredentialType {
default: '',
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
'X-API-KEY': '={{$credentials.apiKey}}',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: 'https://api.apitemplate.io/v1',
url: '/list-templates',
},
};
}
17 changes: 17 additions & 0 deletions packages/nodes-base/credentials/ClickUpApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
Expand All @@ -15,4 +17,19 @@ export class ClickUpApi implements ICredentialType {
default: '',
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
Authorization: '={{$credentials.accessToken}}',
},
},
};

test: ICredentialTestRequest = {
request: {
baseURL: 'https://api.clickup.com/api/v2',
url: '/team',
},
};
}
21 changes: 20 additions & 1 deletion packages/nodes-base/credentials/DropboxApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {
IAuthenticateGeneric,
ICredentialTestFunction,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
INodeProperties
} from 'n8n-workflow';

export class DropboxApi implements ICredentialType {
Expand Down Expand Up @@ -31,4 +34,20 @@ export class DropboxApi implements ICredentialType {
default: 'full',
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
Authorization: '=Bearer {{$credentials.accessToken}}',
},
},
};

test: ICredentialTestRequest = {
request: {
baseURL: 'https://api.dropboxapi.com/2',
url: '/users/get_current_account',
method: 'POST',
},
};
}
16 changes: 16 additions & 0 deletions packages/nodes-base/credentials/FacebookGraphApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
Expand All @@ -16,4 +18,18 @@ export class FacebookGraphApi implements ICredentialType {
default: '',
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
qs: {
access_token: '={{$credentials.accessToken}}',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: 'https://graph.facebook.com/v8.0',
url: '/me',
},
};
}
16 changes: 16 additions & 0 deletions packages/nodes-base/credentials/GetResponseApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
Expand All @@ -15,4 +17,18 @@ export class GetResponseApi implements ICredentialType {
default: '',
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
'X-Auth-Token': '=api-key {{$credentials.apiKey}}',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: 'https://api.getresponse.com/v3',
url: '/campaigns',
},
};
}
17 changes: 17 additions & 0 deletions packages/nodes-base/credentials/GitlabApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
Expand All @@ -22,4 +24,19 @@ export class GitlabApi implements ICredentialType {
default: '',
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
'Private-Token': '={{$credentials.accessToken}}',
},
},
};

test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.server.replace(new RegExp("/$"), "") + "/api/v4" }}',
url: '/users',
},
};
}
17 changes: 17 additions & 0 deletions packages/nodes-base/credentials/GrafanaApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
Expand All @@ -25,4 +27,19 @@ export class GrafanaApi implements ICredentialType {
required: true,
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
Authorization: '=Bearer {{$credentials.apiKey}}',
},
},
};

test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.baseUrl.replace(new RegExp("/$"), "") + "/api" }}',
url: '/folders',
},
};
}
17 changes: 17 additions & 0 deletions packages/nodes-base/credentials/MailchimpApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import {
IAuthenticateGeneric,
ICredentialTestFunctions,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
Expand All @@ -15,4 +18,18 @@ export class MailchimpApi implements ICredentialType {
default: '',
},
];
authenticate: IAuthenticateGeneric = {
type:'generic',
properties:{
headers:{
Authorization: '=apikey {{$credentials.apiKey}}',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: '=https://{{$credentials.apiKey.split("-").pop()}}.api.mailchimp.com/3.0',
url: '/lists',
},
};
}
20 changes: 16 additions & 4 deletions packages/nodes-base/credentials/MattermostApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {
IAuthenticateGeneric,
ICredentialDataDecryptedObject,
ICredentialTestRequest,
ICredentialType,
IHttpRequestOptions,
INodeProperties,
Expand All @@ -24,8 +26,18 @@ export class MattermostApi implements ICredentialType {
default: '',
},
];
async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions> {
requestOptions.headers!['Authorization'] = `Bearer ${credentials.accessToken}`;
return requestOptions;
}
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
Authorization: '=Bearer {{$credentials.accessToken}}',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.baseUrl}}/api/v4',
url: '/users',
},
};
}
31 changes: 29 additions & 2 deletions packages/nodes-base/credentials/MauticApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {
ICredentialType,
INodeProperties,
ICredentialDataDecryptedObject,
ICredentialTestRequest,
ICredentialType,
IHttpRequestOptions,
INodeProperties,
} from 'n8n-workflow';

export class MauticApi implements ICredentialType {
Expand Down Expand Up @@ -31,4 +34,28 @@ export class MauticApi implements ICredentialType {
default: '',
},
];
async authenticate (credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions> {
const {
url,
username,
password,
} = credentials as {
url: string,
username: string,
password: string,
};
const credentialUrl = url.endsWith('/') ? `${url}api/users/self` : `${url}/api/users/self`;
const base64Key = Buffer.from(`${username}:${password}`).toString('base64');
requestOptions.headers!['Authorization'] = `Basic ${base64Key}`;
requestOptions.url = credentialUrl ? credentialUrl : requestOptions.url;

return requestOptions;
}

test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.url.replace(new RegExp("/$"), "")}}',
url: '/api/users/self',
},
};
}
16 changes: 16 additions & 0 deletions packages/nodes-base/credentials/NocoDb.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
Expand All @@ -23,4 +25,18 @@ export class NocoDb implements ICredentialType {
placeholder: 'http(s)://localhost:8080',
},
];
authenticate: IAuthenticateGeneric = {
type:'generic',
properties: {
headers:{
'xc-auth': '={{credentials.apiToken}}',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.host}}',
url: '/lists',
},
};
}
17 changes: 17 additions & 0 deletions packages/nodes-base/credentials/RocketchatApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
Expand Down Expand Up @@ -29,4 +31,19 @@ export class RocketchatApi implements ICredentialType {
placeholder: 'https://n8n.rocket.chat',
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
'X-Auth-Token': '={{$credentials.authKey}}',
'X-User-Id': '={{$credentials.userId}}',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.domain}}',
url: '/api/v1/webdav.getMyAccounts',
},
};
}
12 changes: 10 additions & 2 deletions packages/nodes-base/credentials/SendGridApi.credentials.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
Expand All @@ -16,12 +17,19 @@ export class SendGridApi implements ICredentialType {
default: '',
},
];
authenticate = {
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
Authorization: '=Bearer {{$credentials.apiKey}}',
},
},
} as IAuthenticateGeneric;
};

test: ICredentialTestRequest = {
request: {
baseURL: 'https://api.sendgrid.com/v3',
url: '/marketing/contacts',
},
};
}
Loading