예제 #1
0
 def test_get_variable(self, mock_client):
     mock_client.get_secret.return_value = mock.Mock(value='world')
     backend = AzureKeyVaultBackend()
     returned_uri = backend.get_variable('hello')
     mock_client.get_secret.assert_called_with(
         name='airflow-variables-hello')
     assert 'world' == returned_uri
예제 #2
0
 def test_get_variable_non_existent_key(self, mock_client):
     """
     Test that if Variable key is not present,
     AzureKeyVaultBackend.get_variables should return None
     """
     mock_client.get_secret.side_effect = ResourceNotFoundError
     backend = AzureKeyVaultBackend()
     assert backend.get_variable('test_mysql') is None
예제 #3
0
    def test_variable_prefix_none_value(self, mock_get_secret):
        """
        Test that if Variables prefix is None,
        AzureKeyVaultBackend.get_variables should return None
        AzureKeyVaultBackend._get_secret should not be called
        """
        kwargs = {'variables_prefix': None}

        backend = AzureKeyVaultBackend(**kwargs)
        assert backend.get_variable('hello') is None
        mock_get_secret.assert_not_called()