Skip to content

Commit

Permalink
fix(connectors): handle disable webhook correctly, return 404 (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
chillleader authored Mar 15, 2023
1 parent 1603539 commit fdc277c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class WebhookConnectorRegistry {
new HashMap<>();

public boolean containsContextPath(String context) {
return activeEndpointsByContext.containsKey(context);
return activeEndpointsByContext.containsKey(context) &&
!activeEndpointsByContext.get(context).isEmpty();
}

public List<InboundConnectorContext> getWebhookConnectorByContextPath(String context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package io.camunda.connector.runtime.inbound;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -131,6 +132,24 @@ public void webhookMultipleVersionsDisableWebhook() {
assertEquals(0, connectors2.size()); // No one - as it was disabled
}

@Test
public void webhookDeactivation_shouldReturnNotFound() {
WebhookConnectorRegistry webhook = new WebhookConnectorRegistry();

// given
var processA1 = new InboundConnectorContextBuilder()
.properties(webhookProperties("processA", 1, "myPath"))
.secret(CONNECTOR_SECRET_NAME, CONNECTOR_SECRET_VALUE)
.build();

//when
webhook.activateEndpoint(processA1);
webhook.deactivateEndpoint(processA1.getProperties());

// then
assertFalse(webhook.containsContextPath("myPath"));
}

private static long nextProcessDefinitionKey = 0L;

public static InboundConnectorProperties webhookProperties(
Expand Down

0 comments on commit fdc277c

Please sign in to comment.