Skip to content

Refactor external configuration file mechanism to prevent redefining other properties than parsers

For the moment, to extend parser configurations, we use the Micronaut option -Dmicronaut.config.files=/path/to/file.yaml. It is a mechanism which allows to extend all configuration properties.

This means it is possible to override properties like org.opentestfactory.bus.base-url, or server.port.

Since we don't want to allow this modification, we have to find another way to configure custom parsers without this security issue. An idea is to load a file when starting the service, but not using the Micronaut configuration extension mechanism.

Specifications
  • interpreter service will read the property custom.parsers.file to get the configuration file, so that service must be launched with -Dcustom.parsers.file=/path/to/file or environment variable CUSTOM_PARSERS_FILE should be set.
  • if the variable is not defined, then only internal configuration is loaded
  • if the variable is defined, but no file is found, then an exception should be thrown
  • if the variable is defined and a file is found, then the custom parsers configuration is loaded in addition to the internal configuration, if a technology is mentioned several times, the last listed parser prevails on the others for this technology and custom configuration prevails on internal configuration

The file should look like this:

- name: Surefire
  matchCases:
    - name: syntax full
      regex: ^(?<repository>[^#]+)/(?<class>[^#]+)#(?<method>[^#]+)$
      xpath: //testsuite/testcase[(@name="{method}" or (((contains(@name, "{method}{") and contains(@name, "}[")) or (contains(@name, "{method}(") and contains(@name, ")[")) or contains(@name, "{method}[")) and substring(@name, string-length(@name)) = "]")) and @classname="{class}"]
    - name: syntax no method
      regex: ^(?<repository>[^#]+)/(?<class>[^#]+)$
      xpath: //testsuite/testcase[@classname="{class}" or starts-with(@classname, "{class}$")]
  skippedStatus: success
  acceptedTechnologies:
    - junit
    - skf
  acceptedMediaTypes:
    - application/vnd.opentestfactory.junit-surefire+xml
    - application/vnd.opentestfactory.skf-surefire+xml

- name: SoapUI
  matchCases:
    - name: syntax full
      regex: ^(?<repository>[^#]+)/(?<project>[^#]+)#(?<suite>[^#]+)#(?<testCase>[^#]+)$
      xpath: //testsuite[@name[contains(., ".{suite}")]]/testcase[@name="{testCase}"]
    - name: syntax no test case
      regex: ^(?<repository>[^#]+)/(?<project>[^#]+)#(?<suite>[^#]+)$
      xpath: //testsuite[@name[contains(., ".{suite}")]]/testcase[@name="{testCase}"]
  acceptedTechnologies:
    - soapui
  acceptedMediaTypes:
    - application/vnd.opentestfactory.soapui-surefire+xml

If a file is provided then:

  • each parser should have at least one matchCase defined
  • each matchCase should hava a name, a regex and an xpath

Also:

  • Configuration file extension can be any extension provided that it is well-formed

What was additionally done in this merge request:

  • fix that a parser can have no name, an error message is now sent
  • fix that a matchCase can have no name, an error message is now sent
  • Log a DEBUG message when a parser is overriden by another configuration for a given technology
Edited by Johan Lor