本文整理汇总了Python中oic.utils.sdb.SessionDB.update方法的典型用法代码示例。如果您正苦于以下问题:Python SessionDB.update方法的具体用法?Python SessionDB.update怎么用?Python SessionDB.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oic.utils.sdb.SessionDB
的用法示例。
在下文中一共展示了SessionDB.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update
# 需要导入模块: from oic.utils.sdb import SessionDB [as 别名]
# 或者: from oic.utils.sdb.SessionDB import update [as 别名]
def test_update():
sdb = SessionDB()
sid = sdb.token.key(areq=AREQ)
code = sdb.token(sid=sid)
raises(KeyError, 'sdb.update(sid, "indo", "nebue")')
raises(KeyError, 'sdb.update(code, "indo", "nebue")')
sdb[sid] = {"indo": "china"}
sdb.update(sid, "indo", "nebue")
sdb.update(code, "indo", "second")
raises(KeyError, 'sdb.update("abcdefghijklmnop", "indo", "bar")')
#noinspection PyUnusedLocal
sid2 = sdb.token.key(areq=AREQ)
raises(KeyError, 'sdb.update(sid2, "indo", "bar")')
示例2: TestSessionDB
# 需要导入模块: from oic.utils.sdb import SessionDB [as 别名]
# 或者: from oic.utils.sdb.SessionDB import update [as 别名]
class TestSessionDB(object):
@pytest.fixture(autouse=True)
def create_sdb(self):
self.sdb = SessionDB("https://example.com/")
def test_setitem(self):
sid = self.sdb.token.key(areq=AREQ)
code = self.sdb.token(sid=sid)
self.sdb[sid] = {"indo": "china"}
info = self.sdb[sid]
assert info == {"indo": "china"}
info = self.sdb[code]
assert info == {"indo": "china"}
def test_getitem_key_error(self):
with pytest.raises(KeyError):
self.sdb["abcdefghijklmnop"]
def test_update(self):
sid = self.sdb.token.key(areq=AREQ)
code = self.sdb.token(sid=sid)
self.sdb[sid] = {"indo": "china"}
self.sdb.update(sid, "indo", "nebue")
self.sdb.update(code, "indo", "second")
def test_update_non_existing(self):
sid = self.sdb.token.key(areq=AREQ)
code = self.sdb.token(sid=sid)
# can't update non-existing
with pytest.raises(KeyError):
self.sdb.update(sid, "indo", "nebue")
self.sdb.update(code, "indo", "nebue")
self.sdb.update("abcdefghijklmnop", "indo", "bar")
def test_create_authz_session(self):
ae = AuthnEvent("uid", "salt")
sid = self.sdb.create_authz_session(ae, AREQ)
self.sdb.do_sub(sid, "client_salt")
info = self.sdb[sid]
assert info["oauth_state"] == "authz"
def test_create_authz_session_without_nonce(self):
ae = AuthnEvent("sub", "salt")
sid = self.sdb.create_authz_session(ae, AREQ)
info = self.sdb[sid]
assert info["oauth_state"] == "authz"
def test_create_authz_session_with_nonce(self):
ae = AuthnEvent("sub", "salt")
sid = self.sdb.create_authz_session(ae, AREQN)
info = self.sdb[sid]
assert info["nonce"] == "something"
def test_create_authz_session_with_id_token(self):
ae = AuthnEvent("sub", "salt")
sid = self.sdb.create_authz_session(ae, AREQN, id_token="id_token")
info = self.sdb[sid]
assert info["id_token"] == "id_token"
def test_create_authz_session_with_oidreq(self):
ae = AuthnEvent("sub", "salt")
sid = self.sdb.create_authz_session(ae, AREQN, oidreq=OIDR)
info = self.sdb[sid]
assert "id_token" not in info
assert "oidreq" in info
def test_create_authz_session_with_sector_id(self):
ae = AuthnEvent("sub", "salt")
sid = self.sdb.create_authz_session(ae, AREQN, oidreq=OIDR)
self.sdb.do_sub(sid, "client_salt", "http://example.com/si.jwt",
"pairwise")
info_1 = self.sdb[sid].copy()
assert "id_token" not in info_1
assert "oidreq" in info_1
assert info_1["sub"] != "sub"
self.sdb.do_sub(sid, "client_salt", "http://example.net/si.jwt",
"pairwise")
info_2 = self.sdb[sid]
assert info_2["sub"] != "sub"
assert info_2["sub"] != info_1["sub"]
def test_upgrade_to_token(self):
ae1 = AuthnEvent("uid", "salt")
sid = self.sdb.create_authz_session(ae1, AREQ)
self.sdb[sid]['sub'] = 'sub'
grant = self.sdb[sid]["code"]
_dict = self.sdb.upgrade_to_token(grant)
print(_dict.keys())
assert _eq(list(_dict.keys()),
#.........这里部分代码省略.........