Skip to content
Snippets Groups Projects
Verified Commit 8cc46caa authored by Karel Koci's avatar Karel Koci :metal:
Browse files

test_cryptowrapper: add some basic tests for crypto-wrapper

It tests only if hardware type is correctly reported and if appropriate
serial number is returned.

This adds new requirement for configuration and that is serial number.
We need this to verify that crypto-wrapper correctly returns appropriate
number.
parent 466e943b
1 merge request!8Draft: Feature/target parsing
......@@ -32,6 +32,7 @@ class Target:
"""
return bool(
self.board and self.board in BOARDS and
self.serial_number and len(self.serial_number) == 16 and
self.serial and
self.wan
)
......@@ -62,6 +63,12 @@ class Target:
"""
return self._conf.get("board")
@property
def serial_number(self) -> str:
"""Serial number of target board.
"""
return self._conf.get("serial_number")
@property
def serial(self) -> str:
"""Serial interface connected to target board.
......
......@@ -20,6 +20,8 @@
# * omnia (for Turris Omnia)
# * turris1x (for Turris 1.0 and 1.1)
board = omnia
# Serial number of board in hex format (all 16 characters)
serial_number = 0000000000000000
# This is path to serial TTY. It is suggested to use /dev/serial/by-path/* device
# over /dev/tty* as path is preserved between reboots but device identifier not.
# On the other hand there is no other problem with using /dev/ttyUSB0 and for
......
"""These are tests to check that we are able to communicate with board's crypto.
The backend is different depending on board but common crypto-wrapper unites the
attribute access.
"""
import pytest
@pytest.mark.parametrize("hwtype", [
pytest.param("atsha", marks=pytest.mark.board("omnia", "turris1x")),
pytest.param("otp", marks=pytest.mark.board("mox")),
])
def test_hw_type(hwtype, client_board):
"""Check if reported hardware type matches board.
"""
client_board.run("crypto-wrapper hw-type")
assert client_board.output == hwtype
def test_serial_number(request, client_board):
"""Check that syslog-ng is running by checking if there is /var/log/messages (default log output).
"""
client_board.run("crypto-wrapper serial-number")
assert client_board.output == request.config.target_config.serial_number
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment