2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-05 08:45:22 +00:00

Add unittest for get_last_login_timestamp

... starting with a x86_64 wtmp example file
This commit is contained in:
Christian Boltz
2021-10-24 13:10:25 +02:00
parent 6dc9884c8e
commit 905b89a5c7
4 changed files with 35 additions and 2 deletions

31
utils/test/test-notify.py Normal file
View File

@@ -0,0 +1,31 @@
#! /usr/bin/python3
# ------------------------------------------------------------------
#
# Copyright (C) 2021 Christian Boltz <apparmor@cboltz.de>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# ------------------------------------------------------------------
import unittest
from common_test import AATest, setup_all_loops
from apparmor.notify import get_last_login_timestamp
class TestGet_last_login_timestamp(AATest):
tests = [
(['wtmp-x86_64', 'root' ], 1635070346), # Sun Oct 24 12:12:26 CEST 2021
(['wtmp-x86_64', 'whoever' ], 0),
]
def _run_test(self, params, expected):
filename, user = params
filename = 'wtmp-examples/%s' % filename
self.assertEqual(get_last_login_timestamp(user, filename), expected)
setup_all_loops(__name__)
if __name__ == '__main__':
unittest.main(verbosity=1)