nebius/SWE-bench-extra huggingface dataset:
Repository: scitokens/scitokens

Issue:
aud value ANY not accepted when in an array
A token with audience value:
```
      ["ANY"]
```
is not accepted as valid. Should it be?

In [the _validate_aud method on the Enforcer object](https://github.com/scitokens/scitokens/blob/2be3e7dc5781b8f24ed20b21a6b660c5cb80a814/src/scitokens/scitokens.py#L596C2-L602C24) it looks like `ANY` is only treated as special if it is a stand-alone string. 

If this is not the desired behavior, I think it would work to test if `value` is a list and, if so, return `True` if the list contains the string `"ANY"`. 

Comments:

Patch:
diff --git a/src/scitokens/scitokens.py b/src/scitokens/scitokens.py
index bf9cd74..b88b638 100644
--- a/src/scitokens/scitokens.py
+++ b/src/scitokens/scitokens.py
@@ -598,9 +598,7 @@ class Enforcer(object):
             return False
         elif self._audience == "ANY":
             return False
-        elif value == "ANY":
-            return True
-        
+
         # Convert the value and self._audience both to sets
         # Then perform set intersection
         values = []
@@ -609,6 +607,11 @@ class Enforcer(object):
         else:
             values = value
         set_value = set(values)
+
+        # Check if "ANY" is in the set_value, and always accept if that is true
+        if "ANY" in set_value:
+            return True
+
         audiences = []
         if not isinstance(self._audience, list):
             audiences = [self._audience]


Test patch:
diff --git a/tests/test_scitokens.py b/tests/test_scitokens.py
index 92ecac4..11a435e 100644
--- a/tests/test_scitokens.py
+++ b/tests/test_scitokens.py
@@ -142,6 +142,14 @@ class TestEnforcer(unittest.TestCase):
         self._token2["aud"] = "ANY"
         self.assertTrue(enf.test(self._token2, "read", "/foo/bar"), msg=enf.last_failure)
 
+        # Now set the audience to ANY
+        self._token2["aud"] = ["ANY"]
+        self.assertTrue(enf.test(self._token2, "read", "/foo/bar"), msg=enf.last_failure)
+
+        # Now set the audience to ANY
+        self._token2["aud"] = ["notathing.com", "ANY"]
+        self.assertTrue(enf.test(self._token2, "read", "/foo/bar"), msg=enf.last_failure)
+
         # Now to the correct audience
         self._token2["aud"] = "https://example.unl.edu"
         self.assertTrue(enf.test(self._token2, "read", "/foo/bar"), msg=enf.last_failure)