Skip to content

Commit

Permalink
fix(rest): relax regex check for URL to allow placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
igpetrov committed Mar 30, 2023
1 parent d96625c commit 80cc50e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class CommonRequest {

@NotBlank
@Pattern(regexp = "^(http://|https://|secrets).*$")
@Pattern(regexp = "^(http://|https://|secrets|\\{\\{).*$")
@Secret
private String url;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void shouldRaiseException_WhenExecuted_EndpointMalformed(final String input) {
assertThat(exception.getMessage())
.contains(
"Found constraints violated while validating input",
"must match \"^(http://|https://|secrets).*$\"");
"must match \"^(http://|https://|secrets|\\{\\{).*$\"");
}

@ParameterizedTest(name = "Validate null field # {index}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ interface Body {

protected interface ActualValue {
String URL = "https://camunda.io/http-endpoint";
String URL_WITH_PATH = "https://camunda.io/http-endpoint/path";
String METHOD = "GET";
String CONNECT_TIMEOUT = "50";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void shouldRaiseException_WhenExecuted_EndpointMalformed(final String input) {
assertThat(exception.getMessage())
.contains(
"Found constraints violated while validating input",
"must match \"^(http://|https://|secrets).*$\"");
"must match \"^(http://|https://|secrets|\\{\\{).*$\"");
}

@ParameterizedTest(name = "Validate null field # {index}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void replaceSecrets_shouldReplaceRequestSecrets(String input) {
// When
context.replaceSecrets(httpJsonRequest);
// Then should replace secrets
assertThat(httpJsonRequest.getUrl()).isEqualTo(ActualValue.URL);
assertThat(httpJsonRequest.getUrl()).isIn(ActualValue.URL, ActualValue.URL_WITH_PATH);
assertThat(httpJsonRequest.getMethod()).isEqualTo(ActualValue.METHOD);
assertThat(httpJsonRequest.getConnectionTimeoutInSeconds())
.isEqualTo(ActualValue.CONNECT_TIMEOUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,53 @@
},
"text": "{{secrets.TEXT_PART_1_KEY}}{{secrets.TEXT_PART_2_KEY}}{{secrets.TEXT_PART_3_KEY}}"
}
},
{
"url": "{{secrets.URL_KEY}}",
"method": "secrets.METHOD_KEY",
"authentication": {
"type": "noAuth"
},
"queryParameters": {
"q": "secrets.QUERY_PARAMETER_KEY",
"priority": "secrets.PRIORITY_KEY"
},
"headers": {
"X-Camunda-Cluster-ID": "secrets.CLUSTER_ID_KEY",
"User-Agent": "secrets.USER_AGENT_KEY"
},
"connectionTimeoutInSeconds":"secrets.CONNECT_TIMEOUT_KEY",
"body": {
"customer": {
"id": "startId plus {{secrets.CUSTOMER_ID_KEY}}",
"name": "{{secrets.NAME_KEY}} plus some text",
"email": "start email plus {{secrets.EMAIL_KEY}} plus end email"
},
"text": "secrets.TEXT_KEY"
}
},
{
"url": "{{secrets.URL_KEY}}/path",
"method": "secrets.METHOD_KEY",
"authentication": {
"type": "noAuth"
},
"queryParameters": {
"q": "secrets.QUERY_PARAMETER_KEY",
"priority": "secrets.PRIORITY_KEY"
},
"headers": {
"X-Camunda-Cluster-ID": "secrets.CLUSTER_ID_KEY",
"User-Agent": "secrets.USER_AGENT_KEY"
},
"connectionTimeoutInSeconds":"secrets.CONNECT_TIMEOUT_KEY",
"body": {
"customer": {
"id": "startId plus {{secrets.CUSTOMER_ID_KEY}}",
"name": "{{secrets.NAME_KEY}} plus some text",
"email": "start email plus {{secrets.EMAIL_KEY}} plus end email"
},
"text": "secrets.TEXT_KEY"
}
}
]

0 comments on commit 80cc50e

Please sign in to comment.