summaryrefslogtreecommitdiffstats
path: root/test/test_ssh2_kexdb.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:07:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 17:07:52 +0000
commitf0f453c916e279980df981c1e1dee0d167dc124e (patch)
treed09973c9f173820ade2dc814467d3e57df8a042d /test/test_ssh2_kexdb.py
parentInitial commit. (diff)
downloadssh-audit-f0f453c916e279980df981c1e1dee0d167dc124e.tar.xz
ssh-audit-f0f453c916e279980df981c1e1dee0d167dc124e.zip
Adding upstream version 3.1.0.upstream/3.1.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/test_ssh2_kexdb.py')
-rw-r--r--test/test_ssh2_kexdb.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/test_ssh2_kexdb.py b/test/test_ssh2_kexdb.py
new file mode 100644
index 0000000..c4e3eb7
--- /dev/null
+++ b/test/test_ssh2_kexdb.py
@@ -0,0 +1,35 @@
+import pytest
+
+from ssh_audit.ssh2_kexdb import SSH2_KexDB
+
+
+class Test_SSH2_KexDB:
+
+ @pytest.fixture(autouse=True)
+ def init(self):
+ self.db = SSH2_KexDB.get_db()
+
+ def test_ssh2_kexdb(self):
+ '''Ensures that the SSH2_KexDB.ALGORITHMS dictionary is in the right format.'''
+
+ db_keys = list(self.db.keys())
+ db_keys.sort()
+
+ # Ensure only these keys exist in the database.
+ assert db_keys == ['enc', 'kex', 'key', 'mac']
+
+ # For 'enc', 'kex', etc...
+ for alg_type in self.db:
+
+ # Iterate over algorithms within this type (i.e.: all 'enc' algorithms, all 'kex' algorithms, etc).
+ for alg_name in self.db[alg_type]:
+
+ # Get the list of failures, warnings, etc., for this algorithm.
+ alg_data = self.db[alg_type][alg_name]
+
+ # This list must be between 1 and 4 entries long.
+ assert 1 <= len(alg_data) <= 4
+
+ # The first entry denotes the versions when this algorithm was added to OpenSSH, Dropbear, and/or libssh, followed by when it was deprecated, and finally when it was removed. Hence it must have between 0 and 3 entries.
+ added_entry = alg_data[0]
+ assert 0 <= len(added_entry) <= 3