예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)