]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
tests/krb5: Use __slots__ to indicate which attributes are used by classes
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 30 Oct 2023 01:05:17 +0000 (14:05 +1300)
committerJule Anger <janger@samba.org>
Wed, 3 Jul 2024 08:48:12 +0000 (08:48 +0000)
These should help to catch mistaken attempts to set invalid attributes.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit 2b69e1e7c316e634090aad1d97ecadf8cdf529f3)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15655

python/samba/tests/krb5/kdc_base_test.py
python/samba/tests/krb5/raw_testcase.py

index 96ae43a0937bdc30de4764008eaa085dc52f9c7e..76cea241d30f4bf38a58d405fc83ab0b7aca0eae 100644 (file)
@@ -137,6 +137,8 @@ class GroupType(Enum):
 
 # This simple class encapsulates the DN and SID of a Principal.
 class Principal:
+    __slots__ = ['dn', 'sid']
+
     def __init__(self, dn, sid):
         if dn is not None and not isinstance(dn, ldb.Dn):
             raise AssertionError(f'expected {dn} to be an ldb.Dn')
index 1507e4a9c5adf4d5af81893040146cbd3e8c6154..db4db9c9e85732b0d946fa7b61e32a528edbe05e 100644 (file)
@@ -248,6 +248,13 @@ krb5_asn1.KerbErrorDataType.prettyPrint =\
 
 
 class Krb5EncryptionKey:
+    __slots__ = [
+        'ctype',
+        'etype',
+        'key',
+        'kvno',
+    ]
+
     def __init__(self, key, kvno):
         EncTypeChecksum = {
             kcrypto.Enctype.AES256: kcrypto.Cksumtype.SHA1_AES256,
@@ -304,6 +311,8 @@ class Krb5EncryptionKey:
 
 
 class RodcPacEncryptionKey(Krb5EncryptionKey):
+    __slots__ = ['rodc_id']
+
     def __init__(self, key, kvno, rodc_id=None):
         super().__init__(key, kvno)
 
@@ -351,6 +360,8 @@ class ZeroedChecksumKey(RodcPacEncryptionKey):
 
 
 class WrongLengthChecksumKey(RodcPacEncryptionKey):
+    __slots__ = ['_length']
+
     def __init__(self, key, kvno, length):
         super().__init__(key, kvno)
 
@@ -382,6 +393,20 @@ class WrongLengthChecksumKey(RodcPacEncryptionKey):
 
 
 class KerberosCredentials(Credentials):
+    __slots__ = [
+        '_private_key',
+        'account_type',
+        'ap_supported_enctypes',
+        'as_supported_enctypes',
+        'dn',
+        'forced_keys',
+        'forced_salt',
+        'kvno',
+        'sid',
+        'spn',
+        'tgs_supported_enctypes',
+        'upn',
+    ]
 
     non_etype_bits = (
         security.KERB_ENCTYPE_FAST_SUPPORTED) | (
@@ -577,6 +602,18 @@ class KerberosCredentials(Credentials):
 
 
 class KerberosTicketCreds:
+    __slots__ = [
+        'cname',
+        'crealm',
+        'decryption_key',
+        'encpart_private',
+        'session_key',
+        'sname',
+        'srealm',
+        'ticket_private',
+        'ticket',
+    ]
+
     def __init__(self, ticket, session_key,
                  crealm=None, cname=None,
                  srealm=None, sname=None,