Coverage for tests / integration / tools / gitleaks / test_definition.py: 100%

18 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-04-03 18:53 +0000

1"""Integration tests for GitleaksPlugin definition attributes.""" 

2 

3from __future__ import annotations 

4 

5import shutil 

6from collections.abc import Callable 

7from typing import TYPE_CHECKING 

8 

9import pytest 

10from assertpy import assert_that 

11 

12if TYPE_CHECKING: 

13 from lintro.plugins.base import BaseToolPlugin 

14 

15# Skip all tests if gitleaks is not installed 

16pytestmark = pytest.mark.skipif( 

17 shutil.which("gitleaks") is None, 

18 reason="gitleaks not installed", 

19) 

20 

21 

22@pytest.mark.parametrize( 

23 ("attr", "expected"), 

24 [ 

25 ("name", "gitleaks"), 

26 ("can_fix", False), 

27 ], 

28 ids=["name", "can_fix"], 

29) 

30def test_definition_attributes( 

31 get_plugin: Callable[[str], BaseToolPlugin], 

32 attr: str, 

33 expected: object, 

34) -> None: 

35 """Verify GitleaksPlugin definition has correct attribute values. 

36 

37 Args: 

38 get_plugin: Fixture factory to get plugin instances. 

39 attr: The attribute name to check on the definition. 

40 expected: The expected value of the attribute. 

41 """ 

42 gitleaks_plugin = get_plugin("gitleaks") 

43 assert_that(getattr(gitleaks_plugin.definition, attr)).is_equal_to(expected) 

44 

45 

46def test_definition_file_patterns( 

47 get_plugin: Callable[[str], BaseToolPlugin], 

48) -> None: 

49 """Verify GitleaksPlugin definition scans all files. 

50 

51 Args: 

52 get_plugin: Fixture factory to get plugin instances. 

53 """ 

54 gitleaks_plugin = get_plugin("gitleaks") 

55 assert_that(gitleaks_plugin.definition.file_patterns).contains("*") 

56 

57 

58def test_definition_tool_type( 

59 get_plugin: Callable[[str], BaseToolPlugin], 

60) -> None: 

61 """Verify GitleaksPlugin is a security tool type. 

62 

63 Args: 

64 get_plugin: Fixture factory to get plugin instances. 

65 """ 

66 from lintro.enums.tool_type import ToolType 

67 

68 gitleaks_plugin = get_plugin("gitleaks") 

69 assert_that(gitleaks_plugin.definition.tool_type).is_equal_to(ToolType.SECURITY)