Ejemplo n.º 1
0
 def test_access_token(self):
     access_token = AccessToken(token='abcdef',
                                expires_at=expires_at(hours=1))
     assert access_token.token == 'abcdef'
     assert access_token.expires_in > 0
     assert access_token.expires_in <= 3600
     assert access_token.is_expired() is False
     assert access_token.params['access_token'] == 'abcdef'
     assert 'expires_at' in access_token.params
Ejemplo n.º 2
0
    def create_access_token(self, valid_in_hours=1, data=None):
        """
        Creates an access token.

        TODO: check valid in hours
        TODO: maybe specify how often a token can be used
        """
        data = data or {}
        token = AccessToken(
            token=self.generate(),
            expires_at=expires_at(hours=valid_in_hours),
            data=data)
        return token
Ejemplo n.º 3
0
    def setUp(self):
        self.access_token = AccessToken(token="cdefg",
                                        expires_at=expires_at(hours=1))

        self.tokenstore = MemoryTokenStore()
        self.tokenstore.save_token(self.access_token)
        self.empty_tokenstore = MemoryTokenStore()

        self.service = Service(url='http://nowhere/wps',
                               name='test_wps',
                               public=False)
        self.servicestore = MemoryServiceStore()
        self.servicestore.save_service(self.service)

        self.security = OWSSecurity(tokenstore=self.tokenstore,
                                    servicestore=self.servicestore)
Ejemplo n.º 4
0
 def test_access_token_with_data(self):
     access_token = AccessToken(token='12345',
                                expires_at=expires_at(hours=1),
                                data={'esgf_token': 'bfghk'})
     assert access_token.data == {'esgf_token': 'bfghk'}
Ejemplo n.º 5
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() is True
Ejemplo n.º 6
0
 def setUp(self):
     self.access_token = AccessToken(token="abcdef", expires_at=expires_at(hours=1))