-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fips.py
More file actions
46 lines (35 loc) · 1.49 KB
/
Copy pathtest_fips.py
File metadata and controls
46 lines (35 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
"""
Tests for OpenSSL FIPS provider mode (Component 1).
When GR_LINUX_CRYPTO_FIPS=ON, the FIPS provider is loaded at module init.
These tests verify fips_status() and that FIPS-related behavior is consistent.
"""
import pytest
from gr_linux_crypto import fips_status
class TestFipsStatus:
"""Test fips_status() helper."""
def test_fips_status_returns_dict(self):
status = fips_status()
assert isinstance(status, dict)
assert "fips_active" in status
assert "provider_loaded" in status
assert "openssl_version" in status
assert "certificate_info" in status or "error" in status
def test_fips_status_fips_active_is_bool(self):
status = fips_status()
assert isinstance(status["fips_active"], bool)
def test_fips_status_provider_loaded_is_bool(self):
status = fips_status()
assert isinstance(status["provider_loaded"], bool)
def test_fips_status_openssl_version_string_or_none(self):
status = fips_status()
v = status.get("openssl_version")
assert v is None or isinstance(v, str)
def test_fips_status_error_string_or_none(self):
status = fips_status()
e = status.get("error")
assert e is None or isinstance(e, str)
def test_fips_status_when_provider_loaded_fips_active_consistent(self):
status = fips_status()
if status["provider_loaded"] and status.get("error") is None:
assert status["fips_active"] is True