def test_config_environment_extraction(self): """ The provider serialization loads keys as needed from the environment. Variables from the configuration take precendence over those from the environment, when serializing. """ config = { "access-key": "secret-12345", "secret-key": "secret-abc", "authorized-keys": "0123456789abcdef" } environ = { "AWS_SECRET_ACCESS_KEY": "secret-abc", "AWS_ACCESS_KEY_ID": "secret-123" } self.change_environment(**environ) provider = MachineProvider(self.env_name, { "access-key": "secret-12345", "authorized-keys": "0123456789abcdef" }) serialized = provider.get_serialization_data() self.assertEqual(config, serialized)
def test_config_serialization(self): """ The provider configuration can be serialized to yaml. """ keys_path = self.makeFile("my-keys") config = {"access-key": "secret-123", "secret-key": "secret-abc", "authorized-keys-path": keys_path} expected_serialization = config.copy() expected_serialization.pop("authorized-keys-path") expected_serialization["authorized-keys"] = "my-keys" provider = MachineProvider(self.env_name, config) serialized = provider.get_serialization_data() self.assertEqual(serialized, expected_serialization)
def test_config_serialization(self): """ The provider configuration can be serialized to yaml. """ keys_path = self.makeFile("my-keys") config = { "access-key": "secret-123", "secret-key": "secret-abc", "authorized-keys-path": keys_path } expected_serialization = config.copy() expected_serialization.pop("authorized-keys-path") expected_serialization["authorized-keys"] = "my-keys" provider = MachineProvider(self.env_name, config) serialized = provider.get_serialization_data() self.assertEqual(serialized, expected_serialization)
def test_config_environment_extraction(self): """ The provider serialization loads keys as needed from the environment. Variables from the configuration take precendence over those from the environment, when serializing. """ config = {"access-key": "secret-12345", "secret-key": "secret-abc", "authorized-keys": "0123456789abcdef"} environ = { "AWS_SECRET_ACCESS_KEY": "secret-abc", "AWS_ACCESS_KEY_ID": "secret-123"} self.change_environment(**environ) provider = MachineProvider( self.env_name, {"access-key": "secret-12345", "authorized-keys": "0123456789abcdef"}) serialized = provider.get_serialization_data() self.assertEqual(config, serialized)