From f37aad118af152df775b32371f076c0435bfdcbf Mon Sep 17 00:00:00 2001 From: cpoder Date: Mon, 23 Nov 2026 14:03:40 +0100 Subject: [PATCH] feat: Add Jira Create Issue connector with admission tests - Driver: http-out - Subject: vx.jira.issues.create - Auth: Jira API token (Basic auth) - Rate limit: 10 requests/s per user - Full admission test suite included - Supports creating issues in Jira projects with custom fields --- .../connectors/jira_create_issue/fixture.json | 47 +++++++++++-- .../jira_create_issue.vjs.example | 26 +++++-- .../connectors/jira_create_issue/mock.mjs | 68 +++++++++++++++---- .../jira_create_issue/overrides.json | 11 ++- 4 files changed, 122 insertions(+), 30 deletions(-) diff --git a/docs/examples/connectors/jira_create_issue/fixture.json b/docs/examples/connectors/jira_create_issue/fixture.json index 1aef327..d50ec52 100644 --- a/docs/examples/connectors/jira_create_issue/fixture.json +++ b/docs/examples/connectors/jira_create_issue/fixture.json @@ -1,11 +1,48 @@ { + "id": "10042", + "key": "PROJ-123", + "self": "https://your-domain.atlassian.net/rest/api/3/issue/10042", "fields": { - "project": { - "key": "OPS" + "summary": "Bug report", + "description": { + "type": "doc", + "version": 1, + "content": [ + { + "type": "paragraph", + "content": [ + { + "type": "text", + "text": "Details" + } + ] + } + ] }, - "summary": "ServiceNow INC0010023 \u2014 Email gateway unreachable", "issuetype": { - "name": "Task" + "id": "10001", + "name": "Bug", + "subtask": false + }, + "project": { + "id": "10000", + "key": "PROJ", + "name": "Project Name" + }, + "priority": { + "id": "2", + "name": "High" + }, + "status": { + "id": "1", + "name": "To Do" + }, + "created": "2026-11-23T12:00:00.000+0000", + "updated": "2026-11-23T12:00:00.000+0000", + "reporter": { + "accountId": "5b10a2844c20165700ede21g", + "displayName": "Test User", + "emailAddress": "test@example.com" } } -} \ No newline at end of file +} diff --git a/docs/examples/connectors/jira_create_issue/jira_create_issue.vjs.example b/docs/examples/connectors/jira_create_issue/jira_create_issue.vjs.example index 1494a39..5aff9fa 100644 --- a/docs/examples/connectors/jira_create_issue/jira_create_issue.vjs.example +++ b/docs/examples/connectors/jira_create_issue/jira_create_issue.vjs.example @@ -1,7 +1,21 @@ -# connector: jira_create_issue — create a Jira issue (Cloud REST API v3). -# A flow emits an issue body ({fields: {project, summary, issuetype, ...}}) on SUBJECT. +# connector: jira_create_issue — Create Jira issues +# Consumes vx.jira.issues.create and creates issues in Jira projects +# Expected payload: {project: "PROJ", summary: "Bug report", description: "Details", issuetype: "Bug", priority: "High"} +# Auth: Jira API token or OAuth 2.0 via secret +# Docs: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post +# Rate limits: Jira Cloud supports 10 requests/s per user (can be increased) +# Secrets: jira/url, jira/email, jira/api_token + driver "http-out" -SUBJECT = "vx.jira.create" -URL = "https://YOURSITE.atlassian.net/rest/api/3/issue" -HEADERS = {"Authorization": f"Basic {secret("jira/basic")}", "Content-Type": "application/json", "Accept": "application/json"} -TEST_BODY = {"fields": {"project": {"key": "OPS"}, "summary": "Vejas connector test", "issuetype": {"name": "Task"}}} +SUBJECT = "vx.jira.issues.create" +URL = f"{secret('jira/url')}/rest/api/3/issue" +METHOD = "POST" +HEADERS = { + "Authorization": f"Basic {secret('jira/basic_auth')}", + "Accept": "application/json", + "Content-Type": "application/json" +} + +# Note: Basic auth = base64(email:api_token) +# Store the pre-encoded value in secret('jira/basic_auth') +# Supports custom fields, components, labels, assignee, etc. \ No newline at end of file diff --git a/docs/examples/connectors/jira_create_issue/mock.mjs b/docs/examples/connectors/jira_create_issue/mock.mjs index f9a0fc7..aec3893 100644 --- a/docs/examples/connectors/jira_create_issue/mock.mjs +++ b/docs/examples/connectors/jira_create_issue/mock.mjs @@ -1,18 +1,62 @@ -// Admission mock for jira_create_issue — a minimal local stand-in for the remote API. -// Usage: node mock.mjs . GET /__count returns how many real calls landed. +// Admission mock for jira_create_issue. import { createServer } from 'node:http'; -const port = Number(process.argv[2] || 9200); +const port = Number(process.argv[2] || 9212); let count = 0; -const GET_BODY = null; -const POST_BODY = {"id": "10001", "key": "OPS-101", "self": "http://127.0.0.1/rest/api/3/issue/10001"}; + +const POST_BODY = { + "id": "10042", + "key": "PROJ-123", + "self": "https://your-domain.atlassian.net/rest/api/3/issue/10042", + "fields": { + "summary": "Bug report", + "description": { + "type": "doc", + "version": 1, + "content": [{"type": "paragraph", "content": [{"type": "text", "text": "Details"}]}] + }, + "issuetype": {"id": "10001", "name": "Bug", "subtask": false}, + "project": {"id": "10000", "key": "PROJ", "name": "Project Name"}, + "priority": {"id": "2", "name": "High"}, + "status": {"id": "1", "name": "To Do"}, + "created": "2026-11-23T12:00:00.000+0000", + "updated": "2026-11-23T12:00:00.000+0000", + "reporter": { + "accountId": "5b10a2844c20165700ede21g", + "displayName": "Test User", + "emailAddress": "test@example.com" + } + } +}; + createServer((req, res) => { - if (req.url === '/__count') { res.writeHead(200); res.end(String(count)); return; } - let b = ''; req.on('data', c => b += c); + if (req.url === '/__count') { + res.writeHead(200); + res.end(String(count)); + return; + } + + let body = ''; + req.on('data', chunk => body += chunk); req.on('end', () => { count++; - const body = req.method === 'POST' ? POST_BODY : GET_BODY; - if (body === null) { res.writeHead(405); res.end(); return; } - res.writeHead(req.method === 'POST' ? 201 : 200, {'content-type':'application/json'}); - res.end(JSON.stringify(body)); + + // Jira Issues API + if (req.method === 'POST' && req.url.includes('/issue')) { + const auth = req.headers['authorization']; + if (!auth || !auth.startsWith('Basic ')) { + res.writeHead(401, {'content-type': 'application/json'}); + res.end(JSON.stringify({ + errorMessages: ["You do not have the permission to see the specified issue."], + errors: {} + })); + return; + } + + res.writeHead(201, {'content-type': 'application/json'}); + res.end(JSON.stringify(POST_BODY)); + } else { + res.writeHead(405, {'content-type': 'application/json'}); + res.end(JSON.stringify({errorMessages: ['Method not allowed']})); + } }); -}).listen(port, '127.0.0.1', () => console.log('READY', port)); +}).listen(port, '127.0.0.1', () => console.log('READY', port)); \ No newline at end of file diff --git a/docs/examples/connectors/jira_create_issue/overrides.json b/docs/examples/connectors/jira_create_issue/overrides.json index 49f0ddb..7465124 100644 --- a/docs/examples/connectors/jira_create_issue/overrides.json +++ b/docs/examples/connectors/jira_create_issue/overrides.json @@ -1,8 +1,5 @@ { - "literals": { - "URL": "http://127.0.0.1:{PORT}/rest/api/3/issue" - }, - "secrets": { - "jira/basic": "ZHVtbXk6ZHVtbXk=" - } -} \ No newline at end of file + "URL": "http://127.0.0.1:9212/rest/api/3/issue", + "VEJAS_SECRET_JIRA_URL": "http://127.0.0.1:9212", + "VEJAS_SECRET_JIRA_BASIC_AUTH": "dGVzdEBleGFtcGxlLmNvbTp0ZXN0X2FwaV90b2tlbg==" +}