def test_resolver_fail(self): ''' Test to use a file, that does not exist ''' pw_config = {'linotp.passwdresolver.fileName.my': '/dev/shm/this_file_does_not_exist'} msg = ("File '/dev/shm/this_file_does_not_exist' does not " "exist or is not accesible") with self.assertRaisesRegexp(ResolverLoadConfigError, msg): self.y = PasswdResolver() self.y.loadConfig(pw_config, "my")
def passwd_resolver(): content = """user1:0DM4AJtW/rTYY:10:10:User Eins:Irgendwas:Nochmal user2:.4UO1mxvTmdM6:11:11:User Zwei:Irgendwas:Nochmal""" with tempfile.NamedTemporaryFile(mode="w+") as f: f.write(content) f.flush() pw_file = f.name pw_config = {"linotp.passwdresolver.fileName.my": pw_file} y = PasswdResolver() y.loadConfig(pw_config, "my") yield y
def setUp(self): ''' initalize the config into a shared memory file ''' pw_file = "/dev/shm/test_users.txt" content = '''user1:0DM4AJtW/rTYY:10:10:User Eins:Irgendwas:Nochmal user2:.4UO1mxvTmdM6:11:11:User Zwei:Irgendwas:Nochmal ''' f = open(pw_file, 'w') f.write(content) f.close() pw_config = {'linotp.passwdresolver.fileName.my': pw_file} self.y = PasswdResolver() self.y.loadConfig(pw_config, 'my')
def test_resolver_fail(): """ Test to use a file, that does not exist """ pw_config = { "linotp.passwdresolver.fileName.my": "/dev/shm/this_file_does_not_exist" } msg = ("File '/dev/shm/this_file_does_not_exist' does not " "exist or is not accesible") with pytest.raises(ResolverLoadConfigError, match=msg): y = PasswdResolver() y.loadConfig(pw_config, "my")