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)
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'}
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
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
def setUp(self): self.access_token = AccessToken(token="abcdef", expires_at=expires_at(hours=1))