Commit 4eace7b9 authored by Rob Carleski's avatar Rob Carleski 🇮🇸
Browse files

Hammer out kadmin bugs. Correct mock_kadmin accordingly.

parent 0303f645
......@@ -80,13 +80,20 @@ class SharedAccount():
self.config['kerberos']['keytab']
)
principal = self.account + self.config['kerberos']['realm'].upper()
princ = kadm.get_princ(principal)
princ.change_password(self.password)
princ = kadm.getprinc(principal)
if not princ:
self.logger.warning(
'Kerberos principal does not exist. Creating.',
extra={'entity': self.account}
)
kadm.addprinc(principal, self.password)
else:
princ.change_password(self.password)
except IOError as e:
self.logger.error(e, extra={'entity': self.account})
exit(2)
except kadmin.KAdminError as e:
self.logger.error(e['message'], extra={'entity': self.account})
self.logger.error(e, extra={'entity': self.account})
exit(2)
def set_google_password(self):
......@@ -105,7 +112,7 @@ class SharedAccount():
def upload_and_share_password(self):
try:
passFilePath = '{}/{}-passwd'.format(
passFilePath = '{}/{}-passwd.txt'.format(
self.config['general']['data_dir'],
self.account
)
......@@ -123,7 +130,7 @@ class SharedAccount():
passFilePath,
'parentname',
'Shared Account Passwords'
])
], stderr=STDOUT)
self.file_id = re.search(
r'.*\((.*)\)',
upload_output.decode('UTF-8')
......@@ -133,7 +140,7 @@ class SharedAccount():
# Gather a list of account owners from MCommunity
owners = []
for _ in self.group['ownerDn']:
for _ in self.group_data['ownerDn']:
owner = _.split(',')[0].split('=')[1].strip()
owners.append(owner)
......@@ -150,7 +157,7 @@ class SharedAccount():
owner,
'role',
'reader'
])
], stderr=STDOUT)
except CalledProcessError:
self.logger.warning(
'Unable to share password with {}'.format(owner),
......@@ -168,7 +175,7 @@ The password for your shared account has been changed. The new password for
this account is stored in your Google Drive space, and can be found at the
following link:
https://docs.google.com/a/umich.edu/file/d/{}.
https://docs.google.com/a/{}/file/d/{}.
Please note that this file will expire automatically in ten (10) days, and
has been shared with any additional owners of the MCommunity group associated
......@@ -184,7 +191,7 @@ If you are still unable to log into your shared account, or if you have any
additional questions or concerns, simply reply to this message and your request
will be automatically re-opened.
'''.format(self.file_id))
'''.format(self.config['google']['domain'], self.file_id))
def main():
......
......@@ -26,7 +26,7 @@ class init_with_keytab():
def addprinc(self, princ, passwd):
return True
class get_princ():
class getprinc():
def __init__(self, princ):
return None
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment