Skip to content

Commit

Permalink
Create pyghmi tests (#169)
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Brown <eric.brown@securesauce.dev>
  • Loading branch information
ericwb authored Nov 14, 2023
1 parent 70ac47b commit 922a94e
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 0 deletions.
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)

0 comments on commit 922a94e

Please sign in to comment.