feat(Rundeck Node): Update credential with test and make useable in HTTP Request node (#3879)

* add support for authenticate, test to RundeckApi Credentials

* ensure that the RunDeckApi note uses the authentication mechanism
defined incredentials
This commit is contained in:
AndLLA 2022-10-16 15:26:31 +02:00 committed by GitHub
parent b67e41b45e
commit fc87650180
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 6 deletions

View file

@ -1,4 +1,9 @@
import { ICredentialType, INodeProperties } from 'n8n-workflow';
import {
IAuthenticateGeneric,
ICredentialTestRequest,
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
export class RundeckApi implements ICredentialType {
name = 'rundeckApi';
@ -19,4 +24,22 @@ export class RundeckApi implements ICredentialType {
default: '',
},
];
authenticate: IAuthenticateGeneric = {
type: 'generic',
properties: {
headers: {
'user-agent': 'n8n',
'X-Rundeck-Auth-Token': '={{$credentials?.token}}',
},
},
};
test: ICredentialTestRequest = {
request: {
baseURL: '={{$credentials.url}}',
url: '/api/14/system/info',
method: 'GET',
},
};
}

View file

@ -16,11 +16,9 @@ export class RundeckApi {
}
protected async request(method: string, endpoint: string, body: IDataObject, query: object) {
const credentialType = 'rundeckApi';
const options: OptionsWithUri = {
headers: {
'user-agent': 'n8n',
'X-Rundeck-Auth-Token': this.credentials?.token,
},
rejectUnauthorized: false,
method,
qs: query,
@ -30,7 +28,11 @@ export class RundeckApi {
};
try {
return await this.executeFunctions.helpers.request!(options);
return await this.executeFunctions.helpers.requestWithAuthentication.call(
this.executeFunctions,
credentialType,
options,
);
} catch (error) {
throw new NodeApiError(this.executeFunctions.getNode(), error);
}