def test_value_retrival(self): with self.set_config_dir('testfiles'): parser = server_env._load_config() val = parser.get('external_service.ftp', 'user') self.assertEqual(val, 'testing') val = parser.get('external_service.ftp', 'host') self.assertEqual(val, 'sftp.example.com')
def test_env_variables_override(self): public = ("[external_service.ftp]\n" "user=foo\n") with self.set_config_dir('testfiles'), \ self.set_env_variables(public): parser = server_env._load_config() val = parser.get('external_service.ftp', 'user') self.assertEqual(val, 'foo')
def load_config(self, public=None, secret=None): original_serv_config = server_env_mixin.serv_config try: with self.set_config_dir(None), \ self.set_env_variables(public, secret): parser = server_env._load_config() server_env_mixin.serv_config = parser yield finally: server_env_mixin.serv_config = original_serv_config
def test_env_variables(self): public = ("[section]\n" "foo=bar\n" "bar=baz\n") secret = ("[section]\n" "bar=foo\n" "alice=bob\n") with self.set_config_dir(None), \ self.set_env_variables(public, secret): parser = server_env._load_config() self.assertEqual(list(parser.keys()), ['DEFAULT', 'section']) self.assertDictEqual(dict(parser['section'].items()), { 'alice': 'bob', 'bar': 'foo', 'foo': 'bar' })
def test_env_variables(self): public = "[section]\n" "foo=bar\n" "bar=baz\n" secret = "[section]\n" "bar=foo\n" "alice=bob\n" with self.set_config_dir(None), self.set_env_variables(public, secret): parser = server_env._load_config() self.assertEqual(list(parser.keys()), ["DEFAULT", "section"]) self.assertDictEqual( dict(parser["section"].items()), { "alice": "bob", "bar": "foo", "foo": "bar" }, )
def test_env_variables(self): env_var = ("[auth_saml_provider.sample]\n" "idp_metadata=foo\n" "sp_baseurl=bar\n" "sp_pem_public_path=file1.txt\n" "sp_pem_private_path=file2.txt") with self.set_config_dir(None), self.set_env_variables(env_var): parser = server_env._load_config() self.assertEqual(list(parser.keys()), ["DEFAULT", "auth_saml_provider.sample"]) self.assertDictEqual( dict(parser["auth_saml_provider.sample"].items()), { "idp_metadata": "foo", "sp_baseurl": "bar", "sp_pem_public_path": "file1.txt", "sp_pem_private_path": "file2.txt", }, )
def test_env_variables_override(self): public = "[external_service.ftp]\n" "user=foo\n" with self.set_config_dir("testfiles"), self.set_env_variables(public): parser = server_env._load_config() val = parser.get("external_service.ftp", "user") self.assertEqual(val, "foo")