mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-13 16:14:07 -08:00
🔀 Merge branch 'jira-auth-test' of https://github.com/pemontto/n8n into pemontto-jira-auth-test
This commit is contained in:
commit
db3e0fb422
|
@ -1,3 +1,7 @@
|
||||||
|
import {
|
||||||
|
OptionsWithUri,
|
||||||
|
} from 'request';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
|
@ -5,12 +9,15 @@ import {
|
||||||
import {
|
import {
|
||||||
IBinaryData,
|
IBinaryData,
|
||||||
IBinaryKeyData,
|
IBinaryKeyData,
|
||||||
|
ICredentialsDecrypted,
|
||||||
|
ICredentialTestFunctions,
|
||||||
IDataObject,
|
IDataObject,
|
||||||
ILoadOptionsFunctions,
|
ILoadOptionsFunctions,
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
INodePropertyOptions,
|
INodePropertyOptions,
|
||||||
INodeType,
|
INodeType,
|
||||||
INodeTypeDescription,
|
INodeTypeDescription,
|
||||||
|
NodeCredentialTestResult,
|
||||||
NodeOperationError,
|
NodeOperationError,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
@ -74,6 +81,7 @@ export class Jira implements INodeType {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
testedBy: 'jiraSoftwareApiTest',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'jiraSoftwareServerApi',
|
name: 'jiraSoftwareServerApi',
|
||||||
|
@ -85,6 +93,7 @@ export class Jira implements INodeType {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
testedBy: 'jiraSoftwareApiTest',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
properties: [
|
properties: [
|
||||||
|
@ -145,6 +154,44 @@ export class Jira implements INodeType {
|
||||||
};
|
};
|
||||||
|
|
||||||
methods = {
|
methods = {
|
||||||
|
credentialTest: {
|
||||||
|
async jiraSoftwareApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise<NodeCredentialTestResult> {
|
||||||
|
let data; let domain;
|
||||||
|
const credentials = credential.data;
|
||||||
|
domain = credentials!.domain;
|
||||||
|
data = Buffer.from(`${credentials!.email}:${credentials!.password || credentials!.apiToken}`).toString('base64');
|
||||||
|
|
||||||
|
const endpoint = '/api/2/project';
|
||||||
|
|
||||||
|
const options: OptionsWithUri = {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Basic ${data}`,
|
||||||
|
Accept: 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-Atlassian-Token': 'no-check',
|
||||||
|
},
|
||||||
|
method: 'GET',
|
||||||
|
uri: `${domain}/rest${endpoint}`,
|
||||||
|
qs: {
|
||||||
|
recent: 0,
|
||||||
|
},
|
||||||
|
json: true,
|
||||||
|
timeout: 5000,
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const response = await this.helpers.request!(options);
|
||||||
|
} catch (err) {
|
||||||
|
return {
|
||||||
|
status: 'Error',
|
||||||
|
message: `Connection details not valid; ${err.message}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
status: 'OK',
|
||||||
|
message: 'Authentication successful!',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
loadOptions: {
|
loadOptions: {
|
||||||
// Get all the projects to display them to user so that he can
|
// Get all the projects to display them to user so that he can
|
||||||
// select them easily
|
// select them easily
|
||||||
|
|
Loading…
Reference in a new issue