示例#1
0
    def setUp(self):
        self.access_token = AccessToken(token="cdefg", expires_at=expires_at(hours=1))
        
        self.store_mock = mock.Mock(spec=["fetch_by_token"])
        self.store_mock.fetch_by_token.return_value = self.access_token

        self.registry_mock = mock.Mock(spec=["is_public"])
        self.registry_mock.is_public.return_value = False 
        
        self.security = OWSSecurity(tokenstore=self.store_mock, service_registry=self.registry_mock)
示例#2
0
 def test_access_token_with_user_environ(self):
     access_token = AccessToken(token='12345', expires_at=expires_at(hours=1),
                         user_environ={'data_token': 'bfghk'})
     assert access_token.user_environ == {'data_token': 'bfghk'}
示例#3
0
 def test_access_token(self):
     access_token = AccessToken(token='abcdef', expires_at=expires_at(hours=1))
     assert access_token.expires_in <= 3600
     assert access_token.is_expired() == False
示例#4
0
 def test_invalid_access_token(self):
     access_token = AccessToken(token='abcdef', expires_at=expires_at(hours=-1))
     assert access_token.expires_in == 0
     assert access_token.is_expired() == True
示例#5
0
 def setUp(self):
     self.access_token = AccessToken(token="abcdef", expires_at=expires_at(hours=1))