def test_init_with_keytab_env(config): KrbCommand.kdestroy(config) os.environ['KRB5_KTNAME'] = config.keytab config.keytab = None KrbTicket.init(DEFAULT_PRINCIPAL) del os.environ['KRB5_KTNAME'] assert not os.environ.get('KRB5_KTNAME')
def test_init_without_keytab_env(config): KrbCommand.kdestroy(config) assert not os.environ.get('KRB5_KTNAME') retry_options = { 'wait_exponential_multiplier': 100, 'wait_exponential_max': 1000, 'stop_max_attempt_number': 1 } config.keytab = None try: KrbTicket.init(DEFAULT_PRINCIPAL, retry_options=retry_options) pytest.fail() except subprocess.CalledProcessError: pass
def _create_connection(self): if None is self.connection: logger.debug('creating connection') if None is not self.keytab_path: self.ticket = KrbTicket.init(self.username, self.keytab_path) self.ticket.updater_start() connection = hdfs.connect() assert connection is not None self.connection = connection
def test_init_with_config(config): KrbCommand.kdestroy(config) ticket1 = KrbTicket.init_by_config(config) ticket2 = KrbTicket.init( DEFAULT_PRINCIPAL, DEFAULT_KEYTAB, renewal_threshold=timedelta(seconds=DEFAULT_TICKET_RENEWAL_THRESHOLD_SEC), ticket_lifetime=DEFAULT_TICKET_LIFETIME, ticket_renewable_lifetime=DEFAULT_TICKET_RENEWABLE_LIFETIME, retry_options={ 'wait_exponential_multiplier': 100, 'wait_exponential_max': 1000, 'stop_max_attempt_number': 3}) assert_ticket(ticket1, ticket2)
def test_init(config): KrbCommand.kdestroy(config) KrbTicket.init(DEFAULT_PRINCIPAL, DEFAULT_KEYTAB)