From: Douglas Bagnall Date: Mon, 13 Nov 2023 00:36:00 +0000 (+1300) Subject: pytest: token_factory copes with empty claims X-Git-Tag: talloc-2.4.2~515 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=51d9444baa083e7e2c92e422227df681d466cd7b;p=thirdparty%2Fsamba.git pytest: token_factory copes with empty claims We don't have a good story yet with regard to empty claims, but we at least want to be able to create them in tests. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/token_factory.py b/python/samba/tests/token_factory.py index b2d17b4356c..74a0f6baa57 100644 --- a/python/samba/tests/token_factory.py +++ b/python/samba/tests/token_factory.py @@ -43,17 +43,17 @@ def list_to_claim(k, v, case_sensitive=False): c = security.CLAIM_SECURITY_ATTRIBUTE_RELATIVE_V1() - if len(v) == 0: - raise ValueError("empty claim lists are not valid" - f" (for {k})") - - t = type(v[0]) - for val in v[1:]: - if type(val) != t: - raise TypeError(f"claim values for '{k}' " - "should all be the same type") + if len(v) != 0: + t = type(v[0]) + c.value_type = CLAIM_VAL_TYPES[t] + for val in v[1:]: + if type(val) != t: + raise TypeError(f"claim values for '{k}' " + "should all be the same type") + else: + # pick an arbitrary type + c.value_type = CLAIM_VAL_TYPES['uint'] c.name = k - c.value_type = CLAIM_VAL_TYPES[t] c.values = v c.value_count = len(v) if case_sensitive: