n8n-nodes-allure-testops
Version:
N8N node for Allure TestOps
82 lines • 2.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AllureTestOpsApi = void 0;
class AllureTestOpsApi {
constructor() {
this.name = 'allureTestOpsApi';
this.icon = { light: 'file:allure_testops.svg', dark: 'file:allure_testops.svg' };
this.displayName = 'Allure TestOps API';
this.documentationUrl = 'https://github.com/GAKiknadze/n8n-nodes-allure-testops/blob/master/docs/credentials.md';
this.properties = [
{
displayName: 'API Token',
name: 'apiToken',
type: 'string',
typeOptions: {
password: true,
},
required: true,
default: '',
},
{
displayName: 'JWT Token',
name: 'jwtToken',
type: 'hidden',
typeOptions: {
expirable: true,
},
default: ''
},
{
displayName: 'Server',
name: 'server',
type: 'string',
required: true,
default: '',
placeholder: 'https://sandbox.testops.cloud',
},
];
this.preAuthentication = async function (credentials) {
try {
const serverUrl = credentials.server;
const apiToken = credentials.apiToken;
const response = await this.helpers.httpRequest({
method: 'POST',
url: `${serverUrl}/api/uaa/oauth/token`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json'
},
body: {
grant_type: 'apitoken',
scope: 'openid',
token: apiToken
}
});
const jwtResponse = typeof response === 'string' ? JSON.parse(response) : response;
return {
jwtToken: jwtResponse.access_token
};
}
catch (error) {
throw new Error(`Failed to generate JWT token: ${error.message}`);
}
};
this.authenticate = {
type: 'generic',
properties: {
headers: {
Authorization: '={{"Bearer " + $credentials.jwtToken}}',
},
}
};
this.test = {
request: {
baseURL: '={{$credentials.server}}',
url: '/api/account/me',
},
};
}
}
exports.AllureTestOpsApi = AllureTestOpsApi;
//# sourceMappingURL=AllureTestOpsApi.credentials.js.map