Example #1
0
def _publish_version(packages, config, clusters):
    """Publish production Lambda versions

    Args:
        packages (list[LambdaPackage])
        config (CLIConfig)
        clusters (set)

    Returns:
        bool: Result of Lambda version publishing
    """
    global_packages = {
        'alert_merger', 'alert_processor', 'athena_partition_refresh',
        'threat_intel_downloader'
    }

    for package in packages:
        if package.package_name in global_packages:
            published = LambdaVersion(
                config=config,
                package=package).publish_function(clustered_deploy=False)
        else:
            published = LambdaVersion(config=config,
                                      package=package).publish_function(
                                          clustered_deploy=True,
                                          clusters=clusters)
        if not published:
            return False

    return True
Example #2
0
def test_publish_helper():
    """CLI - Publish Athena Function"""
    config = MockCLIConfig(config=basic_streamalert_config())
    package = AthenaPackage(config=config)
    publish = LambdaVersion(config=config, package=package)
    result = publish._publish_helper()

    assert_equal(
        config['lambda']['athena_partition_refresh_config']['current_version'],
        11)
    assert_true(result)
Example #3
0
def test_publish_helper_clustered():
    """CLI - Publish Clustered Function"""
    config = MockCLIConfig(config=basic_streamalert_config())
    package = RuleProcessorPackage(config=config)
    publish = LambdaVersion(config=config, package=package)
    result = publish._publish_helper(cluster='prod')

    assert_true(result)
    assert_equal(
        config['clusters']['prod']['modules']['stream_alert']['rule_processor']
        ['current_version'], 11)
Example #4
0
def test_version_helper():
    """CLI - Publish Helper"""
    package = AthenaPackage(basic_streamalert_config())
    publish = LambdaVersion(config=basic_streamalert_config(), package=package)
    current_version = 10
    fake_client = MockLambdaClient('athena', current_version=current_version)
    result = publish._version_helper(client=fake_client,
                                     function_name='test',
                                     code_sha_256='12345',
                                     date='2017-01-01')

    assert_equal(result, current_version + 1)
Example #5
0
def test_version_helper_error(mock_logging):
    """CLI - Publish Helper Raises Error"""
    package = AthenaPackage(basic_streamalert_config())
    publish = LambdaVersion(config=basic_streamalert_config(), package=package)
    current_version = 10
    fake_client = MockLambdaClient('athena',
                                   current_version=current_version,
                                   throw_exception=True)
    result = publish._version_helper(client=fake_client,
                                     function_name='test',
                                     code_sha_256='12345',
                                     date='2017-01-01')

    assert_false(result)
    assert_true(mock_logging.error.called)