本文整理汇总了Python中activedirectory.core.creds.Creds.release方法的典型用法代码示例。如果您正苦于以下问题:Python Creds.release方法的具体用法?Python Creds.release怎么用?Python Creds.release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类activedirectory.core.creds.Creds
的用法示例。
在下文中一共展示了Creds.release方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_acquire_keytab
# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import release [as 别名]
def test_acquire_keytab(self, conf):
conf.require(ad_user=True)
domain = conf.domain()
creds = ADCreds(domain)
principal = conf.ad_user_account()
password = conf.ad_user_password()
creds.acquire(principal, password)
os.environ['PATH'] = '/usr/kerberos/sbin:/usr/kerberos/bin:%s' % \
os.environ['PATH']
fullprinc = creds.principal()
child = pexpect.spawn('kvno %s' % fullprinc)
child.expect('kvno =')
kvno = int(child.readline())
child.expect(pexpect.EOF)
child = pexpect.spawn('ktutil')
child.expect('ktutil:')
child.sendline('addent -password -p %s -k %d -e rc4-hmac' %
(fullprinc, kvno))
child.expect('Password for.*:')
child.sendline(password)
child.expect('ktutil:')
keytab = conf.tempfile(remove=True)
child.sendline('wkt %s' % keytab)
child.expect('ktutil:')
child.sendline('quit')
child.expect(pexpect.EOF)
creds.release()
creds.acquire(principal, keytab=keytab)
child = pexpect.spawn('klist')
pattern = '.*krbtgt/%[email protected]%s' % (domain.upper(), domain.upper())
assert child.expect([pattern]) == 0
示例2: test_cleanup_files
# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import release [as 别名]
def test_cleanup_files(self, conf):
conf.require(ad_user=True)
domain = conf.domain()
principal = conf.ad_user_account()
password = conf.ad_user_password()
creds = ADCreds(domain)
creds.acquire(principal, password)
ccache = creds._ccache_name()
config = creds._config_name()
assert os.access(ccache, os.R_OK)
assert os.access(config, os.R_OK)
creds.release()
assert not os.access(ccache, os.R_OK)
assert not os.access(config, os.R_OK)
示例3: test_cleanup_environment
# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import release [as 别名]
def test_cleanup_environment(self, conf):
conf.require(ad_user=True)
domain = conf.domain()
principal = conf.ad_user_account()
password = conf.ad_user_password()
ccorig = os.environ.get('KRB5CCNAME')
cforig = os.environ.get('KRB5_CONFIG')
creds = ADCreds(domain)
creds.acquire(principal, password)
ccache = creds._ccache_name()
config = creds._config_name()
assert ccache != ccorig
assert config != cforig
creds.release()
assert os.environ.get('KRB5CCNAME') == ccorig
assert os.environ.get('KRB5_CONFIG') == cforig
示例4: test_release_multi
# 需要导入模块: from activedirectory.core.creds import Creds [as 别名]
# 或者: from activedirectory.core.creds.Creds import release [as 别名]
def test_release_multi(self, conf):
conf.require(ad_user=True)
domain = conf.domain()
principal = conf.ad_user_account()
password = conf.ad_user_password()
ccorig = os.environ.get('KRB5CCNAME')
cforig = os.environ.get('KRB5_CONFIG')
creds1 = ADCreds(domain)
creds1.acquire(principal, password)
ccache1 = creds1._ccache_name()
config1 = creds1._config_name()
creds2 = ADCreds(domain)
creds2.acquire(principal, password)
ccache2 = creds2._ccache_name()
config2 = creds2._config_name()
creds1.release()
assert os.environ['KRB5CCNAME'] == ccache2
assert os.environ['KRB5_CONFIG'] == config2
creds2.release()
assert os.environ.get('KRB5CCNAME') == ccorig
assert os.environ.get('KRB5_CONFIG') == cforig