mirror of
https://github.com/itplr-kosit/validator.git
synced 2026-05-25 16:55:39 +00:00
#67 [CLI,DAEMON] Return proper return codes / status codes
This commit is contained in:
parent
fa7faf9961
commit
f2223552ad
21 changed files with 424 additions and 248 deletions
46
docs/cli.md
Normal file
46
docs/cli.md
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# Validator CLI
|
||||
|
||||
The validator comes with a commandline interface (CLI) which allows validating any number of input xml files.
|
||||
|
||||
The general way using the CLI is:
|
||||
|
||||
```shell
|
||||
java -jar validationtool-<version>-standalone.jar -s <scenario-config-file> [OPTIONS] [FILE] [FILE] [FILE] ...
|
||||
```
|
||||
|
||||
The validator can also read the xml file from the standard input
|
||||
|
||||
```shell script
|
||||
# via redirection
|
||||
java -jar validationtool-<version>-standalone.jar -s <scenario-config-file> [OPTIONS] < my-input.xml
|
||||
|
||||
# read from pipe
|
||||
cat my-input.xml | validationtool-<version>-standalone.jar -s <scenario-config-file> [OPTIONS]
|
||||
```
|
||||
|
||||
The help option displays further CLI options to customize the process:
|
||||
|
||||
```shell
|
||||
java -jar validationtool-<version>-standalone.jar --help
|
||||
```
|
||||
|
||||
## Special features
|
||||
Besides the obvious functionality of validating, the cli provides additional functionality to customize the processing:
|
||||
|
||||
|name | option | description |
|
||||
| - | - | - |
|
||||
| [Daemon mode](daemon.md) | `-D` | Starts the validator in daemon mode as an HTTP service |
|
||||
| print mode | `-p` | Print the report to stdout |
|
||||
| extract html | `-h` | Extracts any html blocks within the report and saves the content to the filesystem. Note: the file name is derived from the node name the html appears in |
|
||||
| print memory stats | `-m` | Prints some memory usage information. Mainly for debugging purposes on processing huge xml files |
|
||||
| check assertions | `-c <file>` | Check assertions on the generated reports. This is mainly useful for scenario developers. Ask KoSIT for documentation, if you want to use this feauture |
|
||||
|
||||
|
||||
## Return codes
|
||||
|
||||
| code | description |
|
||||
|-|-|
|
||||
| 0 | All validated xml files are acceptable according to the scenario configurations |
|
||||
| positive integer | Number of rejected (e.g. not acceptable) xml files according to the scenario configurations|
|
||||
| -1 | Parsing error. The commandline arguments specified are incorrect |
|
||||
| -2 | Configuration error. There is an error loading the configuration and/or validation targets |
|
||||
|
|
@ -42,9 +42,11 @@ The possible customizations are:
|
|||
|
||||
## Access the HTTP interface
|
||||
|
||||
The validation service listens to `POST`-requests on any server URL. You need to supply the xml/object to validate in the HTTP body.
|
||||
The validation service listens to `POST`-requests on any server URL. You need to supply the xml/object to validate in the HTTP body.
|
||||
The last segment of the request URI is treated as the name of the input. E.g. requests to `/myfile.xml`, `/mypath/myfile.xml` and `/mypath/myfile.xml?someParam=1`
|
||||
would all result in an input named `myfile.xml`. If you don't specify a specific request URI (e.g. POST to `/`), the name is auto generated for you.
|
||||
|
||||
The service expects a single XML input in the HTTP body, e.g. `multipart/form-data` is not supported.
|
||||
The service expects a single XML input in the HTTP body, e.g. `multipart/form-data` is NOT supported.
|
||||
|
||||
Examples:
|
||||
|
||||
|
|
@ -84,6 +86,15 @@ fetch("http://localhost:8080", requestOptions)
|
|||
.then(result => console.log(result))
|
||||
.catch(error => console.log('error', error));
|
||||
```
|
||||
## Status codes
|
||||
| code | description |
|
||||
|-|-|
|
||||
| 200 | The xml file is acceptable according to the scenario configurations |
|
||||
| 400 | Bad request. the request contains errors, e.g. no content supplied |
|
||||
| 405 | Method not allowed. Thec check service is only answering on POST requests |
|
||||
| 406 | The xml file is NOT acceptable according to the scenario configurations|
|
||||
| 422 | Unprocessable entity. Indicates an error while processing the xml file. This hints to errors in the scenario configuration |
|
||||
| 500 | Internal server error. Something went wrong |
|
||||
|
||||
## Authorization
|
||||
There is no mechanism to check, whether client is allowed to consume the service or not. The user is responsible to secure access to the service.
|
||||
|
|
@ -101,7 +112,7 @@ The daemon provides a simple GUI when issuing `GET` requests providing the follo
|
|||
1. information about the actual [validator configuration](configurations.md) used by this daemon
|
||||
1. a simple form to test the daemon with custom inputs
|
||||
|
||||
The GUI can be disabled using the API (see above) or via CLI
|
||||
The GUI can be disabled using the API (see above) or via CLI:
|
||||
|
||||
```shell script
|
||||
java -jar validationtool-<version>-standalone.jar -s <scenario-config-file> -D --disable-gui
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue