test: Added first behave integration test for productid plugin#8
Draft
jirihnidek wants to merge 3 commits intomainfrom
Draft
test: Added first behave integration test for productid plugin#8jirihnidek wants to merge 3 commits intomainfrom
jirihnidek wants to merge 3 commits intomainfrom
Conversation
Reviewer's GuideAdds the first Behave-based integration test for the libdnf5 productid plugin, including shared step-implementation helpers for running CLI commands and a scenario that validates a product certificate is installed when an RPM is installed from a test repository. Sequence diagram for Behave productid integration test scenariosequenceDiagram
actor Tester
participant Behave
participant Step_Productid
participant Candlepin_Server
participant RPM_Repository
participant System_Filesystem
Tester->>Behave: run behave
Behave->>Step_Productid: execute Given system is registered against candlepin server
Step_Productid->>Candlepin_Server: register system (CLI call)
Candlepin_Server-->>Step_Productid: registration success
Behave->>Step_Productid: execute Given repositories are enabled
Step_Productid->>RPM_Repository: enable never-enabled-content-37060 (CLI call)
RPM_Repository-->>Step_Productid: repo enabled
Behave->>Step_Productid: execute When rpm slow-eagle is installed from RPM repository
Step_Productid->>RPM_Repository: install slow-eagle via dnf or rpm
RPM_Repository-->>Step_Productid: installation success
Behave->>Step_Productid: execute Then productid certificate 37060.pem is installed
Step_Productid->>System_Filesystem: check /etc/pki/product/37060.pem exists
System_Filesystem-->>Step_Productid: certificate present
Step_Productid-->>Behave: assertion passed
Behave-->>Tester: scenario passed
Class diagram for Behave productid step implementations and helpersclassDiagram
class Step_Productid {
+given_system_is_registered_against_candlepin_server(context)
+given_repositories_are_enabled(context, table)
+when_rpm_is_installed_from_rpm_repository(context, rpm_name)
+then_productid_certificate_is_installed(context, certificate_name, directory_path)
}
class CliHelper {
+run_command(command, args, env)
+assert_success(result)
+get_stdout(result)
+get_stderr(result)
}
class FileSystemHelper {
+path_exists(path)
+assert_file_exists(path)
+read_file(path)
}
class BehaveContext {
+cli_helper : CliHelper
+fs_helper : FileSystemHelper
+registration_data
}
Step_Productid --> BehaveContext : uses
Step_Productid --> CliHelper : uses
Step_Productid --> FileSystemHelper : uses
BehaveContext o-- CliHelper : composition
BehaveContext o-- FileSystemHelper : composition
Flow diagram for running the new Behave productid testflowchart TD
A[Developer installs python3-behave] --> B[Developer starts candlepin container]
B --> C[Developer runs behave]
C --> D[Behave loads productid.feature]
D --> E[Behave parses scenario steps]
E --> F[Behave maps steps to test_impl_productid step functions]
F --> G[Execute registration step]
G --> H[Execute repository enablement step]
H --> I[Execute RPM installation step]
I --> J[Execute certificate assertion step]
J --> K{All assertions pass}
K -->|Yes| L[Report scenario as passed]
K -->|No| M[Report scenario as failed]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Comment on lines
+14
to
+22
| proc = subprocess.Popen( | ||
| cmd, | ||
| shell=shell, | ||
| cwd=cwd, | ||
| stdout=subprocess.PIPE, | ||
| stderr=subprocess.PIPE, | ||
| universal_newlines=True, | ||
| errors="surrogateescape", | ||
| ) |
There was a problem hiding this comment.
security (python.lang.security.audit.dangerous-subprocess-use-audit): Detected subprocess function 'Popen' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'.
Source: opengrep
* Card ID: CCT-1921 * Only one scenario is added. It tests that product certificate is installed, when RPM is installed from testing repository Signed-off-by: Jiri Hnidek <[email protected]>
* Card ID: CCT-1921 * Added check that productid.json contains wanted repo_id and product_id * Make black more happy Signed-off-by: Jiri Hnidek <[email protected]>
* Added more tests and extend current steps Signed-off-by: Jiri Hnidek <[email protected]>
52ce090 to
fa1e222
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To test this all you need to do is:
sudo dnf -y install python3-behavesudo behave