當前位置: 首頁>>代碼示例>>Python>>正文


Python auth.TokenAPI類代碼示例

本文整理匯總了Python中st2common.models.api.auth.TokenAPI的典型用法代碼示例。如果您正苦於以下問題:Python TokenAPI類的具體用法?Python TokenAPI怎麽用?Python TokenAPI使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TokenAPI類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_token_model

 def test_token_model(self):
     dt = isotime.add_utc_tz(datetime.datetime.utcnow())
     tk1 = TokenAPI(user='stanley', token=uuid.uuid4().hex,
                    expiry=isotime.format(dt, offset=False))
     tkdb1 = TokenAPI.to_model(tk1)
     self.assertIsNotNone(tkdb1)
     self.assertIsInstance(tkdb1, TokenDB)
     self.assertEqual(tkdb1.user, tk1.user)
     self.assertEqual(tkdb1.token, tk1.token)
     self.assertEqual(tkdb1.expiry, isotime.parse(tk1.expiry))
     tkdb2 = Token.add_or_update(tkdb1)
     self.assertEqual(tkdb1, tkdb2)
     self.assertIsNotNone(tkdb2.id)
     tk2 = TokenAPI.from_model(tkdb2)
     self.assertEqual(tk2.user, tk1.user)
     self.assertEqual(tk2.token, tk1.token)
     self.assertEqual(tk2.expiry, tk1.expiry)
開發者ID:Kailashkatheth1,項目名稱:st2,代碼行數:17,代碼來源:test_token.py

示例2: TokenAPI

WF2_SPEC = FIXTURES['workflows'][WF2_YAML_FILE_NAME]
WF2_YAML = yaml.safe_dump(WF2_SPEC, default_flow_style=False)
WF2_NAME = '%s.%s' % (PACK, WF2_YAML_FILE_NAME.replace('.yaml', ''))
WF2 = workflows.Workflow(None, {'name': WF2_NAME, 'definition': WF2_YAML})
WF2_EXEC = copy.deepcopy(MISTRAL_EXECUTION)
WF2_EXEC['workflow_name'] = WF2_NAME

# Action executions requirements
ACTION_CONTEXT = {'user': 'stanley'}
ACTION_PARAMS = {'friend': 'Rocky'}

# Token for auth test cases
TOKEN_API = TokenAPI(
    user=ACTION_CONTEXT['user'], token=uuid.uuid4().hex,
    expiry=isotime.format(date_utils.get_datetime_utc_now(), offset=False))
TOKEN_DB = TokenAPI.to_model(TOKEN_API)

NON_EMPTY_RESULT = 'non-empty'


@mock.patch.object(LocalShellRunner, 'run', mock.
                   MagicMock(return_value=(action_constants.LIVEACTION_STATUS_SUCCEEDED,
                                           NON_EMPTY_RESULT, None)))
@mock.patch.object(CUDPublisher, 'publish_update', mock.MagicMock(return_value=None))
@mock.patch.object(CUDPublisher, 'publish_create',
                   mock.MagicMock(side_effect=MockLiveActionPublisher.publish_create))
@mock.patch.object(LiveActionPublisher, 'publish_state',
                   mock.MagicMock(side_effect=MockLiveActionPublisher.publish_state))
class TestMistralRunner(DbTestCase):

    @classmethod
開發者ID:emptywee,項目名稱:st2,代碼行數:31,代碼來源:test_mistral_v2.py

示例3: test_token_model_null_expiry

 def test_token_model_null_expiry(self):
     tk = TokenAPI(user='stanley', token=uuid.uuid4().hex, expiry=None)
     self.assertRaises(ValueError, Token.add_or_update, TokenAPI.to_model(tk))
開發者ID:Kailashkatheth1,項目名稱:st2,代碼行數:3,代碼來源:test_token.py

示例4: test_token_model_null_user

 def test_token_model_null_user(self):
     dt = isotime.add_utc_tz(datetime.datetime.utcnow())
     tk = TokenAPI(user=None, token=uuid.uuid4().hex, expiry=isotime.format(dt))
     self.assertRaises(ValueError, Token.add_or_update, TokenAPI.to_model(tk))
開發者ID:Kailashkatheth1,項目名稱:st2,代碼行數:4,代碼來源:test_token.py

示例5: _create_token_for_user

 def _create_token_for_user(self, username, ttl=None):
     tokendb = create_token(username=username, ttl=ttl)
     return TokenAPI.from_model(tokendb)
開發者ID:rlugojr,項目名稱:st2,代碼行數:3,代碼來源:auth.py

示例6: test_token_model_null_token

 def test_token_model_null_token(self):
     dt = date_utils.get_datetime_utc_now()
     tk = TokenAPI(user='stanley', token=None, expiry=isotime.format(dt))
     self.assertRaises(ValueError, Token.add_or_update, TokenAPI.to_model(tk))
開發者ID:Bala96,項目名稱:st2,代碼行數:4,代碼來源:test_token.py


注:本文中的st2common.models.api.auth.TokenAPI類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。