Beispiel #1
0
class TestToken(object):
    @pytest.fixture(autouse=True)
    def create_token(self):
        self.token = Token("secret", "password")

    def test_token(self):
        sid = self.token.key(areq=AREQ)
        assert len(sid) == 56

    def test_new_token(self):
        sid = self.token.key(areq=AREQ)
        assert len(sid) == 56

        code2 = self.token('T', sid=sid)
        assert len(sid) == 56

        code3 = self.token(ttype="", prev=code2)
        assert code2 != code3

        sid2 = self.token.key(areq=AREQ, user="******")
        assert len(sid2) == 56
        assert sid != sid2

    def test_type_and_key(self):
        sid = self.token.key(areq=AREQ)
        code = self.token(sid=sid)
        part = self.token.type_and_key(code)
        assert part[0] == "A"
        assert part[1] == sid
Beispiel #2
0
class TestToken(object):
    @pytest.fixture(autouse=True)
    def create_token(self):
        self.token = Token("secret", "password")

    def test_token(self):
        sid = self.token.key(areq=AREQ)
        assert len(sid) == 56

    def test_new_token(self):
        sid = self.token.key(areq=AREQ)
        assert len(sid) == 56

        code2 = self.token('T', sid=sid)
        assert len(sid) == 56

        code3 = self.token(ttype="", prev=code2)
        assert code2 != code3

        sid2 = self.token.key(areq=AREQ, user="******")
        assert len(sid2) == 56
        assert sid != sid2

    def test_type_and_key(self):
        sid = self.token.key(areq=AREQ)
        code = self.token(sid=sid)
        part = self.token.type_and_key(code)
        assert part[0] == "A"
        assert part[1] == sid
Beispiel #3
0
 def __init__(self, typ, lifetime, iss, sign_alg, keyjar, **kwargs):
     Token.__init__(self, typ, lifetime, **kwargs)
     self.iss = iss
     self.lifetime = lifetime
     self.sign_alg = sign_alg
     self.keyjar = keyjar  # my signing key
     self.db = {}
Beispiel #4
0
 def __init__(self, typ, keyjar, lt_pattern=None, **kwargs):
     self.type = typ
     JWT.__init__(self, keyjar, msgtype=TokenAssertion, **kwargs)
     Token.__init__(self, typ, **kwargs)
     self.lt_pattern = lt_pattern or {}
     self.db = {}
     self.session_info = {'': 600}
     self.exp_args = ['sinfo']
Beispiel #5
0
 def __init__(self, typ, keyjar, lifetime, **kwargs):
     self.type = typ
     JWT.__init__(self, keyjar, lifetime=lifetime, msgtype=TokenAssertion,
                  **kwargs)
     Token.__init__(self, typ, lifetime=lifetime, **kwargs)
     self.db = {}
     self.session_info = {}
     self.exp_args = ['sinfo']
Beispiel #6
0
 def __init__(self, typ, keyjar, lt_pattern=None, extra_claims=None, **kwargs):
     self.type = typ
     JWT.__init__(self, keyjar, msgtype=TokenAssertion, **kwargs)
     Token.__init__(self, typ, **kwargs)
     self.lt_pattern = lt_pattern or {}
     self.db = {}
     self.session_info = {"": 600}
     self.exp_args = ["sinfo"]
     self.extra_claims = extra_claims or {}
Beispiel #7
0
 def __init__(self,
              typ,
              keyjar,
              lt_pattern=None,
              extra_claims=None,
              **kwargs):
     self.type = typ
     Token.__init__(self, typ, **kwargs)
     kwargs.pop("token_storage", None)
     JWT.__init__(self, keyjar, msgtype=TokenAssertion, **kwargs)
     self.lt_pattern = lt_pattern or {}
     self.db = {}  # type: Dict[str,str]
     self.session_info = {"": 600}
     self.exp_args = ["sinfo"]
     self.extra_claims = extra_claims or {}
Beispiel #8
0
 def create_token(self):
     self.token = Token("secret", "password")
Beispiel #9
0
 def create_token(self):
     self.token = Token("secret", "password")