def test_jwt_thrift(self): with patch('desktop.lib.thrift_util.TBinaryProtocol'): with patch('desktop.lib.thrift_util.TBufferedTransport'): with patch('desktop.lib.thrift_util.TBufferedTransport'): with patch( 'desktop.lib.thrift_util.THttpClient.set_bearer_auth' ) as set_bearer_auth: self.user.profile.update_data( {'jwt_access_token': self.sample_token}) self.user.profile.save() reset = USE_THRIFT_HTTP_JWT.set_for_testing(True) conf = Mock(klass=Mock(), username="******", transport_mode='http', timeout_seconds=None, use_sasl=None, http_url='some_http_url') try: service, protocol, transport = thrift_util.connect_to_thrift( conf) set_bearer_auth.assert_called_with( 'some_jwt_token') finally: reset()
def _connect_dn(self, node): dn_conf = thrift_util.ConnectionConfig( Datanode.Client, node.host, node.thriftPort, "HDFS Datanode Thrift", use_sasl=self.security_enabled, kerberos_principal=self.dn_kerberos_principal, timeout_seconds=DN_THRIFT_TIMEOUT) service, protocol, transport = \ thrift_util.connect_to_thrift(dn_conf) transport.open() service.close = lambda: transport.close() return service