Metadata-Version: 2.1
Name: leaflet-config-check
Version: 0.1.8ubuntu1-1712045366.gbpa431d4
Summary: Checks the given Configfiles according to Stage, Type and Serialnumber for Leaflet 1U0022.
Home-page: https://gitlab.consolinno-it.de/leafletfirmware/testing/leaflet-config-check
Author: Moritz kolb
Author-email: m.kolb@consolinno.de
License: UNKNOWN
Project-URL: homepage, https://www.consolinno.de
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent

# Leaflet Config Check

`leaflet-config-check` is a Python test automation, which tests the received Data from the Config Manager.

## Installation

You can install `leaflet-config-check` using `apt`. Open terminal and run:

```bash
apt install python3-leaflet-config-check
```

## Function call

The transfer parameters are:

- Folder of the config files: e.g. .../83_1U0022_CO_807
- the stage:                  dev,qa or prod
- the serial number:          e.g. 1u0022-co-807
- version number:             e.g. 1.1.0

There must also be a folder: masterpetternfiles_0_10_3 to test against it

leaflet-config-check < dir of config > < stage > < serial number > < software version >

**example:**

```bash

leaflet-config-check ~/Gitlab/testinghems/Config_Tests/data/83_1U0022_CO_807 dev 1u0022-co-807 1.1.0
```
## Configuration

The Test is configured by the Test config files according to the Config manager Version.
The Test config files consist of reference files, and a testconfig.json.
The reference files present the valid content of specific configuration files. In the testconfig.json there is 
the Test information of each Config file to test.

### Configurationfile: testconfig.json

The Project is using a Configfile in JSON-Format, holding informations about every file in the Config.

#### Aufbau der `testconfig.json`

The Config file has a JSON-Objects with different key pairs. Here are the valid properties:

- **`textfiles` (Object):** contains all text files

  - **`<textfile name>` (Object):** contains the properties of the individual file
    - **`pattern_file` (String):** name of the corresponding reference file
    - **`indevid_lines` (Object):** present if there are individual lines per type or environment
      - **`<number>` (Object):** Line number of the individual line.
        - **`replace_pattern` (String):** string of placeholder
        - **`type` (Object):** lists the individual string per type
          - **`co` (String):** individual co string
          - **`base` (String):** individual base string
        - **`stage` (Objekt):** lists the individual string per environment
          - **`dev` (String):** individual dev string
          - **`qa` (String):** individual qa string
          - **`prod` (String):** individual prod string
        - **`serialnumber` (String):** indicates different types of serial numbers "upper_case", "lower_case" and "productnr"
  - **`present` (Object):** indicates where the file should be present
    - **`stage` (Array):** contains all stage options (dev,qa,prod)
    - **`type` (Array):** contains all type options (co,base)
  - **`covered` (bool):** is used to mark the file as tested during the test should always be false

- **`keyfiles` (Object):** Contains all key files
  - **`<keyfile name>` (Object):** contains the properties of the individual file
    - **`keylength` (int):** key length
    - **`keytype` (String):** there are different key types: (PRIVATE KEY, CERTIVICAATE,RSA PRIVATE KEY, PUBLIC KEY, ssh-rsa or root)
  - **`cryptotest` (Object):** only present if there is a key pair in the Dir
    - **`partner` (String):** name of the partner key
    - **`type` (String):** (private, public)
    - **`covered` (bool):** is used to mark if the test is done 
  - **`present` (Object):** indicates where the file should be present
    - **`stage` (Array):** contains all stage options (dev,qa,prod)
    - **`type` (Array):** contains all type options (co,base)
  - **`covered` (bool):** is used to mark the file as tested during the test should always be false



#### Example `testconfig.json`:

Hier ist ein Beispiel für den Inhalt der `config.json`-Datei:

```json
"device_type": {
                "pattern_file": "devicetype-pattern.txt",
                "indevid_lines": {
                    "1": {
                        "replace_pattern": "DEVICETYPE",
                        "type": {
                            "co": "CO",
                            "base": "BASE"
                        }
                    },
                    "1.0": {
                        "replace_pattern": "PRODUCTNR",
                        "serialnumber": "productnr"
                    }
                },
                "present": {
                    "stage": [
                        "dev",
                        "qa",
                        "prod"
                    ],
                    "type": [
                        "co",
                        "base"
                    ]
                },
                "covered": false
            },
```
## Software classes

The testsoftware consists of 6 classes:
  - LCC_Start
  - LCC_ConfigCheck
  - LCC_Keyfiles
  - LCC_Textfiles
  - LCC_Logging
  - Conso_Confluence

### LCC_Start

manages the Strat, checks if the transferred values are valid and puts them in the right order if theyre not already
If there is a wron function call it will print a --help description
if there is all good it will start the testsoftware and afterwards the documentation (Conso_Confluence)

### LCC_ConfigCheck

Is responsible to select the correct test for the respective file

### LCC_Keyfiles

Tests the key files

### LCC_Textfile

Tests the text files

### LCC_Logging

Logs all errors in a YAML-file

### Conso_Confluence

converts the YAML-file in to a Confluence Page

