def test_unmunge_replay(self): resp=munge.unmunge(self.encoded) assert resp['MESSAGE']==self.message try: resp=munge.unmunge(self.encoded) assert False except OSError: assert True
def test_unmunge_replay(self): resp = munge.unmunge(self.encoded) assert resp['MESSAGE'] == self.message try: resp = munge.unmunge(self.encoded) assert False except OSError: assert True
def _authenticate_munge(self, authstr, system=None): if self.type != 'munge': raise ValueError('incorrect authenticate type!') if authstr is None: raise KeyError("No Auth String Provided") if system is None: raise KeyError('System must be specified for munge') response = munge.unmunge(authstr, socket=self.sockets[system]) if response is None: raise OSError('Authentication Failed') ret = dict() uids = response['UID'] gids = response['GID'] (user, uid) = uids.replace(' ', '').rstrip(')').split('(') (group, gid) = gids.replace(' ', '').rstrip(')').split('(') ret = { 'user': user, 'uid': int(uid), 'group': group, 'gid': int(gid), 'tokens': '' } message_json = response['MESSAGE'] try: ret['tokens'] = json.loads(message_json)['authorized_locations'] except: pass return ret
def _authenticate_munge(self, authstr, system=None): if self.type != 'munge': raise ValueError('incorrect authenticate type!') if authstr is None: raise KeyError("No Auth String Provided") if system is None: raise KeyError('System must be specified for munge') response = munge.unmunge(authstr, socket=self.sockets[system]) if response is None: raise OSError('Authentication Failed') ret = dict() uid = response['UID'] gid = response['GID'] (user, uid) = uid.replace(' ', '').rstrip(')').split('(') (group, gid) = gid.replace(' ', '').rstrip(')').split('(') ret = { 'user': user, 'uid': uid, 'group': group, 'gid': gid, 'tokens': '' } message_json = response['MESSAGE'] try: ret['tokens'] = json.loads(message_json)['authorized_locations'] except: pass return ret
def test_unmunge_expired(self): with open(self.test_dir+"munge.expired",'w') as f: f.write(self.expired) try: resp=munge.unmunge(self.expired) assert False except OSError: assert True
def test_unmunge_expired(self): with open(self.test_dir + "munge.expired", 'w') as f: f.write(self.expired) try: resp = munge.unmunge(self.expired) assert False except OSError: assert True
def test_unmunge(self): resp=munge.unmunge(self.encoded) assert resp['MESSAGE']==self.message
def test_unmunge_replay(self): resp = munge.unmunge(self.encoded) assert resp['MESSAGE'] == self.message with self.assertRaises(OSError): munge.unmunge(self.encoded)
def test_unmunge_expired(self): with open(self.test_dir + "munge.expired", 'w') as f: f.write(self.expired) with self.assertRaises(OSError): munge.unmunge(self.expired)
def test_unmunge(self): resp = munge.unmunge(self.encoded) assert resp['MESSAGE'] == self.message