Exemple #1
0
def to_credentials(obj: CredentialsArg = None) -> Optional[CredentialsT]:
    if obj is not None:
        from faust.auth import SSLCredentials  # XXX :(
        if isinstance(obj, ssl.SSLContext):
            return SSLCredentials(obj)
        if isinstance(obj, CredentialsT):
            return obj
        from faust.exceptions import ImproperlyConfigured
        raise ImproperlyConfigured(
            f'Unknown credentials type {type(obj)}: {obj}')
    return None
Exemple #2
0
 def test_constructor(self):
     with patch("faust.auth.ssl.create_default_context") as cdc:
         c = SSLCredentials(
             purpose=ssl.Purpose.SERVER_AUTH,
             cafile="/foo/bar/ca.file",
             capath="/foo/bar/",
             cadata="moo",
         )
         assert c.context is cdc.return_value
         assert repr(c)
         cdc.assert_called_once_with(
             purpose=ssl.Purpose.SERVER_AUTH,
             cafile="/foo/bar/ca.file",
             capath="/foo/bar/",
             cadata="moo",
         )
Exemple #3
0
 def test_having_context(self):
     context = Mock(name="context")
     c = SSLCredentials(context)
     assert c.context is context