Skip to content

Commit

Permalink
test(element-templates): verify REST connector replace
Browse files Browse the repository at this point in the history
Reproduces #767
  • Loading branch information
nikku committed Sep 30, 2022
1 parent 35a9704 commit 470e068
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,49 @@ describe('provider/cloud-element-templates - ElementTemplates - integration', fu
}
));


it('REST Connector (Basic auth) => REST Connector', inject(
function(elementRegistry, elementTemplates) {
let task = elementRegistry.get('REST_TASK');
const template = elementTemplates.get('io.camunda.connectors.HttpJson.v2');

// assume
expectInputs(task, [
{
target: 'authentication.type',
source: 'basic'
},
{
target: 'url',
source: 'https://foo'
},
{
target: 'authentication.username',
source: 'aaa'
}
]);

// when
task = elementTemplates.applyTemplate(task, template);

// then
expectInputs(task, [
{
target: 'authentication.type',
source: 'basic'
},
{
target: 'url',
source: 'https://foo'
},
{
target: 'authentication.username',
source: 'aaa'
}
]);
}
));

});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,30 @@
</zeebe:ioMapping>
</bpmn:extensionElements>
</bpmn:serviceTask>
<bpmn:serviceTask id="REST_TASK" name="REST_TASK" zeebe:modelerTemplate="io.camunda.connectors.HttpJson.v1.basicAuth" zeebe:modelerTemplateIcon="data:image/svg+xml;utf8,%3Csvg%20width%3D%2218%22%20height%3D%2218%22%20viewBox%3D%221%201%2016%2016%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%0A%3Cpath%20d%3D%22M17.0335%208.99997C17.0335%2013.4475%2013.4281%2017.0529%208.98065%2017.0529C4.53316%2017.0529%200.927765%2013.4475%200.927765%208.99997C0.927765%204.55248%204.53316%200.947083%208.98065%200.947083C13.4281%200.947083%2017.0335%204.55248%2017.0335%208.99997Z%22%20fill%3D%22%23505562%22%2F%3E%0A%3Cpath%20d%3D%22M4.93126%2014.1571L6.78106%203.71471H10.1375C11.1917%203.71471%2011.9824%203.98323%2012.5095%204.52027C13.0465%205.04736%2013.315%205.73358%2013.315%206.57892C13.315%207.44414%2013.0714%208.15522%2012.5841%208.71215C12.1067%209.25913%2011.4553%209.63705%2010.6298%209.8459L12.0619%2014.1571H10.3315L9.03364%2010.0249H7.24351L6.51254%2014.1571H4.93126ZM7.49711%208.59281H9.24248C9.99832%208.59281%2010.5901%208.42374%2011.0177%208.08561C11.4553%207.73753%2011.6741%207.26513%2011.6741%206.66842C11.6741%206.19106%2011.5249%205.81811%2011.2265%205.54959C10.9282%205.27113%2010.4558%205.1319%209.80936%205.1319H8.10874L7.49711%208.59281Z%22%20fill%3D%22white%22%2F%3E%0A%3C%2Fsvg%3E%0A">
<bpmn:extensionElements>
<zeebe:taskDefinition type="io.camunda:http-json:1" />
<zeebe:ioMapping>
<zeebe:input source="basic" target="authentication.type" />
<zeebe:input source="https://foo" target="url" />
<zeebe:input source="aaa" target="authentication.username" />
</zeebe:ioMapping>
<zeebe:taskHeaders />
</bpmn:extensionElements>
</bpmn:serviceTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1sefuog">
<bpmndi:BPMNShape id="Activity_0yr90yc_di" bpmnElement="configuredTask">
<bpmndi:BPMNShape id="templateTask_di" bpmnElement="templateTask">
<dc:Bounds x="290" y="80" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="configuredTask_di" bpmnElement="configuredTask">
<dc:Bounds x="160" y="80" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1f5ssmz_di" bpmnElement="templateTask">
<dc:Bounds x="290" y="80" width="100" height="80" />
<bpmndi:BPMNShape id="REST_TASK_di" bpmnElement="REST_TASK">
<dc:Bounds x="160" y="200" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
Expand Down
135 changes: 135 additions & 0 deletions test/spec/provider/cloud-element-templates/fixtures/integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,140 @@
}
}
]
},
{
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
"name": "REST Connector",
"id": "io.camunda.connectors.HttpJson.v2",
"icon": {
"contents": "data:image/svg+xml;utf8,%3Csvg%20width%3D%2218%22%20height%3D%2218%22%20viewBox%3D%220%200%2018%2018%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%0A%3Cpath%20d%3D%22M17.0335%208.99997C17.0335%2013.4475%2013.4281%2017.0529%208.98065%2017.0529C4.53316%2017.0529%200.927765%2013.4475%200.927765%208.99997C0.927765%204.55248%204.53316%200.947083%208.98065%200.947083C13.4281%200.947083%2017.0335%204.55248%2017.0335%208.99997Z%22%20fill%3D%22%23505562%22%2F%3E%0A%3Cpath%20d%3D%22M4.93126%2014.1571L6.78106%203.71471H10.1375C11.1917%203.71471%2011.9824%203.98323%2012.5095%204.52027C13.0465%205.04736%2013.315%205.73358%2013.315%206.57892C13.315%207.44414%2013.0714%208.15522%2012.5841%208.71215C12.1067%209.25913%2011.4553%209.63705%2010.6298%209.8459L12.0619%2014.1571H10.3315L9.03364%2010.0249H7.24351L6.51254%2014.1571H4.93126ZM7.49711%208.59281H9.24248C9.99832%208.59281%2010.5901%208.42374%2011.0177%208.08561C11.4553%207.73753%2011.6741%207.26513%2011.6741%206.66842C11.6741%206.19106%2011.5249%205.81811%2011.2265%205.54959C10.9282%205.27113%2010.4558%205.1319%209.80936%205.1319H8.10874L7.49711%208.59281Z%22%20fill%3D%22white%22%2F%3E%0A%3C%2Fsvg%3E%0A"
},
"appliesTo": [
"bpmn:Task"
],
"elementType": {
"value": "bpmn:ServiceTask"
},
"properties": [
{
"type": "Hidden",
"value": "io.camunda:http-json:1",
"binding": {
"type": "zeebe:taskDefinition:type"
}
},
{
"label": "Type",
"id": "authenticationType",
"value": "noAuth",
"type": "Dropdown",
"choices": [
{
"name": "No Auth",
"value": "noAuth"
},
{
"name": "Basic Auth",
"value": "basic"
},
{
"name": "Bearer Token Auth",
"value": "bearer"
}
],
"binding": {
"type": "zeebe:input",
"name": "authentication.type"
}
},
{
"label": "URL",
"group": "endpoint",
"type": "String",
"feel": "optional",
"binding": {
"type": "zeebe:input",
"name": "url"
}
},
{
"label": "Bearer Token",
"type": "String",
"feel": "optional",
"binding": {
"type": "zeebe:input",
"name": "authentication.token"
},
"constraints": {
"notEmpty": true
},
"condition": {
"property": "authenticationType",
"equals": "bearer"
}
},
{
"label": "Username",
"group": "authentication",
"type": "String",
"feel": "optional",
"binding": {
"type": "zeebe:input",
"name": "authentication.username"
},
"constraints": {
"notEmpty": true
},
"condition": {
"property": "authenticationType",
"equals": "basic"
}
}
]
},
{
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
"name": "REST Connector (Basic Auth)",
"id": "io.camunda.connectors.HttpJson.v1.basicAuth",
"icon": {
"contents": "data:image/svg+xml;utf8,%3Csvg%20width%3D%2218%22%20height%3D%2218%22%20viewBox%3D%221%201%2016%2016%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%0A%3Cpath%20d%3D%22M17.0335%208.99997C17.0335%2013.4475%2013.4281%2017.0529%208.98065%2017.0529C4.53316%2017.0529%200.927765%2013.4475%200.927765%208.99997C0.927765%204.55248%204.53316%200.947083%208.98065%200.947083C13.4281%200.947083%2017.0335%204.55248%2017.0335%208.99997Z%22%20fill%3D%22%23505562%22%2F%3E%0A%3Cpath%20d%3D%22M4.93126%2014.1571L6.78106%203.71471H10.1375C11.1917%203.71471%2011.9824%203.98323%2012.5095%204.52027C13.0465%205.04736%2013.315%205.73358%2013.315%206.57892C13.315%207.44414%2013.0714%208.15522%2012.5841%208.71215C12.1067%209.25913%2011.4553%209.63705%2010.6298%209.8459L12.0619%2014.1571H10.3315L9.03364%2010.0249H7.24351L6.51254%2014.1571H4.93126ZM7.49711%208.59281H9.24248C9.99832%208.59281%2010.5901%208.42374%2011.0177%208.08561C11.4553%207.73753%2011.6741%207.26513%2011.6741%206.66842C11.6741%206.19106%2011.5249%205.81811%2011.2265%205.54959C10.9282%205.27113%2010.4558%205.1319%209.80936%205.1319H8.10874L7.49711%208.59281Z%22%20fill%3D%22white%22%2F%3E%0A%3C%2Fsvg%3E%0A"
},
"appliesTo": [
"bpmn:Task"
],
"elementType": {
"value": "bpmn:ServiceTask"
},
"properties": [
{
"label": "URL",
"type": "String",
"feel": "optional",
"binding": {
"type": "zeebe:input",
"name": "url"
}
},
{
"type": "Hidden",
"value": "basic",
"binding": {
"type": "zeebe:input",
"name": "authentication.type"
}
},
{
"label": "Username",
"type": "String",
"feel": "optional",
"binding": {
"type": "zeebe:input",
"name": "authentication.username"
},
"constraints": {
"notEmpty": true
}
}
]
}
]

0 comments on commit 470e068

Please sign in to comment.