本文整理汇总了Python中c7n_azure.session.Session.get_functions_auth_string方法的典型用法代码示例。如果您正苦于以下问题:Python Session.get_functions_auth_string方法的具体用法?Python Session.get_functions_auth_string怎么用?Python Session.get_functions_auth_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c7n_azure.session.Session
的用法示例。
在下文中一共展示了Session.get_functions_auth_string方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_functions_auth_string_overrides
# 需要导入模块: from c7n_azure.session import Session [as 别名]
# 或者: from c7n_azure.session.Session import get_functions_auth_string [as 别名]
def test_get_functions_auth_string_overrides(self):
with patch('azure.common.credentials.ServicePrincipalCredentials.__init__',
autospec=True, return_value=None):
with patch.dict(os.environ,
{
constants.ENV_TENANT_ID: 'tenant',
constants.ENV_SUB_ID: 'ea42f556-5106-4743-99b0-c129bfa71a47',
constants.ENV_CLIENT_ID: 'client',
constants.ENV_CLIENT_SECRET: 'secret',
constants.ENV_FUNCTION_TENANT_ID: 'functiontenant',
constants.ENV_FUNCTION_SUB_ID: '000000-5106-4743-99b0-c129bfa71a47',
constants.ENV_FUNCTION_CLIENT_ID: 'functionclient',
constants.ENV_FUNCTION_CLIENT_SECRET: 'functionsecret'
}, clear=True):
s = Session()
auth = s.get_functions_auth_string('000000-5106-4743-99b0-c129bfa71a47')
expected = """{
"credentials": {
"client_id": "functionclient",
"secret": "functionsecret",
"tenant": "functiontenant"
},
"subscription": "000000-5106-4743-99b0-c129bfa71a47"
}"""
self.assertEqual(json.loads(auth), json.loads(expected))
示例2: test_get_functions_auth_string
# 需要导入模块: from c7n_azure.session import Session [as 别名]
# 或者: from c7n_azure.session.Session import get_functions_auth_string [as 别名]
def test_get_functions_auth_string(self):
with patch('azure.common.credentials.ServicePrincipalCredentials.__init__',
autospec=True, return_value=None):
with patch.dict(os.environ,
{
constants.ENV_TENANT_ID: 'tenant',
constants.ENV_SUB_ID: DEFAULT_SUBSCRIPTION_ID,
constants.ENV_CLIENT_ID: 'client',
constants.ENV_CLIENT_SECRET: 'secret'
}, clear=True):
s = Session()
auth = s.get_functions_auth_string(CUSTOM_SUBSCRIPTION_ID)
expected = {"credentials":
{"client_id": "client",
"secret": "secret",
"tenant": "tenant"},
"subscription": CUSTOM_SUBSCRIPTION_ID}
self.assertEqual(json.loads(auth), expected)