I'm looking for help on how to proceed with ensuring that certain values in properties/YAML files are not overridden.
For instance, I have a Spring Boot project and a properties.yml with the following properties.
spring:
  datasource:
    url: ${jdbc.url:}
    username: ${jdbc.username:}
    password: ${jdbc.password:}
In Spring, the value for the url property comes from the environment variable JDBC_URL or JDBC.URL.
We have a group of developers working on said project. Some developers tend to just hard code the values in the file because it is quick and easy.
spring:
  datasource:
    url: jdbc:mysql://localhost:32768/master
    username: root
    password: password
And more often than not, when they commit their code, these changes are often also committed, which I believe is a bad thing. So, rather than rely on the developers being vigilant, how do I ensure that such situations are prevented from happening?
Do bear in mind that sometimes there are legitimate reasons for modifying the properties/YAML files such as adding new properties.
spring:
  datasource:
    url: jdbc:mysql://localhost:32768/master # should NOT be allowed
    username: root                           # should NOT be allowed
    password: password                       # should NOT be allowed
new:
    property: value                          # should be allowed
My first thought was using a unit test for the properties/YAML file. It would provide me with the flexibility to expand if there are new properties that need to be validated. This would prevent unit test stage from passing and thus help to prevent a merge to the master branch but it does not prevent the commit in the first place.
I'm unsure of how to proceed next. Any help is greatly appreciated. If it helps, the project is a Spring Boot application and uses Java and Gradle. The remote repository is GitHub.
 
    