class TestAuthentication: def setup_method(self, method): # TODO: To run against real server please delete ../fixtures/vcr_cassettes/* and replace # login_id and api_key with valid credentials before running the tests login_id = '*****@*****.**' api_key = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef' environment = Config.ENV_DEMO self.client = Client(login_id, api_key, environment) def test_authentication_happens_lazily(self): with Betamax(self.client.config.session) as betamax: betamax.use_cassette('authentication/happens_lazily') assert self.client.config._auth_token is None assert self.client.config.auth_token is not None def test_authentication_can_reuse_an_auth_token(self): special_client = Client(None, None, Config.ENV_DEMO) special_client.config.auth_token = "deadbeefdeadbeefdeadbeefdeadbeef" with Betamax(special_client.config.session) as betamax: betamax.use_cassette('authentication/can_use_just_a_token') response = special_client.beneficiaries.find() assert response is not None def test_authentication_can_be_closed(self): with Betamax(self.client.config.session) as betamax: betamax.use_cassette('authentication/can_be_closed') assert self.client.config.auth_token is not None assert self.client.close_session() is True assert self.client.config._auth_token is None def test_authentication_handles_session_timeout(self): # Set the token to an invalid one self.client.config.auth_token = 'deadbeefdeadbeefdeadbeefdeadbeef' with Betamax(self.client.config.session) as betamax: betamax.use_cassette('authentication/handles_session_timeout', match_requests_on=['uri', 'method']) response = self.client.beneficiaries.find() assert response is not None
class TestAuthentication: def setup_method(self, method): # TODO: To run against real server please delete ../fixtures/vcr_cassettes/* and replace # login_id and api_key with valid credentials before running the tests login_id = '*****@*****.**' api_key = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef' environment = Config.ENV_DEMO self.client = Client(login_id, api_key, environment) def test_authentication_happens_lazily(self): with Betamax(self.client.config.session) as betamax: betamax.use_cassette('authentication/happens_lazily') assert self.client.config._auth_token is None assert self.client.config.auth_token is not None def test_authentication_can_reuse_an_auth_token(self): special_client = Client(None, None, Config.ENV_DEMO) special_client.config.auth_token = "deadbeefdeadbeefdeadbeefdeadbeef" with Betamax(special_client.config.session) as betamax: betamax.use_cassette('authentication/can_use_just_a_token') response = special_client.beneficiaries.find() assert response is not None def test_authentication_can_be_closed(self): with Betamax(self.client.config.session) as betamax: betamax.use_cassette('authentication/can_be_closed') assert self.client.config.auth_token is not None assert self.client.close_session() is True assert self.client.config._auth_token is None def test_authentication_handles_session_timeout(self): # Set the token to an invalid one self.client.config.auth_token = 'deadbeefdeadbeefdeadbeefdeadbeef' with Betamax(self.client.config.session) as betamax: betamax.use_cassette('authentication/handles_session_timeout', match_requests_on=['uri', 'method']) response = self.client.beneficiaries.find() assert response is not None
class TestAuthentication: def setup_method(self, method): login_id = '*****@*****.**' api_key = 'ef0fd50fca1fb14c1fab3a8436b9ecb65f02f129fd87eafa45ded8ae257528f0' environment = Config.ENV_DEMONSTRATION self.client = Client(login_id, api_key, environment) def test_authentication_happens_lazily(self): with Betamax(self.client.config.session) as betamax: betamax.use_cassette('authentication/happens_lazily') assert self.client.config._auth_token is None assert self.client.config.auth_token is not None def test_authentication_can_reuse_an_auth_token(self): special_client = Client(None, None, Config.ENV_DEMONSTRATION) special_client.config.auth_token = self.client.config.auth_token with Betamax(special_client.config.session) as betamax: betamax.use_cassette('authentication/can_use_just_a_token') response = special_client.beneficiaries.find() assert response is not None def test_authentication_can_be_closed(self): with Betamax(self.client.config.session) as betamax: betamax.use_cassette('authentication/can_be_closed') assert self.client.config.auth_token is not None assert self.client.close_session() is True assert self.client.config._auth_token is None def test_authentication_handles_session_timeout(self): # Set the token to an invalid one self.client.config.auth_token = '1234abcd1234abcd1234abcd1234abcd' with Betamax(self.client.config.session) as betamax: betamax.use_cassette('authentication/handles_session_timeout', match_requests_on=['uri', 'method']) response = self.client.beneficiaries.find() assert response is not None