def testSuccess(self): creds = mock.Mock(spec=oauth2client.client.Credentials) opener = base_client.BuildOauth2Opener(creds) self.assertIsInstance(opener, urllib2.OpenerDirector) self.assertIsInstance(GetArgFromCallHistory(creds.apply, 0, 0), dict)
def testSuccess(self): creds = mox.MockAnything() creds.apply(mox.IsA(dict)) self.mox.ReplayAll() opener = base_client.BuildOauth2Opener(creds) self.mox.VerifyAll() self.assertIsInstance(opener, urllib2.OpenerDirector)
def _Authenticate(self, error_func): self._ShowLoggingInMessage() try: credentials = base_client.GetOauthCredentials() except (RuntimeError, base_client.AuthenticationError) as e: error_func(unicode(e)) return opener = base_client.BuildOauth2Opener(credentials) client_ = client.FileVaultClient(self.server_url, opener) try: client_.GetAndValidateMetadata() except base_client.MetadataError as e: error_func(unicode(e)) return return client_
def main(options): if options.login_type == 'oauth2': credentials = base_client.GetOauthCredentials() opener = base_client.BuildOauth2Opener(credentials) else: raise NotImplementedError('Unsupported login type: %s', options.login_type) c = client.LuksClient(options.server_url, opener) if options.mode == 'put': luks_passphrase = open(options.luks_passphrase_file, 'r').read().strip() data = { 'hostname': options.hostname, 'hdd_serial': options.hdd_serial, 'platform_uuid': options.platform_uuid, 'owner': options.username } c.UploadPassphrase(options.volume_uuid, luks_passphrase, data) if options.mode == 'get': print c.RetrieveSecret(options.volume_uuid)
def _GetOpener(): credentials = base_client.GetOauthCredentials() opener = base_client.BuildOauth2Opener(credentials) return opener