当前位置: 首页>>代码示例>>Python>>正文


Python authentication.Authentication方法代码示例

本文整理汇总了Python中msrest.authentication.Authentication方法的典型用法代码示例。如果您正苦于以下问题:Python authentication.Authentication方法的具体用法?Python authentication.Authentication怎么用?Python authentication.Authentication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在msrest.authentication的用法示例。


在下文中一共展示了authentication.Authentication方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_deprecated_creds

# 需要导入模块: from msrest import authentication [as 别名]
# 或者: from msrest.authentication import Authentication [as 别名]
def test_deprecated_creds(self):
        """Test that creds parameters gets populated correctly.

        https://github.com/Azure/msrest-for-python/issues/135
        """

        cfg = Configuration("http://127.0.0.1/")
        assert cfg.credentials is None

        creds = Authentication()

        client = SDKClient(creds, cfg)
        assert cfg.credentials is creds 
开发者ID:Azure,项目名称:msrest-for-python,代码行数:15,代码来源:test_client.py

示例2: test_sdk_context_manager

# 需要导入模块: from msrest import authentication [as 别名]
# 或者: from msrest.authentication import Authentication [as 别名]
def test_sdk_context_manager(self):
        cfg = Configuration("http://127.0.0.1/")

        class Creds(Authentication):
            def __init__(self):
                self.first_session = None
                self.called = 0

            def signed_session(self, session=None):
                self.called += 1
                assert session is not None
                if self.first_session:
                    assert self.first_session is session
                else:
                    self.first_session = session
        cfg.credentials = Creds()

        with SDKClient(None, cfg) as client:
            assert cfg.keep_alive

            req = client._client.get('/')
            try:
                # Will fail, I don't care, that's not the point of the test
                client._client.send(req, timeout=0)
            except Exception:
                pass

            try:
                # Will fail, I don't care, that's not the point of the test
                client._client.send(req, timeout=0)
            except Exception:
                pass

        assert not cfg.keep_alive
        assert cfg.credentials.called == 2 
开发者ID:Azure,项目名称:msrest-for-python,代码行数:37,代码来源:test_client.py

示例3: test_context_manager

# 需要导入模块: from msrest import authentication [as 别名]
# 或者: from msrest.authentication import Authentication [as 别名]
def test_context_manager(self):

        cfg = Configuration("http://127.0.0.1/")

        class Creds(Authentication):
            def __init__(self):
                self.first_session = None
                self.called = 0

            def signed_session(self, session=None):
                self.called += 1
                assert session is not None
                if self.first_session:
                    assert self.first_session is session
                else:
                    self.first_session = session
        cfg.credentials = Creds()

        with ServiceClient(None, cfg) as client:
            assert cfg.keep_alive

            req = client.get('/')
            try:
                # Will fail, I don't care, that's not the point of the test
                client.send(req, timeout=0)
            except Exception:
                pass

            try:
                # Will fail, I don't care, that's not the point of the test
                client.send(req, timeout=0)
            except Exception:
                pass

        assert not cfg.keep_alive
        assert cfg.credentials.called == 2 
开发者ID:Azure,项目名称:msrest-for-python,代码行数:38,代码来源:test_client.py

示例4: test_keep_alive

# 需要导入模块: from msrest import authentication [as 别名]
# 或者: from msrest.authentication import Authentication [as 别名]
def test_keep_alive(self):

        cfg = Configuration("http://127.0.0.1/")
        cfg.keep_alive = True

        class Creds(Authentication):
            def __init__(self):
                self.first_session = None
                self.called = 0

            def signed_session(self, session=None):
                self.called += 1
                assert session is not None
                if self.first_session:
                    assert self.first_session is session
                else:
                    self.first_session = session
        cfg.credentials = Creds()

        client = ServiceClient(None, cfg)
        req = client.get('/')
        try:
            # Will fail, I don't care, that's not the point of the test
            client.send(req, timeout=0)
        except Exception:
            pass

        try:
            # Will fail, I don't care, that's not the point of the test
            client.send(req, timeout=0)
        except Exception:
            pass

        assert cfg.credentials.called == 2
        # Manually close the client in "keep_alive" mode
        client.close() 
开发者ID:Azure,项目名称:msrest-for-python,代码行数:38,代码来源:test_client.py

示例5: credentials

# 需要导入模块: from msrest import authentication [as 别名]
# 或者: from msrest.authentication import Authentication [as 别名]
def credentials(self):
        if self.token:
            return BasicAuthentication("", self.token)
        else:
            warnings.warn(
                "No token available.  No modifications will be possible!"
            )
            return Authentication() 
开发者ID:conda-forge,项目名称:conda-smithy,代码行数:10,代码来源:azure_ci_utils.py

示例6: client

# 需要导入模块: from msrest import authentication [as 别名]
# 或者: from msrest.authentication import Authentication [as 别名]
def client():
    # This is the same client of the "vanilla" one, generated with "azure" because it's the
    # only test that use client level method, and I want to test Azure works too on that.
    return AutoRestResourceFlatteningTestService(Authentication(), base_url="http://localhost:3000") 
开发者ID:Azure,项目名称:autorest.python,代码行数:6,代码来源:test_model_flattening.py


注:本文中的msrest.authentication.Authentication方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。