本文整理汇总了Python中jwkest.jwt.JWT.pack方法的典型用法代码示例。如果您正苦于以下问题:Python JWT.pack方法的具体用法?Python JWT.pack怎么用?Python JWT.pack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jwkest.jwt.JWT
的用法示例。
在下文中一共展示了JWT.pack方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pack_jwt
# 需要导入模块: from jwkest.jwt import JWT [as 别名]
# 或者: from jwkest.jwt.JWT import pack [as 别名]
def test_pack_jwt():
_jwt = JWT(**{"alg": "none", "cty": "jwt"})
jwt = _jwt.pack(parts=[{"iss": "joe", "exp": 1300819380,
"http://example.com/is_root": True}, ""])
p = jwt.split(b'.')
assert len(p) == 3
示例2: test_unpack_pack
# 需要导入模块: from jwkest.jwt import JWT [as 别名]
# 或者: from jwkest.jwt.JWT import pack [as 别名]
def test_unpack_pack():
_jwt = JWT(**{"alg": "none"})
payload = {"iss": "joe", "exp": 1300819380,
"http://example.com/is_root": True}
jwt = _jwt.pack(parts=[payload, ""])
repacked = JWT().unpack(jwt).pack()
assert jwt == repacked
示例3: test_unpack_str
# 需要导入模块: from jwkest.jwt import JWT [as 别名]
# 或者: from jwkest.jwt.JWT import pack [as 别名]
def test_unpack_str():
_jwt = JWT(**{"alg": "none"})
payload = {"iss": "joe", "exp": 1300819380,
"http://example.com/is_root": True}
jwt = _jwt.pack(parts=[payload, ""])
_jwt2 = JWT().unpack(jwt)
assert _jwt2
out_payload = _jwt2.payload()
示例4: test_pack_unpack
# 需要导入模块: from jwkest.jwt import JWT [as 别名]
# 或者: from jwkest.jwt.JWT import pack [as 别名]
def test_pack_unpack():
_jwt = JWT(**{"alg": "none"})
payload = {"iss": "joe", "exp": 1300819380,
"http://example.com/is_root": True}
jwt = _jwt.pack(parts=[payload, ""])
_jwt2 = JWT().unpack(jwt)
assert _jwt2
out_payload = _jwt2.payload()
assert _eq(out_payload.keys(), ["iss", "exp", "http://example.com/is_root"])
assert out_payload["iss"] == payload["iss"]
assert out_payload["exp"] == payload["exp"]
assert out_payload["http://example.com/is_root"] == payload[
"http://example.com/is_root"]
示例5: test_pack_with_headers
# 需要导入模块: from jwkest.jwt import JWT [as 别名]
# 或者: from jwkest.jwt.JWT import pack [as 别名]
def test_pack_with_headers():
_jwt = JWT()
jwt = _jwt.pack(parts=["", ""], headers={"foo": "bar"})
assert JWT().unpack(jwt).headers["foo"] == "bar"