Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create pyghmi tests #169

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# level: ERROR
# start_line: 9
# end_line: 9
# start_column: 6
# end_column: 21
from pyghmi.ipmi import command


cmd = command.Command(
bmc="bmc",
userid="userid",
password="ZjE4ZjI0NTE4YmI2NGJjZDliOGY3ZmJiY2UyN2IzODQK",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# level: WARNING
# start_line: 9
# end_line: 9
# start_column: 6
# end_column: 21
from pyghmi.ipmi import command


cmd = command.Command(bmc="bmc")
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# level: ERROR
# start_line: 9
# end_line: 9
# start_column: 6
# end_column: 21
from pyghmi.ipmi import command


cmd = command.Console(
bmc="bmc",
userid="userid",
password="ZjE4ZjI0NTE4YmI2NGJjZDliOGY3ZmJiY2UyN2IzODQK",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# level: WARNING
# start_line: 9
# end_line: 9
# start_column: 6
# end_column: 21
from pyghmi.ipmi import command


cmd = command.Console(bmc="bmc")
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2023 Secure Saurce LLC
import os

from parameterized import parameterized

from precli.core.level import Level
from precli.parsers import python
from precli.rules import Rule
from tests.unit.rules.python import test_case


class SslContextTests(test_case.TestCase):
def setUp(self):
super().setUp()
self.rule_id = "PRE0517"
self.parser = python.Python(enabled=[self.rule_id])
self.base_path = os.path.join(
"tests",
"unit",
"rules",
"python",
"third_party",
"pyghmi",
"examples",
)

def test_ssl_context_rule_meta(self):
rule = Rule.get_by_id(self.rule_id)
self.assertEqual(self.rule_id, rule.id)
self.assertEqual("cleartext_transmission", rule.name)
self.assertEqual(
f"https://docs.securesauce.dev/rules/{self.rule_id}", rule.help_url
)
self.assertEqual(True, rule.default_config.enabled)
self.assertEqual(Level.WARNING, rule.default_config.level)
self.assertEqual(-1.0, rule.default_config.rank)
self.assertEqual("319", rule.cwe.cwe_id)

@parameterized.expand(
[
"command_command",
"command_command_no_password",
"command_console",
"command_console_no_password",
]
)
def test(self, filename):
self.check(filename)