Пример #1
0
 def test_get_secret_no_attribute(self):
     mock = MagicMock()
     manager = SecretManager(mock, mock)
     mock.get_secret_value.side_effect = Exception
     result = manager.get_secret('test')
     self.assertIsNone(result)
     mock.error.assert_called_once()
Пример #2
0
 def test_get_secret(self):
     mock = MagicMock()
     expected_value = 'test_secret_value'
     mock.get_secret_value.return_value = {'SecretString': expected_value}
     manager = SecretManager(mock, mock)
     actual = manager.get_secret('test')
     self.assertEqual(expected_value, actual)
Пример #3
0
def get_sumologic_api_auth_keys(access_id_name, access_key_name, secrets_manager=SecretManager()):
    if Settings.LOCAL_SUMO_API_KEY:
        split_key = Settings.LOCAL_SUMO_API_KEY.split(Constants.COLON)
        return split_key[0], split_key[1]
    api_id = secrets_manager.get_secret(access_id_name)
    api_key = secrets_manager.get_secret(access_key_name)
    return api_id, api_key
Пример #4
0
def get_acceptable_token_list(version=Settings.VERSION,
                              secret_manager=SecretManager()):
    token_list = [version]
    if Settings.ENV and Settings.ENV != Constants.LOCAL:
        tokens = secret_manager.get_secret(Constants.DEV_TOKEN)
        if tokens:
            token_list.extend(json.loads(tokens))
    return token_list
Пример #5
0
 def __init__(self,
              account_name,
              http=HttpRequestor(),
              secrets_manager=SecretManager()):
     self.http = http
     self.secrets_manager = secrets_manager
     self.account_name = account_name
     self.account_id = get_newrelic_account_id(self.account_name)
     self.api_key = get_newrelic_api_key(self.account_name,
                                         self.secrets_manager)
     self.logger = Logger(Settings.SERVICE_NAME)
Пример #6
0
 def create(component_type, **kwargs):
     if isinstance(component_type, Components.DataClients):
         return Factory._create_data_client(component_type, **kwargs)
     if isinstance(component_type, Components.ServiceClients):
         return Factory._create_service_client(component_type, **kwargs)
     if isinstance(component_type, Components.MonitorClients):
         return MonitoringProvider()
     if isinstance(component_type, Components.LogClients):
         return Logger()
     if isinstance(component_type, Components.SecretsClients):
         return SecretManager()
     if isinstance(component_type, Components.Controllers):
         return Factory._create_controller(component_type, **kwargs)
     return None
Пример #7
0
 def __init__(self, **kwargs):
     self.web_client = kwargs.get(Constants.HTTP_CLIENT, HttpRequestor())
     self.secrets_manager = kwargs.get(Constants.SECRETS_MANAGER,
                                       SecretManager())
Пример #8
0
 def test_real_secret(self):
     manager = SecretManager()
     value = manager.get_secret('reliabilly.developer_keys')
     self.assertEqual(value, 'REPLACE_WITH_EXPECTED')