本文整理汇总了Python中stormpath.resources.application.Application类的典型用法代码示例。如果您正苦于以下问题:Python Application类的具体用法?Python Application怎么用?Python Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Application类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: IDSiteCallbackTest
class IDSiteCallbackTest(IDSiteBuildURITest):
def setUp(self):
super(IDSiteCallbackTest, self).setUp()
self.store = MagicMock()
self.store.get_resource.return_value = {'href': 'acchref', 'sp_http_status': 200}
self.store._cache_get.return_value = False # ignore nonce
self.client.data_store = self.store
self.app = Application(
client=self.client,
properties={'href': 'apphref', 'accounts': {'href': 'acchref'}})
self.acc = MagicMock(href='acchref')
now = datetime.datetime.utcnow()
try:
irt = uuid4().get_hex()
except AttributeError:
irt = uuid4().hex
fake_jwt_data = {
'exp': now + datetime.timedelta(seconds=3600),
'aud': self.app._client.auth.id,
'irt': irt,
'iss': 'Stormpath',
'sub': self.acc.href,
'isNewSub': False,
'state': None,
}
self.fake_jwt = to_unicode(jwt.encode(
fake_jwt_data,
self.app._client.auth.secret,
'HS256'), 'UTF-8')
def test_id_site_callback_handler(self):
fake_jwt_response = 'http://localhost/?jwtResponse=%s' % self.fake_jwt
ret = self.app.handle_id_site_callback(fake_jwt_response)
self.assertIsNotNone(ret)
self.assertEqual(ret.account.href, self.acc.href)
self.assertIsNone(ret.state)
def test_id_site_callback_handler_jwt_already_used(self):
self.store._cache_get.return_value = True # Fake Nonce already used
fake_jwt_response = 'http://localhost/?jwtResponse=%s' % self.fake_jwt
self.assertRaises(ValueError, self.app.handle_id_site_callback, fake_jwt_response)
def test_id_site_callback_handler_invalid_jwt(self):
fake_jwt_response = 'http://localhost/?jwtResponse=%s' % 'INVALID_JWT'
ret = self.app.handle_id_site_callback(fake_jwt_response)
self.assertIsNone(ret)
def test_id_site_callback_handler_invalid_url_response(self):
fake_jwt_response = 'invalid_url_response'
ret = self.app.handle_id_site_callback(fake_jwt_response)
self.assertIsNone(ret)
开发者ID:kkinder,项目名称:stormpath-sdk-python,代码行数:59,代码来源:test_id_site.py
示例2: test_building_saml_redirect_uri
def test_building_saml_redirect_uri(self):
try:
from urlparse import urlparse
except ImportError:
from urllib.parse import urlparse
app = Application(client=self.client, properties={'href': 'apphref'})
ret = app.build_saml_idp_redirect_url(
'http://localhost/', 'apphref/saml/sso/idpRedirect')
try:
jwt_response = urlparse(ret).query.split('=')[1]
except:
self.fail("Failed to parse ID site redirect uri")
try:
decoded_data = jwt.decode(
jwt_response, verify=False, algorithms=['HS256'])
except jwt.DecodeError:
self.fail("Invaid JWT generated.")
self.assertIsNotNone(decoded_data.get('iat'))
self.assertIsNotNone(decoded_data.get('jti'))
self.assertIsNotNone(decoded_data.get('iss'))
self.assertIsNotNone(decoded_data.get('sub'))
self.assertIsNotNone(decoded_data.get('cb_uri'))
self.assertEqual(decoded_data.get('cb_uri'), 'http://localhost/')
self.assertIsNone(decoded_data.get('path'))
self.assertIsNone(decoded_data.get('state'))
ret = app.build_saml_idp_redirect_url(
'http://testserver/',
'apphref/saml/sso/idpRedirect',
path='/#/register',
state='test')
try:
jwt_response = urlparse(ret).query.split('=')[1]
except:
self.fail("Failed to parse SAML redirect uri")
try:
decoded_data = jwt.decode(
jwt_response, verify=False, algorithms=['HS256'])
except jwt.DecodeError:
self.fail("Invaid JWT generated.")
self.assertEqual(decoded_data.get('path'), '/#/register')
self.assertEqual(decoded_data.get('state'), 'test')
开发者ID:RepositPower,项目名称:stormpath-sdk-python,代码行数:48,代码来源:test_saml.py
示例3: setUp
def setUp(self):
super(IDSiteCallbackTest, self).setUp()
self.store = MagicMock()
self.store.get_resource.return_value = {'href': 'acchref', 'sp_http_status': 200}
self.store._cache_get.return_value = False # ignore nonce
self.client.data_store = self.store
self.app = Application(
client=self.client,
properties={'href': 'apphref', 'accounts': {'href': 'acchref'}})
self.acc = MagicMock(href='acchref')
now = datetime.datetime.utcnow()
try:
irt = uuid4().get_hex()
except AttributeError:
irt = uuid4().hex
fake_jwt_data = {
'exp': now + datetime.timedelta(seconds=3600),
'aud': self.app._client.auth.id,
'irt': irt,
'iss': 'Stormpath',
'sub': self.acc.href,
'isNewSub': False,
'state': None,
}
self.fake_jwt = to_unicode(jwt.encode(
fake_jwt_data,
self.app._client.auth.secret,
'HS256'), 'UTF-8')
开发者ID:kkinder,项目名称:stormpath-sdk-python,代码行数:34,代码来源:test_id_site.py
示例4: SamlCallbackTest
class SamlCallbackTest(SamlBuildURITest):
def setUp(self):
super(SamlCallbackTest, self).setUp()
self.store = MagicMock()
self.store.get_resource.return_value = {
'href': 'acchref',
'sp_http_status': 200,
'applications': ApplicationList(
client=self.client,
properties={
'href': 'apps',
'items': [{'href': 'apphref'}],
'offset': 0,
'limit': 25
})
}
self.store._cache_get.return_value = False # ignore nonce
self.client.data_store = self.store
self.app = Application(
client=self.client,
properties={'href': 'apphref', 'accounts': {'href': 'acchref'}})
self.acc = MagicMock(href='acchref')
now = datetime.datetime.utcnow()
try:
irt = uuid4().get_hex()
except AttributeError:
irt = uuid4().hex
fake_jwt_data = {
'exp': now + datetime.timedelta(seconds=3600),
'aud': self.app._client.auth.id,
'irt': irt,
'iss': 'Stormpath',
'sub': self.acc.href,
'isNewSub': False,
'state': None,
}
self.fake_jwt = to_unicode(jwt.encode(
fake_jwt_data,
self.app._client.auth.secret,
'HS256'), 'UTF-8')
def test_saml_callback_handler(self):
fake_jwt_response = 'http://localhost/?jwtResponse=%s' % self.fake_jwt
with patch.object(Application, 'has_account') as mock_has_account:
mock_has_account.return_value = True
ret = self.app.handle_stormpath_callback(fake_jwt_response)
self.assertIsNotNone(ret)
self.assertIsInstance(ret, StormpathCallbackResult)
self.assertEqual(ret.account.href, self.acc.href)
self.assertIsNone(ret.state)
开发者ID:RepositPower,项目名称:stormpath-sdk-python,代码行数:59,代码来源:test_saml.py
示例5: test_app_get_provider_acc_does_create_w_provider_data
def test_app_get_provider_acc_does_create_w_provider_data(self):
ds = MagicMock()
ds.get_resource.return_value = {}
client = MagicMock(data_store=ds, BASE_URL='http://example.com')
app = Application(client=client, properties={
'href': 'test/app',
'accounts': {'href': '/test/app/accounts'}
})
app.get_provider_account('myprovider', access_token='foo')
ds.create_resource.assert_called_once_with(
'http://example.com/test/app/accounts', {
'providerData': {
'providerId': 'myprovider',
'accessToken': 'foo'
}
}, params={})
开发者ID:denibertovic,项目名称:stormpath-sdk-python,代码行数:19,代码来源:test_provider.py
示例6: test_building_id_site_redirect_uri
def test_building_id_site_redirect_uri(self):
app = Application(client=self.client, properties={'href': 'apphref'})
ret = app.build_id_site_redirect_url('http://localhost/')
decoded_data = self.decode_jwt(ret)
self.assertIsNotNone(decoded_data.get('iat'))
self.assertIsNotNone(decoded_data.get('jti'))
self.assertIsNotNone(decoded_data.get('iss'))
self.assertIsNotNone(decoded_data.get('sub'))
self.assertIsNotNone(decoded_data.get('cb_uri'))
self.assertEqual(decoded_data.get('cb_uri'), 'http://localhost/')
self.assertIsNone(decoded_data.get('path'))
self.assertIsNone(decoded_data.get('state'))
self.assertNotEqual(decoded_data.get('sof'), True)
self.assertIsNone(decoded_data.get('onk'))
self.assertIsNone(decoded_data.get('sp_token'))
ret = app.build_id_site_redirect_url(
'http://testserver/',
path='/#/register',
state='test')
decoded_data = self.decode_jwt(ret)
self.assertEqual(decoded_data.get('path'), '/#/register')
self.assertEqual(decoded_data.get('state'), 'test')
sp_token = '{"test":"test"}'
ret = app.build_id_site_redirect_url(
'http://localhost/', show_organization_field=True, sp_token=sp_token)
decoded_data = self.decode_jwt(ret)
self.assertEqual(decoded_data["sof"], True)
self.assertEqual(decoded_data["sp_token"], sp_token)
self.assertIsNone(decoded_data.get('onk'))
ret = app.build_id_site_redirect_url(
'http://localhost/', organization_name_key="testorg")
decoded_data = self.decode_jwt(ret)
self.assertEqual(decoded_data["onk"], "testorg")
self.assertNotEqual(decoded_data.get('sof'), True)
开发者ID:RepositPower,项目名称:stormpath-sdk-python,代码行数:38,代码来源:test_id_site.py
示例7: test_iter_method_on_dict_mixin
def test_iter_method_on_dict_mixin(self):
r = Application(MagicMock(), properties={'name': 'some app'})
self.assertEqual(['name'], list(r.__iter__()))
开发者ID:nkwood,项目名称:stormpath-sdk-python,代码行数:3,代码来源:test_resource.py
示例8: test_getting_items_from_dict_mixing
def test_getting_items_from_dict_mixing(self):
r = Application(MagicMock(), properties={'name': 'some app'})
self.assertEqual([('name', 'some app')], r.items())
开发者ID:nkwood,项目名称:stormpath-sdk-python,代码行数:3,代码来源:test_resource.py
示例9: test_checking_if_status_disabled
def test_checking_if_status_disabled(self):
r = Application(
MagicMock(),
properties={})
self.assertTrue(r.is_disabled())
开发者ID:nkwood,项目名称:stormpath-sdk-python,代码行数:5,代码来源:test_resource.py
示例10: test_checking_if_status_enabled
def test_checking_if_status_enabled(self):
r = Application(
MagicMock(),
properties={'status': Application.STATUS_ENABLED})
self.assertTrue(r.is_enabled())
开发者ID:nkwood,项目名称:stormpath-sdk-python,代码行数:5,代码来源:test_resource.py
示例11: test_getting_resource_status
def test_getting_resource_status(self):
r = Application(
MagicMock(),
properties={'status': Application.STATUS_ENABLED})
self.assertEqual(r.STATUS_ENABLED, r.get_status())
开发者ID:nkwood,项目名称:stormpath-sdk-python,代码行数:5,代码来源:test_resource.py
示例12: test_resource_status_is_disabled_if_not_specified
def test_resource_status_is_disabled_if_not_specified(self):
r = Application(
MagicMock(),
properties={})
self.assertEqual(r.STATUS_DISABLED, r.get_status())
开发者ID:nkwood,项目名称:stormpath-sdk-python,代码行数:5,代码来源:test_resource.py
示例13: test_deleting_new_resource
def test_deleting_new_resource(self):
r = Application(
MagicMock(),
properties={})
self.assertIsNone(r.delete())
开发者ID:nkwood,项目名称:stormpath-sdk-python,代码行数:5,代码来源:test_resource.py
示例14: test_building_id_site_redirect_uri_with_usd
def test_building_id_site_redirect_uri_with_usd(self):
app = Application(client=self.client, properties={'href': 'apphref'})
ret = app.build_id_site_redirect_url('http://localhost/', use_subdomain=True)
decoded_data = self.decode_jwt(ret)
self.assertEqual(decoded_data.get('usd'), True)
开发者ID:stormpath,项目名称:stormpath-sdk-python,代码行数:5,代码来源:test_id_site.py
注:本文中的stormpath.resources.application.Application类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论