Strongbox: Implement a Spring controller that displays the environment variables and properties

Created on 28 Dec 2017  路  5Comments  路  Source: strongbox/strongbox

Description

We need a new Spring controller to be implemented that returns a list of the environment variables and system properties used to launch the application.

  • The controller should:

    • Produce a JSON response

    • Have a /configuration/environment/info web resource path

    • Be called EnvironmentInfoController

    • Be placed in the strongbox-web-core under the org.carlspring.strongbox.controllers

    • Display the following info:

    • Environment variables used when starting the instance

    • System properties used when starting the instance

  • The returned results must be sorted
  • The resource must be secured with a @PreAuthorize("hasAuthority('ADMIN')")

We need a proper test case for this.

Listing all the environment variables and system properties

curl -H "Accept: application/json" -X GET http://localhost:48080/configuration/environment/info

Expected JSON response

{
  "environment": [
    {
      "name": "JAVA_HOME",
      "value": "/java/jdk1.8.0_151"
    },
    {
      "name": "M2_HOME",
      "value": "/java/apache/maven-3.3.9"
    }
    ......
  ],
  "system": [
    {
      "name": "logging.dir",
      "value": "/path/to/logs"
    },
    {
      "name": "java.io.tmpdir",
      "value": "/path/to/tmp"
    },
    ....
  ]
}
good first issue help wanted

All 5 comments

Hello @carlspring. I've been reading the wiki and I'd like to help with this issue you opened.

Hi @ptirador ,

This is great! Please, feel free to pick this task and create a pull for it!

Kind regards,

Martin

Hi again @carlspring, I'd like to ask you a question:
Is it necessary to return a 400 status code if any of the lists (env variables or system props) is empty?

It's highly unlikely that the server will have been started without any system, or environment variables, as we're always setting some. Also, part of the system variables are already exported before we run it, so, there'll definitely be some of both. :)

Thanks for implementing this! :)

Was this page helpful?
0 / 5 - 0 ratings