class GoogleInstalledAppAuthConnectionTest(GoogleTestCase): """ Tests for GoogleInstalledAppAuthConnection """ def setUp(self): GoogleInstalledAppAuthConnection.conn_class = GoogleAuthMockHttp self.mock_scopes = ['https://www.googleapis.com/auth/foo'] kwargs = {'scopes': self.mock_scopes} self.conn = GoogleInstalledAppAuthConnection(*GCE_PARAMS, **kwargs) def test_refresh_token(self): # This token info doesn't have a refresh token, so a new token will be # requested token_info1 = {'access_token': 'tokentoken', 'token_type': 'Bearer', 'expires_in': 3600} new_token1 = self.conn.refresh_token(token_info1) self.assertEqual(new_token1['access_token'], STUB_IA_TOKEN['access_token']) # This token info has a refresh token, so it will be able to be # refreshed. token_info2 = {'access_token': 'tokentoken', 'token_type': 'Bearer', 'expires_in': 3600, 'refresh_token': 'refreshrefresh'} new_token2 = self.conn.refresh_token(token_info2) self.assertEqual(new_token2['access_token'], STUB_REFRESH_TOKEN['access_token']) # Both sets should have refresh info self.assertTrue('refresh_token' in new_token1) self.assertTrue('refresh_token' in new_token2)
class GoogleInstalledAppAuthConnectionTest(LibcloudTestCase): """ Tests for GoogleInstalledAppAuthConnection """ GoogleInstalledAppAuthConnection.get_code = lambda x: "1234" def setUp(self): GoogleInstalledAppAuthConnection.conn_classes = (GoogleAuthMockHttp, GoogleAuthMockHttp) self.mock_scopes = ["https://www.googleapis.com/auth/foo"] kwargs = {"scopes": self.mock_scopes} self.conn = GoogleInstalledAppAuthConnection(*GCE_PARAMS, **kwargs) def test_refresh_token(self): # This token info doesn't have a refresh token, so a new token will be # requested token_info1 = {"access_token": "tokentoken", "token_type": "Bearer", "expires_in": 3600} new_token1 = self.conn.refresh_token(token_info1) self.assertEqual(new_token1["access_token"], "installedapp") # This token info has a refresh token, so it will be able to be # refreshed. token_info2 = { "access_token": "tokentoken", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "refreshrefresh", } new_token2 = self.conn.refresh_token(token_info2) self.assertEqual(new_token2["access_token"], "refreshrefresh") # Both sets should have refresh info self.assertTrue("refresh_token" in new_token1) self.assertTrue("refresh_token" in new_token2)
class GoogleInstalledAppAuthConnectionTest(GoogleTestCase): """ Tests for GoogleInstalledAppAuthConnection """ def setUp(self): GoogleInstalledAppAuthConnection.conn_classes = (GoogleAuthMockHttp, GoogleAuthMockHttp) self.mock_scopes = ['https://www.googleapis.com/auth/foo'] kwargs = {'scopes': self.mock_scopes} self.conn = GoogleInstalledAppAuthConnection(*GCE_PARAMS, **kwargs) def test_refresh_token(self): # This token info doesn't have a refresh token, so a new token will be # requested token_info1 = {'access_token': 'tokentoken', 'token_type': 'Bearer', 'expires_in': 3600} new_token1 = self.conn.refresh_token(token_info1) self.assertEqual(new_token1['access_token'], STUB_IA_TOKEN['access_token']) # This token info has a refresh token, so it will be able to be # refreshed. token_info2 = {'access_token': 'tokentoken', 'token_type': 'Bearer', 'expires_in': 3600, 'refresh_token': 'refreshrefresh'} new_token2 = self.conn.refresh_token(token_info2) self.assertEqual(new_token2['access_token'], STUB_REFRESH_TOKEN['access_token']) # Both sets should have refresh info self.assertTrue('refresh_token' in new_token1) self.assertTrue('refresh_token' in new_token2)
class GoogleInstalledAppAuthConnectionTest(GoogleTestCase): """ Tests for GoogleInstalledAppAuthConnection """ def setUp(self): GoogleInstalledAppAuthConnection.conn_class = GoogleAuthMockHttp self.mock_scopes = ["https://www.googleapis.com/auth/foo"] kwargs = {"scopes": self.mock_scopes} self.conn = GoogleInstalledAppAuthConnection(*GCE_PARAMS, **kwargs) def test_refresh_token(self): # This token info doesn't have a refresh token, so a new token will be # requested token_info1 = { "access_token": "tokentoken", "token_type": "Bearer", "expires_in": 3600, } new_token1 = self.conn.refresh_token(token_info1) self.assertEqual(new_token1["access_token"], STUB_IA_TOKEN["access_token"]) # This token info has a refresh token, so it will be able to be # refreshed. token_info2 = { "access_token": "tokentoken", "token_type": "Bearer", "expires_in": 3600, "refresh_token": "refreshrefresh", } new_token2 = self.conn.refresh_token(token_info2) self.assertEqual(new_token2["access_token"], STUB_REFRESH_TOKEN["access_token"]) # Both sets should have refresh info self.assertTrue("refresh_token" in new_token1) self.assertTrue("refresh_token" in new_token2)