SCAutolib 3.4.0__tar.gz → 3.4.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {scautolib-3.4.0/SCAutolib.egg-info → scautolib-3.4.9}/PKG-INFO +3 -2
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/__init__.py +63 -33
- scautolib-3.4.9/SCAutolib/cli_commands.py +614 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/controller.py +311 -123
- scautolib-3.4.9/SCAutolib/enums.py +75 -0
- scautolib-3.4.9/SCAutolib/exceptions.py +137 -0
- scautolib-3.4.9/SCAutolib/models/CA.py +1068 -0
- scautolib-3.4.9/SCAutolib/models/__init__.py +9 -0
- scautolib-3.4.9/SCAutolib/models/authselect.py +159 -0
- scautolib-3.4.9/SCAutolib/models/card.py +687 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/models/file.py +329 -125
- scautolib-3.4.9/SCAutolib/models/gui.py +1134 -0
- scautolib-3.4.9/SCAutolib/models/log.py +67 -0
- scautolib-3.4.9/SCAutolib/models/user.py +274 -0
- scautolib-3.4.9/SCAutolib/utils.py +193 -0
- {scautolib-3.4.0 → scautolib-3.4.9/SCAutolib.egg-info}/PKG-INFO +3 -2
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib.egg-info/SOURCES.txt +0 -1
- {scautolib-3.4.0 → scautolib-3.4.9}/setup.py +1 -1
- {scautolib-3.4.0 → scautolib-3.4.9}/test/test_file.py +3 -2
- {scautolib-3.4.0 → scautolib-3.4.9}/test/test_sssd_conf.py +2 -1
- {scautolib-3.4.0 → scautolib-3.4.9}/test/test_utils.py +2 -1
- scautolib-3.4.0/SCAutolib/cli_commands.py +0 -318
- scautolib-3.4.0/SCAutolib/enums.py +0 -42
- scautolib-3.4.0/SCAutolib/exceptions.py +0 -34
- scautolib-3.4.0/SCAutolib/isDistro.py +0 -50
- scautolib-3.4.0/SCAutolib/models/CA.py +0 -767
- scautolib-3.4.0/SCAutolib/models/__init__.py +0 -3
- scautolib-3.4.0/SCAutolib/models/authselect.py +0 -89
- scautolib-3.4.0/SCAutolib/models/card.py +0 -463
- scautolib-3.4.0/SCAutolib/models/gui.py +0 -534
- scautolib-3.4.0/SCAutolib/models/log.py +0 -46
- scautolib-3.4.0/SCAutolib/models/user.py +0 -182
- scautolib-3.4.0/SCAutolib/utils.py +0 -212
- {scautolib-3.4.0 → scautolib-3.4.9}/LICENSE +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/MANIFEST.in +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/README.md +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/ca.cnf +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/gnome_disable_welcome +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/softhsm2.conf +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/sssd.conf-10 +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/sssd.conf-8or9 +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/user.cnf +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/virt_cacard.service +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib/templates/virtcacard.cil +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib.egg-info/dependency_links.txt +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib.egg-info/entry_points.txt +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib.egg-info/requires.txt +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/SCAutolib.egg-info/top_level.txt +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/requirements.txt +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/setup.cfg +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/test/test_ca.py +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/test/test_card.py +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/test/test_cli.py +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/test/test_controller.py +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/test/test_openssl_conf.py +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/test/test_user.py +0 -0
- {scautolib-3.4.0 → scautolib-3.4.9}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: SCAutolib
|
|
3
|
-
Version: 3.4.
|
|
3
|
+
Version: 3.4.9
|
|
4
4
|
Summary: Python library for automation tests of smart cards using virtualization.
|
|
5
5
|
Home-page: https://github.com/redhat-qe-security/SCAutolib
|
|
6
6
|
Author: Pavel Yadlouski
|
|
@@ -38,6 +38,7 @@ Dynamic: classifier
|
|
|
38
38
|
Dynamic: description
|
|
39
39
|
Dynamic: description-content-type
|
|
40
40
|
Dynamic: home-page
|
|
41
|
+
Dynamic: license-file
|
|
41
42
|
Dynamic: provides-extra
|
|
42
43
|
Dynamic: requires-dist
|
|
43
44
|
Dynamic: requires-python
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module serves as the initialization point for the SCAutolib package.
|
|
3
|
+
|
|
4
|
+
It sets up the package-wide logging configuration using ``coloredlogs``.
|
|
5
|
+
It defines global constants for directory paths used throughout the library for
|
|
6
|
+
templates, backup files, and data dumps.
|
|
7
|
+
|
|
8
|
+
Additionally, it establishes validation schemas using the ``schema`` library
|
|
9
|
+
for various configuration sections, including CAs (Certificate Authorities),
|
|
10
|
+
users, and smart cards. These schemas ensure that input data conforms to
|
|
11
|
+
expected structures and types, facilitating robust data handling across
|
|
12
|
+
SCAutolib's components.
|
|
13
|
+
|
|
14
|
+
The module also provides a generalized ``run`` function, acting as a wrapper
|
|
15
|
+
for ``subprocess.run``. This wrapper standardizes command execution,
|
|
16
|
+
logging, error checking, and offers options for controlling standard
|
|
17
|
+
output/error, return code validation, and post-execution delays.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
|
|
1
21
|
import coloredlogs
|
|
2
22
|
import logging
|
|
3
23
|
import subprocess
|
|
@@ -71,44 +91,54 @@ schema_card = Schema({'name': Use(str),
|
|
|
71
91
|
Optional('key', default=None): Use(str)})
|
|
72
92
|
|
|
73
93
|
|
|
74
|
-
def run(cmd, stdout=
|
|
75
|
-
|
|
94
|
+
def run(cmd: list[str], stdout: int = subprocess.PIPE,
|
|
95
|
+
stderr: int = subprocess.PIPE, check: bool = True, log: bool = True,
|
|
96
|
+
return_code: list = None, sleep: int = 0, **kwargs) \
|
|
76
97
|
-> subprocess.CompletedProcess:
|
|
77
98
|
"""
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
:param sleep: time to sleep after command is executed
|
|
87
|
-
:type sleep: int
|
|
88
|
-
:param return_code: acceptable return codes from given commands.
|
|
89
|
-
If check=True, and the return code of the cmd is not in the return_code
|
|
90
|
-
list a subprocess.CalledProcessError exception would be raised.
|
|
91
|
-
:type return_code: list
|
|
92
|
-
:param cmd: Command to be executed
|
|
99
|
+
Executes an external command as a subprocess, providing a controlled
|
|
100
|
+
wrapper around ``subprocess.run``. This function
|
|
101
|
+
standardizes command execution, capturing and optionally printing output,
|
|
102
|
+
performing robust error checking based on expected return codes, and
|
|
103
|
+
provides consistent logging of what is being executed.
|
|
104
|
+
|
|
105
|
+
:param cmd: The command to be executed, provided as a list of strings
|
|
106
|
+
(preferred) or a single space-separated string.
|
|
93
107
|
:type cmd: list or str
|
|
94
|
-
:param stdout:
|
|
108
|
+
:param stdout: Redirects the standard output of the command.
|
|
109
|
+
Accepts an int representing a file descriptor, or an
|
|
110
|
+
`IO object <https://docs.python.org/3/library/io.html>`__.
|
|
111
|
+
Defaults to ``subprocess.PIPE`` to capture output.
|
|
95
112
|
:type stdout: None or int or IO
|
|
96
|
-
:param stderr:
|
|
113
|
+
:param stderr: Redirects the standard error of the command.
|
|
114
|
+
Accepts an int representing a file descriptor, or an
|
|
115
|
+
`IO object <https://docs.python.org/3/library/io.html>`__.
|
|
116
|
+
Defaults to ``subprocess.PIPE`` to capture output.
|
|
97
117
|
:type stderr: None or int or IO
|
|
98
|
-
:param check:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
118
|
+
:param check: If ``True``, the function will raise a
|
|
119
|
+
``subprocess.CalledProcessError`` exception if the command's
|
|
120
|
+
return code is not in the ``return_code`` list. Defaults to
|
|
121
|
+
``True``.
|
|
102
122
|
:type check: bool
|
|
103
|
-
:param
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
:type
|
|
107
|
-
:param
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
:
|
|
123
|
+
:param log: If ``True``, the command's standard output will be logged at
|
|
124
|
+
DEBUG level and standard error at WARNING level. Defaults to
|
|
125
|
+
``True``.
|
|
126
|
+
:type log: bool
|
|
127
|
+
:param return_code: A list of acceptable return codes for the command. If
|
|
128
|
+
``check`` is ``True`` and the command's return code is
|
|
129
|
+
not in this list, an exception is raised. Defaults to
|
|
130
|
+
``[0]``.
|
|
131
|
+
:type return_code: list
|
|
132
|
+
:param sleep: The duration in seconds to pause execution after the command
|
|
133
|
+
completes. Defaults to ``0``.
|
|
134
|
+
:type sleep: int
|
|
135
|
+
:param kwargs: Additional keyword arguments are passed directly to the
|
|
136
|
+
``subprocess.run`` function.
|
|
137
|
+
:raises subprocess.CalledProcessError: If ``check`` is ``True`` and the
|
|
138
|
+
command's return code is not among
|
|
139
|
+
the expected ``return_code`` values.
|
|
140
|
+
:return: An object representing the completed process, including stdout,
|
|
141
|
+
stderr, and return code.
|
|
112
142
|
:rtype: subprocess.CompletedProcess
|
|
113
143
|
"""
|
|
114
144
|
if return_code is None:
|
|
@@ -118,7 +148,7 @@ def run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True,
|
|
|
118
148
|
logger.debug(f"run: {' '.join([str(i) for i in cmd])}")
|
|
119
149
|
out = subprocess.run(cmd, stdout=stdout, stderr=stderr, encoding="utf-8",
|
|
120
150
|
**kwargs)
|
|
121
|
-
if
|
|
151
|
+
if log:
|
|
122
152
|
if out.stdout != "":
|
|
123
153
|
logger.debug(out.stdout)
|
|
124
154
|
if out.stderr != "":
|