Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex Validation #111

Merged
merged 3 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.Parameter;
import org.apache.commons.lang3.StringUtils;
import org.assimbly.dil.validation.HttpsCertificateValidator;
import org.assimbly.dil.validation.beans.Expression;
import org.assimbly.dil.validation.beans.FtpSettings;
Expand Down Expand Up @@ -242,13 +243,8 @@ public ResponseEntity<String> validateRegex(
AbstractMap.SimpleEntry regexResp = integration.validateRegex(regex);

if(regexResp!=null) {
if (regexResp.getKey().equals("-1")) {
ValidationErrorMessage validationErrorMessage = new ValidationErrorMessage();
validationErrorMessage.setError((String)regexResp.getValue());
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(out, regexResp);
return ResponseUtil.createSuccessResponse(integrationId, mediaType, "/validation/{integrationId}/regex", out.toString(), plainResponse);
if ((Integer)regexResp.getKey() == -1) {
return ResponseUtil.createFailureResponse(integrationId, mediaType, "/validation/{integrationId}/regex", (String)regexResp.getValue(), plainResponse);
} else {
// success - return group count
return ResponseUtil.createSuccessResponse(integrationId, mediaType, "/validation/{integrationId}/regex", (String)regexResp.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ void shouldValidateRegexWithError() throws Exception {
ResultActions resultActions = this.mockMvc.perform(requestBuilder);

resultActions
.andExpect(status().isOk())
.andExpect(status().isBadRequest())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("message").value("Unclosed group near index 8\n(.*) (.*"))
.andExpect(content().string("Unclosed group near index 8\n(.*) (.*"))
;
}

Expand Down